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 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) {
|
||||
|
||||
+4
-4
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user