]> git.ipfire.org Git - thirdparty/gnulib.git/commitdiff
localename-unsafe: Reduce dependencies.
authorBruno Haible <bruno@clisp.org>
Tue, 15 Jul 2025 08:39:37 +0000 (10:39 +0200)
committerBruno Haible <bruno@clisp.org>
Tue, 15 Jul 2025 08:39:37 +0000 (10:39 +0200)
* lib/localename-unsafe.c: Include windows-mutex.h instead of
glthread/lock.h.
(get_lcid_lock): Change type to glwthread_mutex_t.
(get_lcid): Use glwthread_mutex_* functions.
* modules/localename-unsafe (Depends-on): Add  windows-mutex. Remove
lock.

ChangeLog
lib/localename-unsafe.c
modules/localename-unsafe

index 53cdcee417a0ea0e48d0be07018d305b596b5249..f74c56bbb363bbe82abbc16dae974ede4ad15613 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2025-07-15  Bruno Haible  <bruno@clisp.org>
+
+       localename-unsafe: Reduce dependencies.
+       * lib/localename-unsafe.c: Include windows-mutex.h instead of
+       glthread/lock.h.
+       (get_lcid_lock): Change type to glwthread_mutex_t.
+       (get_lcid): Use glwthread_mutex_* functions.
+       * modules/localename-unsafe (Depends-on): Add  windows-mutex. Remove
+       lock.
+
 2025-07-15  Bruno Haible  <bruno@clisp.org>
 
        next-prime tests: Update unit test after last change.
index a058281f5bfb1a8a9b5aa598a7179045f8d9aa84..35fddfbfe933949eb044954cc2ca54bf566e52b3 100644 (file)
@@ -51,7 +51,9 @@
 
 #if defined _WIN32 && !defined __CYGWIN__
 # define WINDOWS_NATIVE
-# include "glthread/lock.h"
+# define WIN32_LEAN_AND_MEAN
+# include <windows.h>
+# include "windows-mutex.h"
 #endif
 
 #if defined WINDOWS_NATIVE || defined __CYGWIN__ /* Native Windows or Cygwin */
@@ -2540,12 +2542,12 @@ gl_locale_name_from_win32_LCID (LCID lcid)
 
 # ifdef WINDOWS_NATIVE
 
-/* Two variables to interface between get_lcid and the EnumLocales
+/* Two variables to interface between get_lcid and the EnumSystemLocales
    callback function below.  */
 static LCID found_lcid;
 static char lname[LC_MAX * (LOCALE_NAME_MAX_LENGTH + 1) + 1];
 
-/* Callback function for EnumLocales.  */
+/* Callback function for EnumSystemLocales.  */
 static BOOL CALLBACK
 enum_locales_fn (LPSTR locale_num_str)
 {
@@ -2575,7 +2577,7 @@ enum_locales_fn (LPSTR locale_num_str)
 }
 
 /* This lock protects the get_lcid against multiple simultaneous calls.  */
-gl_lock_define_initialized(static, get_lcid_lock)
+static glwthread_mutex_t get_lcid_lock = GLWTHREAD_MUTEX_INIT;
 
 /* Return the Locale ID (LCID) number given the locale's name, a
    string, in LOCALE_NAME.  This works by enumerating all the locales
@@ -2590,10 +2592,10 @@ get_lcid (const char *locale_name)
 
   /* 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);
+  glwthread_mutex_lock (&get_lcid_lock);
   if (last_lcid > 0 && strcmp (locale_name, last_locale) == 0)
     {
-      gl_lock_unlock (get_lcid_lock);
+      glwthread_mutex_unlock (&get_lcid_lock);
       return last_lcid;
     }
   strncpy (lname, locale_name, sizeof (lname) - 1);
@@ -2605,7 +2607,7 @@ get_lcid (const char *locale_name)
       last_lcid = found_lcid;
       strcpy (last_locale, locale_name);
     }
-  gl_lock_unlock (get_lcid_lock);
+  glwthread_mutex_unlock (&get_lcid_lock);
   return found_lcid;
 }
 
index 01ab5a42d08b6e5fa66f283a576e8708806413f0..01901ab1f6bf9676ae72b156670f7fe64fd2fda8 100644 (file)
@@ -17,7 +17,7 @@ localename-environ
 extensions
 locale-h
 strdup
-lock
+windows-mutex
 getlocalename_l-unsafe
 setlocale-null-unlocked