static int dup_task(const void *a, void **n) { task_t *d = (task_t *) lc_alloc(sizeof(task_t)); if (d) { memcpy(d, a, sizeof(task_t)); } *n = d; return 0; }
void task_set_current(task_id tid) { task_id *ptid = lc_local_get(task_key); if (!ptid) { ptid = lc_alloc(sizeof(task_id)); *ptid = tid; lc_local_set(task_key, ptid); } }
static ERTS_INLINE erts_lc_locked_lock_t * new_locked_lock(erts_lc_lock_t *lck, Uint16 op_flags) { erts_lc_locked_lock_t *l_lck = (erts_lc_locked_lock_t *) lc_alloc(); l_lck->next = NULL; l_lck->prev = NULL; l_lck->id = lck->id; l_lck->extra = lck->extra; l_lck->flags = lck->flags | op_flags; return l_lck; }
queue_t *queue_new(copy_cb copy, release_cb rel) { queue_t *q = lc_alloc(sizeof(queue_t)); if (q) { q->copy = copy; q->rel = rel; q->head.next = NULL; q->head.data = NULL; q->tail = &q->head; q->size = 0; } return q; }
extern int *__lc_err_loc( ) { static int init = 0; while (!atomic_int_cas(&init, 1, 1)) { err_key = lc_local_new(lc_err_destroy); int *err = lc_alloc(sizeof(int)); lc_local_set(err_key, err); init = 1; } return (int *) lc_local_get(err_key); }
static ERTS_INLINE erts_lc_locked_lock_t * new_locked_lock(erts_lc_lock_t *lck, Uint16 op_flags, char *file, unsigned int line) { erts_lc_locked_lock_t *l_lck = (erts_lc_locked_lock_t *) lc_alloc(); l_lck->next = NULL; l_lck->prev = NULL; l_lck->id = lck->id; l_lck->extra = lck->extra; l_lck->file = file; l_lck->line = line; l_lck->flags = lck->flags | op_flags; return l_lck; }
static ERTS_INLINE erts_lc_locked_lock_t * new_locked_lock(erts_lc_lock_t *lck, erts_lock_options_t options, char *file, unsigned int line) { erts_lc_locked_lock_t *l_lck = (erts_lc_locked_lock_t *) lc_alloc(); l_lck->next = NULL; l_lck->prev = NULL; l_lck->id = lck->id; l_lck->extra = lck->extra; l_lck->file = file; l_lck->line = line; l_lck->flags = lck->flags; l_lck->taken_options = options; return l_lck; }
static q_node_t *new_node(queue_t *q, void *data) { int err; q_node_t *node = lc_alloc(sizeof(q_node_t)); if (node) { if (q->copy && data) { if ((err = q->copy(data, &node->data)) != SUCCESS) { node = lc_free(node); } } else { node->data = data; } } node->next = NULL; return node; }
static ERTS_INLINE lc_locked_lock_t * new_locked_lock(lc_thread_t* thr, erts_lc_lock_t *lck, erts_lock_options_t options, char *file, unsigned int line) { lc_locked_lock_t *ll = lc_alloc(thr); ll->next = NULL; ll->prev = NULL; ll->id = lck->id; ll->extra = lck->extra; ll->file = file; ll->line = line; ll->flags = lck->flags; ll->taken_options = options; return ll; }