Rename GRIB_PTHREAD_ONCE macro (in preparation for GRIB-884)

This commit is contained in:
Shahram Najm 2015-12-30 11:55:03 +00:00
parent f614084a28
commit bd502a1c6d
18 changed files with 309 additions and 235 deletions

View File

@ -350,30 +350,29 @@ static void _push_multi_handle(grib_multi_handle *h,int *gid){
}
static void push_handle(grib_handle *h,int *gid){
GRIB_PTHREAD_ONCE(&once,&init)
GRIB_MUTEX_LOCK(&handle_mutex)
_push_handle(h,gid);
GRIB_MUTEX_INIT_ONCE(&once,&init)
GRIB_MUTEX_LOCK(&handle_mutex)
_push_handle(h,gid);
GRIB_MUTEX_UNLOCK(&handle_mutex)
return;
}
static void push_index(grib_index *h,int *gid){
GRIB_PTHREAD_ONCE(&once,&init)
GRIB_MUTEX_LOCK(&index_mutex)
_push_index(h,gid);
GRIB_MUTEX_INIT_ONCE(&once,&init)
GRIB_MUTEX_LOCK(&index_mutex)
_push_index(h,gid);
GRIB_MUTEX_UNLOCK(&index_mutex)
return;
}
static void push_multi_handle(grib_multi_handle *h,int *gid){
GRIB_PTHREAD_ONCE(&once,&init)
GRIB_MUTEX_LOCK(&multi_handle_mutex)
_push_multi_handle(h,gid);
GRIB_MUTEX_INIT_ONCE(&once,&init)
GRIB_MUTEX_LOCK(&multi_handle_mutex)
_push_multi_handle(h,gid);
GRIB_MUTEX_UNLOCK(&multi_handle_mutex)
return;
}
static int _push_iterator(grib_iterator *i){
l_grib_iterator* current = iterator_set;
l_grib_iterator* previous = iterator_set;
@ -412,7 +411,7 @@ static int _push_iterator(grib_iterator *i){
static int push_iterator(grib_iterator *i){
int ret=0;
GRIB_PTHREAD_ONCE(&once,&init)
GRIB_MUTEX_INIT_ONCE(&once,&init)
GRIB_MUTEX_LOCK(&iterator_mutex)
ret=_push_iterator(i);
GRIB_MUTEX_UNLOCK(&iterator_mutex)
@ -458,7 +457,7 @@ static int _push_keys_iterator(grib_keys_iterator *i){
static int push_keys_iterator(grib_keys_iterator *i){
int ret=0;
GRIB_PTHREAD_ONCE(&once,&init)
GRIB_MUTEX_INIT_ONCE(&once,&init)
GRIB_MUTEX_LOCK(&keys_iterator_mutex)
ret=_push_keys_iterator(i);
GRIB_MUTEX_UNLOCK(&keys_iterator_mutex)
@ -500,7 +499,7 @@ static grib_multi_handle* _get_multi_handle(int multi_handle_id){
static grib_handle* get_handle(int handle_id){
grib_handle* h=NULL;
GRIB_PTHREAD_ONCE(&once,&init)
GRIB_MUTEX_INIT_ONCE(&once,&init)
GRIB_MUTEX_LOCK(&handle_mutex)
h=_get_handle(handle_id);
GRIB_MUTEX_UNLOCK(&handle_mutex)
@ -509,7 +508,7 @@ static grib_handle* get_handle(int handle_id){
static grib_index* get_index(int index_id){
grib_index* h=NULL;
GRIB_PTHREAD_ONCE(&once,&init)
GRIB_MUTEX_INIT_ONCE(&once,&init)
GRIB_MUTEX_LOCK(&index_mutex)
h=_get_index(index_id);
GRIB_MUTEX_UNLOCK(&index_mutex)
@ -518,7 +517,7 @@ static grib_index* get_index(int index_id){
static grib_multi_handle* get_multi_handle(int multi_handle_id){
grib_multi_handle* h=NULL;
GRIB_PTHREAD_ONCE(&once,&init)
GRIB_MUTEX_INIT_ONCE(&once,&init)
GRIB_MUTEX_LOCK(&multi_handle_mutex)
h=_get_multi_handle(multi_handle_id);
GRIB_MUTEX_UNLOCK(&multi_handle_mutex)
@ -548,7 +547,7 @@ static grib_iterator* _get_iterator(int iterator_id){
}
static grib_iterator* get_iterator(int iterator_id){
grib_iterator* i=NULL;
GRIB_PTHREAD_ONCE(&once,&init)
GRIB_MUTEX_INIT_ONCE(&once,&init)
GRIB_MUTEX_LOCK(&iterator_mutex)
i=_get_iterator(iterator_id);
GRIB_MUTEX_UNLOCK(&iterator_mutex)
@ -567,7 +566,7 @@ static grib_keys_iterator* _get_keys_iterator(int keys_iterator_id){
static grib_keys_iterator* get_keys_iterator(int keys_iterator_id){
grib_keys_iterator* i=NULL;
GRIB_PTHREAD_ONCE(&once,&init)
GRIB_MUTEX_INIT_ONCE(&once,&init)
GRIB_MUTEX_LOCK(&keys_iterator_mutex)
i=_get_keys_iterator(keys_iterator_id);
GRIB_MUTEX_UNLOCK(&keys_iterator_mutex)
@ -635,7 +634,7 @@ static int _clear_multi_handle(int multi_handle_id){
static int clear_handle(int handle_id){
int ret=0;
GRIB_PTHREAD_ONCE(&once,&init)
GRIB_MUTEX_INIT_ONCE(&once,&init)
GRIB_MUTEX_LOCK(&handle_mutex)
ret=_clear_handle(handle_id);
GRIB_MUTEX_UNLOCK(&handle_mutex)
@ -644,7 +643,7 @@ static int clear_handle(int handle_id){
static int clear_index(int index_id){
int ret=0;
GRIB_PTHREAD_ONCE(&once,&init)
GRIB_MUTEX_INIT_ONCE(&once,&init)
GRIB_MUTEX_LOCK(&index_mutex)
ret=_clear_index(index_id);
GRIB_MUTEX_UNLOCK(&index_mutex)
@ -653,7 +652,7 @@ static int clear_index(int index_id){
static int clear_multi_handle(int multi_handle_id){
int ret=0;
GRIB_PTHREAD_ONCE(&once,&init)
GRIB_MUTEX_INIT_ONCE(&once,&init)
GRIB_MUTEX_LOCK(&multi_handle_mutex)
ret=_clear_multi_handle(multi_handle_id);
GRIB_MUTEX_UNLOCK(&multi_handle_mutex)
@ -676,7 +675,7 @@ static int _clear_iterator(int iterator_id){
static int clear_iterator(int iterator_id){
int ret=0;
GRIB_PTHREAD_ONCE(&once,&init)
GRIB_MUTEX_INIT_ONCE(&once,&init)
GRIB_MUTEX_LOCK(&iterator_mutex)
ret=_clear_iterator(iterator_id);
GRIB_MUTEX_UNLOCK(&iterator_mutex)
@ -699,7 +698,7 @@ static int _clear_keys_iterator(int keys_iterator_id){
static int clear_keys_iterator(int keys_iterator_id){
int ret=0;
GRIB_PTHREAD_ONCE(&once,&init)
GRIB_MUTEX_INIT_ONCE(&once,&init)
GRIB_MUTEX_LOCK(&keys_iterator_mutex)
ret=_clear_keys_iterator(keys_iterator_id);
GRIB_MUTEX_UNLOCK(&keys_iterator_mutex)
@ -870,7 +869,7 @@ void grib_f_write_on_fail(int* gid) {
grib_handle* h=NULL;
pid_t pid=getpid();
GRIB_PTHREAD_ONCE(&once,&init)
GRIB_MUTEX_INIT_ONCE(&once,&init)
GRIB_MUTEX_LOCK(&handle_mutex)
file_count++;
GRIB_MUTEX_UNLOCK(&handle_mutex)
@ -932,7 +931,7 @@ static int _grib_f_iterator_new_(int* gid,int* iterid,int* mode) {
}
int grib_f_iterator_new_(int* gid,int* iterid,int* mode) {
int ret=0;
GRIB_PTHREAD_ONCE(&once,&init)
GRIB_MUTEX_INIT_ONCE(&once,&init)
GRIB_MUTEX_LOCK(&iterator_mutex)
ret=_grib_f_iterator_new_(gid,iterid,mode);
GRIB_MUTEX_UNLOCK(&iterator_mutex)
@ -992,7 +991,7 @@ static int _grib_f_keys_iterator_new_(int* gid,int* iterid,char* name_space,int
}
int grib_f_keys_iterator_new_(int* gid,int* iterid,char* name_space,int len) {
int ret=0;
GRIB_PTHREAD_ONCE(&once,&init)
GRIB_MUTEX_INIT_ONCE(&once,&init)
GRIB_MUTEX_LOCK(&keys_iterator_mutex)
ret=_grib_f_keys_iterator_new_(gid,iterid,name_space,len);
GRIB_MUTEX_UNLOCK(&keys_iterator_mutex)

File diff suppressed because it is too large Load Diff

View File

@ -97,7 +97,7 @@ int grib_create_accessor(grib_section* p, grib_action* a, grib_loader* h)
{
if(c->create_accessor) {
int ret;
GRIB_PTHREAD_ONCE(&once,&init_mutex);
GRIB_MUTEX_INIT_ONCE(&once,&init_mutex);
GRIB_MUTEX_LOCK(&mutex1);
ret=c->create_accessor(p, a, h);
GRIB_MUTEX_UNLOCK(&mutex1);

View File

@ -282,7 +282,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_PTHREAD_ONCE(&once,&init)
GRIB_MUTEX_INIT_ONCE(&once,&init)
GRIB_MUTEX_LOCK(&mutex);
result = get_concept_impl(h, self);

View File

@ -230,7 +230,7 @@ static int notify_change_impl(grib_action* a, grib_accessor* observer,grib_acces
static int notify_change(grib_action* a, grib_accessor* observer,grib_accessor* observed)
{
int result = 0;
GRIB_PTHREAD_ONCE(&once,&init)
GRIB_MUTEX_INIT_ONCE(&once,&init)
GRIB_MUTEX_LOCK(&mutex)
result = notify_change_impl(a, observer, observed);

View File

@ -55,7 +55,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_PTHREAD_ONCE(&once,&init);
GRIB_MUTEX_INIT_ONCE(&once,&init);
GRIB_MUTEX_LOCK(&mutex1);
if(h->context->grib_reader == NULL) {
if ((fpath=grib_context_full_defs_path(h->context,"boot.def"))==NULL) {

View File

@ -308,7 +308,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_PTHREAD_ONCE(&once,&thread_init)
GRIB_MUTEX_INIT_ONCE(&once,&thread_init)
GRIB_MUTEX_LOCK(&mutex)
c->smart_table = t;
GRIB_MUTEX_UNLOCK(&mutex)

View File

@ -124,7 +124,7 @@ extern "C" {
#if GRIB_PTHREADS
#include <pthread.h>
#define GRIB_PTHREAD_ONCE(a,b) pthread_once(a,b);
#define GRIB_MUTEX_INIT_ONCE(a,b) pthread_once(a,b);
#define GRIB_MUTEX_LOCK(a) pthread_mutex_lock(a);
#define GRIB_MUTEX_UNLOCK(a) pthread_mutex_unlock(a);
/*
@ -132,7 +132,7 @@ extern "C" {
#define GRIB_MUTEX_UNLOCK(a) {pthread_mutex_unlock(a);printf("MUTEX UNLOCK %p %s line %d\n",(void*)a,__FILE__,__LINE__);}
*/
#else
#define GRIB_PTHREAD_ONCE(a,b)
#define GRIB_MUTEX_INIT_ONCE(a,b)
#define GRIB_MUTEX_LOCK(a)
#define GRIB_MUTEX_UNLOCK(a)
#endif

View File

@ -52,7 +52,7 @@ static long cntp = 0;
static void default_long_lasting_free(const grib_context* c, void* p)
{
GRIB_PTHREAD_ONCE(&once,&init);
GRIB_MUTEX_INIT_ONCE(&once,&init);
free(p);
GRIB_MUTEX_LOCK(&mutex_mem);
cntp--;
@ -62,7 +62,7 @@ static void default_long_lasting_free(const grib_context* c, void* p)
static void* default_long_lasting_malloc(const grib_context* c, size_t size)
{
void* ret;
GRIB_PTHREAD_ONCE(&once,&init);
GRIB_MUTEX_INIT_ONCE(&once,&init);
GRIB_MUTEX_LOCK(&mutex_mem);
cntp++;
GRIB_MUTEX_UNLOCK(&mutex_mem);
@ -72,7 +72,7 @@ static void* default_long_lasting_malloc(const grib_context* c, size_t size)
static void default_buffer_free(const grib_context* c, void* p)
{
GRIB_PTHREAD_ONCE(&once,&init);
GRIB_MUTEX_INIT_ONCE(&once,&init);
free(p);
GRIB_MUTEX_LOCK(&mutex_mem);
cntp--;
@ -82,7 +82,7 @@ static void default_buffer_free(const grib_context* c, void* p)
static void* default_buffer_malloc(const grib_context* c, size_t size)
{
void* ret;
GRIB_PTHREAD_ONCE(&once,&init);
GRIB_MUTEX_INIT_ONCE(&once,&init);
GRIB_MUTEX_LOCK(&mutex_mem);
cntp++;
GRIB_MUTEX_UNLOCK(&mutex_mem);
@ -99,7 +99,7 @@ static void* default_buffer_realloc(const grib_context* c, void* p, size_t size)
static void default_free(const grib_context* c, void* p)
{
GRIB_PTHREAD_ONCE(&once,&init);
GRIB_MUTEX_INIT_ONCE(&once,&init);
free(p);
GRIB_MUTEX_LOCK(&mutex_mem);
cnt--;
@ -109,7 +109,7 @@ static void default_free(const grib_context* c, void* p)
static void* default_malloc(const grib_context* c, size_t size)
{
void* ret;
GRIB_PTHREAD_ONCE(&once,&init);
GRIB_MUTEX_INIT_ONCE(&once,&init);
GRIB_MUTEX_LOCK(&mutex_mem);
cnt++;
GRIB_MUTEX_UNLOCK(&mutex_mem);
@ -331,7 +331,7 @@ static grib_context default_grib_context = {
grib_context* grib_context_get_default()
{
GRIB_PTHREAD_ONCE(&once,&init);
GRIB_MUTEX_INIT_ONCE(&once,&init);
GRIB_MUTEX_LOCK(&mutex_c);
#ifdef ENABLE_FLOATING_POINT_EXCEPTIONS
@ -466,7 +466,7 @@ grib_context* grib_context_new(grib_context* parent)
if (!parent) parent=grib_context_get_default();
GRIB_PTHREAD_ONCE(&once,&init);
GRIB_MUTEX_INIT_ONCE(&once,&init);
GRIB_MUTEX_LOCK(&(parent->mutex));
c = (grib_context*)grib_context_malloc_clear_persistent(&default_grib_context,sizeof(grib_context));
@ -544,7 +544,7 @@ static int init_definition_files_dir(grib_context* c)
/* Note: strtok modifies its first argument so we copy */
strncpy(path, c->grib_definition_files_path, DEF_PATH_MAXLEN);
GRIB_PTHREAD_ONCE(&once,&init);
GRIB_MUTEX_INIT_ONCE(&once,&init);
GRIB_MUTEX_LOCK(&mutex_c);
p=path;
@ -586,7 +586,7 @@ char *grib_context_full_defs_path(grib_context* c,const char* basename)
grib_string_list* fullpath=0;
if (!c) c=grib_context_get_default();
GRIB_PTHREAD_ONCE(&once,&init);
GRIB_MUTEX_INIT_ONCE(&once,&init);
if(*basename == '/' || *basename == '.') {
return (char*)basename;

View File

@ -167,7 +167,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_PTHREAD_ONCE(&once,&init);
GRIB_MUTEX_INIT_ONCE(&once,&init);
if (!file_pool.context) file_pool.context=grib_context_get_default();
@ -244,7 +244,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_PTHREAD_ONCE(&once,&init);
GRIB_MUTEX_INIT_ONCE(&once,&init);
GRIB_MUTEX_LOCK(&mutex1);
if (file==file_pool.first) {
@ -275,7 +275,7 @@ void grib_file_close_force(const char* filename,int* err)
grib_file* file=NULL;
/* fprintf(stderr,"++++ closing file %s\n",filename); */
GRIB_PTHREAD_ONCE(&once,&init);
GRIB_MUTEX_INIT_ONCE(&once,&init);
GRIB_MUTEX_LOCK(&mutex1);
file=grib_get_file(filename,err);
fclose(file->handle);
@ -296,7 +296,7 @@ void grib_file_close(const char* filename,int* err)
/* So only call fclose() when too many files are open */
if ( file_pool.number_of_opened_files > GRIB_MAX_OPENED_FILES ) {
/*printf("++ closing file %s\n",filename);*/
GRIB_PTHREAD_ONCE(&once,&init);
GRIB_MUTEX_INIT_ONCE(&once,&init);
GRIB_MUTEX_LOCK(&mutex1);
file=grib_get_file(filename,err);
if (file->handle) {
@ -319,7 +319,7 @@ void grib_file_close_all(int *err)
grib_file* file = NULL;
if (!file_pool.first) return;
GRIB_PTHREAD_ONCE(&once,&init);
GRIB_MUTEX_INIT_ONCE(&once,&init);
GRIB_MUTEX_LOCK(&mutex1);
file = file_pool.first;
@ -384,7 +384,7 @@ grib_file* grib_file_new(grib_context* c, const char* name, int* err)
*err=GRIB_OUT_OF_MEMORY;
return NULL;
}
GRIB_PTHREAD_ONCE(&once,&init);
GRIB_MUTEX_INIT_ONCE(&once,&init);
file->name=strdup(name);
file->id=next_id;
@ -407,7 +407,7 @@ void grib_file_delete(grib_file* file)
{
if (!file) return;
}
GRIB_PTHREAD_ONCE(&once,&init);
GRIB_MUTEX_INIT_ONCE(&once,&init);
GRIB_MUTEX_LOCK(&mutex1);
/* GRIB-803: cannot call fclose yet! Causes crash */
/* TODO: Set handle to NULL in filepool too */

View File

@ -7490,7 +7490,7 @@ grib_itrie *grib_hash_keys_new(grib_context* c,int* count) {
}
void grib_hash_keys_delete(grib_itrie *t) {
GRIB_PTHREAD_ONCE(&once,&init)
GRIB_MUTEX_INIT_ONCE(&once,&init)
GRIB_MUTEX_LOCK(&mutex)
if(t) {
@ -7520,7 +7520,7 @@ int grib_hash_keys_get_id(grib_itrie* t,const char* key)
/* printf("+++ \"%s\"\n",key); */
GRIB_PTHREAD_ONCE(&once,&init)
GRIB_MUTEX_INIT_ONCE(&once,&init)
GRIB_MUTEX_LOCK(&mutex)
while(*k && t) t = t->next[mapping[(int)*k++]];
@ -7541,7 +7541,7 @@ int grib_hash_keys_insert(grib_itrie* t,const char* key)
grib_itrie *last = t;
int* count;
GRIB_PTHREAD_ONCE(&once,&init)
GRIB_MUTEX_INIT_ONCE(&once,&init)
GRIB_MUTEX_LOCK(&mutex)

View File

@ -56,7 +56,7 @@ static void init_ibm_table()
static void init_table_if_needed()
{
GRIB_PTHREAD_ONCE(&once,&init)
GRIB_MUTEX_INIT_ONCE(&once,&init)
GRIB_MUTEX_LOCK(&mutex)
if (!ibm_table.inited) init_ibm_table();

View File

@ -70,7 +70,7 @@ static void init_ieee_table()
static void init_table_if_needed()
{
GRIB_PTHREAD_ONCE(&once,&init)
GRIB_MUTEX_INIT_ONCE(&once,&init)
GRIB_MUTEX_LOCK(&mutex)
if (!ieee_table.inited) init_ieee_table();

View File

@ -303,7 +303,7 @@ grib_itrie *grib_itrie_new(grib_context* c,int* count)
}
void grib_itrie_delete(grib_itrie *t) {
GRIB_PTHREAD_ONCE(&once,&init)
GRIB_MUTEX_INIT_ONCE(&once,&init)
GRIB_MUTEX_LOCK(&mutex)
if(t) {
@ -324,7 +324,7 @@ int grib_itrie_get_id(grib_itrie* t,const char* key)
const char *k=key;
grib_itrie* last=t;
GRIB_PTHREAD_ONCE(&once,&init)
GRIB_MUTEX_INIT_ONCE(&once,&init)
GRIB_MUTEX_LOCK(&mutex)
while(*k && t) t = t->next[mapping[(int)*k++]];
@ -345,7 +345,7 @@ int grib_itrie_insert(grib_itrie* t,const char* key)
grib_itrie *last = t;
int* count;
GRIB_PTHREAD_ONCE(&once,&init)
GRIB_MUTEX_INIT_ONCE(&once,&init)
GRIB_MUTEX_LOCK(&mutex)

View File

@ -303,7 +303,7 @@ grib_itrie *grib_hash_keys_new(grib_context* c,int* count) {
}
void grib_hash_keys_delete(grib_itrie *t) {
GRIB_PTHREAD_ONCE(&once,&init)
GRIB_MUTEX_INIT_ONCE(&once,&init)
GRIB_MUTEX_LOCK(&mutex)
if(t) {
@ -333,7 +333,7 @@ int grib_hash_keys_get_id(grib_itrie* t,const char* key)
/* printf("+++ \"%s\"\n",key); */
GRIB_PTHREAD_ONCE(&once,&init)
GRIB_MUTEX_INIT_ONCE(&once,&init)
GRIB_MUTEX_LOCK(&mutex)
while(*k && t) t = t->next[mapping[(int)*k++]];
@ -354,7 +354,7 @@ int grib_hash_keys_insert(grib_itrie* t,const char* key)
grib_itrie *last = t;
int* count;
GRIB_PTHREAD_ONCE(&once,&init)
GRIB_MUTEX_INIT_ONCE(&once,&init)
GRIB_MUTEX_LOCK(&mutex)

View File

@ -91,7 +91,7 @@ static void *fast_new(size_t s,mempool *pool)
char *p;
memblk *m;
GRIB_PTHREAD_ONCE(&once,&init)
GRIB_MUTEX_INIT_ONCE(&once,&init)
GRIB_MUTEX_LOCK(&mutex)
m = (memblk*)pool->priv;
@ -153,7 +153,7 @@ static void fast_delete(void *p,mempool *pool)
memblk *m ;
memblk *n = NULL;
GRIB_PTHREAD_ONCE(&once,&init)
GRIB_MUTEX_INIT_ONCE(&once,&init)
GRIB_MUTEX_LOCK(&mutex)
m = (memblk*)pool->priv;
@ -265,7 +265,7 @@ void *grib_buffer_malloc(const grib_context* c,size_t s)
{
memblk *r;
GRIB_PTHREAD_ONCE(&once,&init)
GRIB_MUTEX_INIT_ONCE(&once,&init)
GRIB_MUTEX_LOCK(&mutex)
s = ((s+WORD-1)/WORD)*WORD;
@ -304,7 +304,7 @@ void grib_buffer_free(const grib_context* c,void *p)
memblk *r;
memblk *s;
GRIB_PTHREAD_ONCE(&once,&init)
GRIB_MUTEX_INIT_ONCE(&once,&init)
GRIB_MUTEX_LOCK(&mutex)
r = (memblk*)(((char*)p) - HEADER_SIZE);

View File

@ -610,7 +610,7 @@ extern int grib_yyparse(void);
static int parse(grib_context* gc, const char* filename)
{
int err = 0;
GRIB_PTHREAD_ONCE(&once,&init);
GRIB_MUTEX_INIT_ONCE(&once,&init);
GRIB_MUTEX_LOCK(&mutex_parse);
#ifdef YYDEBUG
@ -643,7 +643,7 @@ static int parse(grib_context* gc, const char* filename)
static grib_action* grib_parse_stream(grib_context* gc, const char* filename)
{
GRIB_PTHREAD_ONCE(&once,&init);
GRIB_MUTEX_INIT_ONCE(&once,&init);
GRIB_MUTEX_LOCK(&mutex_stream);
grib_parser_all_actions = 0;
@ -665,7 +665,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_PTHREAD_ONCE(&once,&init);
GRIB_MUTEX_INIT_ONCE(&once,&init);
GRIB_MUTEX_LOCK(&mutex_concept);
gc = gc ? gc : grib_context_get_default();
@ -682,7 +682,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_PTHREAD_ONCE(&once,&init);
GRIB_MUTEX_INIT_ONCE(&once,&init);
GRIB_MUTEX_LOCK(&mutex_hash_array);
gc = gc ? gc : grib_context_get_default();
@ -701,7 +701,7 @@ grib_rule* grib_parse_rules_file( grib_context* gc,const char* filename)
{
if (!gc) gc=grib_context_get_default();
GRIB_PTHREAD_ONCE(&once,&init);
GRIB_MUTEX_INIT_ONCE(&once,&init);
GRIB_MUTEX_LOCK(&mutex_rules);
gc = gc ? gc : grib_context_get_default();
@ -720,7 +720,7 @@ grib_action* grib_parse_file( grib_context* gc,const char* filename)
{
grib_action_file* af;
GRIB_PTHREAD_ONCE(&once,&init);
GRIB_MUTEX_INIT_ONCE(&once,&init);
GRIB_MUTEX_LOCK(&mutex_file);
af =0;

View File

@ -306,7 +306,7 @@ grib_trie *grib_trie_new(grib_context* c) {
}
void grib_trie_delete(grib_trie *t) {
GRIB_PTHREAD_ONCE(&once,&init)
GRIB_MUTEX_INIT_ONCE(&once,&init)
GRIB_MUTEX_LOCK(&mutex)
if(t) {
int i;
@ -340,7 +340,7 @@ void* grib_trie_insert(grib_trie* t,const char* key,void* data)
const char *k = key;
void* old = NULL;
GRIB_PTHREAD_ONCE(&once,&init)
GRIB_MUTEX_INIT_ONCE(&once,&init)
GRIB_MUTEX_LOCK(&mutex)
while(*k && t) {
@ -396,7 +396,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_PTHREAD_ONCE(&once,&init)
GRIB_MUTEX_INIT_ONCE(&once,&init)
GRIB_MUTEX_LOCK(&mutex)
while(*k && t)