int os_init(int (*init_once)(void)) { int err; #if defined(GENESIS_OS_WINDOWS) PVOID lpContext; BOOL pending; if (!InitOnceBeginInitialize(&win32_init_once, INIT_ONCE_ASYNC, &pending, &lpContext)) return GenesisErrorSystemResources; if (!pending) return 0; if ((err = internal_init(init_once))) return err; if (!InitOnceComplete(&win32_init_once, INIT_ONCE_ASYNC, nullptr)) return GenesisErrorSystemResources; #else assert_no_err(pthread_mutex_lock(&init_mutex)); if (initialized) { assert_no_err(pthread_mutex_unlock(&init_mutex)); return 0; } initialized = true; if ((err = internal_init(init_once))) return err; assert_no_err(pthread_mutex_unlock(&init_mutex)); #endif return 0; }
int soundio_os_init(void) { int err; #if defined(SOUNDIO_OS_WINDOWS) PVOID lpContext; BOOL pending; if (!InitOnceBeginInitialize(&win32_init_once, INIT_ONCE_ASYNC, &pending, &lpContext)) return SoundIoErrorSystemResources; if (!pending) return 0; if ((err = internal_init())) return err; if (!InitOnceComplete(&win32_init_once, INIT_ONCE_ASYNC, NULL)) return SoundIoErrorSystemResources; #else assert_no_err(pthread_mutex_lock(&init_mutex)); if (initialized) { assert_no_err(pthread_mutex_unlock(&init_mutex)); return 0; } initialized = true; if ((err = internal_init())) return err; assert_no_err(pthread_mutex_unlock(&init_mutex)); #endif return 0; }
void Disk::init_fs(on_init_func func) { device.read( 0, hw::Block_device::on_read_func::make_packed( [this, func] (hw::Block_device::buffer_t data) { if (!data) { // TODO: error-case for unable to read MBR func({ error_t::E_IO, "Unable to read MBR"}, fs()); return; } // auto-detect FAT on MBR: auto* mbr = (MBR::mbr*) data.get(); MBR::BPB* bpb = mbr->bpb(); if (bpb->bytes_per_sector >= 512 && bpb->fa_tables != 0 && (bpb->signature != 0 // check MBR signature too || bpb->large_sectors != 0)) // but its not set for FAT32 { // detected FAT on MBR filesys.reset(new FAT(device)); // initialize on MBR internal_init(MBR, func); return; } // go through partition list for (int i = 0; i < 4; i++) { if (mbr->part[i].type != 0 // 0 is unused partition && mbr->part[i].lba_begin != 0 // 0 is MBR anyways && mbr->part[i].sectors != 0) // 0 means no size, so... { // FIXME: for now we can only assume FAT, anyways // To be replaced with lookup table for partition identifiers, // but we really only have FAT atm, so its just wasteful filesys.reset(new FAT(device)); // initialize on VBRn internal_init((partition_t) (VBR1 + i), func); return; } } // no partition was found (TODO: extended partitions) func({ error_t::E_MNT, "No FAT partition auto-detected"}, fs()); }) ); }
XCamReturn X3aAnalyzer::init (uint32_t width, uint32_t height, double framerate) { XCamReturn ret = XCAM_RETURN_NO_ERROR; if (!_ae_handler.ptr() || !_awb_handler.ptr() || !_af_handler.ptr() || !_common_handler.ptr()) { XCAM_LOG_WARNING ( "analyzer:%s init failed, <prepare_handlers> need called first", XCAM_STR(get_name ())); return XCAM_RETURN_ERROR_PARAM; } XCAM_ASSERT (!_width && !_height); _width = width; _height = height; _framerate = framerate; ret = internal_init (width, height, _framerate); if (ret != XCAM_RETURN_NO_ERROR) { XCAM_LOG_WARNING ("analyzer init failed"); deinit (); return ret; } XCAM_LOG_INFO ( "Analyzer(%s) initialized(w:%d, h:%d).", XCAM_STR(get_name()), _width, _height); return XCAM_RETURN_NO_ERROR; }
int eo_init( CONFIG* cfg ) { /* From main_.cpp */ ATA_Init(); sound_init(); load_config(); zx81.cwd[ 0 ] = 0; zx81.temppath[ 0 ] = 0; zx81.inipath[ 0 ] = 0; zx81.configpath[ 0 ] = 0; //RenderInit(); SP0256_Init(); AnimTimer1_Interval = 20; Timer2_Interval = 1000; //AccurateInit(); int res = internal_init( cfg ); AnimTimer1_Interval *= 1000; Timer2_Interval *= 1000; AnimTimer1_Count = AnimTimer1_Interval; return res; }
void ol_lrc_fetch_ui_show (OlLrcFetchEngine *lrcengine, const OlLrcCandidate *candidates, int count, const OlMusicInfo *music_info, const char *filename) { ol_log_func (); if (window == NULL && !internal_init ()) return; if (lrcengine == NULL || candidates == NULL || count <= 0 || filename == NULL) { gtk_widget_hide (window); return; } if (filepath != NULL) g_free (filepath); filepath = g_strdup (filename); engine = lrcengine; ol_lrc_candidate_list_set_list (list, candidates, count); if (info == NULL) info = ol_music_info_new (); ol_music_info_copy (info, music_info); gboolean prompt = TRUE; OlConfig *config = ol_config_get_instance (); if (config != NULL) prompt = ol_config_get_bool (config, "Download", "download-first-lyric"); if (prompt || count == 1) ol_lrc_fetch_ui_download (GTK_WIDGET (download_button), NULL); else gtk_widget_show (window); }
void libxsmm_init(void) { const void *const registry = LIBXSMM_ATOMIC_LOAD(&internal_registry, LIBXSMM_ATOMIC_RELAXED); if (0 == registry) { internal_init(); } }
memory_session::memory_session(bool autostart): unfrozen_threads_count(-1), ram_allocated_bytes(0), total_allocated_bytes(0) { ram_limit_bytes = memory_manager::instance->get_default_session_ram_limit_bytes(); total_limit_bytes = memory_manager::instance->get_default_session_total_limit_bytes(); internal_init(autostart); }
/* creates a simple char* (string) with a name * good for quick manipulation of a string * Based only on the size of the char* array, easy if allocated for a string * */ char* set_stringn(const char* name, int size){ struct address * addr = _next_addr(); if(addr == NULL) return NULL; internal_init(addr, name, sizeof(char*), malloc(size * sizeof(char*))); return (char*) addr->loc; }
/* creates a simple char* (string) * good for quick manipulation of a string * Based only on the size of the char* array, easy if allocated for a string * */ char* set_string(int size){ struct address * addr = _next_addr(); if(addr == NULL) return NULL; internal_init(addr, "array", sizeof(char*), malloc(size * sizeof(char*))); return (char*) addr->loc; }
/* Set array in Heap based on name * Allocates memory internally for you based on type size and default * */ void* set_arrayn(char* name, size_t type){ struct address * addr = _next_addr(); if(addr == NULL) return NULL; internal_init(addr, name, type, calloc(DEFAULT_ALLOC, type)); return addr->loc; }
/* Set array in Heap based on name * Allocates memory based on a specified size passed in * */ void* set_arraynrc(char* name, int rows, int cols, size_t type){ struct address * addr = _next_addr(); if(addr == NULL) return NULL; internal_init(addr, name, type, malloc(rows * cols * type)); return addr->loc; }
/* Set Heap Based on specific size * Allocates memory based on a specified size passed in * */ void* set_heapst(size_t size, size_t type){ struct address * addr = _next_addr(); if(addr == NULL) return NULL; internal_init(addr,"Default", type, malloc(size * type)); return addr->loc; }
/* Set Heap Based on specific size * Allocates memory based on a specified size passed in * */ void* set_heaprct(int rows, int cols, size_t type){ struct address * addr = _next_addr(); if(addr == NULL) return NULL; internal_init(addr,"Default", type, malloc(rows * cols * type)); return addr->loc; }
/* Set Heap Memory (name, type, size) * Allocates memory based on a specified size passed in * */ void* set_file(char* name, size_t size, size_t type){ struct address * addr = _next_addr(); if(addr == NULL) return NULL; internal_init(addr, name, type, malloc(size * type)); return addr->loc; }
GtkWidget* ol_gui_get_widget (const char *name) { ol_assert_ret (name != NULL, NULL); internal_init (); ol_assert_ret (builder != NULL, NULL); GObject *obj = gtk_builder_get_object (builder, name); if (obj != NULL && GTK_IS_WIDGET (obj)) return GTK_WIDGET (obj); else return NULL; }
static void* socket_loop(void* arg) { int msgsock, rval, ret, socket; char buf[1024]; int len; char lsb, msb; ServiceContext *context = get_service_context(); (void) arg; if ((ret = internal_init()) < 0) { LOGE("Error initializing socket"); return NULL; } else socket = ret; LOGD("%s, socket=%d", __FUNCTION__, socket); while(1) { msgsock = accept(socket, 0, 0); context->socket = msgsock; LOGD("%s, msgsock=%d", __FUNCTION__, msgsock); if (msgsock == -1) { LOGE("socket accept: %s, exiting service loop", strerror(errno) ); close(socket); return NULL; } else { do { memset(buf, 0, 1024); len = lsb = msb = 0; if ((rval = read(msgsock, &msb, 1)) < 0) LOGE("reading stream length: %s", strerror(errno)); if ((rval = read(msgsock, &lsb, 1)) < 0) LOGE("reading stream length: %s", strerror(errno)); len |= msb; len = len << 8; len |= lsb; if ((rval = read(msgsock, buf, len)) < 0) LOGE("reading stream message: %s", strerror(errno) ); else if (rval > 0) parse_message(buf); } while (rval > 0); } close(msgsock); } LOGD("%s exiting", __FUNCTION__); return NULL; }
/*ARGSUSED*/ static void initialize(int argc, char *argv[]) { myname = uu_setpname(argv[0]); (void) atexit(lscf_cleanup); (void) setlocale(LC_ALL, ""); (void) textdomain(TEXT_DOMAIN); (void) lxml_init(); internal_init(); engine_init(); lscf_init(); /* must follow engine_init() */ tmpl_init(); }
static int continuation_store (MonoContinuation *cont, int state, MonoException **e) { MonoLMF *lmf = mono_get_lmf (); gsize num_bytes; if (!cont->domain) { *e = mono_get_exception_argument ("cont", "Continuation not initialized"); return 0; } if (cont->domain != mono_domain_get () || cont->thread_id != GetCurrentThreadId ()) { *e = mono_get_exception_argument ("cont", "Continuation from another thread or domain"); return 0; } cont->lmf = lmf; cont->return_ip = __builtin_return_address (0); cont->return_sp = __builtin_frame_address (0); num_bytes = (char*)cont->top_sp - (char*)cont->return_sp; /*g_print ("store: %d bytes, sp: %p, ip: %p, lmf: %p\n", num_bytes, cont->return_sp, cont->return_ip, lmf);*/ if (cont->saved_stack && num_bytes <= cont->stack_alloc_size) { /* clear to avoid GC retention */ if (num_bytes < cont->stack_used_size) { memset ((char*)cont->saved_stack + num_bytes, 0, cont->stack_used_size - num_bytes); } cont->stack_used_size = num_bytes; } else { tasklets_lock (); internal_init (); if (cont->saved_stack) { mono_g_hash_table_remove (keepalive_stacks, cont->saved_stack); mono_gc_free_fixed (cont->saved_stack); } cont->stack_used_size = num_bytes; cont->stack_alloc_size = num_bytes * 1.1; cont->saved_stack = mono_gc_alloc_fixed (cont->stack_alloc_size, NULL); mono_g_hash_table_insert (keepalive_stacks, cont->saved_stack, cont->saved_stack); tasklets_unlock (); } memcpy (cont->saved_stack, cont->return_sp, num_bytes); return state; }
static int continuation_store (MonoContinuation *cont, int state, MonoException **e) { MonoLMF *lmf = mono_get_lmf (); gsize num_bytes; if (!cont->domain) { *e = mono_get_exception_argument ("cont", "Continuation not initialized"); return 0; } if (cont->domain != mono_domain_get () || !mono_native_thread_id_equals (cont->thread_id, mono_native_thread_id_get ())) { *e = mono_get_exception_argument ("cont", "Continuation from another thread or domain"); return 0; } cont->lmf = lmf; cont->return_ip = __builtin_extract_return_addr (__builtin_return_address (0)); cont->return_sp = __builtin_frame_address (0); num_bytes = (char*)cont->top_sp - (char*)cont->return_sp; /*g_print ("store: %d bytes, sp: %p, ip: %p, lmf: %p\n", num_bytes, cont->return_sp, cont->return_ip, lmf);*/ if (cont->saved_stack && num_bytes <= cont->stack_alloc_size) { /* clear to avoid GC retention */ if (num_bytes < cont->stack_used_size) { memset ((char*)cont->saved_stack + num_bytes, 0, cont->stack_used_size - num_bytes); } cont->stack_used_size = num_bytes; } else { tasklets_lock (); internal_init (); if (cont->saved_stack) mono_gc_free_fixed (cont->saved_stack); cont->stack_used_size = num_bytes; cont->stack_alloc_size = num_bytes * 1.1; cont->saved_stack = mono_gc_alloc_fixed (cont->stack_alloc_size, NULL, MONO_ROOT_SOURCE_THREADING, "saved tasklet stack"); tasklets_unlock (); } memcpy (cont->saved_stack, cont->return_sp, num_bytes); return state; }
GtkWidget * nma_wireless_dialog_new (NMClient *client, NMConnection *connection, NMDevice *device, NMAccessPoint *ap) { NMAWirelessDialog *self; NMAWirelessDialogPrivate *priv; guint32 dev_caps; g_return_val_if_fail (NM_IS_CLIENT (client), NULL); g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL); g_return_val_if_fail (NM_IS_DEVICE (device), NULL); g_return_val_if_fail (NM_IS_ACCESS_POINT (ap), NULL); /* Ensure device validity */ dev_caps = nm_device_get_capabilities (device); g_return_val_if_fail (dev_caps & NM_DEVICE_CAP_NM_SUPPORTED, NULL); g_return_val_if_fail (NM_IS_DEVICE_WIFI (device), NULL); self = NMA_WIRELESS_DIALOG (g_object_new (NMA_TYPE_WIRELESS_DIALOG, NULL)); if (!self) return NULL; priv = NMA_WIRELESS_DIALOG_GET_PRIVATE (self); priv->client = g_object_ref (client); priv->ap = g_object_ref (ap); if (!internal_init (self, connection, device, TRUE, FALSE)) { nm_warning ("Couldn't create wireless security dialog."); g_object_unref (self); return NULL; } return GTK_WIDGET (self); }
long joy_core::init(JOY_DEV dev, bool non_block) { try { if (joy_do_mutex_lock(&m_joy_dev_info[dev].init_mutex) != JOY_SUCCESS) { THROW_EXP(JOY_LINUX_ERROR, JOY_MUTEX_LOCK_FAILED, "Mutex lock failed", NULL); } // Check if already initialized if (m_joy_dev_info[dev].initialized) { THROW_EXP(JOY_INTERNAL_ERROR, JOY_ALREADY_INITIALIZED, "Already initialized, dev=%d", dev); } // Do the actual initialization internal_init(dev, non_block); // Initialization completed m_joy_dev_info[dev].initialized = true; if (joy_do_mutex_unlock(&m_joy_dev_info[dev].init_mutex) != JOY_SUCCESS) { THROW_EXP(JOY_LINUX_ERROR, JOY_MUTEX_UNLOCK_FAILED, "Mutex unlock failed", NULL); } return JOY_SUCCESS; } catch (joy_exception &exp) { joy_do_mutex_unlock(&m_joy_dev_info[dev].init_mutex); return set_error(exp); } catch (...) { joy_do_mutex_unlock(&m_joy_dev_info[dev].init_mutex); return set_error(EXP(JOY_INTERNAL_ERROR, JOY_UNEXPECTED_EXCEPTION, NULL, NULL)); } }
GtkWidget * nma_wireless_dialog_hidden_new (NMClient *client) { NMAWirelessDialog *self; NMAWirelessDialogPrivate *priv; g_return_val_if_fail (NM_IS_CLIENT (client), NULL); self = NMA_WIRELESS_DIALOG (g_object_new (NMA_TYPE_WIRELESS_DIALOG, NULL)); if (!self) return NULL; priv = NMA_WIRELESS_DIALOG_GET_PRIVATE (self); priv->client = g_object_ref (client); if (!internal_init (self, NULL, NULL, FALSE, FALSE)) { nm_warning ("Couldn't create wireless security dialog."); g_object_unref (self); return NULL; } return GTK_WIDGET (self); }
void Disk::init_fs(partition_t part, on_init_func func) { filesys.reset(new FAT(device)); internal_init(part, func); }
multi_shortvector(int n) : m_alloc_data(NULL) { internal_init(n); }
memory_session::memory_session(size_t starting_ram_limit_bytes, size_t starting_total_limit_bytes, bool autostart): unfrozen_threads_count(-1), ram_limit_bytes(starting_ram_limit_bytes), total_limit_bytes(starting_total_limit_bytes), ram_allocated_bytes(0), total_allocated_bytes(0) { internal_init(autostart); }
void init(int n) { if (m_alloc_data != NULL) { delete[] m_alloc_data; } internal_init(n); }
static void init() { if (!_init) internal_init(); };
memory_sub_session::memory_sub_session(memory_session* session, bool autobegin): parent(session), unfrozen_threads_count(-1), allocated_bytes(0) { internal_init(autobegin); }
void vertex_separator_flow_solver::find_separator(const PartitionConfig & config, graph_access & G, PartitionID lhs, PartitionID rhs, boundary_starting_nodes lhs_nodes, boundary_starting_nodes rhs_nodes, std::vector<NodeID> & separator) { if(lhs_nodes.size() == 0 || rhs_nodes.size() == 0) return; node *j = NULL; int cc; bucket *l; globUpdtFreq = GLOB_UPDT_FREQ; std::vector<NodeID> new_to_old_ids; EdgeID no_edges_in_flow_graph = 0; bool success = construct_flow_pb(config, G, lhs, rhs, lhs_nodes, rhs_nodes, new_to_old_ids, &n, &m, &nodes, &arcs, &cap, &source, &sink, &nMin, no_edges_in_flow_graph ); cc = internal_allocDS(); if(!success) return; if ( cc ) { fprintf ( stderr, "Allocation error\n"); exit ( 1 ); } internal_init(); internal_stage_one( ); internal_stage_two(); /* check if mincut is saturated */ aMax = dMax = 0; for (l = buckets; l < buckets + n; l++) { l->firstActive = sentinelNode; l->firstInactive = sentinelNode; } internal_global_update(); std::vector<NodeID> S; forAllNodes(j) { if (!(j->d < n)) { if((unsigned) (nNode(j) - 1) < (int)lhs_nodes.size() + rhs_nodes.size()) { //Note: unsigned has been introduced without testing S.push_back(new_to_old_ids[nNode(j) -1]); } } } std::sort(lhs_nodes.begin(), lhs_nodes.end()); std::sort(rhs_nodes.begin(), rhs_nodes.end()); std::sort(S.begin(), S.end()); std::vector<int> separator_tmp(lhs_nodes.size() + rhs_nodes.size(), -1); std::vector<int>::iterator it; it = std::set_intersection(rhs_nodes.begin(), rhs_nodes.end(), S.begin(), S.end(), separator_tmp.begin()); for( unsigned i = 0; i < separator_tmp.size(); i++) { if(separator_tmp[i] != -1) { separator.push_back(separator_tmp[i]); } } std::vector<int>::iterator it2; std::vector<int> separator_tmp2(lhs_nodes.size() + rhs_nodes.size(), -1); it2 = std::set_difference(lhs_nodes.begin(), lhs_nodes.end(), S.begin(), S.end(), separator_tmp2.begin()); for( unsigned i = 0; i < separator_tmp2.size(); i++) { if(separator_tmp2[i] != -1) { separator.push_back(separator_tmp2[i]); } } }