diff --git a/link-grammar/dict-common/regex-morph.c b/link-grammar/dict-common/regex-morph.c index bfbf0094c7..016058aa19 100644 --- a/link-grammar/dict-common/regex-morph.c +++ b/link-grammar/dict-common/regex-morph.c @@ -10,9 +10,9 @@ /* */ /*************************************************************************/ -#if HAVE_THREADS_H +#if HAVE_THREADS_H && !__EMSCRIPTEN__ #include -#endif +#endif // HAVE_THREADS_H && !__EMSCRIPTEN__ /** * Support for the regular-expression based token matching system @@ -177,7 +177,7 @@ static void alloc_key(void) static pcre2_match_data* alloc_match_data(void) { -#if HAVE_THREADS_H +#if HAVE_THREADS_H && !__EMSCRIPTEN__ call_once(&call_once_flag, alloc_key); pcre2_match_data *pmd = (pcre2_match_data *) tss_get(re_md_key); @@ -194,7 +194,7 @@ static pcre2_match_data* alloc_match_data(void) pmd = pcre2_match_data_create(MAX_CAPTURE_GROUPS, NULL); if (pmd) return pmd; -#endif // HAVE_THREADS_H +#endif // HAVE_THREADS_H && !__EMSCRIPTEN__ prt_error("Error: pcre2_match_data_create() failed\n"); return NULL; } diff --git a/link-grammar/parse/count.c b/link-grammar/parse/count.c index 921de47484..731a7a7334 100644 --- a/link-grammar/parse/count.c +++ b/link-grammar/parse/count.c @@ -14,9 +14,9 @@ #include #include // PRIu64 -#if HAVE_THREADS_H +#if HAVE_THREADS_H && !__EMSCRIPTEN__ #include -#endif /* HAVE_THREADS_H */ +#endif /* HAVE_THREADS_H && !__EMSCRIPTEN__ */ #include "link-includes.h" #include "api-structures.h" @@ -124,7 +124,7 @@ struct count_context_s #define MAX_TABLE_SIZE(s) (s / 10) /* Low load factor, for speed */ #define MAX_LOG2_TABLE_SIZE ((sizeof(size_t)==4) ? 25 : 34) -#if HAVE_THREADS_H +#if HAVE_THREADS_H && !__EMSCRIPTEN__ /* Each thread will get it's own version of the `kept_table`. * If the program creates zillions of threads, then there will * be a mem-leak if this table is not released when each thread @@ -147,7 +147,7 @@ static void make_key(void) { tss_create(&key, free_tls_table); } -#endif /* HAVE_THREADS_H */ +#endif /* HAVE_THREADS_H && !__EMSCRIPTEN__ */ /** * Allocate memory for the connector-pair table and initialize table-size @@ -164,14 +164,14 @@ static void table_alloc(count_context_t *ctxt, unsigned int shift) static TLS Table_connector **kept_table = NULL; static TLS unsigned int log2_kept_table_size = 0; -#if HAVE_THREADS_H +#if HAVE_THREADS_H && !__EMSCRIPTEN__ // Install a thread-exit handler, to free kept_table on thread-exit. static once_flag flag = ONCE_FLAG_INIT; call_once(&flag, make_key); if (NULL == kept_table) tss_set(key, &kept_table); -#endif /* HAVE_THREADS_H */ +#endif /* HAVE_THREADS_H && !__EMSCRIPTEN__ */ if (shift == 0) shift = ctxt->log2_table_size + 1; /* Double the table size */