void *spead_api_setup(struct spead_api_module_shared *s) { struct json_file *json; lock_spead_api_module_shared(s); if (!(json = get_data_spead_api_module_shared(s))){ json = shared_malloc(sizeof(struct json_file)); if (json == NULL) return NULL; set_data_spead_api_module_shared(s, json, sizeof(struct json_file)); json->j_name = NULL; json->j_df = NULL; json->j_name = gen_id_avltree("id.json"); if (json->j_name == NULL){ spead_api_destroy(s, json); return NULL; } json->j_df = write_raw_data_file(json->j_name); if (json->j_df == NULL){ spead_api_destroy(s, json); return NULL; } } unlock_spead_api_module_shared(s); return NULL; }
int smem_create(char *filename, int *driverhandle) { DAL_SHM_SEGHEAD *sp; int h, sz, nitems; if (NULL == filename) return(SHARED_NULPTR); /* currently ignored */ if (NULL == driverhandle) return(SHARED_NULPTR); nitems = sscanf(filename, "h%d", &h); if (1 != nitems) return(SHARED_BADARG); if (SHARED_INVALID == (h = shared_malloc(sz = 2880 + sizeof(DAL_SHM_SEGHEAD), SHARED_RESIZE | SHARED_PERSIST, h))) return(SHARED_NOMEM); if (NULL == (sp = (DAL_SHM_SEGHEAD *)shared_lock(h, SHARED_RDWRITE))) { shared_free(h); return(SHARED_BADARG); } sp->ID = DAL_SHM_SEGHEAD_ID; sp->h = h; sp->size = sz; sp->nodeidx = -1; *driverhandle = h; return(0); }
void *spead_api_setup(struct spead_api_module_shared *s) { struct snap_shot *ss; char * env_temp; ss = NULL; lock_spead_api_module_shared(s); if (!(ss = get_data_spead_api_module_shared(s))){ ss = shared_malloc(sizeof(struct snap_shot)); if (ss == NULL){ unlock_spead_api_module_shared(s); return NULL; } ss->flag[0] = 0; ss->flag[1] = 0; ss->flag[2] = 1; ss->flag[3] = 1; ss->prior_ts = 0; ss->master_pid = 0; // change defaults based on environmental variables present env_temp = getenv("TRANSPOSE"); if (env_temp != NULL) ss->transpose = atoi(env_temp); else ss->transpose = DEFAULT_TRANPOSE; env_temp = getenv("FULLBAND"); if (env_temp != NULL) ss->fullband = atoi(env_temp); else ss->fullband = DEFAULT_FULLBAND; env_temp = getenv("PREFIX"); if (env_temp != NULL) ss->prefix = env_temp; else ss->prefix = DEFAULT_PREFIX; set_data_spead_api_module_shared(s, ss, sizeof(struct snap_shot)); fprintf(stderr, "%s: PID [%d] decode BF data\n", __func__, getpid()); fprintf(stderr, "\nConfiguration\n=============\nFilename Prefix (PREFIX): %s\nTranspose data (TRANPOSE): %s\nRecord Fullband (FULLBAND): %s\n\n", ss->prefix, ss->transpose ? "True":"False", ss->fullband ? "True":"False"); fflush(stdout); } heap_count = 1; prior_ts = 0; unlock_spead_api_module_shared(s); return NULL; }
void assoc_init(const int hashtable_init) { if (hashtable_init) { hashpower = hashtable_init; } if (settings.shared_malloc_assoc) { primary_hashtable = shared_malloc((void *)0x00007fa2fdf10000, hashsize(hashpower)*sizeof(void *), settings.shared_malloc_assoc_key, NO_LOCK);//TODO: check that no need to add zeroes (like in calloc) } else { primary_hashtable = calloc(hashsize(hashpower), sizeof(void *)); } if (! primary_hashtable) { fprintf(stderr, "Failed to init hashtable.\n"); exit(EXIT_FAILURE); } STATS_LOCK(); stats.hash_power_level = hashpower; stats.hash_bytes = hashsize(hashpower) * sizeof(void *); STATS_UNLOCK(); }