Fix Windows build for 1.7 release (moar)
This commit is contained in:
1 parent
34182cca7b
commit
a9ce7244b4
3 files changed
+22
-20
No files matched your search
@@ -306,10 +306,10 @@ w32_service_thread_detach(void *unused)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extern void tsd_dtoa_ctx_init();
|
extern void jv_tsd_dtoa_ctx_init();
|
||||||
extern void tsd_dtoa_ctx_fini();
|
extern void jv_tsd_dtoa_ctx_fini();
|
||||||
static void tsd_dec_ctx_fini();
|
void jv_tsd_dec_ctx_fini();
|
||||||
static void tsd_dec_ctx_init();
|
void jv_tsd_dec_ctx_init();
|
||||||
|
|
||||||
BOOL WINAPI DllMain(HINSTANCE hinstDLL,
|
BOOL WINAPI DllMain(HINSTANCE hinstDLL,
|
||||||
DWORD fdwReason,
|
DWORD fdwReason,
|
||||||
@@ -318,18 +318,18 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL,
|
|||||||
switch (fdwReason) {
|
switch (fdwReason) {
|
||||||
case DLL_PROCESS_ATTACH:
|
case DLL_PROCESS_ATTACH:
|
||||||
/*create_pt_key();*/
|
/*create_pt_key();*/
|
||||||
tsd_dtoa_ctx_init();
|
jv_tsd_dtoa_ctx_init();
|
||||||
tsd_dec_ctx_init();
|
jv_tsd_dec_ctx_init();
|
||||||
return 1;
|
return TRUE;
|
||||||
case DLL_PROCESS_DETACH:
|
case DLL_PROCESS_DETACH:
|
||||||
tsd_dtoa_ctx_fini();
|
jv_tsd_dtoa_ctx_fini();
|
||||||
tsd_dec_ctx_fini();
|
jv_tsd_dec_ctx_fini();
|
||||||
return 0;
|
return TRUE;
|
||||||
case DLL_THREAD_ATTACH: return 0;
|
case DLL_THREAD_ATTACH: return 0;
|
||||||
case DLL_THREAD_DETACH:
|
case DLL_THREAD_DETACH:
|
||||||
w32_service_thread_detach(NULL);
|
w32_service_thread_detach(NULL);
|
||||||
return 0;
|
return TRUE;
|
||||||
default: return 0;
|
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
|
// atexit finalizer to clean up the tsd dec contexts if main() exits
|
||||||
// without having called pthread_exit()
|
// 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_key));
|
||||||
jv_mem_free(pthread_getspecific(dec_ctx_dbl_key));
|
jv_mem_free(pthread_getspecific(dec_ctx_dbl_key));
|
||||||
pthread_setspecific(dec_ctx_key, NULL);
|
pthread_setspecific(dec_ctx_key, NULL);
|
||||||
pthread_setspecific(dec_ctx_dbl_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) {
|
if (pthread_key_create(&dec_ctx_key, jv_mem_free) != 0) {
|
||||||
fprintf(stderr, "error: cannot create thread specific key");
|
fprintf(stderr, "error: cannot create thread specific key");
|
||||||
abort();
|
abort();
|
||||||
@@ -520,13 +520,13 @@ static void tsd_dec_ctx_init() {
|
|||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
atexit(tsd_dec_ctx_fini);
|
atexit(jv_tsd_dec_ctx_fini);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static decContext* tsd_dec_ctx_get(pthread_key_t *key) {
|
static decContext* tsd_dec_ctx_get(pthread_key_t *key) {
|
||||||
#ifndef WIN32
|
#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
|
#endif
|
||||||
decContext *ctx = (decContext*)pthread_getspecific(*key);
|
decContext *ctx = (decContext*)pthread_getspecific(*key);
|
||||||
if (ctx) {
|
if (ctx) {
|
||||||
|
|||||||
+4
-4
@@ -21,7 +21,7 @@ static void tsd_dtoa_ctx_dtor(void *ctx) {
|
|||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
static
|
static
|
||||||
#endif
|
#endif
|
||||||
void tsd_dtoa_ctx_fini() {
|
void jv_tsd_dtoa_ctx_fini() {
|
||||||
struct dtoa_context *ctx = pthread_getspecific(dtoa_ctx_key);
|
struct dtoa_context *ctx = pthread_getspecific(dtoa_ctx_key);
|
||||||
tsd_dtoa_ctx_dtor(ctx);
|
tsd_dtoa_ctx_dtor(ctx);
|
||||||
pthread_setspecific(dtoa_ctx_key, NULL);
|
pthread_setspecific(dtoa_ctx_key, NULL);
|
||||||
@@ -30,19 +30,19 @@ void tsd_dtoa_ctx_fini() {
|
|||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
static
|
static
|
||||||
#endif
|
#endif
|
||||||
void tsd_dtoa_ctx_init() {
|
void jv_tsd_dtoa_ctx_init() {
|
||||||
if (pthread_key_create(&dtoa_ctx_key, tsd_dtoa_ctx_dtor) != 0) {
|
if (pthread_key_create(&dtoa_ctx_key, tsd_dtoa_ctx_dtor) != 0) {
|
||||||
fprintf(stderr, "error: cannot create thread specific key");
|
fprintf(stderr, "error: cannot create thread specific key");
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
atexit(tsd_dtoa_ctx_fini);
|
atexit(jv_tsd_dtoa_ctx_fini);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
inline struct dtoa_context *tsd_dtoa_context_get() {
|
inline struct dtoa_context *tsd_dtoa_context_get() {
|
||||||
#ifndef WIN32
|
#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
|
#endif
|
||||||
struct dtoa_context *ctx = (struct dtoa_context*)pthread_getspecific(dtoa_ctx_key);
|
struct dtoa_context *ctx = (struct dtoa_context*)pthread_getspecific(dtoa_ctx_key);
|
||||||
if (!ctx) {
|
if (!ctx) {
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
#include <shellapi.h>
|
#include <shellapi.h>
|
||||||
#include <wchar.h>
|
#include <wchar.h>
|
||||||
#include <wtypes.h>
|
#include <wtypes.h>
|
||||||
|
extern void jv_tsd_dtoa_ctx_init();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(HAVE_ISATTY) && defined(HAVE__ISATTY)
|
#if !defined(HAVE_ISATTY) && defined(HAVE__ISATTY)
|
||||||
@@ -281,6 +282,7 @@ int main(int argc, char* argv[]) {
|
|||||||
jv program_arguments = jv_object(); /* named arguments */
|
jv program_arguments = jv_object(); /* named arguments */
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
|
jv_tsd_dtoa_ctx_init();
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
fflush(stderr);
|
fflush(stderr);
|
||||||
_setmode(fileno(stdout), _O_TEXT | _O_U8TEXT);
|
_setmode(fileno(stdout), _O_TEXT | _O_U8TEXT);
|
||||||
|
|||||||
Reference in new issue
Block a user