Threads: Rename init to init_mutex for clarity

This commit is contained in:
Shahram Najm 2024-07-22 14:22:39 +00:00
parent 809fb99728
commit 5efdd28777
17 changed files with 89 additions and 89 deletions

View File

@ -15,7 +15,7 @@
static pthread_once_t once = PTHREAD_ONCE_INIT;
static pthread_mutex_t mutex1 = PTHREAD_MUTEX_INITIALIZER;
static void thread_init()
static void init_mutex()
{
pthread_mutexattr_t attr;
pthread_mutexattr_init(&attr);
@ -27,7 +27,7 @@ static void thread_init()
static int once = 0;
static omp_nest_lock_t mutex1;
static void thread_init()
static void init_mutex()
{
GRIB_OMP_CRITICAL(lock_grib_accessor_class_bufr_elements_table_c)
{
@ -89,7 +89,7 @@ static grib_trie* load_bufr_elements_table(grib_accessor* a, int* err)
if (self->localDir != NULL)
grib_get_string(h, self->localDir, localDir, &len);
GRIB_MUTEX_INIT_ONCE(&once, &thread_init);
GRIB_MUTEX_INIT_ONCE(&once, &init_mutex);
GRIB_MUTEX_LOCK(&mutex1);
if (*masterDir != 0) {

View File

@ -20,7 +20,7 @@ grib_accessor_class* grib_accessor_class_codetable = &_grib_accessor_class_codet
static pthread_once_t once = PTHREAD_ONCE_INIT;
static pthread_mutex_t mutex1 = PTHREAD_MUTEX_INITIALIZER;
static void thread_init()
static void init_mutex()
{
pthread_mutexattr_t attr;
pthread_mutexattr_init(&attr);
@ -32,7 +32,7 @@ static void thread_init()
static int once = 0;
static omp_nest_lock_t mutex1;
static void thread_init()
static void init_mutex()
{
GRIB_OMP_CRITICAL(lock_grib_accessor_class_codetable_c)
{
@ -205,7 +205,7 @@ static grib_codetable* load_table(grib_accessor* a)
localFilename = grib_context_full_defs_path(c, localRecomposed);
}
GRIB_MUTEX_INIT_ONCE(&once, &thread_init);
GRIB_MUTEX_INIT_ONCE(&once, &init_mutex);
GRIB_MUTEX_LOCK(&mutex1); /* GRIB-930 */
/*printf("DBG %s: Look in cache: f=%s lf=%s (recomposed=%s)\n", self->att.name, filename, localFilename,recomposed);*/

View File

@ -18,7 +18,7 @@ grib_accessor_class* grib_accessor_class_smart_table = &_grib_accessor_class_sma
static pthread_once_t once = PTHREAD_ONCE_INIT;
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
static void thread_init()
static void init_mutex()
{
pthread_mutexattr_t attr;
pthread_mutexattr_init(&attr);
@ -30,7 +30,7 @@ static void thread_init()
static int once = 0;
static omp_nest_lock_t mutex;
static void thread_init()
static void init_mutex()
{
GRIB_OMP_CRITICAL(lock_grib_accessor_class_smart_table_c)
{
@ -183,7 +183,7 @@ static int grib_load_smart_table(grib_context* c, const char* filename,
t->recomposed_name[0] = grib_context_strdup_persistent(c, recomposed_name);
t->next = c->smart_table;
t->numberOfEntries = size;
GRIB_MUTEX_INIT_ONCE(&once, &thread_init);
GRIB_MUTEX_INIT_ONCE(&once, &init_mutex);
GRIB_MUTEX_LOCK(&mutex);
c->smart_table = t;
GRIB_MUTEX_UNLOCK(&mutex);

View File

@ -95,7 +95,7 @@ static void init_class(grib_action_class* c)
static pthread_once_t once = PTHREAD_ONCE_INIT;
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
static void init()
static void init_mutex()
{
pthread_mutexattr_t attr;
pthread_mutexattr_init(&attr);
@ -107,7 +107,7 @@ static void init()
static int once = 0;
static omp_nest_lock_t mutex;
static void init()
static void init_mutex()
{
GRIB_OMP_CRITICAL(lock_action_class_concept_c)
{
@ -306,7 +306,7 @@ static grib_concept_value* get_concept_impl(grib_handle* h, grib_action_concept*
static grib_concept_value* get_concept(grib_handle* h, grib_action_concept* self)
{
grib_concept_value* result = NULL;
GRIB_MUTEX_INIT_ONCE(&once, &init);
GRIB_MUTEX_INIT_ONCE(&once, &init_mutex);
GRIB_MUTEX_LOCK(&mutex);
result = get_concept_impl(h, self);

View File

@ -98,7 +98,7 @@ static void init_class(grib_action_class* c)
static pthread_once_t once = PTHREAD_ONCE_INIT;
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
static void init()
static void init_mutex()
{
pthread_mutexattr_t attr;
pthread_mutexattr_init(&attr);
@ -110,7 +110,7 @@ static void init()
static int once = 0;
static omp_nest_lock_t mutex;
static void init()
static void init_mutex()
{
GRIB_OMP_CRITICAL(lock_action_class_hash_array_c)
{
@ -325,7 +325,7 @@ static grib_hash_array_value* get_hash_array_impl(grib_handle* h, grib_action* a
grib_hash_array_value* get_hash_array(grib_handle* h, grib_action* a)
{
grib_hash_array_value* result = NULL;
GRIB_MUTEX_INIT_ONCE(&once, &init);
GRIB_MUTEX_INIT_ONCE(&once, &init_mutex);
GRIB_MUTEX_LOCK(&mutex);
result = get_hash_array_impl(h, a);

View File

@ -22,7 +22,7 @@
static pthread_once_t once = PTHREAD_ONCE_INIT;
static pthread_mutex_t mutex1 = PTHREAD_MUTEX_INITIALIZER;
static void init()
static void init_mutex()
{
pthread_mutexattr_t attr;
pthread_mutexattr_init(&attr);
@ -34,7 +34,7 @@ static void init()
static int once = 0;
static omp_nest_lock_t mutex1;
static void init()
static void init_mutex()
{
GRIB_OMP_CRITICAL(lock_grib_accessor_class_c)
{
@ -77,7 +77,7 @@ grib_section* grib_create_root_section(const grib_context* context, grib_handle*
char* fpath = 0;
grib_section* s = (grib_section*)grib_context_malloc_clear(context, sizeof(grib_section));
GRIB_MUTEX_INIT_ONCE(&once, &init);
GRIB_MUTEX_INIT_ONCE(&once, &init_mutex);
GRIB_MUTEX_LOCK(&mutex1);
if (h->context->grib_reader == NULL) {
if ((fpath = grib_context_full_defs_path(h->context, "boot.def")) == NULL) {

View File

@ -22,7 +22,7 @@
static pthread_once_t once = PTHREAD_ONCE_INIT;
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
static void init()
static void init_mutex()
{
pthread_mutexattr_t attr;
pthread_mutexattr_init(&attr);
@ -34,7 +34,7 @@ static void init()
static int once = 0;
static omp_nest_lock_t mutex;
static void init()
static void init_mutex()
{
GRIB_OMP_CRITICAL(lock_grib_bits_any_endian_c)
{
@ -77,7 +77,7 @@ static void init_bits_all_one()
static void init_bits_all_one_if_needed()
{
GRIB_MUTEX_INIT_ONCE(&once, &init);
GRIB_MUTEX_INIT_ONCE(&once, &init_mutex);
GRIB_MUTEX_LOCK(&mutex);
if (!bits_all_one.inited)
init_bits_all_one();

View File

@ -41,7 +41,7 @@ static pthread_once_t once = PTHREAD_ONCE_INIT;
static pthread_mutex_t mutex_mem = PTHREAD_MUTEX_INITIALIZER;
static pthread_mutex_t mutex_c = PTHREAD_MUTEX_INITIALIZER;
static void init()
static void init_mutex()
{
pthread_mutexattr_t attr;
pthread_mutexattr_init(&attr);
@ -55,7 +55,7 @@ static int once = 0;
static omp_nest_lock_t mutex_mem;
static omp_nest_lock_t mutex_c;
static void init()
static void init_mutex()
{
GRIB_OMP_CRITICAL(lock_grib_context_c)
{
@ -374,7 +374,7 @@ static grib_context default_grib_context = {
grib_context* grib_context_get_default()
{
GRIB_MUTEX_INIT_ONCE(&once, &init);
GRIB_MUTEX_INIT_ONCE(&once, &init_mutex);
GRIB_MUTEX_LOCK(&mutex_c);
if (!default_grib_context.inited) {
@ -569,7 +569,7 @@ grib_context* grib_context_get_default()
// if (!parent) parent=grib_context_get_default();
// GRIB_MUTEX_INIT_ONCE(&once,&init);
// GRIB_MUTEX_INIT_ONCE(&once,&init_mutex);
// GRIB_MUTEX_LOCK(&(parent->mutex));
// c = (grib_context*)grib_context_malloc_clear_persistent(&default_grib_context,sizeof(grib_context));
@ -646,7 +646,7 @@ static int init_definition_files_dir(grib_context* c)
strncpy(path, c->grib_definition_files_path, ECC_PATH_MAXLEN-1);
path[ ECC_PATH_MAXLEN - 1 ] = '\0';
GRIB_MUTEX_INIT_ONCE(&once, &init);
GRIB_MUTEX_INIT_ONCE(&once, &init_mutex);
GRIB_MUTEX_LOCK(&mutex_c);
p = path;
@ -692,7 +692,7 @@ char* grib_context_full_defs_path(grib_context* c, const char* basename)
if (!c)
c = grib_context_get_default();
GRIB_MUTEX_INIT_ONCE(&once, &init);
GRIB_MUTEX_INIT_ONCE(&once, &init_mutex);
if (*basename == '/' || *basename == '.') {
return (char*)basename;
@ -880,7 +880,7 @@ void grib_context_set_definitions_path(grib_context* c, const char* path)
{
if (!c)
c = grib_context_get_default();
GRIB_MUTEX_INIT_ONCE(&once, &init);
GRIB_MUTEX_INIT_ONCE(&once, &init_mutex);
GRIB_MUTEX_LOCK(&mutex_c);
c->grib_definition_files_path = strdup(path);
@ -892,7 +892,7 @@ void grib_context_set_samples_path(grib_context* c, const char* path)
{
if (!c)
c = grib_context_get_default();
GRIB_MUTEX_INIT_ONCE(&once, &init);
GRIB_MUTEX_INIT_ONCE(&once, &init_mutex);
GRIB_MUTEX_LOCK(&mutex_c);
c->grib_samples_path = strdup(path);
@ -1095,7 +1095,7 @@ int grib_context_get_handle_file_count(grib_context* c)
int r = 0;
if (!c)
c = grib_context_get_default();
GRIB_MUTEX_INIT_ONCE(&once, &init);
GRIB_MUTEX_INIT_ONCE(&once, &init_mutex);
GRIB_MUTEX_LOCK(&mutex_c);
r = c->handle_file_count;
GRIB_MUTEX_UNLOCK(&mutex_c);
@ -1106,7 +1106,7 @@ int grib_context_get_handle_total_count(grib_context* c)
int r = 0;
if (!c)
c = grib_context_get_default();
GRIB_MUTEX_INIT_ONCE(&once, &init);
GRIB_MUTEX_INIT_ONCE(&once, &init_mutex);
GRIB_MUTEX_LOCK(&mutex_c);
r = c->handle_total_count;
GRIB_MUTEX_UNLOCK(&mutex_c);
@ -1117,7 +1117,7 @@ void grib_context_set_handle_file_count(grib_context* c, int new_count)
{
if (!c)
c = grib_context_get_default();
GRIB_MUTEX_INIT_ONCE(&once, &init);
GRIB_MUTEX_INIT_ONCE(&once, &init_mutex);
GRIB_MUTEX_LOCK(&mutex_c);
c->handle_file_count = new_count;
GRIB_MUTEX_UNLOCK(&mutex_c);
@ -1126,7 +1126,7 @@ void grib_context_set_handle_total_count(grib_context* c, int new_count)
{
if (!c)
c = grib_context_get_default();
GRIB_MUTEX_INIT_ONCE(&once, &init);
GRIB_MUTEX_INIT_ONCE(&once, &init_mutex);
GRIB_MUTEX_LOCK(&mutex_c);
c->handle_total_count = new_count;
GRIB_MUTEX_UNLOCK(&mutex_c);
@ -1136,7 +1136,7 @@ void grib_context_increment_handle_file_count(grib_context* c)
{
if (!c)
c = grib_context_get_default();
GRIB_MUTEX_INIT_ONCE(&once, &init);
GRIB_MUTEX_INIT_ONCE(&once, &init_mutex);
GRIB_MUTEX_LOCK(&mutex_c);
c->handle_file_count++;
GRIB_MUTEX_UNLOCK(&mutex_c);
@ -1145,7 +1145,7 @@ void grib_context_increment_handle_total_count(grib_context* c)
{
if (!c)
c = grib_context_get_default();
GRIB_MUTEX_INIT_ONCE(&once, &init);
GRIB_MUTEX_INIT_ONCE(&once, &init_mutex);
GRIB_MUTEX_LOCK(&mutex_c);
c->handle_total_count++;
GRIB_MUTEX_UNLOCK(&mutex_c);
@ -1160,7 +1160,7 @@ bufr_descriptors_array* grib_context_expanded_descriptors_list_get(grib_context*
if (!c)
c = grib_context_get_default();
GRIB_MUTEX_INIT_ONCE(&once, &init);
GRIB_MUTEX_INIT_ONCE(&once, &init_mutex);
GRIB_MUTEX_LOCK(&mutex_c);
if (!c->expanded_descriptors) {
@ -1200,7 +1200,7 @@ void grib_context_expanded_descriptors_list_push(grib_context* c,
if (!c)
c = grib_context_get_default();
GRIB_MUTEX_INIT_ONCE(&once, &init);
GRIB_MUTEX_INIT_ONCE(&once, &init_mutex);
GRIB_MUTEX_LOCK(&mutex_c);
newdescriptorsList = (bufr_descriptors_map_list*)grib_context_malloc_clear(c, sizeof(bufr_descriptors_map_list));

View File

@ -15,7 +15,7 @@
static pthread_once_t once = PTHREAD_ONCE_INIT;
static pthread_mutex_t mutex1 = PTHREAD_MUTEX_INITIALIZER;
static void init()
static void init_mutex()
{
pthread_mutexattr_t attr;
pthread_mutexattr_init(&attr);
@ -27,7 +27,7 @@ static void init()
static int once = 0;
static omp_nest_lock_t mutex1;
static void init()
static void init_mutex()
{
GRIB_OMP_CRITICAL(lock_grib_filepool_c)
{
@ -175,7 +175,7 @@ grib_file* grib_file_open(const char* filename, const char* mode, int* err)
grib_file *file = 0, *prev = 0;
int same_mode = 0;
int is_new = 0;
GRIB_MUTEX_INIT_ONCE(&once, &init);
GRIB_MUTEX_INIT_ONCE(&once, &init_mutex);
if (!file_pool.context)
file_pool.context = grib_context_get_default();
@ -257,7 +257,7 @@ grib_file* grib_file_open(const char* filename, const char* mode, int* err)
void grib_file_pool_delete_file(grib_file* file)
{
grib_file* prev = NULL;
GRIB_MUTEX_INIT_ONCE(&once, &init);
GRIB_MUTEX_INIT_ONCE(&once, &init_mutex);
GRIB_MUTEX_LOCK(&mutex1);
if (file == file_pool.first) {
@ -299,7 +299,7 @@ void grib_file_close(const char* filename, int force, int* err)
if (do_close) {
/*printf("+++++++++++++ closing file %s (n=%d)\n",filename, file_pool.number_of_opened_files);*/
GRIB_MUTEX_INIT_ONCE(&once, &init);
GRIB_MUTEX_INIT_ONCE(&once, &init_mutex);
GRIB_MUTEX_LOCK(&mutex1);
file = grib_get_file(filename, err);
if (file->handle) {
@ -323,7 +323,7 @@ void grib_file_close_all(int* err)
if (!file_pool.first)
return;
GRIB_MUTEX_INIT_ONCE(&once, &init);
GRIB_MUTEX_INIT_ONCE(&once, &init_mutex);
GRIB_MUTEX_LOCK(&mutex1);
file = file_pool.first;
@ -390,7 +390,7 @@ static grib_file* grib_file_new(grib_context* c, const char* name, int* err)
*err = GRIB_OUT_OF_MEMORY;
return NULL;
}
GRIB_MUTEX_INIT_ONCE(&once, &init);
GRIB_MUTEX_INIT_ONCE(&once, &init_mutex);
file->name = strdup(name);
file->id = next_id;
@ -412,7 +412,7 @@ void grib_file_delete(grib_file* file)
{
if (!file) return;
GRIB_MUTEX_INIT_ONCE(&once, &init);
GRIB_MUTEX_INIT_ONCE(&once, &init_mutex);
GRIB_MUTEX_LOCK(&mutex1);
/* GRIB-803: cannot call fclose yet! Causes crash */
/* TODO: Set handle to NULL in filepool too */

View File

@ -9743,7 +9743,7 @@ static const int mapping[] = {
static pthread_once_t once = PTHREAD_ONCE_INIT;
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
static void init()
static void init_mutex()
{
pthread_mutexattr_t attr;
pthread_mutexattr_init(&attr);
@ -9755,7 +9755,7 @@ static void init()
static int once = 0;
static omp_nest_lock_t mutex;
static void init()
static void init_mutex()
{
GRIB_OMP_CRITICAL(lock_grib_itrie_keys_c)
{
@ -9787,7 +9787,7 @@ grib_itrie* grib_hash_keys_new(grib_context* c, int* count)
void grib_hash_keys_delete(grib_itrie* t)
{
GRIB_MUTEX_INIT_ONCE(&once, &init);
GRIB_MUTEX_INIT_ONCE(&once, &init_mutex);
GRIB_MUTEX_LOCK(&mutex);
if (t) {
@ -9808,7 +9808,7 @@ static int grib_hash_keys_insert(grib_itrie* t, const char* key)
grib_itrie* last = t;
int* count;
GRIB_MUTEX_INIT_ONCE(&once, &init);
GRIB_MUTEX_INIT_ONCE(&once, &init_mutex);
GRIB_MUTEX_LOCK(&mutex);
Assert(t);
@ -9862,7 +9862,7 @@ int grib_hash_keys_get_id(grib_itrie* t, const char* key)
const char* k = key;
grib_itrie* last = t;
GRIB_MUTEX_INIT_ONCE(&once, &init);
GRIB_MUTEX_INIT_ONCE(&once, &init_mutex);
GRIB_MUTEX_LOCK(&mutex);
while (*k && t)

View File

@ -14,7 +14,7 @@
static pthread_once_t once = PTHREAD_ONCE_INIT;
static pthread_mutex_t mutex1 = PTHREAD_MUTEX_INITIALIZER;
static pthread_mutex_t mutex2 = PTHREAD_MUTEX_INITIALIZER;
static void init()
static void init_mutex()
{
pthread_mutexattr_t attr;
pthread_mutexattr_init(&attr);
@ -27,7 +27,7 @@ static void init()
static int once = 0;
static omp_nest_lock_t mutex1;
static omp_nest_lock_t mutex2;
static void init()
static void init_mutex()
{
GRIB_OMP_CRITICAL(lock_grib_io_c)
{
@ -931,7 +931,7 @@ static int read_any(reader* r, int no_alloc, int grib_ok, int bufr_ok, int hdf5_
* so each thread gets its own message. Otherwise if threads are passed
* different files, then the lock is not needed
*/
GRIB_MUTEX_INIT_ONCE(&once, &init);
GRIB_MUTEX_INIT_ONCE(&once, &init_mutex);
GRIB_MUTEX_LOCK(&mutex1);
#endif

View File

@ -276,7 +276,7 @@ static const int mapping[] = {
static pthread_once_t once = PTHREAD_ONCE_INIT;
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
static void init()
static void init_mutex()
{
pthread_mutexattr_t attr;
pthread_mutexattr_init(&attr);
@ -288,7 +288,7 @@ static void init()
static int once = 0;
static omp_nest_lock_t mutex;
static void init()
static void init_mutex()
{
GRIB_OMP_CRITICAL(lock_grib_itrie_c)
{
@ -319,7 +319,7 @@ grib_itrie* grib_itrie_new(grib_context* c, int* count)
void grib_itrie_delete(grib_itrie* t)
{
GRIB_MUTEX_INIT_ONCE(&once, &init);
GRIB_MUTEX_INIT_ONCE(&once, &init_mutex);
GRIB_MUTEX_LOCK(&mutex);
if (t) {
@ -343,7 +343,7 @@ int grib_itrie_get_id(grib_itrie* t, const char* key)
return -1;
}
GRIB_MUTEX_INIT_ONCE(&once, &init);
GRIB_MUTEX_INIT_ONCE(&once, &init_mutex);
GRIB_MUTEX_LOCK(&mutex);
while (*k && t)
@ -371,7 +371,7 @@ int grib_itrie_insert(grib_itrie* t, const char* key)
return -1;
}
GRIB_MUTEX_INIT_ONCE(&once, &init);
GRIB_MUTEX_INIT_ONCE(&once, &init_mutex);
GRIB_MUTEX_LOCK(&mutex);
count = t->count;

View File

@ -273,7 +273,7 @@ static const int mapping[] = {
static pthread_once_t once = PTHREAD_ONCE_INIT;
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
static void init()
static void init_mutex()
{
pthread_mutexattr_t attr;
pthread_mutexattr_init(&attr);
@ -285,7 +285,7 @@ static void init()
static int once = 0;
static omp_nest_lock_t mutex;
static void init()
static void init_mutex()
{
GRIB_OMP_CRITICAL(lock_grib_itrie_keys_c)
{
@ -317,7 +317,7 @@ grib_itrie* grib_hash_keys_new(grib_context* c, int* count)
void grib_hash_keys_delete(grib_itrie* t)
{
GRIB_MUTEX_INIT_ONCE(&once, &init);
GRIB_MUTEX_INIT_ONCE(&once, &init_mutex);
GRIB_MUTEX_LOCK(&mutex);
if (t) {
@ -338,7 +338,7 @@ static int grib_hash_keys_insert(grib_itrie* t, const char* key)
grib_itrie* last = t;
int* count;
GRIB_MUTEX_INIT_ONCE(&once, &init);
GRIB_MUTEX_INIT_ONCE(&once, &init_mutex);
GRIB_MUTEX_LOCK(&mutex);
Assert(t);
@ -392,7 +392,7 @@ int grib_hash_keys_get_id(grib_itrie* t, const char* key)
const char* k = key;
grib_itrie* last = t;
GRIB_MUTEX_INIT_ONCE(&once, &init);
GRIB_MUTEX_INIT_ONCE(&once, &init_mutex);
GRIB_MUTEX_LOCK(&mutex);
while (*k && t)

View File

@ -18,7 +18,7 @@
static pthread_once_t once = PTHREAD_ONCE_INIT;
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
static void init()
static void init_mutex()
{
pthread_mutexattr_t attr;
@ -31,7 +31,7 @@ static void init()
static int once = 0;
static omp_nest_lock_t mutex;
static void init()
static void init_mutex()
{
GRIB_OMP_CRITICAL(lock_grib_memory_c)
{
@ -108,7 +108,7 @@ static void* fast_new(size_t s, mempool* pool)
char* p;
memblk* m;
GRIB_MUTEX_INIT_ONCE(&once, &init);
GRIB_MUTEX_INIT_ONCE(&once, &init_mutex);
GRIB_MUTEX_LOCK(&mutex);
m = (memblk*)pool->priv;
@ -167,7 +167,7 @@ static void fast_delete(void* p, mempool* pool)
memblk* m;
memblk* n = NULL;
GRIB_MUTEX_INIT_ONCE(&once, &init);
GRIB_MUTEX_INIT_ONCE(&once, &init_mutex);
GRIB_MUTEX_LOCK(&mutex);
m = (memblk*)pool->priv;
@ -271,7 +271,7 @@ void* grib_buffer_malloc(const grib_context* c, size_t s)
{
memblk* r;
GRIB_MUTEX_INIT_ONCE(&once, &init);
GRIB_MUTEX_INIT_ONCE(&once, &init_mutex);
GRIB_MUTEX_LOCK(&mutex);
s = ((s + WORD - 1) / WORD) * WORD;
@ -307,7 +307,7 @@ void grib_buffer_free(const grib_context* c, void* p)
memblk* r;
memblk* s;
GRIB_MUTEX_INIT_ONCE(&once, &init);
GRIB_MUTEX_INIT_ONCE(&once, &init_mutex);
GRIB_MUTEX_LOCK(&mutex);
r = (memblk*)(((char*)p) - HEADER_SIZE);

View File

@ -35,7 +35,7 @@ static pthread_mutex_t mutex_hash_array = PTHREAD_MUTEX_INITIALIZER;
static pthread_mutex_t mutex_stream = PTHREAD_MUTEX_INITIALIZER;
static pthread_mutex_t mutex_parse = PTHREAD_MUTEX_INITIALIZER;
static void init()
static void init_mutex()
{
pthread_mutexattr_t attr;
pthread_mutexattr_init(&attr);
@ -57,7 +57,7 @@ static omp_nest_lock_t mutex_hash_array;
static omp_nest_lock_t mutex_stream;
static omp_nest_lock_t mutex_parse;
static void init()
static void init_mutex()
{
GRIB_OMP_CRITICAL(lock_grib_parse_utils_c)
{
@ -717,7 +717,7 @@ extern int grib_yyparse(void);
static int parse(grib_context* gc, const char* filename)
{
int err = 0;
GRIB_MUTEX_INIT_ONCE(&once, &init);
GRIB_MUTEX_INIT_ONCE(&once, &init_mutex);
GRIB_MUTEX_LOCK(&mutex_parse);
#ifdef YYDEBUG
@ -752,7 +752,7 @@ static int parse(grib_context* gc, const char* filename)
static grib_action* grib_parse_stream(grib_context* gc, const char* filename)
{
GRIB_MUTEX_INIT_ONCE(&once, &init);
GRIB_MUTEX_INIT_ONCE(&once, &init_mutex);
GRIB_MUTEX_LOCK(&mutex_stream);
grib_parser_all_actions = 0;
@ -776,7 +776,7 @@ static grib_action* grib_parse_stream(grib_context* gc, const char* filename)
grib_concept_value* grib_parse_concept_file(grib_context* gc, const char* filename)
{
GRIB_MUTEX_INIT_ONCE(&once, &init);
GRIB_MUTEX_INIT_ONCE(&once, &init_mutex);
GRIB_MUTEX_LOCK(&mutex_file);
gc = gc ? gc : grib_context_get_default();
@ -794,7 +794,7 @@ grib_concept_value* grib_parse_concept_file(grib_context* gc, const char* filena
grib_hash_array_value* grib_parse_hash_array_file(grib_context* gc, const char* filename)
{
GRIB_MUTEX_INIT_ONCE(&once, &init);
GRIB_MUTEX_INIT_ONCE(&once, &init_mutex);
GRIB_MUTEX_LOCK(&mutex_file);
gc = gc ? gc : grib_context_get_default();
@ -813,7 +813,7 @@ grib_hash_array_value* grib_parse_hash_array_file(grib_context* gc, const char*
// grib_rule* grib_parse_rules_file(grib_context* gc, const char* filename)
// {
// if (!gc) gc = grib_context_get_default();
// GRIB_MUTEX_INIT_ONCE(&once, &init);
// GRIB_MUTEX_INIT_ONCE(&once, &init_mutex);
// GRIB_MUTEX_LOCK(&mutex_rules);
// gc = gc ? gc : grib_context_get_default();
// grib_parser_context = gc;
@ -831,7 +831,7 @@ grib_action* grib_parse_file(grib_context* gc, const char* filename)
{
grib_action_file* af;
GRIB_MUTEX_INIT_ONCE(&once, &init);
GRIB_MUTEX_INIT_ONCE(&once, &init_mutex);
GRIB_MUTEX_LOCK(&mutex_file);
af = 0;

View File

@ -292,7 +292,7 @@ static const size_t NUM_MAPPINGS = sizeof(mapping) / sizeof(mapping[0]);
static pthread_once_t once = PTHREAD_ONCE_INIT;
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
static void init()
static void init_mutex()
{
pthread_mutexattr_t attr;
pthread_mutexattr_init(&attr);
@ -304,7 +304,7 @@ static void init()
static int once = 0;
static omp_nest_lock_t mutex;
static void init()
static void init_mutex()
{
GRIB_OMP_CRITICAL(lock_grib_trie_c)
{
@ -340,7 +340,7 @@ grib_trie* grib_trie_new(grib_context* c)
void grib_trie_delete_container(grib_trie* t)
{
GRIB_MUTEX_INIT_ONCE(&once, &init);
GRIB_MUTEX_INIT_ONCE(&once, &init_mutex);
GRIB_MUTEX_LOCK(&mutex);
if (t) {
int i;
@ -359,7 +359,7 @@ void grib_trie_delete_container(grib_trie* t)
void grib_trie_delete(grib_trie* t)
{
GRIB_MUTEX_INIT_ONCE(&once, &init);
GRIB_MUTEX_INIT_ONCE(&once, &init_mutex);
GRIB_MUTEX_LOCK(&mutex);
if (t) {
int i;
@ -399,7 +399,7 @@ void* grib_trie_insert(grib_trie* t, const char* key, void* data)
return NULL;
}
GRIB_MUTEX_INIT_ONCE(&once, &init);
GRIB_MUTEX_INIT_ONCE(&once, &init_mutex);
GRIB_MUTEX_LOCK(&mutex);
while (*k && t) {
@ -474,7 +474,7 @@ void* grib_trie_insert_no_replace(grib_trie* t, const char* key, void* data)
void* grib_trie_get(grib_trie* t, const char* key)
{
const char* k = key;
GRIB_MUTEX_INIT_ONCE(&once, &init);
GRIB_MUTEX_INIT_ONCE(&once, &init_mutex);
GRIB_MUTEX_LOCK(&mutex);
while (*k && t) {

View File

@ -292,7 +292,7 @@ static const size_t NUM_MAPPINGS = sizeof(mapping) / sizeof(mapping[0]);
static pthread_once_t once = PTHREAD_ONCE_INIT;
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
static void init()
static void init_mutex()
{
pthread_mutexattr_t attr;
pthread_mutexattr_init(&attr);
@ -304,7 +304,7 @@ static void init()
static int once = 0;
static omp_nest_lock_t mutex;
static void init()
static void init_mutex()
{
GRIB_OMP_CRITICAL(lock_grib_trie_with_rank_c)
{
@ -376,7 +376,7 @@ static void _grib_trie_with_rank_delete_container(grib_trie_with_rank* t)
}
void grib_trie_with_rank_delete_container(grib_trie_with_rank* t)
{
GRIB_MUTEX_INIT_ONCE(&once, &init);
GRIB_MUTEX_INIT_ONCE(&once, &init_mutex);
GRIB_MUTEX_LOCK(&mutex);
_grib_trie_with_rank_delete_container(t);
GRIB_MUTEX_UNLOCK(&mutex);
@ -397,7 +397,7 @@ static void grib_trie_with_rank_delete_list(grib_context* c,grib_trie_with_rank_
void grib_trie_with_rank_delete(grib_trie_with_rank* t)
{
GRIB_MUTEX_INIT_ONCE(&once, &init);
GRIB_MUTEX_INIT_ONCE(&once, &init_mutex);
GRIB_MUTEX_LOCK(&mutex);
if (t) {
int i;
@ -456,7 +456,7 @@ int grib_trie_with_rank_insert(grib_trie_with_rank* t, const char* key, void* da
DEBUG_ASSERT(t);
if (!t) return -1;
GRIB_MUTEX_INIT_ONCE(&once, &init);
GRIB_MUTEX_INIT_ONCE(&once, &init_mutex);
GRIB_MUTEX_LOCK(&mutex);
while (*k && t) {
@ -506,7 +506,7 @@ void* grib_trie_with_rank_get(grib_trie_with_rank* t, const char* key, int rank)
{
const char* k = key;
void* data;
GRIB_MUTEX_INIT_ONCE(&once, &init);
GRIB_MUTEX_INIT_ONCE(&once, &init_mutex);
if (rank < 0)
return NULL;