Daiki Ueno <u...@gnu.org> writes: > I could be wrong and perhaps it might not be a problem with the recent > MinGW releases.
FWIW I just tried myself (on wine, though) and it seems to work with: - GCC 4.8.3 (Fedora mingw64-gcc package, cross compiling) - GCC 4.7.2 (mingw-w32-bin_i686-mingw_20111219, self compiling) So, I guess it is OK to use __thread, though other 3 static variables (lname, last_lcid, and last_locale) would also need the same care. For the archive, I'm attaching a test program:
#include <config.h> #include <windows.h> #include <locale.h> #include <localename.h> #include <process.h> #include <stdio.h> static void func (LPVOID p) { char *locale = (char *) p; _configthreadlocale (_ENABLE_PER_THREAD_LOCALE); setlocale (LC_CTYPE, locale); while (1) { const char *actual = gl_locale_name_thread (LC_CTYPE, "LC_CTYPE"); if (actual == NULL || strcmp (actual, locale) != 0) printf ("%s != %s\n", actual, locale); } } int main (void) { HANDLE threads[2]; threads[0] = (HANDLE) _beginthread (func, 0, "de_DE"); threads[1] = (HANDLE) _beginthread (func, 0, "ja_JP"); WaitForMultipleObjects (2, threads, TRUE, INFINITE); CloseHandle (threads[0]); CloseHandle (threads[1]); return 0; }
Regards, -- Daiki Ueno