+2014-08-07 Daiki Ueno <ueno@gnu.org>
+
+ localename: make gl_locale_name_thread really thread-safe on Windows
+ * lib/localename.c [WINDOWS_NATIVE && !IN_LIBINTL]: Include
+ "glthread/lock.h".
+ (get_lcid_lock) [WINDOWS_NATIVE]: New variable.
+ (get_lcid) [WINDOWS_NATIVE]: Lock while looking for an LCID.
+
2014-08-07 Paul Eggert <eggert@cs.ucla.edu>
getpass: don't assume struct termios
#if defined _WIN32 || defined __WIN32__
# define WINDOWS_NATIVE
+# if !defined IN_LIBINTL
+# include "glthread/lock.h"
+# endif
#endif
#if defined WINDOWS_NATIVE || defined __CYGWIN__ /* Native Windows or Cygwin */
return TRUE;
}
+/* This lock protects the get_lcid against multiple simultaneous calls. */
+gl_lock_define_initialized(static, get_lcid_lock)
+
/* Return the Locale ID (LCID) number given the locale's name, a
string, in LOCALE_NAME. This works by enumerating all the locales
supported by the system, until we find one whose name matches
static LCID last_lcid;
static char last_locale[1000];
+ /* Lock while looking for an LCID, to protect access to static
+ variables: last_lcid, last_locale, found_lcid, and lname. */
+ gl_lock_lock (get_lcid_lock);
if (last_lcid > 0 && strcmp (locale_name, last_locale) == 0)
- return last_lcid;
+ {
+ gl_lock_unlock (get_lcid_lock);
+ return last_lcid;
+ }
strncpy (lname, locale_name, sizeof (lname) - 1);
lname[sizeof (lname) - 1] = '\0';
found_lcid = 0;
last_lcid = found_lcid;
strcpy (last_locale, locale_name);
}
+ gl_lock_unlock (get_lcid_lock);
return found_lcid;
}