/** * Uninitialize testing stuff */ void Informatics_done_testing (void) { Informatics_stop_testing (0, 0); if (active) { mutex_free (active); } if (unlink_mutex) { mutex_free (unlink_mutex); } if (suspended) { mutex_free (suspended); } if (lck_mutex) { mutex_free (lck_mutex); } if (pool) { g_thread_pool_free (pool, FALSE, FALSE); } }
struct msg *mqueue_pull(uint8_t port, uint64_t source) { struct mqueue_msg *node; struct msg *msg; mutex_spin(&mqueue[port].mutex); if (source) { for (node = mqueue[port].front; node; node = node->next) { if (node->msg->source == source) { break; } } } else { node = mqueue[port].front; } if (!node) { mutex_free(&mqueue[port].mutex); return NULL; } if (node->prev) node->prev->next = node->next; else mqueue[port].front = node->next; if (node->next) node->next->prev = node->prev; else mqueue[port].back = node->prev; mutex_free(&mqueue[port].mutex); msg = node->msg; free(node); return msg; }
static inline void read_byte() { #if USE_IRQ int dx = 0, dy = 0; int buttons; #endif bytes[curbyte++] = inb(0x60); if (curbyte == 1) { if (!(bytes[0] & 0x08)) { // Out of sync curbyte = 0; return; } buttons = bytes[0] & 0x7; #if USE_IRQ mutex_free(&mutex); send_event_button(buttons); #endif } if (curbyte == 3) { curbyte = 0; dx += bytes[1] - ((bytes[0] & 0x10) ? 256 : 0); dy -= bytes[2] - ((bytes[0] & 0x20) ? 256 : 0); #if USE_IRQ mutex_free(&mutex); send_event_delta(dx, dy); #endif } }
size_t tmpfs_read(struct robject *self, rp_t source, uint8_t *buffer, size_t size, off_t offset) { uint8_t *file_data; off_t *file_size; mutex_spin(&self->driver_mutex); file_data = robject_data(self, "data"); file_size = robject_data(self, "size"); if (!file_data || !file_size) { mutex_free(&self->driver_mutex); return 0; } if (offset > *file_size) { mutex_free(&self->driver_mutex); return 0; } if (offset + size >= *file_size) { size = *file_size - offset; } memcpy(buffer, &file_data[offset], size); mutex_free(&self->driver_mutex); return size; }
char *svga_rcall(uint64_t source, struct vfs_obj *file, const char *args) { char *rets = NULL; int x, y, d, w, h; int mode; if (!strcmp(args, "getmode")) { rets = malloc(16); sprintf(rets, "%d %d %d", svga.w, svga.h, svga.d); return rets; } if (!strcmp(args, "listmodes")) { return strdup(modesstr); } if (!strcmp(args, "unshare")) { mutex_spin(&file->mutex); page_free(buffer, msize(buffer)); free(buffer); buffer = valloc(svga.w * svga.h * 4); mutex_free(&file->mutex); return strdup("T"); } if (!strncmp(args, "setmode ", 8)) { if (sscanf(args + 8, "%i %i %i", &x, &y, &d) != 3) { return strdup(""); } mutex_spin(&file->mutex); mode = svga_find_mode(x, y, d); if (svga_set_mode(mode)) { return strdup(""); } page_free(buffer, msize(buffer)); free(buffer); buffer = valloc(svga.w * svga.h * 4); mutex_free(&file->mutex); return strdup("T"); } if (!strncmp(args, "syncrect ", 9)) { if (sscanf(args + 9, "%i %i %i %i", &x, &y, &w, &h) != 4) { return strdup(""); } mutex_spin(&file->mutex); svga_fliprect(buffer, x, y, w, h); mutex_free(&file->mutex); return strdup("T"); } return NULL; }
void cb_free(CircBuff_t * cb) { if (cb->invalid) return; critical_enter(&cb->mutex); free((void *) cb->buffer); cb->invalid = 1; if (cb->is_waiting) mutex_signal(&cb->locker); critical_leave(&cb->mutex); mutex_free(&cb->locker); mutex_free(&cb->mutex); }
void rw_lock_free( /*=========*/ rw_lock_t* lock) /* in: rw-lock */ { ut_ad(rw_lock_validate(lock)); ut_a(rw_lock_get_writer(lock) == RW_LOCK_NOT_LOCKED); ut_a(rw_lock_get_waiters(lock) == 0); ut_a(rw_lock_get_reader_count(lock) == 0); lock->magic_n = 0; mutex_free(rw_lock_get_mutex(lock)); mutex_enter(&rw_lock_list_mutex); os_event_free(lock->event); #ifdef __WIN__ os_event_free(lock->wait_ex_event); #endif if (UT_LIST_GET_PREV(list, lock)) { ut_a(UT_LIST_GET_PREV(list, lock)->magic_n == RW_LOCK_MAGIC_N); } if (UT_LIST_GET_NEXT(list, lock)) { ut_a(UT_LIST_GET_NEXT(list, lock)->magic_n == RW_LOCK_MAGIC_N); } UT_LIST_REMOVE(list, rw_lock_list, lock); mutex_exit(&rw_lock_list_mutex); }
int mqueue_push(struct msg *msg) { struct mqueue_msg *node; uint8_t port; if (!msg) { return 1; } port = msg->port; mutex_spin(&mqueue[port].mutex); node = malloc(sizeof(struct mqueue_msg)); if (!node) { return 1; } node->next = NULL; node->prev = mqueue[port].back; node->msg = msg; if (!mqueue[port].front) mqueue[port].front = node; if (mqueue[port].back) mqueue[port].back->next = node; mqueue[port].back = node; mutex_free(&mqueue[port].mutex); return 0; }
/******************************************************************//** Calling this function is obligatory only if the memory buffer containing the rw-lock is freed. Removes an rw-lock object from the global list. The rw-lock is checked to be in the non-locked state. */ UNIV_INTERN void rw_lock_free_func( /*==============*/ rw_lock_t* lock) /*!< in: rw-lock */ { ut_ad(rw_lock_validate(lock)); ut_a(lock->lock_word == X_LOCK_DECR); #ifndef INNODB_RW_LOCKS_USE_ATOMICS mutex_free(rw_lock_get_mutex(lock)); #endif /* INNODB_RW_LOCKS_USE_ATOMICS */ mutex_enter(&rw_lock_list_mutex); os_event_free(lock->event); os_event_free(lock->wait_ex_event); ut_ad(UT_LIST_GET_PREV(list, lock) == NULL || UT_LIST_GET_PREV(list, lock)->magic_n == RW_LOCK_MAGIC_N); ut_ad(UT_LIST_GET_NEXT(list, lock) == NULL || UT_LIST_GET_NEXT(list, lock)->magic_n == RW_LOCK_MAGIC_N); UT_LIST_REMOVE(list, rw_lock_list, lock); mutex_exit(&rw_lock_list_mutex); ut_d(lock->magic_n = 0); }
size_t tmpfs_write(struct robject *self, rp_t source, uint8_t *buffer, size_t size, off_t offset) { uint8_t *file_data; off_t _file_size = 0; off_t *file_size; mutex_spin(&self->driver_mutex); file_data = robject_data(self, "data"); file_size = robject_data(self, "size"); if (!file_size) { file_size = &_file_size; } if (offset + size >= *file_size) { file_data = realloc(file_data, offset + size); robject_set_data(self, "data", file_data); if (file_size == &_file_size) { file_size = malloc(sizeof(off_t)); } *file_size = offset + size; robject_set_data(self, "size", file_size); } memcpy(&file_data[offset], buffer, size); mutex_free(&self->driver_mutex); return size; }
/************************************************************************ Frees the global purge system control structure. */ UNIV_INTERN void trx_purge_sys_close(void) /*======================*/ { ut_ad(!mutex_own(&kernel_mutex)); que_graph_free(purge_sys->query); ut_a(purge_sys->sess->trx->is_purge); purge_sys->sess->trx->conc_state = TRX_NOT_STARTED; sess_close(purge_sys->sess); purge_sys->sess = NULL; if (purge_sys->view != NULL) { /* Because acquiring the kernel mutex is a pre-condition of read_view_close(). We don't really need it here. */ mutex_enter(&kernel_mutex); read_view_close(purge_sys->view); purge_sys->view = NULL; mutex_exit(&kernel_mutex); } trx_undo_arr_free(purge_sys->arr); rw_lock_free(&purge_sys->latch); mutex_free(&purge_sys->mutex); mem_heap_free(purge_sys->heap); mem_free(purge_sys); purge_sys = NULL; }
void IORecursiveLockFree( IORecursiveLock * _lock ) { _IORecursiveLock * lock = (_IORecursiveLock *)_lock; mutex_free( lock->mutex ); IODelete( lock, _IORecursiveLock, 1); }
int fb_setbmp(struct fb *fb, uint32_t *bitmap) { if (!fb) { return 1; } mutex_spin(&fb->mutex); // unshare old bitmap if (fb->flags & FB_SHARED) { rp_share(fb->rp, fd_getkey(fb->fd, AC_WRITE), NULL, 0, 0, 0); fb->flags &= ~FB_SHARED; } // free old bitmap if (fb->bitmap && !(fb->flags & FB_USRBMP)) { free(fb->bitmap); } // set bitmap fb->bitmap = bitmap; fb->flags |= FB_USRBMP; // check for shared memory interface if (!rp_share(fb->rp, fd_getkey(fb->fd, AC_WRITE), fb->bitmap, fb->xdim * fb->ydim * sizeof(uint32_t), 0, PROT_READ)) { // successful fb->flags |= FB_SHARED; } mutex_free(&fb->mutex); return 0; }
/******************************************************************//** Frees the resources in a wait array. */ UNIV_INTERN void sync_array_free( /*============*/ sync_array_t* arr) /*!< in, own: sync wait array */ { ulint protection; ut_a(arr->n_reserved == 0); sync_array_validate(arr); protection = arr->protection; /* Release the mutex protecting the wait array complex */ if (protection == SYNC_ARRAY_OS_MUTEX) { os_mutex_free(arr->os_mutex); } else if (protection == SYNC_ARRAY_MUTEX) { mutex_free(&(arr->mutex)); } else { ut_error; } ut_free(arr->array); ut_free(arr); }
size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream) { const uint8_t *data = ptr; size_t i, ret; if (!stream) { return 0; } if (!(size * nmemb)) { return 0; } mutex_spin(&stream->mutex); if (stream->flags & FILE_NBF) { ret = write(stream->fd, (void*) ptr, size * nmemb, stream->position); stream->position += ret; if (size == 0) { size = 1; } mutex_free(&stream->mutex); return (ret / size); } for (i = 0; i < size * nmemb; i++) { stream->buffer[stream->buffpos++] = data[i]; if (stream->flags & FILE_LBF) { if ((data[i] == '\n') || (stream->buffpos > stream->buffsize)) { mutex_free(&stream->mutex); fflush(stream); } } else { if (stream->buffpos >= stream->buffsize) { mutex_free(&stream->mutex); fflush(stream); } } } return nmemb; }
void rewind(FILE *stream) { fflush(stream); mutex_spin(&stream->mutex); stream->position = 0; mutex_free(&stream->mutex); }
void handler_free (handler_t *h) { mutex_lock (h->mutex); handler_reset (h); mutex_unlock (h->mutex); mutex_free (h->mutex); cond_free (h->cond); free (h); }
static void destroy(Link self){ Dict dict = self->value.vptr; if (dict){ dictionary_free(dict->dictionary); mutex_free(dict->mutex); free(self->value.vptr); } object_destroy(self); }
/** * Uninitialize configuration stuff */ void config_done (void) { mutex_free (mutex); if (config_error) { free (config_error); } config_uload (); }
char *svga_rcall_unshare(struct robject *self, rp_t source, int argc, char **argv) { mutex_spin(&self->driver_mutex); page_free(buffer, msize(buffer)); free(buffer); buffer = valloc(svga.w * svga.h * 4); mutex_free(&self->driver_mutex); return strdup("T"); }
void Log_Exit(void) { if (logState.f) { mutex_destroy(logState.lock); mutex_free(logState.lock); fclose(logState.f); logState.f = NULL; logState.filePath[0] = '\0'; } }
/******************************************************************//** Closes the memory system. */ UNIV_INTERN void mem_close(void) /*===========*/ { mem_pool_free(mem_comm_pool); mem_comm_pool = NULL; #ifdef UNIV_MEM_DEBUG mutex_free(&mem_hash_mutex); mem_hash_initialized = FALSE; #endif /* UNIV_MEM_DEBUG */ }
fpos_t ftell(FILE *stream) { fpos_t pos; mutex_spin(&stream->mutex); pos = stream->position; pos += stream->buffpos; mutex_free(&stream->mutex); return pos; }
int svga_sync(uint64_t source, struct vfs_obj *file) { if (!buffer) { return -1; } mutex_spin(&file->mutex); svga_flip(buffer); mutex_free(&file->mutex); return 0; }
void __sig_init(void) { size_t i; mutex_spin(&__sigmutex); for (i = 0; i < SIGMAX; i++) { __sighandlerv[i] = SIG_DFL; when(i, _sigwrap); } mutex_free(&__sigmutex); }
/** * Uninitialize IPC stuff */ void wt_ipc_done (void) { ipc_enabled = FALSE; wt_ipc_builtin_done (); hook_unregister (CORE_ACTIVATE, wt_ipc_start, HOOK_PRIORITY_NORMAL); hook_unregister (CORE_DEACTIVATE, wt_ipc_stop, HOOK_PRIORITY_NORMAL); ipc_done (); mutex_free (mutex); }
void conf_free (void) { mutex_lock (mutex); DB_conf_item_t *next = NULL; for (DB_conf_item_t *it = conf_items; it; it = next) { next = it->next; conf_item_free (it); } conf_items = NULL; changed = 0; mutex_free (mutex); mutex = 0; }
/****************************************************************//** Free a work queue. */ UNIV_INTERN void ib_wqueue_free( /*===========*/ ib_wqueue_t* wq) /*!< in: work queue */ { ut_a(!ib_list_get_first(wq->items)); mutex_free(&wq->mutex); ib_list_free(wq->items); os_event_free(wq->event); mem_free(wq); }
int fflush(FILE *stream) { mutex_spin(&stream->mutex); if (stream->buffer && stream->buffpos) { write(stream->fd, stream->buffer, stream->buffpos, stream->position); stream->position += stream->buffpos; stream->buffpos = 0; } mutex_free(&stream->mutex); return 0; }
void thread_free(struct thread_handle *pt) { struct thread_priv *priv = (struct thread_priv *)pt->priv; if (pt->priv != NULL) { thread_join(pt); mutex_free(&priv->mutex); free(pt->priv); pt->priv = NULL; } }