summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Williams <nico@cryptonector.com>2021-09-06 18:26:14 -0500
committerNicolas Williams <nico@cryptonector.com>2021-09-06 22:17:57 -0500
commita9ce7244b4241c457bace5f7d7871268ed00c40b (patch)
tree125a6be0229414bdbadb2d5b6ad8716270a3ec0a
parent34182cca7babec086bbc93dec209275be896ca9e (diff)
downloadjq-a9ce7244b4241c457bace5f7d7871268ed00c40b.tar.gz
Fix Windows build for 1.7 release (moar)
-rw-r--r--src/jv.c32
-rw-r--r--src/jv_dtoa_tsd.c8
-rw-r--r--src/main.c2
3 files changed, 22 insertions, 20 deletions
diff --git a/src/jv.c b/src/jv.c
index 10eff41..9784b22 100644
--- a/src/jv.c
+++ b/src/jv.c
@@ -306,10 +306,10 @@ w32_service_thread_detach(void *unused)
}
}
-extern void tsd_dtoa_ctx_init();
-extern void tsd_dtoa_ctx_fini();
-static void tsd_dec_ctx_fini();
-static void tsd_dec_ctx_init();
+extern void jv_tsd_dtoa_ctx_init();
+extern void jv_tsd_dtoa_ctx_fini();
+void jv_tsd_dec_ctx_fini();
+void jv_tsd_dec_ctx_init();
BOOL WINAPI DllMain(HINSTANCE hinstDLL,
DWORD fdwReason,
@@ -318,18 +318,18 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL,
switch (fdwReason) {
case DLL_PROCESS_ATTACH:
/*create_pt_key();*/
- tsd_dtoa_ctx_init();
- tsd_dec_ctx_init();
- return 1;
+ jv_tsd_dtoa_ctx_init();
+ jv_tsd_dec_ctx_init();
+ return TRUE;
case DLL_PROCESS_DETACH:
- tsd_dtoa_ctx_fini();
- tsd_dec_ctx_fini();
- return 0;
+ jv_tsd_dtoa_ctx_fini();
+ jv_tsd_dec_ctx_fini();
+ return TRUE;
case DLL_THREAD_ATTACH: return 0;
case DLL_THREAD_DETACH:
w32_service_thread_detach(NULL);
- return 0;
- default: return 0;
+ return TRUE;
+ default: return TRUE;
}
}
@@ -503,14 +503,14 @@ static pthread_once_t dec_ctx_once = PTHREAD_ONCE_INIT;
// atexit finalizer to clean up the tsd dec contexts if main() exits
// without having called pthread_exit()
-static void tsd_dec_ctx_fini() {
+void jv_tsd_dec_ctx_fini() {
jv_mem_free(pthread_getspecific(dec_ctx_key));
jv_mem_free(pthread_getspecific(dec_ctx_dbl_key));
pthread_setspecific(dec_ctx_key, NULL);
pthread_setspecific(dec_ctx_dbl_key, NULL);
}
-static void tsd_dec_ctx_init() {
+void jv_tsd_dec_ctx_init() {
if (pthread_key_create(&dec_ctx_key, jv_mem_free) != 0) {
fprintf(stderr, "error: cannot create thread specific key");
abort();
@@ -520,13 +520,13 @@ static void tsd_dec_ctx_init() {
abort();
}
#ifndef WIN32
- atexit(tsd_dec_ctx_fini);
+ atexit(jv_tsd_dec_ctx_fini);
#endif
}
static decContext* tsd_dec_ctx_get(pthread_key_t *key) {
#ifndef WIN32
- pthread_once(&dec_ctx_once, tsd_dec_ctx_init); // cannot fail
+ pthread_once(&dec_ctx_once, jv_tsd_dec_ctx_init); // cannot fail
#endif
decContext *ctx = (decContext*)pthread_getspecific(*key);
if (ctx) {
diff --git a/src/jv_dtoa_tsd.c b/src/jv_dtoa_tsd.c
index cafd141..cfccd40 100644
--- a/src/jv_dtoa_tsd.c
+++ b/src/jv_dtoa_tsd.c
@@ -21,7 +21,7 @@ static void tsd_dtoa_ctx_dtor(void *ctx) {
#ifndef WIN32
static
#endif
-void tsd_dtoa_ctx_fini() {
+void jv_tsd_dtoa_ctx_fini() {
struct dtoa_context *ctx = pthread_getspecific(dtoa_ctx_key);
tsd_dtoa_ctx_dtor(ctx);
pthread_setspecific(dtoa_ctx_key, NULL);
@@ -30,19 +30,19 @@ void tsd_dtoa_ctx_fini() {
#ifndef WIN32
static
#endif
-void tsd_dtoa_ctx_init() {
+void jv_tsd_dtoa_ctx_init() {
if (pthread_key_create(&dtoa_ctx_key, tsd_dtoa_ctx_dtor) != 0) {
fprintf(stderr, "error: cannot create thread specific key");
abort();
}
#ifndef WIN32
- atexit(tsd_dtoa_ctx_fini);
+ atexit(jv_tsd_dtoa_ctx_fini);
#endif
}
inline struct dtoa_context *tsd_dtoa_context_get() {
#ifndef WIN32
- pthread_once(&dtoa_ctx_once, tsd_dtoa_ctx_init); // cannot fail
+ pthread_once(&dtoa_ctx_once, jv_tsd_dtoa_ctx_init); // cannot fail
#endif
struct dtoa_context *ctx = (struct dtoa_context*)pthread_getspecific(dtoa_ctx_key);
if (!ctx) {
diff --git a/src/main.c b/src/main.c
index 7022f19..4b33f65 100644
--- a/src/main.c
+++ b/src/main.c
@@ -15,6 +15,7 @@
#include <shellapi.h>
#include <wchar.h>
#include <wtypes.h>
+extern void jv_tsd_dtoa_ctx_init();
#endif
#if !defined(HAVE_ISATTY) && defined(HAVE__ISATTY)
@@ -281,6 +282,7 @@ int main(int argc, char* argv[]) {
jv program_arguments = jv_object(); /* named arguments */
#ifdef WIN32
+ jv_tsd_dtoa_ctx_init();
fflush(stdout);
fflush(stderr);
_setmode(fileno(stdout), _O_TEXT | _O_U8TEXT);