bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

mbrtowc: ensure the mbtowc_lock is unique


From: Bruno Haible
Subject: mbrtowc: ensure the mbtowc_lock is unique
Date: Fri, 03 Jan 2020 17:08:08 +0100
User-agent: KMail/5.1.3 (Linux/4.4.0-170-generic; KDE/5.18.0; x86_64; ; )

On IRIX and 32-bit AIX, our mbrtowc implementation uses a lock to protect
against use of the internal state of mbtowc in the same thread.

To make this work reliably, the lock needs to be unique in an application:
- When linking statically, make sure only one copy of this lock exists.
  This is done by moving the lock's definition to a separate compilation
  unit.
- When different shared libraries define the lock, make sure only one of
  these makes the lock visible. This is done by accessing the lock through
  a global function.
Like done recently for the setlocale lock in module 'setlocale-null'.

This patch updates the link dependencies, according to the dependency tree
from <https://lists.gnu.org/archive/html/bug-gnulib/2019-12/msg00008.html>.

Tested on
  - 32-bit AIX with --enable-threads=posix
  - 32-bit AIX with --enable-threads=isoc
  - IRIX
  - FreeBSD 12 with --enable-threads=isoc


2020-01-03  Bruno Haible  <address@hidden>

        mbrtowc: Ensure the mbtowc_lock is unique.
        * lib/mbtowc-lock.c: New file, based on lib/setlocale-lock.c.
        * lib/mbtowc-lock.h: New file, extracted from lib/mbrtowc.c and
        lib/setlocale_null.c.
        * lib/mbrtowc.c: Include headers needed for mbtowc-lock.h. Don't include
        glthread/lock.h. Include mbtowc-lock.h.
        (mbtowc_lock): Remove declaration.
        (mbrtowc): Use mbtowc_with_lock.
        * m4/mbrtowc.m4 (gl_FUNC_MBRTOWC): Require gl_PTHREADLIB. Check for
        threads.h. Set LIB_MBRTOWC.
        (gl_PREREQ_MBTOWC_LOCK): New macro.
        * modules/mbrtowc (Files): Add lib/mbtowc-lock.h, lib/mbtowc-lock.c,
        lib/windows-initguard.h, m4/threadlib.m4, m4/visibility.m4.
        (Depends-on): Remove lock.
        (configure.ac): Arrange to compile mbtowc-lock.c.
        (Link): Mention $(LIB_MBRTOWC) instead of $(LIBTHREAD).
        * modules/acl (Link): Likewise.
        * modules/argmatch (Link): Likewise.
        * modules/backup-rename (Link): Likewise.
        * modules/backupfile (Link): Likewise.
        * modules/closein (Link): Likewise.
        * modules/closeout (Link): Likewise.
        * modules/copy-file (Link): Likewise.
        * modules/csharpcomp (Link): Likewise.
        * modules/csharpexec (Link): Likewise.
        * modules/dfa (Link): Likewise.
        * modules/exclude (Link): Likewise.
        * modules/fnmatch (Link): Likewise.
        * modules/fnmatch-gnu (Link): Likewise.
        * modules/fnmatch-posix (Link): Likewise.
        * modules/glob (Link): Likewise.
        * modules/human (Link): Likewise.
        * modules/javacomp (Link): Likewise.
        * modules/javaexec (Link): Likewise.
        * modules/javaversion (Link): Likewise.
        * modules/mbfile (Link): Likewise.
        * modules/mbiter (Link): Likewise.
        * modules/mbmemcasecmp (Link): Likewise.
        * modules/mbmemcasecoll (Link): Likewise.
        * modules/mbrlen (Link): Likewise.
        * modules/mbscasecmp (Link): Likewise.
        * modules/mbscasestr (Link): Likewise.
        * modules/mbschr (Link): Likewise.
        * modules/mbscspn (Link): Likewise.
        * modules/mbsinit (Link): Likewise.
        * modules/mbslen (Link): Likewise.
        * modules/mbsncasecmp (Link): Likewise.
        * modules/mbsnlen (Link): Likewise.
        * modules/mbsnrtowcs (Link): Likewise.
        * modules/mbspbrk (Link): Likewise.
        * modules/mbspcasecmp (Link): Likewise.
        * modules/mbsrchr (Link): Likewise.
        * modules/mbsrtowcs (Link): Likewise.
        * modules/mbssep (Link): Likewise.
        * modules/mbsspn (Link): Likewise.
        * modules/mbsstr (Link): Likewise.
        * modules/mbstok_r (Link): Likewise.
        * modules/mbswidth (Link): Likewise.
        * modules/mbuiter (Link): Likewise.
        * modules/mkdir-p (Link): Likewise.
        * modules/propername (Link): Likewise.
        * modules/quote (Link): Likewise.
        * modules/quotearg (Link): Likewise.
        * modules/quotearg-simple (Link): Likewise.
        * modules/regex-quote (Link): Likewise.
        * modules/rpmatch (Link): Likewise.
        * modules/sh-quote (Link): Likewise.
        * modules/system-quote (Link): Likewise.
        * modules/trim (Link): Likewise.
        * modules/unistdio/ulc-asnprintf (Link): Likewise.
        * modules/unistdio/ulc-fprintf (Link): Likewise.
        * modules/unistdio/ulc-vasnprintf (Link): Likewise.
        * modules/unistdio/ulc-vasprintf (Link): Likewise.
        * modules/unistdio/ulc-vfprintf (Link): Likewise.
        * modules/unistdio/ulc-vsnprintf (Link): Likewise.
        * modules/unistdio/ulc-vsprintf (Link): Likewise.
        * modules/xfreopen (Link): Likewise.
        * modules/xmemcoll (Link): Likewise.
        * modules/yesno (Link): Likewise.
        * modules/regex (Link): Add $(LIB_MBRTOWC).
        * modules/acl-tests (Makefile.am): Link the programs with $(LIB_MBRTOWC)
        instead of $(LIBTHREAD).
        * modules/argmatch-tests (Makefile.am): Likewise.
        * modules/closein-tests (Makefile.am): Likewise.
        * modules/copy-file-tests (Makefile.am): Likewise.
        * modules/dfa-tests (Makefile.am): Likewise.
        * modules/fnmatch-tests (Makefile.am): Likewise.
        * modules/glob-tests (Makefile.am): Likewise.
        * modules/mbmemcasecmp-tests (Makefile.am): Likewise.
        * modules/mbmemcasecoll-tests (Makefile.am): Likewise.
        * modules/mbrtowc-tests (Makefile.am): Likewise.
        * modules/mbscasecmp-tests (Makefile.am): Likewise.
        * modules/mbscasestr-tests (Makefile.am): Likewise.
        * modules/mbschr-tests (Makefile.am): Likewise.
        * modules/mbscspn-tests (Makefile.am): Likewise.
        * modules/mbsinit-tests (Makefile.am): Likewise.
        * modules/mbsncasecmp-tests (Makefile.am): Likewise.
        * modules/mbsnrtowcs-tests (Makefile.am): Likewise.
        * modules/mbspbrk-tests (Makefile.am): Likewise.
        * modules/mbspcasecmp-tests (Makefile.am): Likewise.
        * modules/mbsrchr-tests (Makefile.am): Likewise.
        * modules/mbsrtowcs-tests (Makefile.am): Likewise.
        * modules/mbsspn-tests (Makefile.am): Likewise.
        * modules/mbsstr-tests (Makefile.am): Likewise.
        * modules/quotearg-simple-tests (Makefile.am): Likewise.
        * modules/quotearg-tests (Makefile.am): Likewise.
        * modules/readtokens-tests (Makefile.am): Likewise.
        * modules/sh-quote-tests (Makefile.am): Likewise.
        * modules/system-quote-tests (Makefile.am): Likewise.
        * modules/unistdio/ulc-asnprintf-tests (Makefile.am): Likewise.
        * modules/unistdio/ulc-vasnprintf-tests (Makefile.am): Likewise.
        * modules/unistdio/ulc-vasprintf-tests (Makefile.am): Likewise.
        * modules/unistdio/ulc-vsnprintf-tests (Makefile.am): Likewise.
        * modules/unistdio/ulc-vsprintf-tests (Makefile.am): Likewise.
        * modules/yesno-tests (Makefile.am): Likewise.
        * modules/exclude-tests (Makefile.am): Link the programs with
        $(LIB_MBRTOWC).
        * modules/regex-tests (Makefile.am): Likewise.
        * modules/regex-quote-tests (Makefile.am): Likewise.

diff --git a/lib/mbrtowc.c b/lib/mbrtowc.c
index 1cdd1af..066d949 100644
--- a/lib/mbrtowc.c
+++ b/lib/mbrtowc.c
@@ -32,10 +32,32 @@
 # include <stdint.h>
 # include <stdlib.h>
 
+# if defined _WIN32 && !defined __CYGWIN__
+
+#  define WIN32_LEAN_AND_MEAN  /* avoid including junk */
+#  include <windows.h>
+
+# elif HAVE_PTHREAD_API
+
+#  include <pthread.h>
+#  if HAVE_THREADS_H && HAVE_WEAK_SYMBOLS
+#   include <threads.h>
+#   pragma weak thrd_exit
+#   define c11_threads_in_use() (thrd_exit != NULL)
+#  else
+#   define c11_threads_in_use() 0
+#  endif
+
+# elif HAVE_THREADS_H
+
+#  include <threads.h>
+
+# endif
+
 # include "localcharset.h"
 # include "streq.h"
 # include "verify.h"
-# include "glthread/lock.h"
+# include "mbtowc-lock.h"
 
 # ifndef FALLTHROUGH
 #  if __GNUC__ < 7
@@ -93,12 +115,7 @@ locale_enc_cached (void)
 #  define locale_enc_cached locale_enc
 # endif
 
-/* This lock protects the internal state of mbtowc against multiple 
simultaneous
-   calls of mbrtowc.  */
-gl_lock_define_initialized(static, mbtowc_lock)
-
 verify (sizeof (mbstate_t) >= 4);
-
 static char internal_state[4];
 
 size_t
@@ -286,16 +303,7 @@ mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t 
*ps)
       {
         /* The hidden internal state of mbtowc would make this function not
            multi-thread safe.  Achieve multi-thread safety through a lock.  */
-        gl_lock_lock (mbtowc_lock);
-
-        /* Put the hidden internal state of mbtowc into its initial state.
-           This is needed at least with glibc, uClibc, and MSVC CRT.
-           See <https://sourceware.org/bugzilla/show_bug.cgi?id=9674>.  */
-        mbtowc (NULL, NULL, 0);
-
-        res = mbtowc (pwc, p, m);
-
-        gl_lock_unlock (mbtowc_lock);
+        res = mbtowc_with_lock (pwc, p, m);
 
         if (res >= 0)
           {
diff --git a/lib/mbtowc-lock.c b/lib/mbtowc-lock.c
new file mode 100644
index 0000000..85ad3c4
--- /dev/null
+++ b/lib/mbtowc-lock.c
@@ -0,0 +1,150 @@
+/* Return the internal lock used by mbrtowc and mbrtoc32.
+   Copyright (C) 2019-2020 Free Software Foundation, Inc.
+
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
+
+/* Written by Bruno Haible <address@hidden>, 2019-2020.  */
+
+#include <config.h>
+
+/* When it is known that the gl_get_mbtowc_lock function is defined
+   by a dependency library, it should not be defined here.  */
+#if OMIT_MBTOWC_LOCK
+
+/* This declaration is solely to ensure that after preprocessing
+   this file is never empty.  */
+typedef int dummy;
+
+#else
+
+/* This file defines the internal lock used by mbrtowc and mbrtoc32.
+   It is a separate compilation unit, so that only one copy of it is
+   present when linking statically.  */
+
+/* Prohibit renaming this symbol.  */
+# undef gl_get_mbtowc_lock
+
+/* Macro for exporting a symbol (function, not variable) defined in this file,
+   when compiled into a shared library.  */
+# ifndef DLL_EXPORTED
+#  if HAVE_VISIBILITY
+  /* Override the effect of the compiler option '-fvisibility=hidden'.  */
+#   define DLL_EXPORTED __attribute__((__visibility__("default")))
+#  elif defined _WIN32 || defined __CYGWIN__
+#   define DLL_EXPORTED __declspec(dllexport)
+#  else
+#   define DLL_EXPORTED
+#  endif
+# endif
+
+# if defined _WIN32 && !defined __CYGWIN__
+
+#  define WIN32_LEAN_AND_MEAN  /* avoid including junk */
+#  include <windows.h>
+
+#  include "windows-initguard.h"
+
+/* The return type is a 'CRITICAL_SECTION *', not a 'glwthread_mutex_t *',
+   because the latter is not guaranteed to be a stable ABI in the future.  */
+
+/* Make sure the function gets exported from DLLs.  */
+DLL_EXPORTED CRITICAL_SECTION *gl_get_mbtowc_lock (void);
+
+static glwthread_initguard_t guard = GLWTHREAD_INITGUARD_INIT;
+static CRITICAL_SECTION lock;
+
+/* Returns the internal lock used by mbrtowc and mbrtoc32.  */
+CRITICAL_SECTION *
+gl_get_mbtowc_lock (void)
+{
+  if (!guard.done)
+    {
+      if (InterlockedIncrement (&guard.started) == 0)
+        {
+          /* This thread is the first one to need the lock.  Initialize it.  */
+          InitializeCriticalSection (&lock);
+          guard.done = 1;
+        }
+      else
+        {
+          /* Don't let guard.started grow and wrap around.  */
+          InterlockedDecrement (&guard.started);
+          /* Yield the CPU while waiting for another thread to finish
+             initializing this mutex.  */
+          while (!guard.done)
+            Sleep (0);
+        }
+    }
+  return &lock;
+}
+
+# elif HAVE_PTHREAD_API
+
+#  include <pthread.h>
+
+static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
+
+/* Make sure the function gets exported from shared libraries.  */
+DLL_EXPORTED pthread_mutex_t *gl_get_mbtowc_lock (void);
+
+/* Returns the internal lock used by mbrtowc and mbrtoc32.  */
+pthread_mutex_t *
+gl_get_mbtowc_lock (void)
+{
+  return &mutex;
+}
+
+# elif HAVE_THREADS_H
+
+#  include <threads.h>
+#  include <stdlib.h>
+
+static int volatile init_needed = 1;
+static once_flag init_once = ONCE_FLAG_INIT;
+static mtx_t mutex;
+
+static void
+atomic_init (void)
+{
+  if (mtx_init (&mutex, mtx_plain) != thrd_success)
+    abort ();
+  init_needed = 0;
+}
+
+/* Make sure the function gets exported from shared libraries.  */
+DLL_EXPORTED mtx_t *gl_get_mbtowc_lock (void);
+
+/* Returns the internal lock used by mbrtowc and mbrtoc32.  */
+mtx_t *
+gl_get_mbtowc_lock (void)
+{
+  if (init_needed)
+    call_once (&init_once, atomic_init);
+  return &mutex;
+}
+
+# endif
+
+# if (defined _WIN32 || defined __CYGWIN__) && !defined _MSC_VER
+/* Make sure the '__declspec(dllimport)' in mbrtowc.c and mbrtoc32.c does not
+   cause a link failure when no DLLs are involved.  */
+#  if defined _WIN64 || defined _LP64
+#   define IMP(x) __imp_##x
+#  else
+#   define IMP(x) _imp__##x
+#  endif
+void * IMP(gl_get_mbtowc_lock) = &gl_get_mbtowc_lock;
+# endif
+
+#endif
diff --git a/lib/mbtowc-lock.h b/lib/mbtowc-lock.h
new file mode 100644
index 0000000..e101978
--- /dev/null
+++ b/lib/mbtowc-lock.h
@@ -0,0 +1,115 @@
+/* Use the internal lock used by mbrtowc and mbrtoc32.
+   Copyright (C) 2019-2020 Free Software Foundation, Inc.
+
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
+
+/* Written by Bruno Haible <address@hidden>, 2019-2020.  */
+
+/* Use a lock, so that no two threads can invoke mbtowc at the same time.  */
+
+static inline int
+mbtowc_unlocked (wchar_t *pwc, const char *p, size_t m)
+{
+  /* Put the hidden internal state of mbtowc into its initial state.
+     This is needed at least with glibc, uClibc, and MSVC CRT.
+     See <https://sourceware.org/bugzilla/show_bug.cgi?id=9674>.  */
+  mbtowc (NULL, NULL, 0);
+
+  return mbtowc (pwc, p, m);
+}
+
+/* Prohibit renaming this symbol.  */
+#undef gl_get_mbtowc_lock
+
+#if defined _WIN32 && !defined __CYGWIN__
+
+extern __declspec(dllimport) CRITICAL_SECTION *gl_get_mbtowc_lock (void);
+
+static int
+mbtowc_with_lock (wchar_t *pwc, const char *p, size_t m)
+{
+  CRITICAL_SECTION *lock = gl_get_mbtowc_lock ();
+  int ret;
+
+  EnterCriticalSection (lock);
+  ret = mbtowc_unlocked (pwc, p, m);
+  LeaveCriticalSection (lock);
+
+  return ret;
+}
+
+#elif HAVE_PTHREAD_API /* AIX, IRIX, Cygwin */
+
+extern
+# if defined _WIN32 || defined __CYGWIN__
+  __declspec(dllimport)
+# endif
+  pthread_mutex_t *gl_get_mbtowc_lock (void);
+
+# if HAVE_WEAK_SYMBOLS /* IRIX */
+
+   /* Avoid the need to link with '-lpthread'.  */
+#  pragma weak pthread_mutex_lock
+#  pragma weak pthread_mutex_unlock
+
+   /* Determine whether libpthread is in use.  */
+#  pragma weak pthread_mutexattr_gettype
+   /* See the comments in lock.h.  */
+#  define pthread_in_use() \
+     (pthread_mutexattr_gettype != NULL || c11_threads_in_use ())
+
+# else
+#  define pthread_in_use() 1
+# endif
+
+static int
+mbtowc_with_lock (wchar_t *pwc, const char *p, size_t m)
+{
+  if (pthread_in_use())
+    {
+      pthread_mutex_t *lock = gl_get_mbtowc_lock ();
+      int ret;
+
+      if (pthread_mutex_lock (lock))
+        abort ();
+      ret = mbtowc_unlocked (pwc, p, m);
+      if (pthread_mutex_unlock (lock))
+        abort ();
+
+      return ret;
+    }
+  else
+    return mbtowc_unlocked (pwc, p, m);
+}
+
+#elif HAVE_THREADS_H
+
+extern mtx_t *gl_get_mbtowc_lock (void);
+
+static int
+mbtowc_with_lock (wchar_t *pwc, const char *p, size_t m)
+{
+  mtx_t *lock = gl_get_mbtowc_lock ();
+  int ret;
+
+  if (mtx_lock (lock) != thrd_success)
+    abort ();
+  ret = mbtowc_unlocked (pwc, p, m);
+  if (mtx_unlock (lock) != thrd_success)
+    abort ();
+
+  return ret;
+}
+
+#endif
diff --git a/m4/mbrtowc.m4 b/m4/mbrtowc.m4
index 5ad246f..bd9225b 100644
--- a/m4/mbrtowc.m4
+++ b/m4/mbrtowc.m4
@@ -1,4 +1,4 @@
-# mbrtowc.m4 serial 36  -*- coding: utf-8 -*-
+# mbrtowc.m4 serial 37  -*- coding: utf-8 -*-
 dnl Copyright (C) 2001-2002, 2004-2005, 2008-2020 Free Software Foundation,
 dnl Inc.
 dnl This file is free software; the Free Software Foundation
@@ -8,6 +8,8 @@ dnl with or without modifications, as long as this notice is 
preserved.
 AC_DEFUN([gl_FUNC_MBRTOWC],
 [
   AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
+  AC_REQUIRE([gl_PTHREADLIB])
+  AC_CHECK_HEADERS_ONCE([threads.h])
 
   AC_REQUIRE([AC_TYPE_MBSTATE_T])
   gl_MBSTATE_T_BROKEN
@@ -94,6 +96,23 @@ AC_DEFUN([gl_FUNC_MBRTOWC],
       esac
     fi
   fi
+  if test $REPLACE_MBSTATE_T = 1; then
+    case "$host_os" in
+      mingw*) LIB_MBRTOWC= ;;
+      *)
+        gl_WEAK_SYMBOLS
+        case "$gl_cv_have_weak" in
+          *yes) LIB_MBRTOWC= ;;
+          *)    LIB_MBRTOWC="$LIBPTHREAD" ;;
+        esac
+        ;;
+    esac
+  else
+    LIB_MBRTOWC=
+  fi
+  dnl LIB_MBRTOWC is expected to be '-pthread' or '-lpthread' on AIX
+  dnl with gcc or xlc, and empty otherwise.
+  AC_SUBST([LIB_MBRTOWC])
 ])
 
 dnl Test whether mbsinit() and mbrtowc() need to be overridden in a way that
@@ -808,6 +827,12 @@ AC_DEFUN([gl_PREREQ_MBRTOWC], [
   :
 ])
 
+# Prerequisites of lib/mbtowc-lock.c.
+AC_DEFUN([gl_PREREQ_MBTOWC_LOCK],
+[
+  gl_VISIBILITY
+])
+
 
 dnl From Paul Eggert
 
diff --git a/modules/acl b/modules/acl
index 9c398dd..a0a5e45 100644
--- a/modules/acl
+++ b/modules/acl
@@ -22,7 +22,7 @@ Include:
 "acl.h"
 
 Link:
-$(LIBTHREAD)
+$(LIB_MBRTOWC)
 
 License:
 GPL
diff --git a/modules/acl-tests b/modules/acl-tests
index 1c6b7c4..e4173fe 100644
--- a/modules/acl-tests
+++ b/modules/acl-tests
@@ -25,6 +25,6 @@ TESTS += \
   test-copy-acl.sh test-copy-acl-1.sh test-copy-acl-2.sh
 TESTS_ENVIRONMENT += USE_ACL=$(USE_ACL)
 check_PROGRAMS += test-set-mode-acl test-copy-acl test-sameacls
-test_set_mode_acl_LDADD = $(LDADD) $(LIB_ACL) @LIBINTL@ $(LIBTHREAD)
-test_copy_acl_LDADD = $(LDADD) $(LIB_ACL) @LIBINTL@ $(LIBTHREAD)
-test_sameacls_LDADD = $(LDADD) $(LIB_ACL) @LIBINTL@ $(LIBTHREAD)
+test_set_mode_acl_LDADD = $(LDADD) $(LIB_ACL) @LIBINTL@ $(LIB_MBRTOWC)
+test_copy_acl_LDADD = $(LDADD) $(LIB_ACL) @LIBINTL@ $(LIB_MBRTOWC)
+test_sameacls_LDADD = $(LDADD) $(LIB_ACL) @LIBINTL@ $(LIB_MBRTOWC)
diff --git a/modules/argmatch b/modules/argmatch
index 7fdbe66..97d84fb 100644
--- a/modules/argmatch
+++ b/modules/argmatch
@@ -27,7 +27,7 @@ Include:
 "argmatch.h"
 
 Link:
-$(LIBTHREAD)
+$(LIB_MBRTOWC)
 
 License:
 GPL
diff --git a/modules/argmatch-tests b/modules/argmatch-tests
index 1b2f3c4..1ede023 100644
--- a/modules/argmatch-tests
+++ b/modules/argmatch-tests
@@ -9,5 +9,5 @@ configure.ac:
 Makefile.am:
 TESTS += test-argmatch
 check_PROGRAMS += test-argmatch
-test_argmatch_LDADD = $(LDADD) @LIBINTL@ $(LIBTHREAD)
+test_argmatch_LDADD = $(LDADD) @LIBINTL@ $(LIB_MBRTOWC)
 
diff --git a/modules/backup-rename b/modules/backup-rename
index 65ebe45..0d6c34b 100644
--- a/modules/backup-rename
+++ b/modules/backup-rename
@@ -33,7 +33,7 @@ Include:
 "backupfile.h"
 
 Link:
-$(LIBTHREAD)
+$(LIB_MBRTOWC)
 
 License:
 GPL
diff --git a/modules/backupfile b/modules/backupfile
index 67c7971..7916d6a 100644
--- a/modules/backupfile
+++ b/modules/backupfile
@@ -34,7 +34,7 @@ Include:
 "backupfile.h"
 
 Link:
-$(LIBTHREAD)
+$(LIB_MBRTOWC)
 
 License:
 GPL
diff --git a/modules/closein b/modules/closein
index a5e8a53..6a34d83 100644
--- a/modules/closein
+++ b/modules/closein
@@ -20,7 +20,7 @@ Include:
 "closein.h"
 
 Link:
-$(LIBTHREAD)
+$(LIB_MBRTOWC)
 
 License:
 GPL
diff --git a/modules/closein-tests b/modules/closein-tests
index bffa63a..dc288f2 100644
--- a/modules/closein-tests
+++ b/modules/closein-tests
@@ -12,4 +12,4 @@ configure.ac:
 Makefile.am:
 TESTS += test-closein.sh
 check_PROGRAMS += test-closein
-test_closein_LDADD = $(LDADD) @LIBINTL@ $(LIBTHREAD)
+test_closein_LDADD = $(LDADD) @LIBINTL@ $(LIB_MBRTOWC)
diff --git a/modules/closeout b/modules/closeout
index 5482357..e51489f 100644
--- a/modules/closeout
+++ b/modules/closeout
@@ -22,7 +22,7 @@ Include:
 "closeout.h"
 
 Link:
-$(LIBTHREAD)
+$(LIB_MBRTOWC)
 
 License:
 GPL
diff --git a/modules/copy-file b/modules/copy-file
index 36d25af..cc4a3c7 100644
--- a/modules/copy-file
+++ b/modules/copy-file
@@ -34,7 +34,7 @@ Include:
 "copy-file.h"
 
 Link:
-$(LIBTHREAD)
+$(LIB_MBRTOWC)
 
 License:
 GPL
diff --git a/modules/copy-file-tests b/modules/copy-file-tests
index d33de79..a078875 100644
--- a/modules/copy-file-tests
+++ b/modules/copy-file-tests
@@ -18,4 +18,4 @@ Makefile.am:
 TESTS += test-copy-file.sh test-copy-file-1.sh test-copy-file-2.sh
 TESTS_ENVIRONMENT += USE_ACL=$(USE_ACL)
 check_PROGRAMS += test-copy-file
-test_copy_file_LDADD = $(LDADD) $(LIB_ACL) $(LIB_CLOCK_GETTIME) @LIBINTL@ 
$(LIBTHREAD)
+test_copy_file_LDADD = $(LDADD) $(LIB_ACL) $(LIB_CLOCK_GETTIME) @LIBINTL@ 
$(LIB_MBRTOWC)
diff --git a/modules/csharpcomp b/modules/csharpcomp
index 9afcefa..62163f6 100644
--- a/modules/csharpcomp
+++ b/modules/csharpcomp
@@ -28,7 +28,7 @@ Include:
 "csharpcomp.h"
 
 Link:
-$(LIBTHREAD)
+$(LIB_MBRTOWC)
 
 License:
 GPL
diff --git a/modules/csharpexec b/modules/csharpexec
index ed1723a..714e0b9 100644
--- a/modules/csharpexec
+++ b/modules/csharpexec
@@ -28,7 +28,7 @@ Include:
 "csharpexec.h"
 
 Link:
-$(LIBTHREAD)
+$(LIB_MBRTOWC)
 
 License:
 GPL
diff --git a/modules/dfa b/modules/dfa
index f1b00fe..9b112af 100644
--- a/modules/dfa
+++ b/modules/dfa
@@ -38,7 +38,7 @@ Include:
 "localeinfo.h"
 
 Link:
-$(LIBTHREAD)
+$(LIB_MBRTOWC)
 
 License:
 GPL
diff --git a/modules/dfa-tests b/modules/dfa-tests
index 0128dca..5855652 100644
--- a/modules/dfa-tests
+++ b/modules/dfa-tests
@@ -18,4 +18,4 @@ TESTS +=                      \
   dfa-match.sh
 
 check_PROGRAMS += dfa-match-aux
-dfa_match_aux_LDADD = $(LDADD) $(LIB_SETLOCALE) @LIBINTL@ $(LIBTHREAD)
+dfa_match_aux_LDADD = $(LDADD) $(LIB_SETLOCALE) @LIBINTL@ $(LIB_MBRTOWC)
diff --git a/modules/exclude b/modules/exclude
index d05fdb2..5ff0539 100644
--- a/modules/exclude
+++ b/modules/exclude
@@ -25,7 +25,7 @@ Include:
 "exclude.h"
 
 Link:
-$(LIBTHREAD)
+$(LIB_MBRTOWC)
 
 License:
 GPL
diff --git a/modules/exclude-tests b/modules/exclude-tests
index f0dffe8..f8372a3 100644
--- a/modules/exclude-tests
+++ b/modules/exclude-tests
@@ -26,4 +26,4 @@ TESTS += \
  test-exclude8.sh
 
 check_PROGRAMS += test-exclude
-test_exclude_LDADD = $(LDADD) @LIBINTL@ $(LIBTHREAD)
+test_exclude_LDADD = $(LDADD) @LIBINTL@ $(LIB_MBRTOWC) $(LIBTHREAD)
diff --git a/modules/fnmatch b/modules/fnmatch
index 6722457..50a2c71 100644
--- a/modules/fnmatch
+++ b/modules/fnmatch
@@ -34,7 +34,7 @@ Include:
 <fnmatch.h>
 
 Link:
-$(LIBTHREAD)
+$(LIB_MBRTOWC)
 
 License:
 LGPLv2+
diff --git a/modules/fnmatch-gnu b/modules/fnmatch-gnu
index 8a592f2..f2c49de 100644
--- a/modules/fnmatch-gnu
+++ b/modules/fnmatch-gnu
@@ -20,7 +20,7 @@ Include:
 <fnmatch.h>
 
 Link:
-$(LIBTHREAD)
+$(LIB_MBRTOWC)
 
 License:
 LGPLv2+
diff --git a/modules/fnmatch-posix b/modules/fnmatch-posix
index f1e5b69..508da56 100644
--- a/modules/fnmatch-posix
+++ b/modules/fnmatch-posix
@@ -20,7 +20,7 @@ Include:
 "fnmatch.h"
 
 Link:
-$(LIBTHREAD)
+$(LIB_MBRTOWC)
 
 License:
 LGPLv2+
diff --git a/modules/fnmatch-tests b/modules/fnmatch-tests
index 55c94cb..5fd97c7 100644
--- a/modules/fnmatch-tests
+++ b/modules/fnmatch-tests
@@ -6,4 +6,4 @@ tests/macros.h
 Makefile.am:
 TESTS += test-fnmatch
 check_PROGRAMS += test-fnmatch
-test_fnmatch_LDADD = $(LDADD) $(LIBTHREAD)
+test_fnmatch_LDADD = $(LDADD) $(LIB_MBRTOWC)
diff --git a/modules/glob b/modules/glob
index 0f7dad6..33d43bf 100644
--- a/modules/glob
+++ b/modules/glob
@@ -50,7 +50,7 @@ Include:
 <glob.h>
 
 Link:
-$(LIBTHREAD)
+$(LIB_MBRTOWC)
 
 License:
 LGPLv2+
diff --git a/modules/glob-tests b/modules/glob-tests
index 5e83c43..f551f6c 100644
--- a/modules/glob-tests
+++ b/modules/glob-tests
@@ -11,4 +11,4 @@ configure.ac:
 Makefile.am:
 TESTS += test-glob
 check_PROGRAMS += test-glob
-test_glob_LDADD = $(LDADD) $(LIBTHREAD)
+test_glob_LDADD = $(LDADD) $(LIB_MBRTOWC)
diff --git a/modules/human b/modules/human
index 362b858..58b1b79 100644
--- a/modules/human
+++ b/modules/human
@@ -27,7 +27,7 @@ Include:
 "human.h"
 
 Link:
-$(LIBTHREAD)
+$(LIB_MBRTOWC)
 
 License:
 GPL
diff --git a/modules/javacomp b/modules/javacomp
index 082a6c5..d1cc559 100644
--- a/modules/javacomp
+++ b/modules/javacomp
@@ -39,7 +39,7 @@ Include:
 "javacomp.h"
 
 Link:
-$(LIBTHREAD)
+$(LIB_MBRTOWC)
 
 License:
 GPL
diff --git a/modules/javaexec b/modules/javaexec
index 04b997b..773093e 100644
--- a/modules/javaexec
+++ b/modules/javaexec
@@ -29,7 +29,7 @@ Include:
 "javaexec.h"
 
 Link:
-$(LIBTHREAD)
+$(LIB_MBRTOWC)
 
 License:
 GPL
diff --git a/modules/javaversion b/modules/javaversion
index b86edb0..d1e426c 100644
--- a/modules/javaversion
+++ b/modules/javaversion
@@ -26,7 +26,7 @@ Include:
 "javaversion.h"
 
 Link:
-$(LIBTHREAD)
+$(LIB_MBRTOWC)
 
 License:
 GPL
diff --git a/modules/mbfile b/modules/mbfile
index 386f3e9..ae7704b 100644
--- a/modules/mbfile
+++ b/modules/mbfile
@@ -25,7 +25,7 @@ Include:
 "mbfile.h"
 
 Link:
-$(LIBTHREAD)
+$(LIB_MBRTOWC)
 
 License:
 LGPL
diff --git a/modules/mbiter b/modules/mbiter
index 347e777..0f08040 100644
--- a/modules/mbiter
+++ b/modules/mbiter
@@ -25,7 +25,7 @@ Include:
 "mbiter.h"
 
 Link:
-$(LIBTHREAD)
+$(LIB_MBRTOWC)
 
 License:
 LGPLv2+
diff --git a/modules/mbmemcasecmp b/modules/mbmemcasecmp
index 22075b5..1af2b1c 100644
--- a/modules/mbmemcasecmp
+++ b/modules/mbmemcasecmp
@@ -17,7 +17,7 @@ Include:
 "mbmemcasecmp.h"
 
 Link:
-$(LIBTHREAD)
+$(LIB_MBRTOWC)
 
 License:
 LGPL
diff --git a/modules/mbmemcasecmp-tests b/modules/mbmemcasecmp-tests
index 16a1123..69c1d0e 100644
--- a/modules/mbmemcasecmp-tests
+++ b/modules/mbmemcasecmp-tests
@@ -25,4 +25,4 @@ TESTS_ENVIRONMENT += \
   LOCALE_FR_UTF8='@LOCALE_FR_UTF8@' \
   LOCALE_TR_UTF8='@LOCALE_TR_UTF8@'
 check_PROGRAMS += test-mbmemcasecmp
-test_mbmemcasecmp_LDADD = $(LDADD) $(LIB_SETLOCALE) $(LIBTHREAD)
+test_mbmemcasecmp_LDADD = $(LDADD) $(LIB_SETLOCALE) $(LIB_MBRTOWC)
diff --git a/modules/mbmemcasecoll b/modules/mbmemcasecoll
index e0674fa..db20df0 100644
--- a/modules/mbmemcasecoll
+++ b/modules/mbmemcasecoll
@@ -24,7 +24,7 @@ Include:
 "mbmemcasecoll.h"
 
 Link:
-$(LIBTHREAD)
+$(LIB_MBRTOWC)
 
 License:
 GPL
diff --git a/modules/mbmemcasecoll-tests b/modules/mbmemcasecoll-tests
index 56a3db0..5201618 100644
--- a/modules/mbmemcasecoll-tests
+++ b/modules/mbmemcasecoll-tests
@@ -25,4 +25,4 @@ TESTS_ENVIRONMENT += \
   LOCALE_FR_UTF8='@LOCALE_FR_UTF8@' \
   LOCALE_TR_UTF8='@LOCALE_TR_UTF8@'
 check_PROGRAMS += test-mbmemcasecoll
-test_mbmemcasecoll_LDADD = $(LDADD) $(LIB_SETLOCALE) $(LIBTHREAD)
+test_mbmemcasecoll_LDADD = $(LDADD) $(LIB_SETLOCALE) $(LIB_MBRTOWC)
diff --git a/modules/mbrlen b/modules/mbrlen
index e1caa2a..b06362a 100644
--- a/modules/mbrlen
+++ b/modules/mbrlen
@@ -25,7 +25,7 @@ Include:
 <wchar.h>
 
 Link:
-$(LIBTHREAD)
+$(LIB_MBRTOWC)
 
 License:
 LGPL
diff --git a/modules/mbrtowc b/modules/mbrtowc
index d2dc54c..db10256 100644
--- a/modules/mbrtowc
+++ b/modules/mbrtowc
@@ -3,12 +3,17 @@ mbrtowc() function: convert multibyte character to wide 
character.
 
 Files:
 lib/mbrtowc.c
+lib/mbtowc-lock.h
+lib/mbtowc-lock.c
+lib/windows-initguard.h
 m4/mbrtowc.m4
 m4/mbstate_t.m4
 m4/locale-fr.m4
 m4/locale-ja.m4
 m4/locale-zh.m4
 m4/codeset.m4
+m4/threadlib.m4
+m4/visibility.m4
 
 Depends-on:
 wchar
@@ -19,13 +24,14 @@ mbsinit         [test $HAVE_MBRTOWC = 0 || test 
$REPLACE_MBRTOWC = 1]
 localcharset    [test $HAVE_MBRTOWC = 0 || test $REPLACE_MBRTOWC = 1]
 streq           [test $HAVE_MBRTOWC = 0 || test $REPLACE_MBRTOWC = 1]
 verify          [test $HAVE_MBRTOWC = 0 || test $REPLACE_MBRTOWC = 1]
-lock            [test $HAVE_MBRTOWC = 0 || { test $REPLACE_MBRTOWC = 1 && { 
test $HAVE_MBSINIT = 0 || test $REPLACE_MBSTATE_T = 1; }; }]
 
 configure.ac:
 gl_FUNC_MBRTOWC
 if test $HAVE_MBRTOWC = 0 || test $REPLACE_MBRTOWC = 1; then
   AC_LIBOBJ([mbrtowc])
+  AC_LIBOBJ([mbtowc-lock])
   gl_PREREQ_MBRTOWC
+  gl_PREREQ_MBTOWC_LOCK
 fi
 gl_WCHAR_MODULE_INDICATOR([mbrtowc])
 
@@ -35,7 +41,7 @@ Include:
 <wchar.h>
 
 Link:
-$(LIBTHREAD)
+$(LIB_MBRTOWC)
 
 License:
 LGPLv2+
diff --git a/modules/mbrtowc-tests b/modules/mbrtowc-tests
index f5c9166..6331be0 100644
--- a/modules/mbrtowc-tests
+++ b/modules/mbrtowc-tests
@@ -45,4 +45,4 @@ TESTS_ENVIRONMENT += \
   LOCALE_JA='@LOCALE_JA@' \
   LOCALE_ZH_CN='@LOCALE_ZH_CN@'
 check_PROGRAMS += test-mbrtowc test-mbrtowc-w32
-test_mbrtowc_LDADD = $(LDADD) $(LIB_SETLOCALE) $(LIBTHREAD)
+test_mbrtowc_LDADD = $(LDADD) $(LIB_SETLOCALE) $(LIB_MBRTOWC)
diff --git a/modules/mbscasecmp b/modules/mbscasecmp
index 2be11e0..6c4249c 100644
--- a/modules/mbscasecmp
+++ b/modules/mbscasecmp
@@ -18,7 +18,7 @@ Include:
 <string.h>
 
 Link:
-$(LIBTHREAD)
+$(LIB_MBRTOWC)
 
 License:
 LGPL
diff --git a/modules/mbscasecmp-tests b/modules/mbscasecmp-tests
index 9f77064..6894553 100644
--- a/modules/mbscasecmp-tests
+++ b/modules/mbscasecmp-tests
@@ -15,4 +15,4 @@ Makefile.am:
 TESTS += test-mbscasecmp.sh
 TESTS_ENVIRONMENT += LOCALE_TR_UTF8='@LOCALE_TR_UTF8@'
 check_PROGRAMS += test-mbscasecmp
-test_mbscasecmp_LDADD = $(LDADD) $(LIB_SETLOCALE) $(LIBTHREAD)
+test_mbscasecmp_LDADD = $(LDADD) $(LIB_SETLOCALE) $(LIB_MBRTOWC)
diff --git a/modules/mbscasestr b/modules/mbscasestr
index a731dd0..8c12c8d 100644
--- a/modules/mbscasestr
+++ b/modules/mbscasestr
@@ -23,7 +23,7 @@ Include:
 <string.h>
 
 Link:
-$(LIBTHREAD)
+$(LIB_MBRTOWC)
 
 License:
 LGPL
diff --git a/modules/mbscasestr-tests b/modules/mbscasestr-tests
index 3395c1f..0def3bf 100644
--- a/modules/mbscasestr-tests
+++ b/modules/mbscasestr-tests
@@ -24,7 +24,7 @@ Makefile.am:
 TESTS += test-mbscasestr1 test-mbscasestr2.sh test-mbscasestr3.sh 
test-mbscasestr4.sh
 TESTS_ENVIRONMENT += LOCALE_FR_UTF8='@LOCALE_FR_UTF8@' 
LOCALE_TR_UTF8='@LOCALE_TR_UTF8@' LOCALE_ZH_CN='@LOCALE_ZH_CN@'
 check_PROGRAMS += test-mbscasestr1 test-mbscasestr2 test-mbscasestr3 
test-mbscasestr4
-test_mbscasestr1_LDADD = $(LDADD) $(LIBTHREAD)
-test_mbscasestr2_LDADD = $(LDADD) $(LIB_SETLOCALE) $(LIBTHREAD)
-test_mbscasestr3_LDADD = $(LDADD) $(LIB_SETLOCALE) $(LIBTHREAD)
-test_mbscasestr4_LDADD = $(LDADD) $(LIB_SETLOCALE) $(LIBTHREAD)
+test_mbscasestr1_LDADD = $(LDADD) $(LIB_MBRTOWC)
+test_mbscasestr2_LDADD = $(LDADD) $(LIB_SETLOCALE) $(LIB_MBRTOWC)
+test_mbscasestr3_LDADD = $(LDADD) $(LIB_SETLOCALE) $(LIB_MBRTOWC)
+test_mbscasestr4_LDADD = $(LDADD) $(LIB_SETLOCALE) $(LIB_MBRTOWC)
diff --git a/modules/mbschr b/modules/mbschr
index ca67f30..dd55613 100644
--- a/modules/mbschr
+++ b/modules/mbschr
@@ -18,7 +18,7 @@ Include:
 <string.h>
 
 Link:
-$(LIBTHREAD)
+$(LIB_MBRTOWC)
 
 License:
 LGPL
diff --git a/modules/mbschr-tests b/modules/mbschr-tests
index 33ee83f..85e30f6 100644
--- a/modules/mbschr-tests
+++ b/modules/mbschr-tests
@@ -15,4 +15,4 @@ Makefile.am:
 TESTS += test-mbschr.sh
 TESTS_ENVIRONMENT += LOCALE_ZH_CN='@LOCALE_ZH_CN@'
 check_PROGRAMS += test-mbschr
-test_mbschr_LDADD = $(LDADD) $(LIB_SETLOCALE) $(LIBTHREAD)
+test_mbschr_LDADD = $(LDADD) $(LIB_SETLOCALE) $(LIB_MBRTOWC)
diff --git a/modules/mbscspn b/modules/mbscspn
index 6861e61..95cc670 100644
--- a/modules/mbscspn
+++ b/modules/mbscspn
@@ -20,7 +20,7 @@ Include:
 <string.h>
 
 Link:
-$(LIBTHREAD)
+$(LIB_MBRTOWC)
 
 License:
 LGPL
diff --git a/modules/mbscspn-tests b/modules/mbscspn-tests
index 8c4a3d1..effac53 100644
--- a/modules/mbscspn-tests
+++ b/modules/mbscspn-tests
@@ -15,4 +15,4 @@ Makefile.am:
 TESTS += test-mbscspn.sh
 TESTS_ENVIRONMENT += LOCALE_FR_UTF8='@LOCALE_FR_UTF8@'
 check_PROGRAMS += test-mbscspn
-test_mbscspn_LDADD = $(LDADD) $(LIB_SETLOCALE) $(LIBTHREAD)
+test_mbscspn_LDADD = $(LDADD) $(LIB_SETLOCALE) $(LIB_MBRTOWC)
diff --git a/modules/mbsinit b/modules/mbsinit
index 941c583..3f7596d 100644
--- a/modules/mbsinit
+++ b/modules/mbsinit
@@ -26,7 +26,7 @@ Include:
 <wchar.h>
 
 Link:
-$(LIBTHREAD)
+$(LIB_MBRTOWC)
 
 License:
 LGPLv2+
diff --git a/modules/mbsinit-tests b/modules/mbsinit-tests
index 0674e9c..b41fff3 100644
--- a/modules/mbsinit-tests
+++ b/modules/mbsinit-tests
@@ -17,4 +17,4 @@ Makefile.am:
 TESTS += test-mbsinit.sh
 TESTS_ENVIRONMENT += LOCALE_FR_UTF8='@LOCALE_FR_UTF8@'
 check_PROGRAMS += test-mbsinit
-test_mbsinit_LDADD = $(LDADD) $(LIB_SETLOCALE) $(LIBTHREAD)
+test_mbsinit_LDADD = $(LDADD) $(LIB_SETLOCALE) $(LIB_MBRTOWC)
diff --git a/modules/mbslen b/modules/mbslen
index ed8dfe7..41a2531 100644
--- a/modules/mbslen
+++ b/modules/mbslen
@@ -20,7 +20,7 @@ Include:
 <string.h>
 
 Link:
-$(LIBTHREAD)
+$(LIB_MBRTOWC)
 
 License:
 LGPL
diff --git a/modules/mbsncasecmp b/modules/mbsncasecmp
index 2857f4f..5dc287d 100644
--- a/modules/mbsncasecmp
+++ b/modules/mbsncasecmp
@@ -18,7 +18,7 @@ Include:
 <string.h>
 
 Link:
-$(LIBTHREAD)
+$(LIB_MBRTOWC)
 
 License:
 LGPL
diff --git a/modules/mbsncasecmp-tests b/modules/mbsncasecmp-tests
index 050201a..a18fc3b 100644
--- a/modules/mbsncasecmp-tests
+++ b/modules/mbsncasecmp-tests
@@ -15,4 +15,4 @@ Makefile.am:
 TESTS += test-mbsncasecmp.sh
 TESTS_ENVIRONMENT += LOCALE_TR_UTF8='@LOCALE_TR_UTF8@'
 check_PROGRAMS += test-mbsncasecmp
-test_mbsncasecmp_LDADD = $(LDADD) $(LIB_SETLOCALE) $(LIBTHREAD)
+test_mbsncasecmp_LDADD = $(LDADD) $(LIB_SETLOCALE) $(LIB_MBRTOWC)
diff --git a/modules/mbsnlen b/modules/mbsnlen
index fa22964..0d4ad37 100644
--- a/modules/mbsnlen
+++ b/modules/mbsnlen
@@ -18,7 +18,7 @@ Include:
 <string.h>
 
 Link:
-$(LIBTHREAD)
+$(LIB_MBRTOWC)
 
 License:
 LGPLv2+
diff --git a/modules/mbsnrtowcs b/modules/mbsnrtowcs
index b1a9721..2f1c52d 100644
--- a/modules/mbsnrtowcs
+++ b/modules/mbsnrtowcs
@@ -30,7 +30,7 @@ Include:
 <wchar.h>
 
 Link:
-$(LIBTHREAD)
+$(LIB_MBRTOWC)
 
 License:
 LGPL
diff --git a/modules/mbsnrtowcs-tests b/modules/mbsnrtowcs-tests
index 4d90f17..ce5ae46 100644
--- a/modules/mbsnrtowcs-tests
+++ b/modules/mbsnrtowcs-tests
@@ -31,4 +31,4 @@ TESTS_ENVIRONMENT += \
   LOCALE_JA='@LOCALE_JA@' \
   LOCALE_ZH_CN='@LOCALE_ZH_CN@'
 check_PROGRAMS += test-mbsnrtowcs
-test_mbsnrtowcs_LDADD = $(LDADD) $(LIB_SETLOCALE) $(LIBTHREAD)
+test_mbsnrtowcs_LDADD = $(LDADD) $(LIB_SETLOCALE) $(LIB_MBRTOWC)
diff --git a/modules/mbspbrk b/modules/mbspbrk
index 77bf03f..5a167f3 100644
--- a/modules/mbspbrk
+++ b/modules/mbspbrk
@@ -20,7 +20,7 @@ Include:
 <string.h>
 
 Link:
-$(LIBTHREAD)
+$(LIB_MBRTOWC)
 
 License:
 LGPL
diff --git a/modules/mbspbrk-tests b/modules/mbspbrk-tests
index 902e5b3..bb001fe 100644
--- a/modules/mbspbrk-tests
+++ b/modules/mbspbrk-tests
@@ -15,4 +15,4 @@ Makefile.am:
 TESTS += test-mbspbrk.sh
 TESTS_ENVIRONMENT += LOCALE_FR_UTF8='@LOCALE_FR_UTF8@'
 check_PROGRAMS += test-mbspbrk
-test_mbspbrk_LDADD = $(LDADD) $(LIB_SETLOCALE) $(LIBTHREAD)
+test_mbspbrk_LDADD = $(LDADD) $(LIB_SETLOCALE) $(LIB_MBRTOWC)
diff --git a/modules/mbspcasecmp b/modules/mbspcasecmp
index 9e87536..f581f82 100644
--- a/modules/mbspcasecmp
+++ b/modules/mbspcasecmp
@@ -18,7 +18,7 @@ Include:
 <string.h>
 
 Link:
-$(LIBTHREAD)
+$(LIB_MBRTOWC)
 
 License:
 LGPL
diff --git a/modules/mbspcasecmp-tests b/modules/mbspcasecmp-tests
index e6f11ff..b6b0e2d 100644
--- a/modules/mbspcasecmp-tests
+++ b/modules/mbspcasecmp-tests
@@ -15,4 +15,4 @@ Makefile.am:
 TESTS += test-mbspcasecmp.sh
 TESTS_ENVIRONMENT += LOCALE_TR_UTF8='@LOCALE_TR_UTF8@'
 check_PROGRAMS += test-mbspcasecmp
-test_mbspcasecmp_LDADD = $(LDADD) $(LIB_SETLOCALE) $(LIBTHREAD)
+test_mbspcasecmp_LDADD = $(LDADD) $(LIB_SETLOCALE) $(LIB_MBRTOWC)
diff --git a/modules/mbsrchr b/modules/mbsrchr
index b73b59f..6f272e0 100644
--- a/modules/mbsrchr
+++ b/modules/mbsrchr
@@ -18,7 +18,7 @@ Include:
 <string.h>
 
 Link:
-$(LIBTHREAD)
+$(LIB_MBRTOWC)
 
 License:
 LGPL
diff --git a/modules/mbsrchr-tests b/modules/mbsrchr-tests
index 1d97804..d104196 100644
--- a/modules/mbsrchr-tests
+++ b/modules/mbsrchr-tests
@@ -15,4 +15,4 @@ Makefile.am:
 TESTS += test-mbsrchr.sh
 TESTS_ENVIRONMENT += LOCALE_ZH_CN='@LOCALE_ZH_CN@'
 check_PROGRAMS += test-mbsrchr
-test_mbsrchr_LDADD = $(LDADD) $(LIB_SETLOCALE) $(LIBTHREAD)
+test_mbsrchr_LDADD = $(LDADD) $(LIB_SETLOCALE) $(LIB_MBRTOWC)
diff --git a/modules/mbsrtowcs b/modules/mbsrtowcs
index c742f49..9da2d07 100644
--- a/modules/mbsrtowcs
+++ b/modules/mbsrtowcs
@@ -33,7 +33,7 @@ Include:
 <wchar.h>
 
 Link:
-$(LIBTHREAD)
+$(LIB_MBRTOWC)
 
 License:
 LGPLv2+
diff --git a/modules/mbsrtowcs-tests b/modules/mbsrtowcs-tests
index 3de9d73..8073a53 100644
--- a/modules/mbsrtowcs-tests
+++ b/modules/mbsrtowcs-tests
@@ -31,4 +31,4 @@ TESTS_ENVIRONMENT += \
   LOCALE_JA='@LOCALE_JA@' \
   LOCALE_ZH_CN='@LOCALE_ZH_CN@'
 check_PROGRAMS += test-mbsrtowcs
-test_mbsrtowcs_LDADD = $(LDADD) $(LIB_SETLOCALE) $(LIBTHREAD)
+test_mbsrtowcs_LDADD = $(LDADD) $(LIB_SETLOCALE) $(LIB_MBRTOWC)
diff --git a/modules/mbssep b/modules/mbssep
index 465dc51..7e3726d 100644
--- a/modules/mbssep
+++ b/modules/mbssep
@@ -20,7 +20,7 @@ Include:
 <string.h>
 
 Link:
-$(LIBTHREAD)
+$(LIB_MBRTOWC)
 
 License:
 LGPL
diff --git a/modules/mbsspn b/modules/mbsspn
index 6cec1da..8d63084 100644
--- a/modules/mbsspn
+++ b/modules/mbsspn
@@ -19,7 +19,7 @@ Include:
 <string.h>
 
 Link:
-$(LIBTHREAD)
+$(LIB_MBRTOWC)
 
 License:
 LGPL
diff --git a/modules/mbsspn-tests b/modules/mbsspn-tests
index 994a706..af17401 100644
--- a/modules/mbsspn-tests
+++ b/modules/mbsspn-tests
@@ -15,4 +15,4 @@ Makefile.am:
 TESTS += test-mbsspn.sh
 TESTS_ENVIRONMENT += LOCALE_FR_UTF8='@LOCALE_FR_UTF8@'
 check_PROGRAMS += test-mbsspn
-test_mbsspn_LDADD = $(LDADD) $(LIB_SETLOCALE) $(LIBTHREAD)
+test_mbsspn_LDADD = $(LDADD) $(LIB_SETLOCALE) $(LIB_MBRTOWC)
diff --git a/modules/mbsstr b/modules/mbsstr
index 5b418dc..5458607 100644
--- a/modules/mbsstr
+++ b/modules/mbsstr
@@ -23,7 +23,7 @@ Include:
 <string.h>
 
 Link:
-$(LIBTHREAD)
+$(LIB_MBRTOWC)
 
 License:
 LGPL
diff --git a/modules/mbsstr-tests b/modules/mbsstr-tests
index 739e51d..697aaf8 100644
--- a/modules/mbsstr-tests
+++ b/modules/mbsstr-tests
@@ -20,6 +20,6 @@ Makefile.am:
 TESTS += test-mbsstr1 test-mbsstr2.sh test-mbsstr3.sh
 TESTS_ENVIRONMENT += LOCALE_FR_UTF8='@LOCALE_FR_UTF8@' 
LOCALE_ZH_CN='@LOCALE_ZH_CN@'
 check_PROGRAMS += test-mbsstr1 test-mbsstr2 test-mbsstr3
-test_mbsstr1_LDADD = $(LDADD) $(LIBTHREAD)
-test_mbsstr2_LDADD = $(LDADD) $(LIB_SETLOCALE) $(LIBTHREAD)
-test_mbsstr3_LDADD = $(LDADD) $(LIB_SETLOCALE) $(LIBTHREAD)
+test_mbsstr1_LDADD = $(LDADD) $(LIB_MBRTOWC)
+test_mbsstr2_LDADD = $(LDADD) $(LIB_SETLOCALE) $(LIB_MBRTOWC)
+test_mbsstr3_LDADD = $(LDADD) $(LIB_SETLOCALE) $(LIB_MBRTOWC)
diff --git a/modules/mbstok_r b/modules/mbstok_r
index 67de3d7..ad518bb 100644
--- a/modules/mbstok_r
+++ b/modules/mbstok_r
@@ -21,7 +21,7 @@ Include:
 <string.h>
 
 Link:
-$(LIBTHREAD)
+$(LIB_MBRTOWC)
 
 License:
 LGPL
diff --git a/modules/mbswidth b/modules/mbswidth
index 934ab59..736d902 100644
--- a/modules/mbswidth
+++ b/modules/mbswidth
@@ -26,7 +26,7 @@ Include:
 "mbswidth.h"
 
 Link:
-$(LIBTHREAD)
+$(LIB_MBRTOWC)
 
 License:
 GPL
diff --git a/modules/mbuiter b/modules/mbuiter
index 6763f0b..78af61d 100644
--- a/modules/mbuiter
+++ b/modules/mbuiter
@@ -26,7 +26,7 @@ Include:
 "mbuiter.h"
 
 Link:
-$(LIBTHREAD)
+$(LIB_MBRTOWC)
 
 License:
 LGPL
diff --git a/modules/mkdir-p b/modules/mkdir-p
index 72f8b09..a9df81a 100644
--- a/modules/mkdir-p
+++ b/modules/mkdir-p
@@ -34,7 +34,7 @@ Include:
 "mkdir-p.h"
 
 Link:
-$(LIBTHREAD)
+$(LIB_MBRTOWC)
 
 License:
 GPL
diff --git a/modules/propername b/modules/propername
index 22d6073..e753ee7 100644
--- a/modules/propername
+++ b/modules/propername
@@ -36,7 +36,7 @@ Include:
 "propername.h"
 
 Link:
-$(LIBTHREAD)
+$(LIB_MBRTOWC)
 
 License:
 GPL
diff --git a/modules/quote b/modules/quote
index a01a16d..35c30ce 100644
--- a/modules/quote
+++ b/modules/quote
@@ -17,7 +17,7 @@ Include:
 "quote.h"
 
 Link:
-$(LIBTHREAD)
+$(LIB_MBRTOWC)
 
 License:
 GPL
diff --git a/modules/quotearg b/modules/quotearg
index 3d56dc5..9d9276e 100644
--- a/modules/quotearg
+++ b/modules/quotearg
@@ -35,7 +35,7 @@ Include:
 "quotearg.h"
 
 Link:
-$(LIBTHREAD)
+$(LIB_MBRTOWC)
 
 License:
 GPL
diff --git a/modules/quotearg-simple b/modules/quotearg-simple
index 5ba13ce..6a5c892 100644
--- a/modules/quotearg-simple
+++ b/modules/quotearg-simple
@@ -13,7 +13,7 @@ Makefile.am:
 Include:
 
 Link:
-$(LIBTHREAD)
+$(LIB_MBRTOWC)
 
 License:
 GPL
diff --git a/modules/quotearg-simple-tests b/modules/quotearg-simple-tests
index 701da5f..5470dfe 100644
--- a/modules/quotearg-simple-tests
+++ b/modules/quotearg-simple-tests
@@ -18,4 +18,4 @@ AC_CHECK_FUNCS_ONCE([mprotect])
 Makefile.am:
 TESTS += test-quotearg-simple
 check_PROGRAMS += test-quotearg-simple
-test_quotearg_simple_LDADD = $(LDADD) @LIBINTL@ $(LIBTHREAD)
+test_quotearg_simple_LDADD = $(LDADD) @LIBINTL@ $(LIB_MBRTOWC)
diff --git a/modules/quotearg-tests b/modules/quotearg-tests
index 77fde80..aed92ce 100644
--- a/modules/quotearg-tests
+++ b/modules/quotearg-tests
@@ -27,4 +27,4 @@ Makefile.am:
 TESTS += test-quotearg.sh
 TESTS_ENVIRONMENT += LOCALE_FR='@LOCALE_FR@' LOCALE_FR_UTF8='@LOCALE_FR_UTF8@'
 check_PROGRAMS += test-quotearg
-test_quotearg_LDADD = $(LDADD) $(LIB_SETLOCALE) @LIBINTL@ $(LIBTHREAD)
+test_quotearg_LDADD = $(LDADD) $(LIB_SETLOCALE) @LIBINTL@ $(LIB_MBRTOWC)
diff --git a/modules/readtokens-tests b/modules/readtokens-tests
index 5e83e47..9e4c060 100644
--- a/modules/readtokens-tests
+++ b/modules/readtokens-tests
@@ -11,4 +11,4 @@ configure.ac:
 Makefile.am:
 TESTS += test-readtokens.sh
 check_PROGRAMS += test-readtokens
-test_readtokens_LDADD = $(LDADD) @LIBINTL@ $(LIBTHREAD)
+test_readtokens_LDADD = $(LDADD) @LIBINTL@ $(LIB_MBRTOWC)
diff --git a/modules/regex b/modules/regex
index 42c9344..9d77df7 100644
--- a/modules/regex
+++ b/modules/regex
@@ -49,6 +49,7 @@ Include:
 <regex.h>
 
 Link:
+$(LIB_MBRTOWC)
 $(LIBTHREAD)
 $(LTLIBINTL) when linking with libtool, $(LIBINTL) otherwise
 
diff --git a/modules/regex-quote b/modules/regex-quote
index 085e5b6..9b67ca2 100644
--- a/modules/regex-quote
+++ b/modules/regex-quote
@@ -19,7 +19,7 @@ Include:
 "regex-quote.h"
 
 Link:
-$(LIBTHREAD)
+$(LIB_MBRTOWC)
 
 License:
 GPL
diff --git a/modules/regex-quote-tests b/modules/regex-quote-tests
index b396a00..aa99cd0 100644
--- a/modules/regex-quote-tests
+++ b/modules/regex-quote-tests
@@ -11,4 +11,4 @@ configure.ac:
 Makefile.am:
 TESTS += test-regex-quote
 check_PROGRAMS += test-regex-quote
-test_regex_quote_LDADD = $(LDADD) $(LIBINTL) $(LIBTHREAD)
+test_regex_quote_LDADD = $(LDADD) $(LIBINTL) $(LIB_MBRTOWC) $(LIBTHREAD)
diff --git a/modules/regex-tests b/modules/regex-tests
index e8821ec..711632a 100644
--- a/modules/regex-tests
+++ b/modules/regex-tests
@@ -11,4 +11,4 @@ configure.ac:
 Makefile.am:
 TESTS += test-regex
 check_PROGRAMS += test-regex
-test_regex_LDADD = $(LDADD) $(LIB_SETLOCALE) @LIBINTL@ $(LIBTHREAD)
+test_regex_LDADD = $(LDADD) $(LIB_SETLOCALE) $(LIB_MBRTOWC) @LIBINTL@ 
$(LIBTHREAD)
diff --git a/modules/rpmatch b/modules/rpmatch
index 3b754c6..2e0e7e3 100644
--- a/modules/rpmatch
+++ b/modules/rpmatch
@@ -27,7 +27,7 @@ Include:
 <stdlib.h>
 
 Link:
-$(LIBTHREAD)
+$(LIB_MBRTOWC)
 $(LTLIBINTL) when linking with libtool, $(LIBINTL) otherwise
 
 License:
diff --git a/modules/sh-quote b/modules/sh-quote
index a95dea9..83fa089 100644
--- a/modules/sh-quote
+++ b/modules/sh-quote
@@ -18,7 +18,7 @@ Include:
 "sh-quote.h"
 
 Link:
-$(LIBTHREAD)
+$(LIB_MBRTOWC)
 
 License:
 GPL
diff --git a/modules/sh-quote-tests b/modules/sh-quote-tests
index 8252fee..2ac9722 100644
--- a/modules/sh-quote-tests
+++ b/modules/sh-quote-tests
@@ -8,4 +8,4 @@ configure.ac:
 Makefile.am:
 TESTS += test-sh-quote
 check_PROGRAMS += test-sh-quote
-test_sh_quote_LDADD = $(LDADD) @LIBINTL@ $(LIBTHREAD)
+test_sh_quote_LDADD = $(LDADD) @LIBINTL@ $(LIB_MBRTOWC)
diff --git a/modules/system-quote b/modules/system-quote
index 09503e5..f34d58a 100644
--- a/modules/system-quote
+++ b/modules/system-quote
@@ -18,7 +18,7 @@ Include:
 "system-quote.h"
 
 Link:
-$(LIBTHREAD)
+$(LIB_MBRTOWC)
 
 License:
 GPL
diff --git a/modules/system-quote-tests b/modules/system-quote-tests
index 413453b..4e2782a 100644
--- a/modules/system-quote-tests
+++ b/modules/system-quote-tests
@@ -18,7 +18,7 @@ configure.ac:
 Makefile.am:
 TESTS += test-system-quote.sh
 check_PROGRAMS += test-system-quote-main test-system-quote-child
-test_system_quote_main_LDADD = $(LDADD) @LIBINTL@ $(LIBTHREAD)
+test_system_quote_main_LDADD = $(LDADD) @LIBINTL@ $(LIB_MBRTOWC)
 # The test-system-quote-child program must be a real executable, not a libtool
 # wrapper script, and should link against as few libraries as possible.
 # Therefore don't link it against any libraries other than -lc.
diff --git a/modules/trim b/modules/trim
index 13d3579..3d29e3a 100644
--- a/modules/trim
+++ b/modules/trim
@@ -21,7 +21,7 @@ Include:
 "trim.h"
 
 Link:
-$(LIBTHREAD)
+$(LIB_MBRTOWC)
 
 License:
 GPL
diff --git a/modules/unistdio/ulc-asnprintf b/modules/unistdio/ulc-asnprintf
index a0c1d1f..7a8255b 100644
--- a/modules/unistdio/ulc-asnprintf
+++ b/modules/unistdio/ulc-asnprintf
@@ -22,7 +22,7 @@ Include:
 "unistdio.h"
 
 Link:
-$(LIBTHREAD)
+$(LIB_MBRTOWC)
 
 License:
 LGPLv3+ or GPLv2
diff --git a/modules/unistdio/ulc-asnprintf-tests 
b/modules/unistdio/ulc-asnprintf-tests
index 276c7e5..16699cd 100644
--- a/modules/unistdio/ulc-asnprintf-tests
+++ b/modules/unistdio/ulc-asnprintf-tests
@@ -12,4 +12,4 @@ Makefile.am:
 TESTS += test-ulc-asnprintf1
 check_PROGRAMS += test-ulc-asnprintf1
 test_ulc_asnprintf1_SOURCES = unistdio/test-ulc-asnprintf1.c
-test_ulc_asnprintf1_LDADD = $(LDADD) $(LIBUNISTRING) @LIBICONV@ $(LIBTHREAD)
+test_ulc_asnprintf1_LDADD = $(LDADD) $(LIBUNISTRING) @LIBICONV@ $(LIB_MBRTOWC)
diff --git a/modules/unistdio/ulc-fprintf b/modules/unistdio/ulc-fprintf
index ad3d2d8..74c8269 100644
--- a/modules/unistdio/ulc-fprintf
+++ b/modules/unistdio/ulc-fprintf
@@ -22,7 +22,7 @@ Include:
 "unistdio.h"
 
 Link:
-$(LIBTHREAD)
+$(LIB_MBRTOWC)
 
 License:
 LGPLv3+ or GPLv2
diff --git a/modules/unistdio/ulc-vasnprintf b/modules/unistdio/ulc-vasnprintf
index 77a0b8c..750602f 100644
--- a/modules/unistdio/ulc-vasnprintf
+++ b/modules/unistdio/ulc-vasnprintf
@@ -58,7 +58,7 @@ Include:
 "unistdio.h"
 
 Link:
-$(LIBTHREAD)
+$(LIB_MBRTOWC)
 
 License:
 LGPLv3+ or GPLv2
diff --git a/modules/unistdio/ulc-vasnprintf-tests 
b/modules/unistdio/ulc-vasnprintf-tests
index 0af2361..55e55ce 100644
--- a/modules/unistdio/ulc-vasnprintf-tests
+++ b/modules/unistdio/ulc-vasnprintf-tests
@@ -22,8 +22,8 @@ TESTS += test-ulc-vasnprintf1 
unistdio/test-ulc-vasnprintf2.sh unistdio/test-ulc
 TESTS_ENVIRONMENT += LOCALE_FR='@LOCALE_FR@' LOCALE_FR_UTF8='@LOCALE_FR_UTF8@'
 check_PROGRAMS += test-ulc-vasnprintf1 test-ulc-vasnprintf2 
test-ulc-vasnprintf3
 test_ulc_vasnprintf1_SOURCES = unistdio/test-ulc-vasnprintf1.c
-test_ulc_vasnprintf1_LDADD = $(LDADD) $(LIBUNISTRING) @LIBICONV@ $(LIBTHREAD)
+test_ulc_vasnprintf1_LDADD = $(LDADD) $(LIBUNISTRING) @LIBICONV@ $(LIB_MBRTOWC)
 test_ulc_vasnprintf2_SOURCES = unistdio/test-ulc-vasnprintf2.c
-test_ulc_vasnprintf2_LDADD = $(LDADD) $(LIB_SETLOCALE) $(LIBUNISTRING) 
@LIBICONV@ $(LIBTHREAD)
+test_ulc_vasnprintf2_LDADD = $(LDADD) $(LIB_SETLOCALE) $(LIBUNISTRING) 
@LIBICONV@ $(LIB_MBRTOWC)
 test_ulc_vasnprintf3_SOURCES = unistdio/test-ulc-vasnprintf3.c
-test_ulc_vasnprintf3_LDADD = $(LDADD) $(LIB_SETLOCALE) $(LIBUNISTRING) 
@LIBICONV@ $(LIBTHREAD)
+test_ulc_vasnprintf3_LDADD = $(LDADD) $(LIB_SETLOCALE) $(LIBUNISTRING) 
@LIBICONV@ $(LIB_MBRTOWC)
diff --git a/modules/unistdio/ulc-vasprintf b/modules/unistdio/ulc-vasprintf
index 19965c1..f84da41 100644
--- a/modules/unistdio/ulc-vasprintf
+++ b/modules/unistdio/ulc-vasprintf
@@ -22,7 +22,7 @@ Include:
 "unistdio.h"
 
 Link:
-$(LIBTHREAD)
+$(LIB_MBRTOWC)
 
 License:
 LGPLv3+ or GPLv2
diff --git a/modules/unistdio/ulc-vasprintf-tests 
b/modules/unistdio/ulc-vasprintf-tests
index b034f3f..abbdfc5 100644
--- a/modules/unistdio/ulc-vasprintf-tests
+++ b/modules/unistdio/ulc-vasprintf-tests
@@ -11,4 +11,4 @@ Makefile.am:
 TESTS += test-ulc-vasprintf1
 check_PROGRAMS += test-ulc-vasprintf1
 test_ulc_vasprintf1_SOURCES = unistdio/test-ulc-vasprintf1.c
-test_ulc_vasprintf1_LDADD = $(LDADD) $(LIBUNISTRING) @LIBICONV@ $(LIBTHREAD)
+test_ulc_vasprintf1_LDADD = $(LDADD) $(LIBUNISTRING) @LIBICONV@ $(LIB_MBRTOWC)
diff --git a/modules/unistdio/ulc-vfprintf b/modules/unistdio/ulc-vfprintf
index 28d19ab..590a299 100644
--- a/modules/unistdio/ulc-vfprintf
+++ b/modules/unistdio/ulc-vfprintf
@@ -22,7 +22,7 @@ Include:
 "unistdio.h"
 
 Link:
-$(LIBTHREAD)
+$(LIB_MBRTOWC)
 
 License:
 LGPLv3+ or GPLv2
diff --git a/modules/unistdio/ulc-vsnprintf b/modules/unistdio/ulc-vsnprintf
index c204b75..5f69d4d 100644
--- a/modules/unistdio/ulc-vsnprintf
+++ b/modules/unistdio/ulc-vsnprintf
@@ -22,7 +22,7 @@ Include:
 "unistdio.h"
 
 Link:
-$(LIBTHREAD)
+$(LIB_MBRTOWC)
 
 License:
 LGPLv3+ or GPLv2
diff --git a/modules/unistdio/ulc-vsnprintf-tests 
b/modules/unistdio/ulc-vsnprintf-tests
index 029a825..735a111 100644
--- a/modules/unistdio/ulc-vsnprintf-tests
+++ b/modules/unistdio/ulc-vsnprintf-tests
@@ -12,4 +12,4 @@ Makefile.am:
 TESTS += test-ulc-vsnprintf1
 check_PROGRAMS += test-ulc-vsnprintf1
 test_ulc_vsnprintf1_SOURCES = unistdio/test-ulc-vsnprintf1.c
-test_ulc_vsnprintf1_LDADD = $(LDADD) $(LIBUNISTRING) @LIBINTL@ @LIBICONV@ 
$(LIBTHREAD)
+test_ulc_vsnprintf1_LDADD = $(LDADD) $(LIBUNISTRING) @LIBINTL@ @LIBICONV@ 
$(LIB_MBRTOWC)
diff --git a/modules/unistdio/ulc-vsprintf b/modules/unistdio/ulc-vsprintf
index b536826..de233b0 100644
--- a/modules/unistdio/ulc-vsprintf
+++ b/modules/unistdio/ulc-vsprintf
@@ -23,7 +23,7 @@ Include:
 "unistdio.h"
 
 Link:
-$(LIBTHREAD)
+$(LIB_MBRTOWC)
 
 License:
 LGPLv3+ or GPLv2
diff --git a/modules/unistdio/ulc-vsprintf-tests 
b/modules/unistdio/ulc-vsprintf-tests
index 32b1b5c..98a6a6c 100644
--- a/modules/unistdio/ulc-vsprintf-tests
+++ b/modules/unistdio/ulc-vsprintf-tests
@@ -12,4 +12,4 @@ Makefile.am:
 TESTS += test-ulc-vsprintf1
 check_PROGRAMS += test-ulc-vsprintf1
 test_ulc_vsprintf1_SOURCES = unistdio/test-ulc-vsprintf1.c
-test_ulc_vsprintf1_LDADD = $(LDADD) $(LIBUNISTRING) @LIBINTL@ @LIBICONV@ 
$(LIBTHREAD)
+test_ulc_vsprintf1_LDADD = $(LDADD) $(LIBUNISTRING) @LIBINTL@ @LIBICONV@ 
$(LIB_MBRTOWC)
diff --git a/modules/xfreopen b/modules/xfreopen
index 63266db..dfd3d9e 100644
--- a/modules/xfreopen
+++ b/modules/xfreopen
@@ -20,7 +20,7 @@ Include:
 "xfreopen.h"
 
 Link:
-$(LIBTHREAD)
+$(LIB_MBRTOWC)
 
 License:
 GPL
diff --git a/modules/xmemcoll b/modules/xmemcoll
index 4f13d85..9724945 100644
--- a/modules/xmemcoll
+++ b/modules/xmemcoll
@@ -21,7 +21,7 @@ Include:
 "xmemcoll.h"
 
 Link:
-$(LIBTHREAD)
+$(LIB_MBRTOWC)
 
 License:
 GPL
diff --git a/modules/yesno b/modules/yesno
index 8ae50df..7a45e0f 100644
--- a/modules/yesno
+++ b/modules/yesno
@@ -22,7 +22,7 @@ Include:
 "yesno.h"
 
 Link:
-$(LIBTHREAD)
+$(LIB_MBRTOWC)
 
 License:
 GPL
diff --git a/modules/yesno-tests b/modules/yesno-tests
index 8836ee8..45f429f 100644
--- a/modules/yesno-tests
+++ b/modules/yesno-tests
@@ -12,4 +12,4 @@ configure.ac:
 Makefile.am:
 TESTS += test-yesno.sh
 check_PROGRAMS += test-yesno
-test_yesno_LDADD = $(LDADD) @LIBINTL@ $(LIBTHREAD)
+test_yesno_LDADD = $(LDADD) @LIBINTL@ $(LIB_MBRTOWC)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]