Import the strerror_r-posix module and use it in GDB.

Makes sure to assign the return value of strerror_r to an int,
so that we get a compile error if we accidentally get the
wrong version.

gdb/ChangeLog:

2019-11-15  Christian Biesinger  <cbiesinger@google.com>

	* config.in: Regenerate.
	* configure: Regenerate.
	* gdbsupport/common.m4: No longer check for strerror_r.
	* gdbsupport/posix-strerror.c (safe_strerror): Always call the
	POSIX version of strerror_r, now that gnulib provides it if
	necessary.

gdb/gdbserver/ChangeLog:

2019-11-15  Christian Biesinger  <cbiesinger@google.com>

	* config.in: Regenerate.
	* configure: Regenerate.

gnulib/ChangeLog:

2019-11-15  Christian Biesinger  <cbiesinger@google.com>

	* Makefile.in: Regenerate.
	* aclocal.m4: Regenerate.
	* config.in: Regenerate.
	* configure: Regenerate.
	* import/Makefile.am: Update.
	* import/Makefile.in: Regenerate.
	* import/extra/config.rpath: New file.
	* import/glthread/lock.c: New file.
	* import/glthread/lock.h: New file.
	* import/glthread/threadlib.c: New file.
	* import/m4/gnulib-cache.m4: Update.
	* import/m4/gnulib-comp.m4: Update.
	* import/m4/lib-ld.m4: New file.
	* import/m4/lib-link.m4: New file.
	* import/m4/lib-prefix.m4: New file.
	* import/m4/lock.m4: New file.
	* import/m4/strerror_r.m4: New file.
	* import/m4/threadlib.m4: New file.
	* import/strerror_r.c: New file.
	* update-gnulib.sh: Import strerror_r-posix.

Change-Id: I5cfeb12a5203a4cd94a78581541e6085a68685c3
This commit is contained in:
Christian Biesinger 2019-11-06 12:49:52 -06:00
parent 33bd0102c1
commit 5abebf3c3f
29 changed files with 6662 additions and 162 deletions

View File

@ -1,3 +1,12 @@
2019-11-15 Christian Biesinger <cbiesinger@google.com>
* config.in: Regenerate.
* configure: Regenerate.
* gdbsupport/common.m4: No longer check for strerror_r.
* gdbsupport/posix-strerror.c (safe_strerror): Always call the
POSIX version of strerror_r, now that gnulib provides it if
necessary.
2019-11-14 Christian Biesinger <cbiesinger@google.com>
* README (`configure' options): Update.

View File

@ -423,9 +423,6 @@
/* Define to 1 if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H
/* Define to 1 if you have the `strerror_r' function. */
#undef HAVE_STRERROR_R
/* Define to 1 if you have the <strings.h> header file. */
#undef HAVE_STRINGS_H

2
gdb/configure vendored
View File

@ -13480,7 +13480,7 @@ done
for ac_func in fdwalk getrlimit pipe pipe2 socketpair sigaction \
sigprocmask strerror_r
sigprocmask
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"

View File

@ -1,3 +1,8 @@
2019-11-15 Christian Biesinger <cbiesinger@google.com>
* config.in: Regenerate.
* configure: Regenerate.
2019-11-12 Andrew Burgess <andrew.burgess@embecosm.com>
* ax.c (ax_printf): Handle size_t_arg.

View File

@ -229,9 +229,6 @@
/* Define to 1 if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H
/* Define to 1 if you have the `strerror_r' function. */
#undef HAVE_STRERROR_R
/* Define to 1 if you have the <strings.h> header file. */
#undef HAVE_STRINGS_H

View File

@ -6822,7 +6822,7 @@ done
for ac_func in fdwalk getrlimit pipe pipe2 socketpair sigaction \
sigprocmask strerror_r
sigprocmask
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"

View File

@ -33,7 +33,7 @@ AC_DEFUN([GDB_AC_COMMON], [
dlfcn.h)
AC_CHECK_FUNCS([fdwalk getrlimit pipe pipe2 socketpair sigaction \
sigprocmask strerror_r])
sigprocmask])
AC_CHECK_DECLS([strerror, strstr])

View File

@ -18,6 +18,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "common-defs.h"
#include <string.h>
/* Implementation of safe_strerror as defined in common-utils.h. */
@ -26,23 +27,12 @@ safe_strerror (int errnum)
{
static thread_local char buf[1024];
char *msg = nullptr;
#ifdef HAVE_STRERROR_R
# if !__GLIBC__ || ((_POSIX_C_SOURCE >= 200112L) && ! _GNU_SOURCE)
/* Glibc has two different, incompatible versions of strerror_r. */
if (strerror_r (errnum, buf, sizeof (buf)) == 0)
msg = buf;
# else
msg = strerror_r (errnum, buf, sizeof (buf));
# endif
#else
msg = strerror (errnum);
#endif
if (msg == nullptr)
{
/* Assign the return value to an int, so we get an error if we accidentally
get the wrong version of this function (glibc has two of them...). */
int ret = strerror_r (errnum, buf, sizeof (buf));
if (ret == 0)
return buf;
xsnprintf (buf, sizeof buf, "(undocumented errno %d)", errnum);
msg = buf;
}
return (msg);
xsnprintf (buf, sizeof buf, "(undocumented errno %d)", errnum);
return buf;
}

View File

@ -1,3 +1,26 @@
2019-11-15 Christian Biesinger <cbiesinger@google.com>
* Makefile.in: Regenerate.
* aclocal.m4: Regenerate.
* config.in: Regenerate.
* configure: Regenerate.
* import/Makefile.am: Update.
* import/Makefile.in: Regenerate.
* import/extra/config.rpath: New file.
* import/glthread/lock.c: New file.
* import/glthread/lock.h: New file.
* import/glthread/threadlib.c: New file.
* import/m4/gnulib-cache.m4: Update.
* import/m4/gnulib-comp.m4: Update.
* import/m4/lib-ld.m4: New file.
* import/m4/lib-link.m4: New file.
* import/m4/lib-prefix.m4: New file.
* import/m4/lock.m4: New file.
* import/m4/strerror_r.m4: New file.
* import/m4/threadlib.m4: New file.
* import/strerror_r.c: New file.
* update-gnulib.sh: Import strerror_r-posix.
2019-11-15 Christian Biesinger <cbiesinger@google.com>
* Makefile.am: New file.

View File

@ -169,11 +169,15 @@ am__aclocal_m4_deps = $(top_srcdir)/../config/depstand.m4 \
$(top_srcdir)/import/m4/isnand.m4 \
$(top_srcdir)/import/m4/isnanl.m4 \
$(top_srcdir)/import/m4/largefile.m4 \
$(top_srcdir)/import/m4/lib-ld.m4 \
$(top_srcdir)/import/m4/lib-link.m4 \
$(top_srcdir)/import/m4/lib-prefix.m4 \
$(top_srcdir)/import/m4/limits-h.m4 \
$(top_srcdir)/import/m4/localcharset.m4 \
$(top_srcdir)/import/m4/locale-fr.m4 \
$(top_srcdir)/import/m4/locale-ja.m4 \
$(top_srcdir)/import/m4/locale-zh.m4 \
$(top_srcdir)/import/m4/lock.m4 \
$(top_srcdir)/import/m4/longlong.m4 \
$(top_srcdir)/import/m4/lstat.m4 \
$(top_srcdir)/import/m4/malloc.m4 \
@ -227,6 +231,7 @@ am__aclocal_m4_deps = $(top_srcdir)/../config/depstand.m4 \
$(top_srcdir)/import/m4/strchrnul.m4 \
$(top_srcdir)/import/m4/strdup.m4 \
$(top_srcdir)/import/m4/strerror.m4 \
$(top_srcdir)/import/m4/strerror_r.m4 \
$(top_srcdir)/import/m4/string_h.m4 \
$(top_srcdir)/import/m4/strstr.m4 \
$(top_srcdir)/import/m4/strtok_r.m4 \
@ -236,6 +241,7 @@ am__aclocal_m4_deps = $(top_srcdir)/../config/depstand.m4 \
$(top_srcdir)/import/m4/sys_types_h.m4 \
$(top_srcdir)/import/m4/sys_uio_h.m4 \
$(top_srcdir)/import/m4/tempname.m4 \
$(top_srcdir)/import/m4/threadlib.m4 \
$(top_srcdir)/import/m4/time_h.m4 \
$(top_srcdir)/import/m4/unistd-safer.m4 \
$(top_srcdir)/import/m4/unistd_h.m4 \
@ -313,13 +319,13 @@ CSCOPE = cscope
DIST_SUBDIRS = $(SUBDIRS)
am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/config.in \
$(top_srcdir)/../ar-lib $(top_srcdir)/../compile \
$(top_srcdir)/../config.guess $(top_srcdir)/../config.sub \
$(top_srcdir)/../install-sh $(top_srcdir)/../missing \
$(top_srcdir)/../mkinstalldirs ../COPYING ../COPYING.LIB \
../ChangeLog ../README ../ar-lib ../compile ../config.guess \
../config.rpath ../config.sub ../depcomp ../install-sh \
../ltmain.sh ../missing ../mkinstalldirs ../ylwrap ChangeLog \
README
$(top_srcdir)/../config.guess $(top_srcdir)/../config.rpath \
$(top_srcdir)/../config.sub $(top_srcdir)/../install-sh \
$(top_srcdir)/../missing $(top_srcdir)/../mkinstalldirs \
../COPYING ../COPYING.LIB ../ChangeLog ../README ../ar-lib \
../compile ../config.guess ../config.rpath ../config.sub \
../depcomp ../install-sh ../ltmain.sh ../missing \
../mkinstalldirs ../ylwrap ChangeLog README
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
distdir = $(PACKAGE)-$(VERSION)
top_distdir = $(distdir)
@ -1115,8 +1121,12 @@ LDFLAGS = @LDFLAGS@
LIBGNU_LIBDEPS = @LIBGNU_LIBDEPS@
LIBGNU_LTLIBDEPS = @LIBGNU_LTLIBDEPS@
LIBINTL = @LIBINTL@
LIBMULTITHREAD = @LIBMULTITHREAD@
LIBOBJS = @LIBOBJS@
LIBPTH = @LIBPTH@
LIBPTH_PREFIX = @LIBPTH_PREFIX@
LIBS = @LIBS@
LIBTHREAD = @LIBTHREAD@
LIMITS_H = @LIMITS_H@
LN_S = @LN_S@
LOCALCHARSET_TESTS_ENVIRONMENT = @LOCALCHARSET_TESTS_ENVIRONMENT@
@ -1125,7 +1135,10 @@ LOCALE_FR_UTF8 = @LOCALE_FR_UTF8@
LOCALE_JA = @LOCALE_JA@
LOCALE_ZH_CN = @LOCALE_ZH_CN@
LTLIBINTL = @LTLIBINTL@
LTLIBMULTITHREAD = @LTLIBMULTITHREAD@
LTLIBOBJS = @LTLIBOBJS@
LTLIBPTH = @LTLIBPTH@
LTLIBTHREAD = @LTLIBTHREAD@
MAINT = @MAINT@
MAKEINFO = @MAKEINFO@
MKDIR_P = @MKDIR_P@

6
gnulib/aclocal.m4 vendored
View File

@ -1774,11 +1774,15 @@ m4_include([import/m4/inttypes.m4])
m4_include([import/m4/isnand.m4])
m4_include([import/m4/isnanl.m4])
m4_include([import/m4/largefile.m4])
m4_include([import/m4/lib-ld.m4])
m4_include([import/m4/lib-link.m4])
m4_include([import/m4/lib-prefix.m4])
m4_include([import/m4/limits-h.m4])
m4_include([import/m4/localcharset.m4])
m4_include([import/m4/locale-fr.m4])
m4_include([import/m4/locale-ja.m4])
m4_include([import/m4/locale-zh.m4])
m4_include([import/m4/lock.m4])
m4_include([import/m4/longlong.m4])
m4_include([import/m4/lstat.m4])
m4_include([import/m4/malloc.m4])
@ -1832,6 +1836,7 @@ m4_include([import/m4/stdlib_h.m4])
m4_include([import/m4/strchrnul.m4])
m4_include([import/m4/strdup.m4])
m4_include([import/m4/strerror.m4])
m4_include([import/m4/strerror_r.m4])
m4_include([import/m4/string_h.m4])
m4_include([import/m4/strstr.m4])
m4_include([import/m4/strtok_r.m4])
@ -1841,6 +1846,7 @@ m4_include([import/m4/sys_time_h.m4])
m4_include([import/m4/sys_types_h.m4])
m4_include([import/m4/sys_uio_h.m4])
m4_include([import/m4/tempname.m4])
m4_include([import/m4/threadlib.m4])
m4_include([import/m4/time_h.m4])
m4_include([import/m4/unistd-safer.m4])
m4_include([import/m4/unistd_h.m4])

View File

@ -95,6 +95,10 @@
whether the gnulib module getcwd shall be considered present. */
#undef GNULIB_GETCWD
/* Define to a C preprocessor expression that evaluates to 1 or 0, depending
whether the gnulib module lock shall be considered present. */
#undef GNULIB_LOCK
/* Define to a C preprocessor expression that evaluates to 1 or 0, depending
whether the gnulib module mkostemp shall be considered present. */
#undef GNULIB_MKOSTEMP
@ -260,6 +264,9 @@
/* Define to 1 when the gnulib module strerror should be tested. */
#undef GNULIB_TEST_STRERROR
/* Define to 1 when the gnulib module strerror_r should be tested. */
#undef GNULIB_TEST_STRERROR_R
/* Define to 1 when the gnulib module strstr should be tested. */
#undef GNULIB_TEST_STRSTR
@ -289,6 +296,9 @@
/* Define to 1 if you have the 'canonicalize_file_name' function. */
#undef HAVE_CANONICALIZE_FILE_NAME
/* Define to 1 if you have the 'catgets' function. */
#undef HAVE_CATGETS
/* Define to 1 if you have the `closedir' function. */
#undef HAVE_CLOSEDIR
@ -372,10 +382,13 @@
*/
#undef HAVE_DECL_STRDUP
/* Define to 1 if you have the declaration of `strerror_r', and to 0 if you
don't. */
/* Define to 1, since you should have the declaration of strerror_r. */
#undef HAVE_DECL_STRERROR_R
/* Define to 1 if you have the declaration of 'strerror_r' in the system
include files, or to 0 otherwise. */
#undef HAVE_DECL_STRERROR_R_ORIG
/* Define to 1 if you have the declaration of `strtok_r', and to 0 if you
don't. */
#undef HAVE_DECL_STRTOK_R
@ -586,6 +599,12 @@
/* Define to 1 if you have the 'pipe' function. */
#undef HAVE_PIPE
/* Define if the <pthread.h> defines PTHREAD_MUTEX_RECURSIVE. */
#undef HAVE_PTHREAD_MUTEX_RECURSIVE
/* Define if the POSIX multithreading library has read/write locks. */
#undef HAVE_PTHREAD_RWLOCK
/* Define to 1 if you have the `rawmemchr' function. */
#undef HAVE_RAWMEMCHR
@ -1511,6 +1530,9 @@
/* Define to 1 if the system has the type `sigset_t'. */
#undef HAVE_SIGSET_T
/* Define to 1 if you have the 'snprintf' function. */
#undef HAVE_SNPRINTF
/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H
@ -1523,7 +1545,7 @@
/* Define to 1 if you have the 'strdup' function. */
#undef HAVE_STRDUP
/* Define to 1 if you have the `strerror_r' function. */
/* Define to 1, since you should have the function strerror_r. */
#undef HAVE_STRERROR_R
/* Define to 1 if you have the <strings.h> header file. */
@ -1651,6 +1673,9 @@
/* Define to 1 if you have the `__secure_getenv' function. */
#undef HAVE___SECURE_GETENV
/* Define to 1 if you have the '__xpg_strerror_r' function. */
#undef HAVE___XPG_STRERROR_R
/* Define as the bit index in the word where to find bit 0 of the exponent of
'long double'. */
#undef LDBL_EXPBIT0_BIT
@ -1718,6 +1743,9 @@
type mode_t. */
#undef PROMOTED_MODE_T
/* Define if the pthread_in_use() detection is hard. */
#undef PTHREAD_IN_USE_DETECTION_HARD
/* Define to l, ll, u, ul, ull, etc., as suitable for constants of type
'ptrdiff_t'. */
#undef PTRDIFF_T_SUFFIX
@ -1784,9 +1812,30 @@
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
/* Define to 1 if strerror_r returns char *. */
/* Define to 0, since strerror_r should not return char *. */
#undef STRERROR_R_CHAR_P
/* Define if the POSIX multithreading library can be used. */
#undef USE_POSIX_THREADS
/* Define if references to the POSIX multithreading library should be made
weak. */
#undef USE_POSIX_THREADS_WEAK
/* Define if the GNU Pth multithreading library can be used. */
#undef USE_PTH_THREADS
/* Define if references to the GNU Pth multithreading library should be made
weak. */
#undef USE_PTH_THREADS_WEAK
/* Define if the old Solaris multithreading library can be used. */
#undef USE_SOLARIS_THREADS
/* Define if references to the old Solaris multithreading library should be
made weak. */
#undef USE_SOLARIS_THREADS_WEAK
/* Enable extensions on AIX 3, Interix. */
#ifndef _ALL_SOURCE
# undef _ALL_SOURCE
@ -1847,6 +1896,9 @@
#endif
/* Define if the native Windows multithreading API can be used. */
#undef USE_WINDOWS_THREADS
/* Define to 1 if unsetenv returns void instead of int. */
#undef VOID_UNSETENV

1663
gnulib/configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -21,9 +21,9 @@
# the same distribution terms as the rest of that program.
#
# Generated by gnulib-tool.
# Reproduce by: gnulib-tool --import --lib=libgnu --source-base=import --m4-base=import/m4 --doc-base=doc --tests-base=tests --aux-dir=import/extra --no-conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca canonicalize-lgpl dirent dirfd errno fnmatch-gnu frexpl getcwd glob inet_ntop inttypes limits-h lstat memchr memmem mkdir mkdtemp mkostemp pathmax rawmemchr readlink rename setenv signal-h strchrnul strstr strtok_r sys_stat unistd unsetenv update-copyright wchar wctype-h
# Reproduce by: gnulib-tool --import --lib=libgnu --source-base=import --m4-base=import/m4 --doc-base=doc --tests-base=tests --aux-dir=import/extra --no-conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca canonicalize-lgpl dirent dirfd errno fnmatch-gnu frexpl getcwd glob inet_ntop inttypes limits-h lstat memchr memmem mkdir mkdtemp mkostemp pathmax rawmemchr readlink rename setenv signal-h strchrnul strerror_r-posix strstr strtok_r sys_stat unistd unsetenv update-copyright wchar wctype-h
AUTOMAKE_OPTIONS = 1.9.6 gnits
AUTOMAKE_OPTIONS = 1.9.6 gnits subdir-objects
SUBDIRS =
noinst_HEADERS =
@ -660,6 +660,13 @@ EXTRA_DIST += hard-locale.h
## end gnulib module hard-locale
## begin gnulib module havelib
EXTRA_DIST += $(top_srcdir)/import/extra/config.rpath
## end gnulib module havelib
## begin gnulib module inet_ntop
@ -841,6 +848,12 @@ EXTRA_DIST += config.charset ref-add.sin ref-del.sin
## end gnulib module localcharset
## begin gnulib module lock
libgnu_a_SOURCES += glthread/lock.h glthread/lock.c
## end gnulib module lock
## begin gnulib module lstat
@ -1970,6 +1983,15 @@ EXTRA_libgnu_a_SOURCES += strerror-override.c
## end gnulib module strerror-override
## begin gnulib module strerror_r-posix
EXTRA_DIST += strerror_r.c
EXTRA_libgnu_a_SOURCES += strerror_r.c
## end gnulib module strerror_r-posix
## begin gnulib module string
BUILT_SOURCES += string.h
@ -2301,6 +2323,14 @@ EXTRA_DIST += tempname.h
## end gnulib module tempname
## begin gnulib module threadlib
libgnu_a_SOURCES += glthread/threadlib.c
EXTRA_DIST += $(top_srcdir)/import/extra/config.rpath
## end gnulib module threadlib
## begin gnulib module time
BUILT_SOURCES += time.h

View File

@ -35,7 +35,7 @@
# the same distribution terms as the rest of that program.
#
# Generated by gnulib-tool.
# Reproduce by: gnulib-tool --import --lib=libgnu --source-base=import --m4-base=import/m4 --doc-base=doc --tests-base=tests --aux-dir=import/extra --no-conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca canonicalize-lgpl dirent dirfd errno fnmatch-gnu frexpl getcwd glob inet_ntop inttypes limits-h lstat memchr memmem mkdir mkdtemp mkostemp pathmax rawmemchr readlink rename setenv signal-h strchrnul strstr strtok_r sys_stat unistd unsetenv update-copyright wchar wctype-h
# Reproduce by: gnulib-tool --import --lib=libgnu --source-base=import --m4-base=import/m4 --doc-base=doc --tests-base=tests --aux-dir=import/extra --no-conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca canonicalize-lgpl dirent dirfd errno fnmatch-gnu frexpl getcwd glob inet_ntop inttypes limits-h lstat memchr memmem mkdir mkdtemp mkostemp pathmax rawmemchr readlink rename setenv signal-h strchrnul strerror_r-posix strstr strtok_r sys_stat unistd unsetenv update-copyright wchar wctype-h
@ -178,11 +178,15 @@ am__aclocal_m4_deps = $(top_srcdir)/../config/depstand.m4 \
$(top_srcdir)/import/m4/isnand.m4 \
$(top_srcdir)/import/m4/isnanl.m4 \
$(top_srcdir)/import/m4/largefile.m4 \
$(top_srcdir)/import/m4/lib-ld.m4 \
$(top_srcdir)/import/m4/lib-link.m4 \
$(top_srcdir)/import/m4/lib-prefix.m4 \
$(top_srcdir)/import/m4/limits-h.m4 \
$(top_srcdir)/import/m4/localcharset.m4 \
$(top_srcdir)/import/m4/locale-fr.m4 \
$(top_srcdir)/import/m4/locale-ja.m4 \
$(top_srcdir)/import/m4/locale-zh.m4 \
$(top_srcdir)/import/m4/lock.m4 \
$(top_srcdir)/import/m4/longlong.m4 \
$(top_srcdir)/import/m4/lstat.m4 \
$(top_srcdir)/import/m4/malloc.m4 \
@ -236,6 +240,7 @@ am__aclocal_m4_deps = $(top_srcdir)/../config/depstand.m4 \
$(top_srcdir)/import/m4/strchrnul.m4 \
$(top_srcdir)/import/m4/strdup.m4 \
$(top_srcdir)/import/m4/strerror.m4 \
$(top_srcdir)/import/m4/strerror_r.m4 \
$(top_srcdir)/import/m4/string_h.m4 \
$(top_srcdir)/import/m4/strstr.m4 \
$(top_srcdir)/import/m4/strtok_r.m4 \
@ -245,6 +250,7 @@ am__aclocal_m4_deps = $(top_srcdir)/../config/depstand.m4 \
$(top_srcdir)/import/m4/sys_types_h.m4 \
$(top_srcdir)/import/m4/sys_uio_h.m4 \
$(top_srcdir)/import/m4/tempname.m4 \
$(top_srcdir)/import/m4/threadlib.m4 \
$(top_srcdir)/import/m4/time_h.m4 \
$(top_srcdir)/import/m4/unistd-safer.m4 \
$(top_srcdir)/import/m4/unistd_h.m4 \
@ -268,15 +274,18 @@ am__v_AR_0 = @echo " AR " $@;
am__v_AR_1 =
libgnu_a_AR = $(AR) $(ARFLAGS)
am__DEPENDENCIES_1 =
am__dirstamp = $(am__leading_dot)dirstamp
am_libgnu_a_OBJECTS = cloexec.$(OBJEXT) dirname-lgpl.$(OBJEXT) \
basename-lgpl.$(OBJEXT) stripslash.$(OBJEXT) \
exitfail.$(OBJEXT) fd-hook.$(OBJEXT) \
filenamecat-lgpl.$(OBJEXT) getprogname.$(OBJEXT) \
hard-locale.$(OBJEXT) localcharset.$(OBJEXT) malloca.$(OBJEXT) \
math.$(OBJEXT) openat-die.$(OBJEXT) save-cwd.$(OBJEXT) \
strnlen1.$(OBJEXT) sys_socket.$(OBJEXT) tempname.$(OBJEXT) \
unistd.$(OBJEXT) dup-safer.$(OBJEXT) fd-safer.$(OBJEXT) \
pipe-safer.$(OBJEXT) wctype-h.$(OBJEXT)
hard-locale.$(OBJEXT) localcharset.$(OBJEXT) \
glthread/lock.$(OBJEXT) malloca.$(OBJEXT) math.$(OBJEXT) \
openat-die.$(OBJEXT) save-cwd.$(OBJEXT) strnlen1.$(OBJEXT) \
sys_socket.$(OBJEXT) tempname.$(OBJEXT) \
glthread/threadlib.$(OBJEXT) unistd.$(OBJEXT) \
dup-safer.$(OBJEXT) fd-safer.$(OBJEXT) pipe-safer.$(OBJEXT) \
wctype-h.$(OBJEXT)
libgnu_a_OBJECTS = $(am_libgnu_a_OBJECTS)
LTLIBRARIES = $(noinst_LTLIBRARIES)
AM_V_P = $(am__v_P_@AM_V@)
@ -1132,8 +1141,12 @@ LDFLAGS = @LDFLAGS@
LIBGNU_LIBDEPS = @LIBGNU_LIBDEPS@
LIBGNU_LTLIBDEPS = @LIBGNU_LTLIBDEPS@
LIBINTL = @LIBINTL@
LIBMULTITHREAD = @LIBMULTITHREAD@
LIBOBJS = @LIBOBJS@
LIBPTH = @LIBPTH@
LIBPTH_PREFIX = @LIBPTH_PREFIX@
LIBS = @LIBS@
LIBTHREAD = @LIBTHREAD@
LIMITS_H = @LIMITS_H@
LN_S = @LN_S@
LOCALCHARSET_TESTS_ENVIRONMENT = @LOCALCHARSET_TESTS_ENVIRONMENT@
@ -1142,7 +1155,10 @@ LOCALE_FR_UTF8 = @LOCALE_FR_UTF8@
LOCALE_JA = @LOCALE_JA@
LOCALE_ZH_CN = @LOCALE_ZH_CN@
LTLIBINTL = @LTLIBINTL@
LTLIBMULTITHREAD = @LTLIBMULTITHREAD@
LTLIBOBJS = @LTLIBOBJS@
LTLIBPTH = @LTLIBPTH@
LTLIBTHREAD = @LTLIBTHREAD@
MAINT = @MAINT@
MAKEINFO = @MAKEINFO@
MKDIR_P = @MKDIR_P@
@ -1499,7 +1515,7 @@ target_vendor = @target_vendor@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
AUTOMAKE_OPTIONS = 1.9.6 gnits
AUTOMAKE_OPTIONS = 1.9.6 gnits subdir-objects
SUBDIRS =
noinst_HEADERS =
noinst_LIBRARIES = libgnu.a
@ -1514,31 +1530,33 @@ EXTRA_DIST = m4/gnulib-cache.m4 alloca.c alloca.in.h arpa_inet.in.h \
fnmatch_loop.c fpucw.h frexp.c frexp.c frexpl.c fstat.c \
at-func.c fstatat.c getcwd.c getcwd-lgpl.c getdtablesize.c \
getlogin_r.c gettimeofday.c glob-libc.h glob.c glob.in.h \
hard-locale.h inet_ntop.c intprops.h inttypes.in.h float+.h \
isnan.c isnand-nolibm.h isnand.c float+.h isnan.c \
isnanl-nolibm.h isnanl.c limits.in.h config.charset \
ref-add.sin ref-del.sin lstat.c malloc.c malloca.h \
malloca.valgrind math.in.h mbrtowc.c mbsinit.c \
mbsrtowcs-impl.h mbsrtowcs-state.c mbsrtowcs.c memchr.c \
memchr.valgrind memmem.c str-two-way.h mempcpy.c memrchr.c \
mkdir.c mkdtemp.c mkostemp.c msvc-inval.c msvc-inval.h \
msvc-nothrow.c msvc-nothrow.h netinet_in.in.h open.c openat.c \
openat.h dirent-private.h opendir.c pathmax.h rawmemchr.c \
rawmemchr.valgrind dirent-private.h readdir.c readlink.c \
realloc.c rename.c dirent-private.h rewinddir.c rmdir.c \
same-inode.h save-cwd.h secure_getenv.c setenv.c signal.in.h \
$(top_srcdir)/import/extra/snippet/_Noreturn.h \
hard-locale.h $(top_srcdir)/import/extra/config.rpath \
inet_ntop.c intprops.h inttypes.in.h float+.h isnan.c \
isnand-nolibm.h isnand.c float+.h isnan.c isnanl-nolibm.h \
isnanl.c limits.in.h config.charset ref-add.sin ref-del.sin \
lstat.c malloc.c malloca.h malloca.valgrind math.in.h \
mbrtowc.c mbsinit.c mbsrtowcs-impl.h mbsrtowcs-state.c \
mbsrtowcs.c memchr.c memchr.valgrind memmem.c str-two-way.h \
mempcpy.c memrchr.c mkdir.c mkdtemp.c mkostemp.c msvc-inval.c \
msvc-inval.h msvc-nothrow.c msvc-nothrow.h netinet_in.in.h \
open.c openat.c openat.h dirent-private.h opendir.c pathmax.h \
rawmemchr.c rawmemchr.valgrind dirent-private.h readdir.c \
readlink.c realloc.c rename.c dirent-private.h rewinddir.c \
rmdir.c same-inode.h save-cwd.h secure_getenv.c setenv.c \
signal.in.h $(top_srcdir)/import/extra/snippet/_Noreturn.h \
$(top_srcdir)/import/extra/snippet/arg-nonnull.h \
$(top_srcdir)/import/extra/snippet/c++defs.h \
$(top_srcdir)/import/extra/snippet/warn-on-use.h stat.c \
stdalign.in.h stdbool.in.h stddef.in.h stdint.in.h stdio.in.h \
stdlib.in.h strchrnul.c strchrnul.valgrind strdup.c streq.h \
strerror.c strerror-override.c strerror-override.h string.in.h \
str-two-way.h strstr.c strtok_r.c sys_socket.in.h \
sys_stat.in.h sys_time.in.h sys_types.in.h sys_uio.in.h \
tempname.h time.in.h unistd.in.h unistd--.h unistd-safer.h \
unsetenv.c $(top_srcdir)/import/extra/update-copyright \
verify.h wchar.in.h wctype.in.h
strerror.c strerror-override.c strerror-override.h \
strerror_r.c string.in.h str-two-way.h strstr.c strtok_r.c \
sys_socket.in.h sys_stat.in.h sys_time.in.h sys_types.in.h \
sys_uio.in.h tempname.h \
$(top_srcdir)/import/extra/config.rpath time.in.h unistd.in.h \
unistd--.h unistd-safer.h unsetenv.c \
$(top_srcdir)/import/extra/update-copyright verify.h \
wchar.in.h wctype.in.h
# The BUILT_SOURCES created by this Makefile snippet are not used via #include
# statements but through direct file reference. Therefore this snippet must be
@ -1580,9 +1598,10 @@ AM_CFLAGS =
libgnu_a_SOURCES = cloexec.c dirname-lgpl.c basename-lgpl.c \
stripslash.c exitfail.c fd-hook.c filenamecat-lgpl.c \
getprogname.h getprogname.c gettext.h hard-locale.c \
localcharset.h localcharset.c malloca.c math.c openat-die.c \
save-cwd.c strnlen1.h strnlen1.c sys_socket.c tempname.c \
unistd.c dup-safer.c fd-safer.c pipe-safer.c wctype-h.c
localcharset.h localcharset.c glthread/lock.h glthread/lock.c \
malloca.c math.c openat-die.c save-cwd.c strnlen1.h strnlen1.c \
sys_socket.c tempname.c glthread/threadlib.c unistd.c \
dup-safer.c fd-safer.c pipe-safer.c wctype-h.c
libgnu_a_LIBADD = $(gl_LIBOBJS) @ALLOCA@
libgnu_a_DEPENDENCIES = $(gl_LIBOBJS) @ALLOCA@
EXTRA_libgnu_a_SOURCES = alloca.c openat-proc.c canonicalize-lgpl.c \
@ -1597,7 +1616,8 @@ EXTRA_libgnu_a_SOURCES = alloca.c openat-proc.c canonicalize-lgpl.c \
msvc-nothrow.c open.c openat.c opendir.c rawmemchr.c readdir.c \
readlink.c realloc.c rename.c rewinddir.c rmdir.c \
secure_getenv.c setenv.c stat.c strchrnul.c strdup.c \
strerror.c strerror-override.c strstr.c strtok_r.c unsetenv.c
strerror.c strerror-override.c strerror_r.c strstr.c \
strtok_r.c unsetenv.c
# Use this preprocessor expression to decide whether #include_next works.
# Do not rely on a 'configure'-time test for this, since the expression
@ -1650,6 +1670,16 @@ $(am__aclocal_m4_deps):
clean-noinstLIBRARIES:
-test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES)
glthread/$(am__dirstamp):
@$(MKDIR_P) glthread
@: > glthread/$(am__dirstamp)
glthread/$(DEPDIR)/$(am__dirstamp):
@$(MKDIR_P) glthread/$(DEPDIR)
@: > glthread/$(DEPDIR)/$(am__dirstamp)
glthread/lock.$(OBJEXT): glthread/$(am__dirstamp) \
glthread/$(DEPDIR)/$(am__dirstamp)
glthread/threadlib.$(OBJEXT): glthread/$(am__dirstamp) \
glthread/$(DEPDIR)/$(am__dirstamp)
libgnu.a: $(libgnu_a_OBJECTS) $(libgnu_a_DEPENDENCIES) $(EXTRA_libgnu_a_DEPENDENCIES)
$(AM_V_at)-rm -f libgnu.a
@ -1669,6 +1699,7 @@ clean-noinstLTLIBRARIES:
mostlyclean-compile:
-rm -f *.$(OBJEXT)
-rm -f glthread/*.$(OBJEXT)
distclean-compile:
-rm -f *.tab.c
@ -1753,6 +1784,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strdup.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strerror-override.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strerror.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strerror_r.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stripslash.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strnlen1.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strstr.Po@am__quote@
@ -1762,17 +1794,21 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unistd.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unsetenv.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wctype-h.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@glthread/$(DEPDIR)/lock.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@glthread/$(DEPDIR)/threadlib.Po@am__quote@
.c.o:
@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $<
.c.obj:
@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\
@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\
@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
@ -1966,6 +2002,8 @@ clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
-rm -f glthread/$(DEPDIR)/$(am__dirstamp)
-rm -f glthread/$(am__dirstamp)
-test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES)
maintainer-clean-generic:
@ -1979,7 +2017,7 @@ clean-am: clean-generic clean-noinstLIBRARIES clean-noinstLTLIBRARIES \
mostlyclean-am
distclean: distclean-recursive
-rm -rf ./$(DEPDIR)
-rm -rf ./$(DEPDIR) glthread/$(DEPDIR)
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-tags
@ -2025,7 +2063,7 @@ install-ps-am:
installcheck-am:
maintainer-clean: maintainer-clean-recursive
-rm -rf ./$(DEPDIR)
-rm -rf ./$(DEPDIR) glthread/$(DEPDIR)
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic

684
gnulib/import/extra/config.rpath Executable file
View File

@ -0,0 +1,684 @@
#! /bin/sh
# Output a system dependent set of variables, describing how to set the
# run time search path of shared libraries in an executable.
#
# Copyright 1996-2016 Free Software Foundation, Inc.
# Taken from GNU libtool, 2001
# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
#
# This file is free software; the Free Software Foundation gives
# unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
#
# The first argument passed to this file is the canonical host specification,
# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
# or
# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
# The environment variables CC, GCC, LDFLAGS, LD, with_gnu_ld
# should be set by the caller.
#
# The set of defined variables is at the end of this script.
# Known limitations:
# - On IRIX 6.5 with CC="cc", the run time search patch must not be longer
# than 256 bytes, otherwise the compiler driver will dump core. The only
# known workaround is to choose shorter directory names for the build
# directory and/or the installation directory.
# All known linkers require a '.a' archive for static linking (except MSVC,
# which needs '.lib').
libext=a
shrext=.so
host="$1"
host_cpu=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
host_vendor=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
host_os=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
# Code taken from libtool.m4's _LT_CC_BASENAME.
for cc_temp in $CC""; do
case $cc_temp in
compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
\-*) ;;
*) break;;
esac
done
cc_basename=`echo "$cc_temp" | sed -e 's%^.*/%%'`
# Code taken from libtool.m4's _LT_COMPILER_PIC.
wl=
if test "$GCC" = yes; then
wl='-Wl,'
else
case "$host_os" in
aix*)
wl='-Wl,'
;;
mingw* | cygwin* | pw32* | os2* | cegcc*)
;;
hpux9* | hpux10* | hpux11*)
wl='-Wl,'
;;
irix5* | irix6* | nonstopux*)
wl='-Wl,'
;;
linux* | k*bsd*-gnu | kopensolaris*-gnu)
case $cc_basename in
ecc*)
wl='-Wl,'
;;
icc* | ifort*)
wl='-Wl,'
;;
lf95*)
wl='-Wl,'
;;
nagfor*)
wl='-Wl,-Wl,,'
;;
pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*)
wl='-Wl,'
;;
ccc*)
wl='-Wl,'
;;
xl* | bgxl* | bgf* | mpixl*)
wl='-Wl,'
;;
como)
wl='-lopt='
;;
*)
case `$CC -V 2>&1 | sed 5q` in
*Sun\ F* | *Sun*Fortran*)
wl=
;;
*Sun\ C*)
wl='-Wl,'
;;
esac
;;
esac
;;
newsos6)
;;
*nto* | *qnx*)
;;
osf3* | osf4* | osf5*)
wl='-Wl,'
;;
rdos*)
;;
solaris*)
case $cc_basename in
f77* | f90* | f95* | sunf77* | sunf90* | sunf95*)
wl='-Qoption ld '
;;
*)
wl='-Wl,'
;;
esac
;;
sunos4*)
wl='-Qoption ld '
;;
sysv4 | sysv4.2uw2* | sysv4.3*)
wl='-Wl,'
;;
sysv4*MP*)
;;
sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
wl='-Wl,'
;;
unicos*)
wl='-Wl,'
;;
uts4*)
;;
esac
fi
# Code taken from libtool.m4's _LT_LINKER_SHLIBS.
hardcode_libdir_flag_spec=
hardcode_libdir_separator=
hardcode_direct=no
hardcode_minus_L=no
case "$host_os" in
cygwin* | mingw* | pw32* | cegcc*)
# FIXME: the MSVC++ port hasn't been tested in a loooong time
# When not using gcc, we currently assume that we are using
# Microsoft Visual C++.
if test "$GCC" != yes; then
with_gnu_ld=no
fi
;;
interix*)
# we just hope/assume this is gcc and not c89 (= MSVC++)
with_gnu_ld=yes
;;
openbsd*)
with_gnu_ld=no
;;
esac
ld_shlibs=yes
if test "$with_gnu_ld" = yes; then
# Set some defaults for GNU ld with shared library support. These
# are reset later if shared libraries are not supported. Putting them
# here allows them to be overridden if necessary.
# Unlike libtool, we use -rpath here, not --rpath, since the documented
# option of GNU ld is called -rpath, not --rpath.
hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
case "$host_os" in
aix[3-9]*)
# On AIX/PPC, the GNU linker is very broken
if test "$host_cpu" != ia64; then
ld_shlibs=no
fi
;;
amigaos*)
case "$host_cpu" in
powerpc)
;;
m68k)
hardcode_libdir_flag_spec='-L$libdir'
hardcode_minus_L=yes
;;
esac
;;
beos*)
if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
:
else
ld_shlibs=no
fi
;;
cygwin* | mingw* | pw32* | cegcc*)
# hardcode_libdir_flag_spec is actually meaningless, as there is
# no search path for DLLs.
hardcode_libdir_flag_spec='-L$libdir'
if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
:
else
ld_shlibs=no
fi
;;
haiku*)
;;
interix[3-9]*)
hardcode_direct=no
hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
;;
gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu)
if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
:
else
ld_shlibs=no
fi
;;
netbsd*)
;;
solaris*)
if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then
ld_shlibs=no
elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
:
else
ld_shlibs=no
fi
;;
sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)
case `$LD -v 2>&1` in
*\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*)
ld_shlibs=no
;;
*)
if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
hardcode_libdir_flag_spec='`test -z "$SCOABSPATH" && echo ${wl}-rpath,$libdir`'
else
ld_shlibs=no
fi
;;
esac
;;
sunos4*)
hardcode_direct=yes
;;
*)
if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
:
else
ld_shlibs=no
fi
;;
esac
if test "$ld_shlibs" = no; then
hardcode_libdir_flag_spec=
fi
else
case "$host_os" in
aix3*)
# Note: this linker hardcodes the directories in LIBPATH if there
# are no directories specified by -L.
hardcode_minus_L=yes
if test "$GCC" = yes; then
# Neither direct hardcoding nor static linking is supported with a
# broken collect2.
hardcode_direct=unsupported
fi
;;
aix[4-9]*)
if test "$host_cpu" = ia64; then
# On IA64, the linker does run time linking by default, so we don't
# have to do anything special.
aix_use_runtimelinking=no
else
aix_use_runtimelinking=no
# Test if we are trying to use run time linking or normal
# AIX style linking. If -brtl is somewhere in LDFLAGS, we
# need to do runtime linking.
case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*)
for ld_flag in $LDFLAGS; do
if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
aix_use_runtimelinking=yes
break
fi
done
;;
esac
fi
hardcode_direct=yes
hardcode_libdir_separator=':'
if test "$GCC" = yes; then
case $host_os in aix4.[012]|aix4.[012].*)
collect2name=`${CC} -print-prog-name=collect2`
if test -f "$collect2name" && \
strings "$collect2name" | grep resolve_lib_name >/dev/null
then
# We have reworked collect2
:
else
# We have old collect2
hardcode_direct=unsupported
hardcode_minus_L=yes
hardcode_libdir_flag_spec='-L$libdir'
hardcode_libdir_separator=
fi
;;
esac
fi
# Begin _LT_AC_SYS_LIBPATH_AIX.
echo 'int main () { return 0; }' > conftest.c
${CC} ${LDFLAGS} conftest.c -o conftest
aix_libpath=`dump -H conftest 2>/dev/null | sed -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
}'`
if test -z "$aix_libpath"; then
aix_libpath=`dump -HX64 conftest 2>/dev/null | sed -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
}'`
fi
if test -z "$aix_libpath"; then
aix_libpath="/usr/lib:/lib"
fi
rm -f conftest.c conftest
# End _LT_AC_SYS_LIBPATH_AIX.
if test "$aix_use_runtimelinking" = yes; then
hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
else
if test "$host_cpu" = ia64; then
hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib'
else
hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
fi
fi
;;
amigaos*)
case "$host_cpu" in
powerpc)
;;
m68k)
hardcode_libdir_flag_spec='-L$libdir'
hardcode_minus_L=yes
;;
esac
;;
bsdi[45]*)
;;
cygwin* | mingw* | pw32* | cegcc*)
# When not using gcc, we currently assume that we are using
# Microsoft Visual C++.
# hardcode_libdir_flag_spec is actually meaningless, as there is
# no search path for DLLs.
hardcode_libdir_flag_spec=' '
libext=lib
;;
darwin* | rhapsody*)
hardcode_direct=no
if { case $cc_basename in ifort*) true;; *) test "$GCC" = yes;; esac; }; then
:
else
ld_shlibs=no
fi
;;
dgux*)
hardcode_libdir_flag_spec='-L$libdir'
;;
freebsd2.[01]*)
hardcode_direct=yes
hardcode_minus_L=yes
;;
freebsd* | dragonfly*)
hardcode_libdir_flag_spec='-R$libdir'
hardcode_direct=yes
;;
hpux9*)
hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
hardcode_libdir_separator=:
hardcode_direct=yes
# hardcode_minus_L: Not really in the search PATH,
# but as the default location of the library.
hardcode_minus_L=yes
;;
hpux10*)
if test "$with_gnu_ld" = no; then
hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
hardcode_libdir_separator=:
hardcode_direct=yes
# hardcode_minus_L: Not really in the search PATH,
# but as the default location of the library.
hardcode_minus_L=yes
fi
;;
hpux11*)
if test "$with_gnu_ld" = no; then
hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
hardcode_libdir_separator=:
case $host_cpu in
hppa*64*|ia64*)
hardcode_direct=no
;;
*)
hardcode_direct=yes
# hardcode_minus_L: Not really in the search PATH,
# but as the default location of the library.
hardcode_minus_L=yes
;;
esac
fi
;;
irix5* | irix6* | nonstopux*)
hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
hardcode_libdir_separator=:
;;
netbsd*)
hardcode_libdir_flag_spec='-R$libdir'
hardcode_direct=yes
;;
newsos6)
hardcode_direct=yes
hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
hardcode_libdir_separator=:
;;
*nto* | *qnx*)
;;
openbsd*)
if test -f /usr/libexec/ld.so; then
hardcode_direct=yes
if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
else
case "$host_os" in
openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*)
hardcode_libdir_flag_spec='-R$libdir'
;;
*)
hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
;;
esac
fi
else
ld_shlibs=no
fi
;;
os2*)
hardcode_libdir_flag_spec='-L$libdir'
hardcode_minus_L=yes
;;
osf3*)
hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
hardcode_libdir_separator=:
;;
osf4* | osf5*)
if test "$GCC" = yes; then
hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
else
# Both cc and cxx compiler support -rpath directly
hardcode_libdir_flag_spec='-rpath $libdir'
fi
hardcode_libdir_separator=:
;;
solaris*)
hardcode_libdir_flag_spec='-R$libdir'
;;
sunos4*)
hardcode_libdir_flag_spec='-L$libdir'
hardcode_direct=yes
hardcode_minus_L=yes
;;
sysv4)
case $host_vendor in
sni)
hardcode_direct=yes # is this really true???
;;
siemens)
hardcode_direct=no
;;
motorola)
hardcode_direct=no #Motorola manual says yes, but my tests say they lie
;;
esac
;;
sysv4.3*)
;;
sysv4*MP*)
if test -d /usr/nec; then
ld_shlibs=yes
fi
;;
sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*)
;;
sysv5* | sco3.2v5* | sco5v6*)
hardcode_libdir_flag_spec='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`'
hardcode_libdir_separator=':'
;;
uts4*)
hardcode_libdir_flag_spec='-L$libdir'
;;
*)
ld_shlibs=no
;;
esac
fi
# Check dynamic linker characteristics
# Code taken from libtool.m4's _LT_SYS_DYNAMIC_LINKER.
# Unlike libtool.m4, here we don't care about _all_ names of the library, but
# only about the one the linker finds when passed -lNAME. This is the last
# element of library_names_spec in libtool.m4, or possibly two of them if the
# linker has special search rules.
library_names_spec= # the last element of library_names_spec in libtool.m4
libname_spec='lib$name'
case "$host_os" in
aix3*)
library_names_spec='$libname.a'
;;
aix[4-9]*)
library_names_spec='$libname$shrext'
;;
amigaos*)
case "$host_cpu" in
powerpc*)
library_names_spec='$libname$shrext' ;;
m68k)
library_names_spec='$libname.a' ;;
esac
;;
beos*)
library_names_spec='$libname$shrext'
;;
bsdi[45]*)
library_names_spec='$libname$shrext'
;;
cygwin* | mingw* | pw32* | cegcc*)
shrext=.dll
library_names_spec='$libname.dll.a $libname.lib'
;;
darwin* | rhapsody*)
shrext=.dylib
library_names_spec='$libname$shrext'
;;
dgux*)
library_names_spec='$libname$shrext'
;;
freebsd[23].*)
library_names_spec='$libname$shrext$versuffix'
;;
freebsd* | dragonfly*)
library_names_spec='$libname$shrext'
;;
gnu*)
library_names_spec='$libname$shrext'
;;
haiku*)
library_names_spec='$libname$shrext'
;;
hpux9* | hpux10* | hpux11*)
case $host_cpu in
ia64*)
shrext=.so
;;
hppa*64*)
shrext=.sl
;;
*)
shrext=.sl
;;
esac
library_names_spec='$libname$shrext'
;;
interix[3-9]*)
library_names_spec='$libname$shrext'
;;
irix5* | irix6* | nonstopux*)
library_names_spec='$libname$shrext'
case "$host_os" in
irix5* | nonstopux*)
libsuff= shlibsuff=
;;
*)
case $LD in
*-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") libsuff= shlibsuff= ;;
*-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") libsuff=32 shlibsuff=N32 ;;
*-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") libsuff=64 shlibsuff=64 ;;
*) libsuff= shlibsuff= ;;
esac
;;
esac
;;
linux*oldld* | linux*aout* | linux*coff*)
;;
linux* | k*bsd*-gnu | kopensolaris*-gnu)
library_names_spec='$libname$shrext'
;;
knetbsd*-gnu)
library_names_spec='$libname$shrext'
;;
netbsd*)
library_names_spec='$libname$shrext'
;;
newsos6)
library_names_spec='$libname$shrext'
;;
*nto* | *qnx*)
library_names_spec='$libname$shrext'
;;
openbsd*)
library_names_spec='$libname$shrext$versuffix'
;;
os2*)
libname_spec='$name'
shrext=.dll
library_names_spec='$libname.a'
;;
osf3* | osf4* | osf5*)
library_names_spec='$libname$shrext'
;;
rdos*)
;;
solaris*)
library_names_spec='$libname$shrext'
;;
sunos4*)
library_names_spec='$libname$shrext$versuffix'
;;
sysv4 | sysv4.3*)
library_names_spec='$libname$shrext'
;;
sysv4*MP*)
library_names_spec='$libname$shrext'
;;
sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
library_names_spec='$libname$shrext'
;;
tpf*)
library_names_spec='$libname$shrext'
;;
uts4*)
library_names_spec='$libname$shrext'
;;
esac
sed_quote_subst='s/\(["`$\\]\)/\\\1/g'
escaped_wl=`echo "X$wl" | sed -e 's/^X//' -e "$sed_quote_subst"`
shlibext=`echo "$shrext" | sed -e 's,^\.,,'`
escaped_libname_spec=`echo "X$libname_spec" | sed -e 's/^X//' -e "$sed_quote_subst"`
escaped_library_names_spec=`echo "X$library_names_spec" | sed -e 's/^X//' -e "$sed_quote_subst"`
escaped_hardcode_libdir_flag_spec=`echo "X$hardcode_libdir_flag_spec" | sed -e 's/^X//' -e "$sed_quote_subst"`
LC_ALL=C sed -e 's/^\([a-zA-Z0-9_]*\)=/acl_cv_\1=/' <<EOF
# How to pass a linker flag through the compiler.
wl="$escaped_wl"
# Static library suffix (normally "a").
libext="$libext"
# Shared library suffix (normally "so").
shlibext="$shlibext"
# Format of library name prefix.
libname_spec="$escaped_libname_spec"
# Library names that the linker finds when passed -lNAME.
library_names_spec="$escaped_library_names_spec"
# Flag to hardcode \$libdir into a binary during linking.
# This must work even if \$libdir does not exist.
hardcode_libdir_flag_spec="$escaped_hardcode_libdir_flag_spec"
# Whether we need a single -rpath flag with a separated argument.
hardcode_libdir_separator="$hardcode_libdir_separator"
# Set to yes if using DIR/libNAME.so during linking hardcodes DIR into the
# resulting binary.
hardcode_direct="$hardcode_direct"
# Set to yes if using the -LDIR flag during linking hardcodes DIR into the
# resulting binary.
hardcode_minus_L="$hardcode_minus_L"
EOF

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,927 @@
/* Locking in multithreaded situations.
Copyright (C) 2005-2016 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, 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 <http://www.gnu.org/licenses/>. */
/* Written by Bruno Haible <bruno@clisp.org>, 2005.
Based on GCC's gthr-posix.h, gthr-posix95.h, gthr-solaris.h,
gthr-win32.h. */
/* This file contains locking primitives for use with a given thread library.
It does not contain primitives for creating threads or for other
synchronization primitives.
Normal (non-recursive) locks:
Type: gl_lock_t
Declaration: gl_lock_define(extern, name)
Initializer: gl_lock_define_initialized(, name)
Initialization: gl_lock_init (name);
Taking the lock: gl_lock_lock (name);
Releasing the lock: gl_lock_unlock (name);
De-initialization: gl_lock_destroy (name);
Equivalent functions with control of error handling:
Initialization: err = glthread_lock_init (&name);
Taking the lock: err = glthread_lock_lock (&name);
Releasing the lock: err = glthread_lock_unlock (&name);
De-initialization: err = glthread_lock_destroy (&name);
Read-Write (non-recursive) locks:
Type: gl_rwlock_t
Declaration: gl_rwlock_define(extern, name)
Initializer: gl_rwlock_define_initialized(, name)
Initialization: gl_rwlock_init (name);
Taking the lock: gl_rwlock_rdlock (name);
gl_rwlock_wrlock (name);
Releasing the lock: gl_rwlock_unlock (name);
De-initialization: gl_rwlock_destroy (name);
Equivalent functions with control of error handling:
Initialization: err = glthread_rwlock_init (&name);
Taking the lock: err = glthread_rwlock_rdlock (&name);
err = glthread_rwlock_wrlock (&name);
Releasing the lock: err = glthread_rwlock_unlock (&name);
De-initialization: err = glthread_rwlock_destroy (&name);
Recursive locks:
Type: gl_recursive_lock_t
Declaration: gl_recursive_lock_define(extern, name)
Initializer: gl_recursive_lock_define_initialized(, name)
Initialization: gl_recursive_lock_init (name);
Taking the lock: gl_recursive_lock_lock (name);
Releasing the lock: gl_recursive_lock_unlock (name);
De-initialization: gl_recursive_lock_destroy (name);
Equivalent functions with control of error handling:
Initialization: err = glthread_recursive_lock_init (&name);
Taking the lock: err = glthread_recursive_lock_lock (&name);
Releasing the lock: err = glthread_recursive_lock_unlock (&name);
De-initialization: err = glthread_recursive_lock_destroy (&name);
Once-only execution:
Type: gl_once_t
Initializer: gl_once_define(extern, name)
Execution: gl_once (name, initfunction);
Equivalent functions with control of error handling:
Execution: err = glthread_once (&name, initfunction);
*/
#ifndef _LOCK_H
#define _LOCK_H
#include <errno.h>
#include <stdlib.h>
/* ========================================================================= */
#if USE_POSIX_THREADS
/* Use the POSIX threads library. */
# include <pthread.h>
# ifdef __cplusplus
extern "C" {
# endif
# if PTHREAD_IN_USE_DETECTION_HARD
/* The pthread_in_use() detection needs to be done at runtime. */
# define pthread_in_use() \
glthread_in_use ()
extern int glthread_in_use (void);
# endif
# if USE_POSIX_THREADS_WEAK
/* Use weak references to the POSIX threads library. */
/* Weak references avoid dragging in external libraries if the other parts
of the program don't use them. Here we use them, because we don't want
every program that uses libintl to depend on libpthread. This assumes
that libpthread would not be loaded after libintl; i.e. if libintl is
loaded first, by an executable that does not depend on libpthread, and
then a module is dynamically loaded that depends on libpthread, libintl
will not be multithread-safe. */
/* The way to test at runtime whether libpthread is present is to test
whether a function pointer's value, such as &pthread_mutex_init, is
non-NULL. However, some versions of GCC have a bug through which, in
PIC mode, &foo != NULL always evaluates to true if there is a direct
call to foo(...) in the same function. To avoid this, we test the
address of a function in libpthread that we don't use. */
# pragma weak pthread_mutex_init
# pragma weak pthread_mutex_lock
# pragma weak pthread_mutex_unlock
# pragma weak pthread_mutex_destroy
# pragma weak pthread_rwlock_init
# pragma weak pthread_rwlock_rdlock
# pragma weak pthread_rwlock_wrlock
# pragma weak pthread_rwlock_unlock
# pragma weak pthread_rwlock_destroy
# pragma weak pthread_once
# pragma weak pthread_cond_init
# pragma weak pthread_cond_wait
# pragma weak pthread_cond_signal
# pragma weak pthread_cond_broadcast
# pragma weak pthread_cond_destroy
# pragma weak pthread_mutexattr_init
# pragma weak pthread_mutexattr_settype
# pragma weak pthread_mutexattr_destroy
# ifndef pthread_self
# pragma weak pthread_self
# endif
# if !PTHREAD_IN_USE_DETECTION_HARD
# pragma weak pthread_cancel
# define pthread_in_use() (pthread_cancel != NULL)
# endif
# else
# if !PTHREAD_IN_USE_DETECTION_HARD
# define pthread_in_use() 1
# endif
# endif
/* -------------------------- gl_lock_t datatype -------------------------- */
typedef pthread_mutex_t gl_lock_t;
# define gl_lock_define(STORAGECLASS, NAME) \
STORAGECLASS pthread_mutex_t NAME;
# define gl_lock_define_initialized(STORAGECLASS, NAME) \
STORAGECLASS pthread_mutex_t NAME = gl_lock_initializer;
# define gl_lock_initializer \
PTHREAD_MUTEX_INITIALIZER
# define glthread_lock_init(LOCK) \
(pthread_in_use () ? pthread_mutex_init (LOCK, NULL) : 0)
# define glthread_lock_lock(LOCK) \
(pthread_in_use () ? pthread_mutex_lock (LOCK) : 0)
# define glthread_lock_unlock(LOCK) \
(pthread_in_use () ? pthread_mutex_unlock (LOCK) : 0)
# define glthread_lock_destroy(LOCK) \
(pthread_in_use () ? pthread_mutex_destroy (LOCK) : 0)
/* ------------------------- gl_rwlock_t datatype ------------------------- */
# if HAVE_PTHREAD_RWLOCK
# ifdef PTHREAD_RWLOCK_INITIALIZER
typedef pthread_rwlock_t gl_rwlock_t;
# define gl_rwlock_define(STORAGECLASS, NAME) \
STORAGECLASS pthread_rwlock_t NAME;
# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \
STORAGECLASS pthread_rwlock_t NAME = gl_rwlock_initializer;
# define gl_rwlock_initializer \
PTHREAD_RWLOCK_INITIALIZER
# define glthread_rwlock_init(LOCK) \
(pthread_in_use () ? pthread_rwlock_init (LOCK, NULL) : 0)
# define glthread_rwlock_rdlock(LOCK) \
(pthread_in_use () ? pthread_rwlock_rdlock (LOCK) : 0)
# define glthread_rwlock_wrlock(LOCK) \
(pthread_in_use () ? pthread_rwlock_wrlock (LOCK) : 0)
# define glthread_rwlock_unlock(LOCK) \
(pthread_in_use () ? pthread_rwlock_unlock (LOCK) : 0)
# define glthread_rwlock_destroy(LOCK) \
(pthread_in_use () ? pthread_rwlock_destroy (LOCK) : 0)
# else
typedef struct
{
int initialized;
pthread_mutex_t guard; /* protects the initialization */
pthread_rwlock_t rwlock; /* read-write lock */
}
gl_rwlock_t;
# define gl_rwlock_define(STORAGECLASS, NAME) \
STORAGECLASS gl_rwlock_t NAME;
# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \
STORAGECLASS gl_rwlock_t NAME = gl_rwlock_initializer;
# define gl_rwlock_initializer \
{ 0, PTHREAD_MUTEX_INITIALIZER }
# define glthread_rwlock_init(LOCK) \
(pthread_in_use () ? glthread_rwlock_init_multithreaded (LOCK) : 0)
# define glthread_rwlock_rdlock(LOCK) \
(pthread_in_use () ? glthread_rwlock_rdlock_multithreaded (LOCK) : 0)
# define glthread_rwlock_wrlock(LOCK) \
(pthread_in_use () ? glthread_rwlock_wrlock_multithreaded (LOCK) : 0)
# define glthread_rwlock_unlock(LOCK) \
(pthread_in_use () ? glthread_rwlock_unlock_multithreaded (LOCK) : 0)
# define glthread_rwlock_destroy(LOCK) \
(pthread_in_use () ? glthread_rwlock_destroy_multithreaded (LOCK) : 0)
extern int glthread_rwlock_init_multithreaded (gl_rwlock_t *lock);
extern int glthread_rwlock_rdlock_multithreaded (gl_rwlock_t *lock);
extern int glthread_rwlock_wrlock_multithreaded (gl_rwlock_t *lock);
extern int glthread_rwlock_unlock_multithreaded (gl_rwlock_t *lock);
extern int glthread_rwlock_destroy_multithreaded (gl_rwlock_t *lock);
# endif
# else
typedef struct
{
pthread_mutex_t lock; /* protects the remaining fields */
pthread_cond_t waiting_readers; /* waiting readers */
pthread_cond_t waiting_writers; /* waiting writers */
unsigned int waiting_writers_count; /* number of waiting writers */
int runcount; /* number of readers running, or -1 when a writer runs */
}
gl_rwlock_t;
# define gl_rwlock_define(STORAGECLASS, NAME) \
STORAGECLASS gl_rwlock_t NAME;
# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \
STORAGECLASS gl_rwlock_t NAME = gl_rwlock_initializer;
# define gl_rwlock_initializer \
{ PTHREAD_MUTEX_INITIALIZER, PTHREAD_COND_INITIALIZER, PTHREAD_COND_INITIALIZER, 0, 0 }
# define glthread_rwlock_init(LOCK) \
(pthread_in_use () ? glthread_rwlock_init_multithreaded (LOCK) : 0)
# define glthread_rwlock_rdlock(LOCK) \
(pthread_in_use () ? glthread_rwlock_rdlock_multithreaded (LOCK) : 0)
# define glthread_rwlock_wrlock(LOCK) \
(pthread_in_use () ? glthread_rwlock_wrlock_multithreaded (LOCK) : 0)
# define glthread_rwlock_unlock(LOCK) \
(pthread_in_use () ? glthread_rwlock_unlock_multithreaded (LOCK) : 0)
# define glthread_rwlock_destroy(LOCK) \
(pthread_in_use () ? glthread_rwlock_destroy_multithreaded (LOCK) : 0)
extern int glthread_rwlock_init_multithreaded (gl_rwlock_t *lock);
extern int glthread_rwlock_rdlock_multithreaded (gl_rwlock_t *lock);
extern int glthread_rwlock_wrlock_multithreaded (gl_rwlock_t *lock);
extern int glthread_rwlock_unlock_multithreaded (gl_rwlock_t *lock);
extern int glthread_rwlock_destroy_multithreaded (gl_rwlock_t *lock);
# endif
/* --------------------- gl_recursive_lock_t datatype --------------------- */
# if HAVE_PTHREAD_MUTEX_RECURSIVE
# if defined PTHREAD_RECURSIVE_MUTEX_INITIALIZER || defined PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
typedef pthread_mutex_t gl_recursive_lock_t;
# define gl_recursive_lock_define(STORAGECLASS, NAME) \
STORAGECLASS pthread_mutex_t NAME;
# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \
STORAGECLASS pthread_mutex_t NAME = gl_recursive_lock_initializer;
# ifdef PTHREAD_RECURSIVE_MUTEX_INITIALIZER
# define gl_recursive_lock_initializer \
PTHREAD_RECURSIVE_MUTEX_INITIALIZER
# else
# define gl_recursive_lock_initializer \
PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
# endif
# define glthread_recursive_lock_init(LOCK) \
(pthread_in_use () ? glthread_recursive_lock_init_multithreaded (LOCK) : 0)
# define glthread_recursive_lock_lock(LOCK) \
(pthread_in_use () ? pthread_mutex_lock (LOCK) : 0)
# define glthread_recursive_lock_unlock(LOCK) \
(pthread_in_use () ? pthread_mutex_unlock (LOCK) : 0)
# define glthread_recursive_lock_destroy(LOCK) \
(pthread_in_use () ? pthread_mutex_destroy (LOCK) : 0)
extern int glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock);
# else
typedef struct
{
pthread_mutex_t recmutex; /* recursive mutex */
pthread_mutex_t guard; /* protects the initialization */
int initialized;
}
gl_recursive_lock_t;
# define gl_recursive_lock_define(STORAGECLASS, NAME) \
STORAGECLASS gl_recursive_lock_t NAME;
# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \
STORAGECLASS gl_recursive_lock_t NAME = gl_recursive_lock_initializer;
# define gl_recursive_lock_initializer \
{ PTHREAD_MUTEX_INITIALIZER, PTHREAD_MUTEX_INITIALIZER, 0 }
# define glthread_recursive_lock_init(LOCK) \
(pthread_in_use () ? glthread_recursive_lock_init_multithreaded (LOCK) : 0)
# define glthread_recursive_lock_lock(LOCK) \
(pthread_in_use () ? glthread_recursive_lock_lock_multithreaded (LOCK) : 0)
# define glthread_recursive_lock_unlock(LOCK) \
(pthread_in_use () ? glthread_recursive_lock_unlock_multithreaded (LOCK) : 0)
# define glthread_recursive_lock_destroy(LOCK) \
(pthread_in_use () ? glthread_recursive_lock_destroy_multithreaded (LOCK) : 0)
extern int glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock);
extern int glthread_recursive_lock_lock_multithreaded (gl_recursive_lock_t *lock);
extern int glthread_recursive_lock_unlock_multithreaded (gl_recursive_lock_t *lock);
extern int glthread_recursive_lock_destroy_multithreaded (gl_recursive_lock_t *lock);
# endif
# else
/* Old versions of POSIX threads on Solaris did not have recursive locks.
We have to implement them ourselves. */
typedef struct
{
pthread_mutex_t mutex;
pthread_t owner;
unsigned long depth;
}
gl_recursive_lock_t;
# define gl_recursive_lock_define(STORAGECLASS, NAME) \
STORAGECLASS gl_recursive_lock_t NAME;
# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \
STORAGECLASS gl_recursive_lock_t NAME = gl_recursive_lock_initializer;
# define gl_recursive_lock_initializer \
{ PTHREAD_MUTEX_INITIALIZER, (pthread_t) 0, 0 }
# define glthread_recursive_lock_init(LOCK) \
(pthread_in_use () ? glthread_recursive_lock_init_multithreaded (LOCK) : 0)
# define glthread_recursive_lock_lock(LOCK) \
(pthread_in_use () ? glthread_recursive_lock_lock_multithreaded (LOCK) : 0)
# define glthread_recursive_lock_unlock(LOCK) \
(pthread_in_use () ? glthread_recursive_lock_unlock_multithreaded (LOCK) : 0)
# define glthread_recursive_lock_destroy(LOCK) \
(pthread_in_use () ? glthread_recursive_lock_destroy_multithreaded (LOCK) : 0)
extern int glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock);
extern int glthread_recursive_lock_lock_multithreaded (gl_recursive_lock_t *lock);
extern int glthread_recursive_lock_unlock_multithreaded (gl_recursive_lock_t *lock);
extern int glthread_recursive_lock_destroy_multithreaded (gl_recursive_lock_t *lock);
# endif
/* -------------------------- gl_once_t datatype -------------------------- */
typedef pthread_once_t gl_once_t;
# define gl_once_define(STORAGECLASS, NAME) \
STORAGECLASS pthread_once_t NAME = PTHREAD_ONCE_INIT;
# define glthread_once(ONCE_CONTROL, INITFUNCTION) \
(pthread_in_use () \
? pthread_once (ONCE_CONTROL, INITFUNCTION) \
: (glthread_once_singlethreaded (ONCE_CONTROL) ? (INITFUNCTION (), 0) : 0))
extern int glthread_once_singlethreaded (pthread_once_t *once_control);
# ifdef __cplusplus
}
# endif
#endif
/* ========================================================================= */
#if USE_PTH_THREADS
/* Use the GNU Pth threads library. */
# include <pth.h>
# ifdef __cplusplus
extern "C" {
# endif
# if USE_PTH_THREADS_WEAK
/* Use weak references to the GNU Pth threads library. */
# pragma weak pth_mutex_init
# pragma weak pth_mutex_acquire
# pragma weak pth_mutex_release
# pragma weak pth_rwlock_init
# pragma weak pth_rwlock_acquire
# pragma weak pth_rwlock_release
# pragma weak pth_once
# pragma weak pth_cancel
# define pth_in_use() (pth_cancel != NULL)
# else
# define pth_in_use() 1
# endif
/* -------------------------- gl_lock_t datatype -------------------------- */
typedef pth_mutex_t gl_lock_t;
# define gl_lock_define(STORAGECLASS, NAME) \
STORAGECLASS pth_mutex_t NAME;
# define gl_lock_define_initialized(STORAGECLASS, NAME) \
STORAGECLASS pth_mutex_t NAME = gl_lock_initializer;
# define gl_lock_initializer \
PTH_MUTEX_INIT
# define glthread_lock_init(LOCK) \
(pth_in_use () && !pth_mutex_init (LOCK) ? errno : 0)
# define glthread_lock_lock(LOCK) \
(pth_in_use () && !pth_mutex_acquire (LOCK, 0, NULL) ? errno : 0)
# define glthread_lock_unlock(LOCK) \
(pth_in_use () && !pth_mutex_release (LOCK) ? errno : 0)
# define glthread_lock_destroy(LOCK) \
((void)(LOCK), 0)
/* ------------------------- gl_rwlock_t datatype ------------------------- */
typedef pth_rwlock_t gl_rwlock_t;
# define gl_rwlock_define(STORAGECLASS, NAME) \
STORAGECLASS pth_rwlock_t NAME;
# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \
STORAGECLASS pth_rwlock_t NAME = gl_rwlock_initializer;
# define gl_rwlock_initializer \
PTH_RWLOCK_INIT
# define glthread_rwlock_init(LOCK) \
(pth_in_use () && !pth_rwlock_init (LOCK) ? errno : 0)
# define glthread_rwlock_rdlock(LOCK) \
(pth_in_use () && !pth_rwlock_acquire (LOCK, PTH_RWLOCK_RD, 0, NULL) ? errno : 0)
# define glthread_rwlock_wrlock(LOCK) \
(pth_in_use () && !pth_rwlock_acquire (LOCK, PTH_RWLOCK_RW, 0, NULL) ? errno : 0)
# define glthread_rwlock_unlock(LOCK) \
(pth_in_use () && !pth_rwlock_release (LOCK) ? errno : 0)
# define glthread_rwlock_destroy(LOCK) \
((void)(LOCK), 0)
/* --------------------- gl_recursive_lock_t datatype --------------------- */
/* In Pth, mutexes are recursive by default. */
typedef pth_mutex_t gl_recursive_lock_t;
# define gl_recursive_lock_define(STORAGECLASS, NAME) \
STORAGECLASS pth_mutex_t NAME;
# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \
STORAGECLASS pth_mutex_t NAME = gl_recursive_lock_initializer;
# define gl_recursive_lock_initializer \
PTH_MUTEX_INIT
# define glthread_recursive_lock_init(LOCK) \
(pth_in_use () && !pth_mutex_init (LOCK) ? errno : 0)
# define glthread_recursive_lock_lock(LOCK) \
(pth_in_use () && !pth_mutex_acquire (LOCK, 0, NULL) ? errno : 0)
# define glthread_recursive_lock_unlock(LOCK) \
(pth_in_use () && !pth_mutex_release (LOCK) ? errno : 0)
# define glthread_recursive_lock_destroy(LOCK) \
((void)(LOCK), 0)
/* -------------------------- gl_once_t datatype -------------------------- */
typedef pth_once_t gl_once_t;
# define gl_once_define(STORAGECLASS, NAME) \
STORAGECLASS pth_once_t NAME = PTH_ONCE_INIT;
# define glthread_once(ONCE_CONTROL, INITFUNCTION) \
(pth_in_use () \
? glthread_once_multithreaded (ONCE_CONTROL, INITFUNCTION) \
: (glthread_once_singlethreaded (ONCE_CONTROL) ? (INITFUNCTION (), 0) : 0))
extern int glthread_once_multithreaded (pth_once_t *once_control, void (*initfunction) (void));
extern int glthread_once_singlethreaded (pth_once_t *once_control);
# ifdef __cplusplus
}
# endif
#endif
/* ========================================================================= */
#if USE_SOLARIS_THREADS
/* Use the old Solaris threads library. */
# include <thread.h>
# include <synch.h>
# ifdef __cplusplus
extern "C" {
# endif
# if USE_SOLARIS_THREADS_WEAK
/* Use weak references to the old Solaris threads library. */
# pragma weak mutex_init
# pragma weak mutex_lock
# pragma weak mutex_unlock
# pragma weak mutex_destroy
# pragma weak rwlock_init
# pragma weak rw_rdlock
# pragma weak rw_wrlock
# pragma weak rw_unlock
# pragma weak rwlock_destroy
# pragma weak thr_self
# pragma weak thr_suspend
# define thread_in_use() (thr_suspend != NULL)
# else
# define thread_in_use() 1
# endif
/* -------------------------- gl_lock_t datatype -------------------------- */
typedef mutex_t gl_lock_t;
# define gl_lock_define(STORAGECLASS, NAME) \
STORAGECLASS mutex_t NAME;
# define gl_lock_define_initialized(STORAGECLASS, NAME) \
STORAGECLASS mutex_t NAME = gl_lock_initializer;
# define gl_lock_initializer \
DEFAULTMUTEX
# define glthread_lock_init(LOCK) \
(thread_in_use () ? mutex_init (LOCK, USYNC_THREAD, NULL) : 0)
# define glthread_lock_lock(LOCK) \
(thread_in_use () ? mutex_lock (LOCK) : 0)
# define glthread_lock_unlock(LOCK) \
(thread_in_use () ? mutex_unlock (LOCK) : 0)
# define glthread_lock_destroy(LOCK) \
(thread_in_use () ? mutex_destroy (LOCK) : 0)
/* ------------------------- gl_rwlock_t datatype ------------------------- */
typedef rwlock_t gl_rwlock_t;
# define gl_rwlock_define(STORAGECLASS, NAME) \
STORAGECLASS rwlock_t NAME;
# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \
STORAGECLASS rwlock_t NAME = gl_rwlock_initializer;
# define gl_rwlock_initializer \
DEFAULTRWLOCK
# define glthread_rwlock_init(LOCK) \
(thread_in_use () ? rwlock_init (LOCK, USYNC_THREAD, NULL) : 0)
# define glthread_rwlock_rdlock(LOCK) \
(thread_in_use () ? rw_rdlock (LOCK) : 0)
# define glthread_rwlock_wrlock(LOCK) \
(thread_in_use () ? rw_wrlock (LOCK) : 0)
# define glthread_rwlock_unlock(LOCK) \
(thread_in_use () ? rw_unlock (LOCK) : 0)
# define glthread_rwlock_destroy(LOCK) \
(thread_in_use () ? rwlock_destroy (LOCK) : 0)
/* --------------------- gl_recursive_lock_t datatype --------------------- */
/* Old Solaris threads did not have recursive locks.
We have to implement them ourselves. */
typedef struct
{
mutex_t mutex;
thread_t owner;
unsigned long depth;
}
gl_recursive_lock_t;
# define gl_recursive_lock_define(STORAGECLASS, NAME) \
STORAGECLASS gl_recursive_lock_t NAME;
# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \
STORAGECLASS gl_recursive_lock_t NAME = gl_recursive_lock_initializer;
# define gl_recursive_lock_initializer \
{ DEFAULTMUTEX, (thread_t) 0, 0 }
# define glthread_recursive_lock_init(LOCK) \
(thread_in_use () ? glthread_recursive_lock_init_multithreaded (LOCK) : 0)
# define glthread_recursive_lock_lock(LOCK) \
(thread_in_use () ? glthread_recursive_lock_lock_multithreaded (LOCK) : 0)
# define glthread_recursive_lock_unlock(LOCK) \
(thread_in_use () ? glthread_recursive_lock_unlock_multithreaded (LOCK) : 0)
# define glthread_recursive_lock_destroy(LOCK) \
(thread_in_use () ? glthread_recursive_lock_destroy_multithreaded (LOCK) : 0)
extern int glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock);
extern int glthread_recursive_lock_lock_multithreaded (gl_recursive_lock_t *lock);
extern int glthread_recursive_lock_unlock_multithreaded (gl_recursive_lock_t *lock);
extern int glthread_recursive_lock_destroy_multithreaded (gl_recursive_lock_t *lock);
/* -------------------------- gl_once_t datatype -------------------------- */
typedef struct
{
volatile int inited;
mutex_t mutex;
}
gl_once_t;
# define gl_once_define(STORAGECLASS, NAME) \
STORAGECLASS gl_once_t NAME = { 0, DEFAULTMUTEX };
# define glthread_once(ONCE_CONTROL, INITFUNCTION) \
(thread_in_use () \
? glthread_once_multithreaded (ONCE_CONTROL, INITFUNCTION) \
: (glthread_once_singlethreaded (ONCE_CONTROL) ? (INITFUNCTION (), 0) : 0))
extern int glthread_once_multithreaded (gl_once_t *once_control, void (*initfunction) (void));
extern int glthread_once_singlethreaded (gl_once_t *once_control);
# ifdef __cplusplus
}
# endif
#endif
/* ========================================================================= */
#if USE_WINDOWS_THREADS
# define WIN32_LEAN_AND_MEAN /* avoid including junk */
# include <windows.h>
# ifdef __cplusplus
extern "C" {
# endif
/* We can use CRITICAL_SECTION directly, rather than the native Windows Event,
Mutex, Semaphore types, because
- we need only to synchronize inside a single process (address space),
not inter-process locking,
- we don't need to support trylock operations. (TryEnterCriticalSection
does not work on Windows 95/98/ME. Packages that need trylock usually
define their own mutex type.) */
/* There is no way to statically initialize a CRITICAL_SECTION. It needs
to be done lazily, once only. For this we need spinlocks. */
typedef struct { volatile int done; volatile long started; } gl_spinlock_t;
/* -------------------------- gl_lock_t datatype -------------------------- */
typedef struct
{
gl_spinlock_t guard; /* protects the initialization */
CRITICAL_SECTION lock;
}
gl_lock_t;
# define gl_lock_define(STORAGECLASS, NAME) \
STORAGECLASS gl_lock_t NAME;
# define gl_lock_define_initialized(STORAGECLASS, NAME) \
STORAGECLASS gl_lock_t NAME = gl_lock_initializer;
# define gl_lock_initializer \
{ { 0, -1 } }
# define glthread_lock_init(LOCK) \
(glthread_lock_init_func (LOCK), 0)
# define glthread_lock_lock(LOCK) \
glthread_lock_lock_func (LOCK)
# define glthread_lock_unlock(LOCK) \
glthread_lock_unlock_func (LOCK)
# define glthread_lock_destroy(LOCK) \
glthread_lock_destroy_func (LOCK)
extern void glthread_lock_init_func (gl_lock_t *lock);
extern int glthread_lock_lock_func (gl_lock_t *lock);
extern int glthread_lock_unlock_func (gl_lock_t *lock);
extern int glthread_lock_destroy_func (gl_lock_t *lock);
/* ------------------------- gl_rwlock_t datatype ------------------------- */
/* It is impossible to implement read-write locks using plain locks, without
introducing an extra thread dedicated to managing read-write locks.
Therefore here we need to use the low-level Event type. */
typedef struct
{
HANDLE *array; /* array of waiting threads, each represented by an event */
unsigned int count; /* number of waiting threads */
unsigned int alloc; /* length of allocated array */
unsigned int offset; /* index of first waiting thread in array */
}
gl_carray_waitqueue_t;
typedef struct
{
gl_spinlock_t guard; /* protects the initialization */
CRITICAL_SECTION lock; /* protects the remaining fields */
gl_carray_waitqueue_t waiting_readers; /* waiting readers */
gl_carray_waitqueue_t waiting_writers; /* waiting writers */
int runcount; /* number of readers running, or -1 when a writer runs */
}
gl_rwlock_t;
# define gl_rwlock_define(STORAGECLASS, NAME) \
STORAGECLASS gl_rwlock_t NAME;
# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \
STORAGECLASS gl_rwlock_t NAME = gl_rwlock_initializer;
# define gl_rwlock_initializer \
{ { 0, -1 } }
# define glthread_rwlock_init(LOCK) \
(glthread_rwlock_init_func (LOCK), 0)
# define glthread_rwlock_rdlock(LOCK) \
glthread_rwlock_rdlock_func (LOCK)
# define glthread_rwlock_wrlock(LOCK) \
glthread_rwlock_wrlock_func (LOCK)
# define glthread_rwlock_unlock(LOCK) \
glthread_rwlock_unlock_func (LOCK)
# define glthread_rwlock_destroy(LOCK) \
glthread_rwlock_destroy_func (LOCK)
extern void glthread_rwlock_init_func (gl_rwlock_t *lock);
extern int glthread_rwlock_rdlock_func (gl_rwlock_t *lock);
extern int glthread_rwlock_wrlock_func (gl_rwlock_t *lock);
extern int glthread_rwlock_unlock_func (gl_rwlock_t *lock);
extern int glthread_rwlock_destroy_func (gl_rwlock_t *lock);
/* --------------------- gl_recursive_lock_t datatype --------------------- */
/* The native Windows documentation says that CRITICAL_SECTION already
implements a recursive lock. But we need not rely on it: It's easy to
implement a recursive lock without this assumption. */
typedef struct
{
gl_spinlock_t guard; /* protects the initialization */
DWORD owner;
unsigned long depth;
CRITICAL_SECTION lock;
}
gl_recursive_lock_t;
# define gl_recursive_lock_define(STORAGECLASS, NAME) \
STORAGECLASS gl_recursive_lock_t NAME;
# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \
STORAGECLASS gl_recursive_lock_t NAME = gl_recursive_lock_initializer;
# define gl_recursive_lock_initializer \
{ { 0, -1 }, 0, 0 }
# define glthread_recursive_lock_init(LOCK) \
(glthread_recursive_lock_init_func (LOCK), 0)
# define glthread_recursive_lock_lock(LOCK) \
glthread_recursive_lock_lock_func (LOCK)
# define glthread_recursive_lock_unlock(LOCK) \
glthread_recursive_lock_unlock_func (LOCK)
# define glthread_recursive_lock_destroy(LOCK) \
glthread_recursive_lock_destroy_func (LOCK)
extern void glthread_recursive_lock_init_func (gl_recursive_lock_t *lock);
extern int glthread_recursive_lock_lock_func (gl_recursive_lock_t *lock);
extern int glthread_recursive_lock_unlock_func (gl_recursive_lock_t *lock);
extern int glthread_recursive_lock_destroy_func (gl_recursive_lock_t *lock);
/* -------------------------- gl_once_t datatype -------------------------- */
typedef struct
{
volatile int inited;
volatile long started;
CRITICAL_SECTION lock;
}
gl_once_t;
# define gl_once_define(STORAGECLASS, NAME) \
STORAGECLASS gl_once_t NAME = { -1, -1 };
# define glthread_once(ONCE_CONTROL, INITFUNCTION) \
(glthread_once_func (ONCE_CONTROL, INITFUNCTION), 0)
extern void glthread_once_func (gl_once_t *once_control, void (*initfunction) (void));
# ifdef __cplusplus
}
# endif
#endif
/* ========================================================================= */
#if !(USE_POSIX_THREADS || USE_PTH_THREADS || USE_SOLARIS_THREADS || USE_WINDOWS_THREADS)
/* Provide dummy implementation if threads are not supported. */
/* -------------------------- gl_lock_t datatype -------------------------- */
typedef int gl_lock_t;
# define gl_lock_define(STORAGECLASS, NAME)
# define gl_lock_define_initialized(STORAGECLASS, NAME)
# define glthread_lock_init(NAME) 0
# define glthread_lock_lock(NAME) 0
# define glthread_lock_unlock(NAME) 0
# define glthread_lock_destroy(NAME) 0
/* ------------------------- gl_rwlock_t datatype ------------------------- */
typedef int gl_rwlock_t;
# define gl_rwlock_define(STORAGECLASS, NAME)
# define gl_rwlock_define_initialized(STORAGECLASS, NAME)
# define glthread_rwlock_init(NAME) 0
# define glthread_rwlock_rdlock(NAME) 0
# define glthread_rwlock_wrlock(NAME) 0
# define glthread_rwlock_unlock(NAME) 0
# define glthread_rwlock_destroy(NAME) 0
/* --------------------- gl_recursive_lock_t datatype --------------------- */
typedef int gl_recursive_lock_t;
# define gl_recursive_lock_define(STORAGECLASS, NAME)
# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME)
# define glthread_recursive_lock_init(NAME) 0
# define glthread_recursive_lock_lock(NAME) 0
# define glthread_recursive_lock_unlock(NAME) 0
# define glthread_recursive_lock_destroy(NAME) 0
/* -------------------------- gl_once_t datatype -------------------------- */
typedef int gl_once_t;
# define gl_once_define(STORAGECLASS, NAME) \
STORAGECLASS gl_once_t NAME = 0;
# define glthread_once(ONCE_CONTROL, INITFUNCTION) \
(*(ONCE_CONTROL) == 0 ? (*(ONCE_CONTROL) = ~ 0, INITFUNCTION (), 0) : 0)
#endif
/* ========================================================================= */
/* Macros with built-in error handling. */
/* -------------------------- gl_lock_t datatype -------------------------- */
#define gl_lock_init(NAME) \
do \
{ \
if (glthread_lock_init (&NAME)) \
abort (); \
} \
while (0)
#define gl_lock_lock(NAME) \
do \
{ \
if (glthread_lock_lock (&NAME)) \
abort (); \
} \
while (0)
#define gl_lock_unlock(NAME) \
do \
{ \
if (glthread_lock_unlock (&NAME)) \
abort (); \
} \
while (0)
#define gl_lock_destroy(NAME) \
do \
{ \
if (glthread_lock_destroy (&NAME)) \
abort (); \
} \
while (0)
/* ------------------------- gl_rwlock_t datatype ------------------------- */
#define gl_rwlock_init(NAME) \
do \
{ \
if (glthread_rwlock_init (&NAME)) \
abort (); \
} \
while (0)
#define gl_rwlock_rdlock(NAME) \
do \
{ \
if (glthread_rwlock_rdlock (&NAME)) \
abort (); \
} \
while (0)
#define gl_rwlock_wrlock(NAME) \
do \
{ \
if (glthread_rwlock_wrlock (&NAME)) \
abort (); \
} \
while (0)
#define gl_rwlock_unlock(NAME) \
do \
{ \
if (glthread_rwlock_unlock (&NAME)) \
abort (); \
} \
while (0)
#define gl_rwlock_destroy(NAME) \
do \
{ \
if (glthread_rwlock_destroy (&NAME)) \
abort (); \
} \
while (0)
/* --------------------- gl_recursive_lock_t datatype --------------------- */
#define gl_recursive_lock_init(NAME) \
do \
{ \
if (glthread_recursive_lock_init (&NAME)) \
abort (); \
} \
while (0)
#define gl_recursive_lock_lock(NAME) \
do \
{ \
if (glthread_recursive_lock_lock (&NAME)) \
abort (); \
} \
while (0)
#define gl_recursive_lock_unlock(NAME) \
do \
{ \
if (glthread_recursive_lock_unlock (&NAME)) \
abort (); \
} \
while (0)
#define gl_recursive_lock_destroy(NAME) \
do \
{ \
if (glthread_recursive_lock_destroy (&NAME)) \
abort (); \
} \
while (0)
/* -------------------------- gl_once_t datatype -------------------------- */
#define gl_once(NAME, INITFUNCTION) \
do \
{ \
if (glthread_once (&NAME, INITFUNCTION)) \
abort (); \
} \
while (0)
/* ========================================================================= */
#endif /* _LOCK_H */

View File

@ -0,0 +1,73 @@
/* Multithreading primitives.
Copyright (C) 2005-2016 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, 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 <http://www.gnu.org/licenses/>. */
/* Written by Bruno Haible <bruno@clisp.org>, 2005. */
#include <config.h>
/* ========================================================================= */
#if USE_POSIX_THREADS
/* Use the POSIX threads library. */
# include <pthread.h>
# include <stdlib.h>
# if PTHREAD_IN_USE_DETECTION_HARD
/* The function to be executed by a dummy thread. */
static void *
dummy_thread_func (void *arg)
{
return arg;
}
int
glthread_in_use (void)
{
static int tested;
static int result; /* 1: linked with -lpthread, 0: only with libc */
if (!tested)
{
pthread_t thread;
if (pthread_create (&thread, NULL, dummy_thread_func, NULL) != 0)
/* Thread creation failed. */
result = 0;
else
{
/* Thread creation works. */
void *retval;
if (pthread_join (thread, &retval) != 0)
abort ();
result = 1;
}
tested = 1;
}
return result;
}
# endif
#endif
/* ========================================================================= */
/* This declaration is solely to ensure that after preprocessing
this file is never empty. */
typedef int dummy;

View File

@ -27,7 +27,7 @@
# Specification in the form of a command-line invocation:
# gnulib-tool --import --lib=libgnu --source-base=import --m4-base=import/m4 --doc-base=doc --tests-base=tests --aux-dir=import/extra --no-conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca canonicalize-lgpl dirent dirfd errno fnmatch-gnu frexpl getcwd glob inet_ntop inttypes limits-h lstat memchr memmem mkdir mkdtemp mkostemp pathmax rawmemchr readlink rename setenv signal-h strchrnul strstr strtok_r sys_stat unistd unsetenv update-copyright wchar wctype-h
# gnulib-tool --import --lib=libgnu --source-base=import --m4-base=import/m4 --doc-base=doc --tests-base=tests --aux-dir=import/extra --no-conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca canonicalize-lgpl dirent dirfd errno fnmatch-gnu frexpl getcwd glob inet_ntop inttypes limits-h lstat memchr memmem mkdir mkdtemp mkostemp pathmax rawmemchr readlink rename setenv signal-h strchrnul strerror_r-posix strstr strtok_r sys_stat unistd unsetenv update-copyright wchar wctype-h
# Specification in the form of a few gnulib-tool.m4 macro invocations:
gl_LOCAL_DIR([])
@ -57,6 +57,7 @@ gl_MODULES([
setenv
signal-h
strchrnul
strerror_r-posix
strstr
strtok_r
sys_stat

View File

@ -42,6 +42,7 @@ AC_DEFUN([gl_EARLY],
AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
AC_REQUIRE([gl_PROG_AR_RANLIB])
AC_REQUIRE([AM_PROG_CC_C_O])
# Code from module absolute-header:
# Code from module alloca:
# Code from module alloca-opt:
@ -97,6 +98,7 @@ AC_DEFUN([gl_EARLY],
# Code from module gettimeofday:
# Code from module glob:
# Code from module hard-locale:
# Code from module havelib:
# Code from module include_next:
# Code from module inet_ntop:
# Code from module intprops:
@ -108,6 +110,7 @@ AC_DEFUN([gl_EARLY],
AC_REQUIRE([AC_SYS_LARGEFILE])
# Code from module limits-h:
# Code from module localcharset:
# Code from module lock:
# Code from module lstat:
# Code from module malloc-posix:
# Code from module malloca:
@ -164,6 +167,7 @@ AC_DEFUN([gl_EARLY],
# Code from module streq:
# Code from module strerror:
# Code from module strerror-override:
# Code from module strerror_r-posix:
# Code from module string:
# Code from module strnlen1:
# Code from module strstr:
@ -175,6 +179,8 @@ AC_DEFUN([gl_EARLY],
# Code from module sys_types:
# Code from module sys_uio:
# Code from module tempname:
# Code from module threadlib:
gl_THREADLIB_EARLY
# Code from module time:
# Code from module unistd:
# Code from module unistd-safer:
@ -382,6 +388,8 @@ AC_DEFUN([gl_INIT],
gl_LOCALCHARSET
LOCALCHARSET_TESTS_ENVIRONMENT="CHARSETALIASDIR=\"\$(abs_top_builddir)/$gl_source_base\""
AC_SUBST([LOCALCHARSET_TESTS_ENVIRONMENT])
gl_LOCK
gl_MODULE_INDICATOR([lock])
gl_FUNC_LSTAT
if test $REPLACE_LSTAT = 1; then
AC_LIBOBJ([lstat])
@ -576,6 +584,12 @@ AC_DEFUN([gl_INIT],
AC_LIBOBJ([strerror-override])
gl_PREREQ_SYS_H_WINSOCK2
fi
gl_FUNC_STRERROR_R
if test $HAVE_DECL_STRERROR_R = 0 || test $REPLACE_STRERROR_R = 1; then
AC_LIBOBJ([strerror_r])
gl_PREREQ_STRERROR_R
fi
gl_STRING_MODULE_INDICATOR([strerror_r])
gl_HEADER_STRING_H
gl_FUNC_STRSTR
if test $REPLACE_STRSTR = 1; then
@ -603,6 +617,7 @@ AC_DEFUN([gl_INIT],
gl_HEADER_SYS_UIO
AC_PROG_MKDIR_P
gl_FUNC_GEN_TEMPNAME
gl_THREADLIB
gl_HEADER_TIME_H
gl_UNISTD_H
gl_UNISTD_SAFER
@ -754,6 +769,7 @@ AC_DEFUN([gltests_LIBSOURCES], [
# This macro records the list of files which have been installed by
# gnulib-tool and may be removed by future gnulib-tool invocations.
AC_DEFUN([gl_FILE_LIST], [
build-aux/config.rpath
build-aux/snippet/_Noreturn.h
build-aux/snippet/arg-nonnull.h
build-aux/snippet/c++defs.h
@ -820,6 +836,9 @@ AC_DEFUN([gl_FILE_LIST], [
lib/glob-libc.h
lib/glob.c
lib/glob.in.h
lib/glthread/lock.c
lib/glthread/lock.h
lib/glthread/threadlib.c
lib/hard-locale.c
lib/hard-locale.h
lib/inet_ntop.c
@ -899,6 +918,7 @@ AC_DEFUN([gl_FILE_LIST], [
lib/strerror-override.c
lib/strerror-override.h
lib/strerror.c
lib/strerror_r.c
lib/string.in.h
lib/stripslash.c
lib/strnlen1.c
@ -981,11 +1001,15 @@ AC_DEFUN([gl_FILE_LIST], [
m4/isnand.m4
m4/isnanl.m4
m4/largefile.m4
m4/lib-ld.m4
m4/lib-link.m4
m4/lib-prefix.m4
m4/limits-h.m4
m4/localcharset.m4
m4/locale-fr.m4
m4/locale-ja.m4
m4/locale-zh.m4
m4/lock.m4
m4/longlong.m4
m4/lstat.m4
m4/malloc.m4
@ -1039,6 +1063,7 @@ AC_DEFUN([gl_FILE_LIST], [
m4/strchrnul.m4
m4/strdup.m4
m4/strerror.m4
m4/strerror_r.m4
m4/string_h.m4
m4/strstr.m4
m4/strtok_r.m4
@ -1048,6 +1073,7 @@ AC_DEFUN([gl_FILE_LIST], [
m4/sys_types_h.m4
m4/sys_uio_h.m4
m4/tempname.m4
m4/threadlib.m4
m4/time_h.m4
m4/unistd-safer.m4
m4/unistd_h.m4

119
gnulib/import/m4/lib-ld.m4 Normal file
View File

@ -0,0 +1,119 @@
# lib-ld.m4 serial 6
dnl Copyright (C) 1996-2003, 2009-2016 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
dnl Subroutines of libtool.m4,
dnl with replacements s/_*LT_PATH/AC_LIB_PROG/ and s/lt_/acl_/ to avoid
dnl collision with libtool.m4.
dnl From libtool-2.4. Sets the variable with_gnu_ld to yes or no.
AC_DEFUN([AC_LIB_PROG_LD_GNU],
[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], [acl_cv_prog_gnu_ld],
[# I'd rather use --version here, but apparently some GNU lds only accept -v.
case `$LD -v 2>&1 </dev/null` in
*GNU* | *'with BFD'*)
acl_cv_prog_gnu_ld=yes
;;
*)
acl_cv_prog_gnu_ld=no
;;
esac])
with_gnu_ld=$acl_cv_prog_gnu_ld
])
dnl From libtool-2.4. Sets the variable LD.
AC_DEFUN([AC_LIB_PROG_LD],
[AC_REQUIRE([AC_PROG_CC])dnl
AC_REQUIRE([AC_CANONICAL_HOST])dnl
AC_ARG_WITH([gnu-ld],
[AS_HELP_STRING([--with-gnu-ld],
[assume the C compiler uses GNU ld [default=no]])],
[test "$withval" = no || with_gnu_ld=yes],
[with_gnu_ld=no])dnl
# Prepare PATH_SEPARATOR.
# The user is always right.
if test "${PATH_SEPARATOR+set}" != set; then
# Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which
# contains only /bin. Note that ksh looks also at the FPATH variable,
# so we have to set that as well for the test.
PATH_SEPARATOR=:
(PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
&& { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
|| PATH_SEPARATOR=';'
}
fi
ac_prog=ld
if test "$GCC" = yes; then
# Check if gcc -print-prog-name=ld gives a path.
AC_MSG_CHECKING([for ld used by $CC])
case $host in
*-*-mingw*)
# gcc leaves a trailing carriage return which upsets mingw
ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
*)
ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
esac
case $ac_prog in
# Accept absolute paths.
[[\\/]]* | ?:[[\\/]]*)
re_direlt='/[[^/]][[^/]]*/\.\./'
# Canonicalize the pathname of ld
ac_prog=`echo "$ac_prog"| sed 's%\\\\%/%g'`
while echo "$ac_prog" | grep "$re_direlt" > /dev/null 2>&1; do
ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
done
test -z "$LD" && LD="$ac_prog"
;;
"")
# If it fails, then pretend we aren't using GCC.
ac_prog=ld
;;
*)
# If it is relative, then search for the first ld in PATH.
with_gnu_ld=unknown
;;
esac
elif test "$with_gnu_ld" = yes; then
AC_MSG_CHECKING([for GNU ld])
else
AC_MSG_CHECKING([for non-GNU ld])
fi
AC_CACHE_VAL([acl_cv_path_LD],
[if test -z "$LD"; then
acl_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
for ac_dir in $PATH; do
IFS="$acl_save_ifs"
test -z "$ac_dir" && ac_dir=.
if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
acl_cv_path_LD="$ac_dir/$ac_prog"
# Check to see if the program is GNU ld. I'd rather use --version,
# but apparently some variants of GNU ld only accept -v.
# Break only if it was the GNU/non-GNU ld that we prefer.
case `"$acl_cv_path_LD" -v 2>&1 </dev/null` in
*GNU* | *'with BFD'*)
test "$with_gnu_ld" != no && break
;;
*)
test "$with_gnu_ld" != yes && break
;;
esac
fi
done
IFS="$acl_save_ifs"
else
acl_cv_path_LD="$LD" # Let the user override the test with a path.
fi])
LD="$acl_cv_path_LD"
if test -n "$LD"; then
AC_MSG_RESULT([$LD])
else
AC_MSG_RESULT([no])
fi
test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
AC_LIB_PROG_LD_GNU
])

View File

@ -0,0 +1,777 @@
# lib-link.m4 serial 26 (gettext-0.18.2)
dnl Copyright (C) 2001-2016 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
dnl From Bruno Haible.
AC_PREREQ([2.54])
dnl AC_LIB_LINKFLAGS(name [, dependencies]) searches for libname and
dnl the libraries corresponding to explicit and implicit dependencies.
dnl Sets and AC_SUBSTs the LIB${NAME} and LTLIB${NAME} variables and
dnl augments the CPPFLAGS variable.
dnl Sets and AC_SUBSTs the LIB${NAME}_PREFIX variable to nonempty if libname
dnl was found in ${LIB${NAME}_PREFIX}/$acl_libdirstem.
AC_DEFUN([AC_LIB_LINKFLAGS],
[
AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
AC_REQUIRE([AC_LIB_RPATH])
pushdef([Name],[m4_translit([$1],[./+-], [____])])
pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-],
[ABCDEFGHIJKLMNOPQRSTUVWXYZ____])])
AC_CACHE_CHECK([how to link with lib[]$1], [ac_cv_lib[]Name[]_libs], [
AC_LIB_LINKFLAGS_BODY([$1], [$2])
ac_cv_lib[]Name[]_libs="$LIB[]NAME"
ac_cv_lib[]Name[]_ltlibs="$LTLIB[]NAME"
ac_cv_lib[]Name[]_cppflags="$INC[]NAME"
ac_cv_lib[]Name[]_prefix="$LIB[]NAME[]_PREFIX"
])
LIB[]NAME="$ac_cv_lib[]Name[]_libs"
LTLIB[]NAME="$ac_cv_lib[]Name[]_ltlibs"
INC[]NAME="$ac_cv_lib[]Name[]_cppflags"
LIB[]NAME[]_PREFIX="$ac_cv_lib[]Name[]_prefix"
AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME)
AC_SUBST([LIB]NAME)
AC_SUBST([LTLIB]NAME)
AC_SUBST([LIB]NAME[_PREFIX])
dnl Also set HAVE_LIB[]NAME so that AC_LIB_HAVE_LINKFLAGS can reuse the
dnl results of this search when this library appears as a dependency.
HAVE_LIB[]NAME=yes
popdef([NAME])
popdef([Name])
])
dnl AC_LIB_HAVE_LINKFLAGS(name, dependencies, includes, testcode, [missing-message])
dnl searches for libname and the libraries corresponding to explicit and
dnl implicit dependencies, together with the specified include files and
dnl the ability to compile and link the specified testcode. The missing-message
dnl defaults to 'no' and may contain additional hints for the user.
dnl If found, it sets and AC_SUBSTs HAVE_LIB${NAME}=yes and the LIB${NAME}
dnl and LTLIB${NAME} variables and augments the CPPFLAGS variable, and
dnl #defines HAVE_LIB${NAME} to 1. Otherwise, it sets and AC_SUBSTs
dnl HAVE_LIB${NAME}=no and LIB${NAME} and LTLIB${NAME} to empty.
dnl Sets and AC_SUBSTs the LIB${NAME}_PREFIX variable to nonempty if libname
dnl was found in ${LIB${NAME}_PREFIX}/$acl_libdirstem.
AC_DEFUN([AC_LIB_HAVE_LINKFLAGS],
[
AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
AC_REQUIRE([AC_LIB_RPATH])
pushdef([Name],[m4_translit([$1],[./+-], [____])])
pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-],
[ABCDEFGHIJKLMNOPQRSTUVWXYZ____])])
dnl Search for lib[]Name and define LIB[]NAME, LTLIB[]NAME and INC[]NAME
dnl accordingly.
AC_LIB_LINKFLAGS_BODY([$1], [$2])
dnl Add $INC[]NAME to CPPFLAGS before performing the following checks,
dnl because if the user has installed lib[]Name and not disabled its use
dnl via --without-lib[]Name-prefix, he wants to use it.
ac_save_CPPFLAGS="$CPPFLAGS"
AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME)
AC_CACHE_CHECK([for lib[]$1], [ac_cv_lib[]Name], [
ac_save_LIBS="$LIBS"
dnl If $LIB[]NAME contains some -l options, add it to the end of LIBS,
dnl because these -l options might require -L options that are present in
dnl LIBS. -l options benefit only from the -L options listed before it.
dnl Otherwise, add it to the front of LIBS, because it may be a static
dnl library that depends on another static library that is present in LIBS.
dnl Static libraries benefit only from the static libraries listed after
dnl it.
case " $LIB[]NAME" in
*" -l"*) LIBS="$LIBS $LIB[]NAME" ;;
*) LIBS="$LIB[]NAME $LIBS" ;;
esac
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([[$3]], [[$4]])],
[ac_cv_lib[]Name=yes],
[ac_cv_lib[]Name='m4_if([$5], [], [no], [[$5]])'])
LIBS="$ac_save_LIBS"
])
if test "$ac_cv_lib[]Name" = yes; then
HAVE_LIB[]NAME=yes
AC_DEFINE([HAVE_LIB]NAME, 1, [Define if you have the lib][$1 library.])
AC_MSG_CHECKING([how to link with lib[]$1])
AC_MSG_RESULT([$LIB[]NAME])
else
HAVE_LIB[]NAME=no
dnl If $LIB[]NAME didn't lead to a usable library, we don't need
dnl $INC[]NAME either.
CPPFLAGS="$ac_save_CPPFLAGS"
LIB[]NAME=
LTLIB[]NAME=
LIB[]NAME[]_PREFIX=
fi
AC_SUBST([HAVE_LIB]NAME)
AC_SUBST([LIB]NAME)
AC_SUBST([LTLIB]NAME)
AC_SUBST([LIB]NAME[_PREFIX])
popdef([NAME])
popdef([Name])
])
dnl Determine the platform dependent parameters needed to use rpath:
dnl acl_libext,
dnl acl_shlibext,
dnl acl_libname_spec,
dnl acl_library_names_spec,
dnl acl_hardcode_libdir_flag_spec,
dnl acl_hardcode_libdir_separator,
dnl acl_hardcode_direct,
dnl acl_hardcode_minus_L.
AC_DEFUN([AC_LIB_RPATH],
[
dnl Tell automake >= 1.10 to complain if config.rpath is missing.
m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([config.rpath])])
AC_REQUIRE([AC_PROG_CC]) dnl we use $CC, $GCC, $LDFLAGS
AC_REQUIRE([AC_LIB_PROG_LD]) dnl we use $LD, $with_gnu_ld
AC_REQUIRE([AC_CANONICAL_HOST]) dnl we use $host
AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT]) dnl we use $ac_aux_dir
AC_CACHE_CHECK([for shared library run path origin], [acl_cv_rpath], [
CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \
${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh
. ./conftest.sh
rm -f ./conftest.sh
acl_cv_rpath=done
])
wl="$acl_cv_wl"
acl_libext="$acl_cv_libext"
acl_shlibext="$acl_cv_shlibext"
acl_libname_spec="$acl_cv_libname_spec"
acl_library_names_spec="$acl_cv_library_names_spec"
acl_hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec"
acl_hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator"
acl_hardcode_direct="$acl_cv_hardcode_direct"
acl_hardcode_minus_L="$acl_cv_hardcode_minus_L"
dnl Determine whether the user wants rpath handling at all.
AC_ARG_ENABLE([rpath],
[ --disable-rpath do not hardcode runtime library paths],
:, enable_rpath=yes)
])
dnl AC_LIB_FROMPACKAGE(name, package)
dnl declares that libname comes from the given package. The configure file
dnl will then not have a --with-libname-prefix option but a
dnl --with-package-prefix option. Several libraries can come from the same
dnl package. This declaration must occur before an AC_LIB_LINKFLAGS or similar
dnl macro call that searches for libname.
AC_DEFUN([AC_LIB_FROMPACKAGE],
[
pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-],
[ABCDEFGHIJKLMNOPQRSTUVWXYZ____])])
define([acl_frompackage_]NAME, [$2])
popdef([NAME])
pushdef([PACK],[$2])
pushdef([PACKUP],[m4_translit(PACK,[abcdefghijklmnopqrstuvwxyz./+-],
[ABCDEFGHIJKLMNOPQRSTUVWXYZ____])])
define([acl_libsinpackage_]PACKUP,
m4_ifdef([acl_libsinpackage_]PACKUP, [m4_defn([acl_libsinpackage_]PACKUP)[, ]],)[lib$1])
popdef([PACKUP])
popdef([PACK])
])
dnl AC_LIB_LINKFLAGS_BODY(name [, dependencies]) searches for libname and
dnl the libraries corresponding to explicit and implicit dependencies.
dnl Sets the LIB${NAME}, LTLIB${NAME} and INC${NAME} variables.
dnl Also, sets the LIB${NAME}_PREFIX variable to nonempty if libname was found
dnl in ${LIB${NAME}_PREFIX}/$acl_libdirstem.
AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
[
AC_REQUIRE([AC_LIB_PREPARE_MULTILIB])
pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-],
[ABCDEFGHIJKLMNOPQRSTUVWXYZ____])])
pushdef([PACK],[m4_ifdef([acl_frompackage_]NAME, [acl_frompackage_]NAME, lib[$1])])
pushdef([PACKUP],[m4_translit(PACK,[abcdefghijklmnopqrstuvwxyz./+-],
[ABCDEFGHIJKLMNOPQRSTUVWXYZ____])])
pushdef([PACKLIBS],[m4_ifdef([acl_frompackage_]NAME, [acl_libsinpackage_]PACKUP, lib[$1])])
dnl Autoconf >= 2.61 supports dots in --with options.
pushdef([P_A_C_K],[m4_if(m4_version_compare(m4_defn([m4_PACKAGE_VERSION]),[2.61]),[-1],[m4_translit(PACK,[.],[_])],PACK)])
dnl By default, look in $includedir and $libdir.
use_additional=yes
AC_LIB_WITH_FINAL_PREFIX([
eval additional_includedir=\"$includedir\"
eval additional_libdir=\"$libdir\"
])
AC_ARG_WITH(P_A_C_K[-prefix],
[[ --with-]]P_A_C_K[[-prefix[=DIR] search for ]PACKLIBS[ in DIR/include and DIR/lib
--without-]]P_A_C_K[[-prefix don't search for ]PACKLIBS[ in includedir and libdir]],
[
if test "X$withval" = "Xno"; then
use_additional=no
else
if test "X$withval" = "X"; then
AC_LIB_WITH_FINAL_PREFIX([
eval additional_includedir=\"$includedir\"
eval additional_libdir=\"$libdir\"
])
else
additional_includedir="$withval/include"
additional_libdir="$withval/$acl_libdirstem"
if test "$acl_libdirstem2" != "$acl_libdirstem" \
&& ! test -d "$withval/$acl_libdirstem"; then
additional_libdir="$withval/$acl_libdirstem2"
fi
fi
fi
])
dnl Search the library and its dependencies in $additional_libdir and
dnl $LDFLAGS. Using breadth-first-seach.
LIB[]NAME=
LTLIB[]NAME=
INC[]NAME=
LIB[]NAME[]_PREFIX=
dnl HAVE_LIB${NAME} is an indicator that LIB${NAME}, LTLIB${NAME} have been
dnl computed. So it has to be reset here.
HAVE_LIB[]NAME=
rpathdirs=
ltrpathdirs=
names_already_handled=
names_next_round='$1 $2'
while test -n "$names_next_round"; do
names_this_round="$names_next_round"
names_next_round=
for name in $names_this_round; do
already_handled=
for n in $names_already_handled; do
if test "$n" = "$name"; then
already_handled=yes
break
fi
done
if test -z "$already_handled"; then
names_already_handled="$names_already_handled $name"
dnl See if it was already located by an earlier AC_LIB_LINKFLAGS
dnl or AC_LIB_HAVE_LINKFLAGS call.
uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./+-|ABCDEFGHIJKLMNOPQRSTUVWXYZ____|'`
eval value=\"\$HAVE_LIB$uppername\"
if test -n "$value"; then
if test "$value" = yes; then
eval value=\"\$LIB$uppername\"
test -z "$value" || LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$value"
eval value=\"\$LTLIB$uppername\"
test -z "$value" || LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$value"
else
dnl An earlier call to AC_LIB_HAVE_LINKFLAGS has determined
dnl that this library doesn't exist. So just drop it.
:
fi
else
dnl Search the library lib$name in $additional_libdir and $LDFLAGS
dnl and the already constructed $LIBNAME/$LTLIBNAME.
found_dir=
found_la=
found_so=
found_a=
eval libname=\"$acl_libname_spec\" # typically: libname=lib$name
if test -n "$acl_shlibext"; then
shrext=".$acl_shlibext" # typically: shrext=.so
else
shrext=
fi
if test $use_additional = yes; then
dir="$additional_libdir"
dnl The same code as in the loop below:
dnl First look for a shared library.
if test -n "$acl_shlibext"; then
if test -f "$dir/$libname$shrext"; then
found_dir="$dir"
found_so="$dir/$libname$shrext"
else
if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then
ver=`(cd "$dir" && \
for f in "$libname$shrext".*; do echo "$f"; done \
| sed -e "s,^$libname$shrext\\\\.,," \
| sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \
| sed 1q ) 2>/dev/null`
if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then
found_dir="$dir"
found_so="$dir/$libname$shrext.$ver"
fi
else
eval library_names=\"$acl_library_names_spec\"
for f in $library_names; do
if test -f "$dir/$f"; then
found_dir="$dir"
found_so="$dir/$f"
break
fi
done
fi
fi
fi
dnl Then look for a static library.
if test "X$found_dir" = "X"; then
if test -f "$dir/$libname.$acl_libext"; then
found_dir="$dir"
found_a="$dir/$libname.$acl_libext"
fi
fi
if test "X$found_dir" != "X"; then
if test -f "$dir/$libname.la"; then
found_la="$dir/$libname.la"
fi
fi
fi
if test "X$found_dir" = "X"; then
for x in $LDFLAGS $LTLIB[]NAME; do
AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
case "$x" in
-L*)
dir=`echo "X$x" | sed -e 's/^X-L//'`
dnl First look for a shared library.
if test -n "$acl_shlibext"; then
if test -f "$dir/$libname$shrext"; then
found_dir="$dir"
found_so="$dir/$libname$shrext"
else
if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then
ver=`(cd "$dir" && \
for f in "$libname$shrext".*; do echo "$f"; done \
| sed -e "s,^$libname$shrext\\\\.,," \
| sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \
| sed 1q ) 2>/dev/null`
if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then
found_dir="$dir"
found_so="$dir/$libname$shrext.$ver"
fi
else
eval library_names=\"$acl_library_names_spec\"
for f in $library_names; do
if test -f "$dir/$f"; then
found_dir="$dir"
found_so="$dir/$f"
break
fi
done
fi
fi
fi
dnl Then look for a static library.
if test "X$found_dir" = "X"; then
if test -f "$dir/$libname.$acl_libext"; then
found_dir="$dir"
found_a="$dir/$libname.$acl_libext"
fi
fi
if test "X$found_dir" != "X"; then
if test -f "$dir/$libname.la"; then
found_la="$dir/$libname.la"
fi
fi
;;
esac
if test "X$found_dir" != "X"; then
break
fi
done
fi
if test "X$found_dir" != "X"; then
dnl Found the library.
LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$found_dir -l$name"
if test "X$found_so" != "X"; then
dnl Linking with a shared library. We attempt to hardcode its
dnl directory into the executable's runpath, unless it's the
dnl standard /usr/lib.
if test "$enable_rpath" = no \
|| test "X$found_dir" = "X/usr/$acl_libdirstem" \
|| test "X$found_dir" = "X/usr/$acl_libdirstem2"; then
dnl No hardcoding is needed.
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
else
dnl Use an explicit option to hardcode DIR into the resulting
dnl binary.
dnl Potentially add DIR to ltrpathdirs.
dnl The ltrpathdirs will be appended to $LTLIBNAME at the end.
haveit=
for x in $ltrpathdirs; do
if test "X$x" = "X$found_dir"; then
haveit=yes
break
fi
done
if test -z "$haveit"; then
ltrpathdirs="$ltrpathdirs $found_dir"
fi
dnl The hardcoding into $LIBNAME is system dependent.
if test "$acl_hardcode_direct" = yes; then
dnl Using DIR/libNAME.so during linking hardcodes DIR into the
dnl resulting binary.
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
else
if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then
dnl Use an explicit option to hardcode DIR into the resulting
dnl binary.
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
dnl Potentially add DIR to rpathdirs.
dnl The rpathdirs will be appended to $LIBNAME at the end.
haveit=
for x in $rpathdirs; do
if test "X$x" = "X$found_dir"; then
haveit=yes
break
fi
done
if test -z "$haveit"; then
rpathdirs="$rpathdirs $found_dir"
fi
else
dnl Rely on "-L$found_dir".
dnl But don't add it if it's already contained in the LDFLAGS
dnl or the already constructed $LIBNAME
haveit=
for x in $LDFLAGS $LIB[]NAME; do
AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
if test "X$x" = "X-L$found_dir"; then
haveit=yes
break
fi
done
if test -z "$haveit"; then
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir"
fi
if test "$acl_hardcode_minus_L" != no; then
dnl FIXME: Not sure whether we should use
dnl "-L$found_dir -l$name" or "-L$found_dir $found_so"
dnl here.
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
else
dnl We cannot use $acl_hardcode_runpath_var and LD_RUN_PATH
dnl here, because this doesn't fit in flags passed to the
dnl compiler. So give up. No hardcoding. This affects only
dnl very old systems.
dnl FIXME: Not sure whether we should use
dnl "-L$found_dir -l$name" or "-L$found_dir $found_so"
dnl here.
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name"
fi
fi
fi
fi
else
if test "X$found_a" != "X"; then
dnl Linking with a static library.
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_a"
else
dnl We shouldn't come here, but anyway it's good to have a
dnl fallback.
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir -l$name"
fi
fi
dnl Assume the include files are nearby.
additional_includedir=
case "$found_dir" in
*/$acl_libdirstem | */$acl_libdirstem/)
basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem/"'*$,,'`
if test "$name" = '$1'; then
LIB[]NAME[]_PREFIX="$basedir"
fi
additional_includedir="$basedir/include"
;;
*/$acl_libdirstem2 | */$acl_libdirstem2/)
basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem2/"'*$,,'`
if test "$name" = '$1'; then
LIB[]NAME[]_PREFIX="$basedir"
fi
additional_includedir="$basedir/include"
;;
esac
if test "X$additional_includedir" != "X"; then
dnl Potentially add $additional_includedir to $INCNAME.
dnl But don't add it
dnl 1. if it's the standard /usr/include,
dnl 2. if it's /usr/local/include and we are using GCC on Linux,
dnl 3. if it's already present in $CPPFLAGS or the already
dnl constructed $INCNAME,
dnl 4. if it doesn't exist as a directory.
if test "X$additional_includedir" != "X/usr/include"; then
haveit=
if test "X$additional_includedir" = "X/usr/local/include"; then
if test -n "$GCC"; then
case $host_os in
linux* | gnu* | k*bsd*-gnu) haveit=yes;;
esac
fi
fi
if test -z "$haveit"; then
for x in $CPPFLAGS $INC[]NAME; do
AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
if test "X$x" = "X-I$additional_includedir"; then
haveit=yes
break
fi
done
if test -z "$haveit"; then
if test -d "$additional_includedir"; then
dnl Really add $additional_includedir to $INCNAME.
INC[]NAME="${INC[]NAME}${INC[]NAME:+ }-I$additional_includedir"
fi
fi
fi
fi
fi
dnl Look for dependencies.
if test -n "$found_la"; then
dnl Read the .la file. It defines the variables
dnl dlname, library_names, old_library, dependency_libs, current,
dnl age, revision, installed, dlopen, dlpreopen, libdir.
save_libdir="$libdir"
case "$found_la" in
*/* | *\\*) . "$found_la" ;;
*) . "./$found_la" ;;
esac
libdir="$save_libdir"
dnl We use only dependency_libs.
for dep in $dependency_libs; do
case "$dep" in
-L*)
additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'`
dnl Potentially add $additional_libdir to $LIBNAME and $LTLIBNAME.
dnl But don't add it
dnl 1. if it's the standard /usr/lib,
dnl 2. if it's /usr/local/lib and we are using GCC on Linux,
dnl 3. if it's already present in $LDFLAGS or the already
dnl constructed $LIBNAME,
dnl 4. if it doesn't exist as a directory.
if test "X$additional_libdir" != "X/usr/$acl_libdirstem" \
&& test "X$additional_libdir" != "X/usr/$acl_libdirstem2"; then
haveit=
if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem" \
|| test "X$additional_libdir" = "X/usr/local/$acl_libdirstem2"; then
if test -n "$GCC"; then
case $host_os in
linux* | gnu* | k*bsd*-gnu) haveit=yes;;
esac
fi
fi
if test -z "$haveit"; then
haveit=
for x in $LDFLAGS $LIB[]NAME; do
AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
if test "X$x" = "X-L$additional_libdir"; then
haveit=yes
break
fi
done
if test -z "$haveit"; then
if test -d "$additional_libdir"; then
dnl Really add $additional_libdir to $LIBNAME.
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$additional_libdir"
fi
fi
haveit=
for x in $LDFLAGS $LTLIB[]NAME; do
AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
if test "X$x" = "X-L$additional_libdir"; then
haveit=yes
break
fi
done
if test -z "$haveit"; then
if test -d "$additional_libdir"; then
dnl Really add $additional_libdir to $LTLIBNAME.
LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$additional_libdir"
fi
fi
fi
fi
;;
-R*)
dir=`echo "X$dep" | sed -e 's/^X-R//'`
if test "$enable_rpath" != no; then
dnl Potentially add DIR to rpathdirs.
dnl The rpathdirs will be appended to $LIBNAME at the end.
haveit=
for x in $rpathdirs; do
if test "X$x" = "X$dir"; then
haveit=yes
break
fi
done
if test -z "$haveit"; then
rpathdirs="$rpathdirs $dir"
fi
dnl Potentially add DIR to ltrpathdirs.
dnl The ltrpathdirs will be appended to $LTLIBNAME at the end.
haveit=
for x in $ltrpathdirs; do
if test "X$x" = "X$dir"; then
haveit=yes
break
fi
done
if test -z "$haveit"; then
ltrpathdirs="$ltrpathdirs $dir"
fi
fi
;;
-l*)
dnl Handle this in the next round.
names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'`
;;
*.la)
dnl Handle this in the next round. Throw away the .la's
dnl directory; it is already contained in a preceding -L
dnl option.
names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'`
;;
*)
dnl Most likely an immediate library name.
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$dep"
LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$dep"
;;
esac
done
fi
else
dnl Didn't find the library; assume it is in the system directories
dnl known to the linker and runtime loader. (All the system
dnl directories known to the linker should also be known to the
dnl runtime loader, otherwise the system is severely misconfigured.)
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name"
LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-l$name"
fi
fi
fi
done
done
if test "X$rpathdirs" != "X"; then
if test -n "$acl_hardcode_libdir_separator"; then
dnl Weird platform: only the last -rpath option counts, the user must
dnl pass all path elements in one option. We can arrange that for a
dnl single library, but not when more than one $LIBNAMEs are used.
alldirs=
for found_dir in $rpathdirs; do
alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$found_dir"
done
dnl Note: acl_hardcode_libdir_flag_spec uses $libdir and $wl.
acl_save_libdir="$libdir"
libdir="$alldirs"
eval flag=\"$acl_hardcode_libdir_flag_spec\"
libdir="$acl_save_libdir"
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag"
else
dnl The -rpath options are cumulative.
for found_dir in $rpathdirs; do
acl_save_libdir="$libdir"
libdir="$found_dir"
eval flag=\"$acl_hardcode_libdir_flag_spec\"
libdir="$acl_save_libdir"
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag"
done
fi
fi
if test "X$ltrpathdirs" != "X"; then
dnl When using libtool, the option that works for both libraries and
dnl executables is -R. The -R options are cumulative.
for found_dir in $ltrpathdirs; do
LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-R$found_dir"
done
fi
popdef([P_A_C_K])
popdef([PACKLIBS])
popdef([PACKUP])
popdef([PACK])
popdef([NAME])
])
dnl AC_LIB_APPENDTOVAR(VAR, CONTENTS) appends the elements of CONTENTS to VAR,
dnl unless already present in VAR.
dnl Works only for CPPFLAGS, not for LIB* variables because that sometimes
dnl contains two or three consecutive elements that belong together.
AC_DEFUN([AC_LIB_APPENDTOVAR],
[
for element in [$2]; do
haveit=
for x in $[$1]; do
AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
if test "X$x" = "X$element"; then
haveit=yes
break
fi
done
if test -z "$haveit"; then
[$1]="${[$1]}${[$1]:+ }$element"
fi
done
])
dnl For those cases where a variable contains several -L and -l options
dnl referring to unknown libraries and directories, this macro determines the
dnl necessary additional linker options for the runtime path.
dnl AC_LIB_LINKFLAGS_FROM_LIBS([LDADDVAR], [LIBSVALUE], [USE-LIBTOOL])
dnl sets LDADDVAR to linker options needed together with LIBSVALUE.
dnl If USE-LIBTOOL evaluates to non-empty, linking with libtool is assumed,
dnl otherwise linking without libtool is assumed.
AC_DEFUN([AC_LIB_LINKFLAGS_FROM_LIBS],
[
AC_REQUIRE([AC_LIB_RPATH])
AC_REQUIRE([AC_LIB_PREPARE_MULTILIB])
$1=
if test "$enable_rpath" != no; then
if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then
dnl Use an explicit option to hardcode directories into the resulting
dnl binary.
rpathdirs=
next=
for opt in $2; do
if test -n "$next"; then
dir="$next"
dnl No need to hardcode the standard /usr/lib.
if test "X$dir" != "X/usr/$acl_libdirstem" \
&& test "X$dir" != "X/usr/$acl_libdirstem2"; then
rpathdirs="$rpathdirs $dir"
fi
next=
else
case $opt in
-L) next=yes ;;
-L*) dir=`echo "X$opt" | sed -e 's,^X-L,,'`
dnl No need to hardcode the standard /usr/lib.
if test "X$dir" != "X/usr/$acl_libdirstem" \
&& test "X$dir" != "X/usr/$acl_libdirstem2"; then
rpathdirs="$rpathdirs $dir"
fi
next= ;;
*) next= ;;
esac
fi
done
if test "X$rpathdirs" != "X"; then
if test -n ""$3""; then
dnl libtool is used for linking. Use -R options.
for dir in $rpathdirs; do
$1="${$1}${$1:+ }-R$dir"
done
else
dnl The linker is used for linking directly.
if test -n "$acl_hardcode_libdir_separator"; then
dnl Weird platform: only the last -rpath option counts, the user
dnl must pass all path elements in one option.
alldirs=
for dir in $rpathdirs; do
alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$dir"
done
acl_save_libdir="$libdir"
libdir="$alldirs"
eval flag=\"$acl_hardcode_libdir_flag_spec\"
libdir="$acl_save_libdir"
$1="$flag"
else
dnl The -rpath options are cumulative.
for dir in $rpathdirs; do
acl_save_libdir="$libdir"
libdir="$dir"
eval flag=\"$acl_hardcode_libdir_flag_spec\"
libdir="$acl_save_libdir"
$1="${$1}${$1:+ }$flag"
done
fi
fi
fi
fi
fi
AC_SUBST([$1])
])

View File

@ -0,0 +1,224 @@
# lib-prefix.m4 serial 7 (gettext-0.18)
dnl Copyright (C) 2001-2005, 2008-2016 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
dnl From Bruno Haible.
dnl AC_LIB_ARG_WITH is synonymous to AC_ARG_WITH in autoconf-2.13, and
dnl similar to AC_ARG_WITH in autoconf 2.52...2.57 except that is doesn't
dnl require excessive bracketing.
ifdef([AC_HELP_STRING],
[AC_DEFUN([AC_LIB_ARG_WITH], [AC_ARG_WITH([$1],[[$2]],[$3],[$4])])],
[AC_DEFUN([AC_][LIB_ARG_WITH], [AC_ARG_WITH([$1],[$2],[$3],[$4])])])
dnl AC_LIB_PREFIX adds to the CPPFLAGS and LDFLAGS the flags that are needed
dnl to access previously installed libraries. The basic assumption is that
dnl a user will want packages to use other packages he previously installed
dnl with the same --prefix option.
dnl This macro is not needed if only AC_LIB_LINKFLAGS is used to locate
dnl libraries, but is otherwise very convenient.
AC_DEFUN([AC_LIB_PREFIX],
[
AC_BEFORE([$0], [AC_LIB_LINKFLAGS])
AC_REQUIRE([AC_PROG_CC])
AC_REQUIRE([AC_CANONICAL_HOST])
AC_REQUIRE([AC_LIB_PREPARE_MULTILIB])
AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
dnl By default, look in $includedir and $libdir.
use_additional=yes
AC_LIB_WITH_FINAL_PREFIX([
eval additional_includedir=\"$includedir\"
eval additional_libdir=\"$libdir\"
])
AC_LIB_ARG_WITH([lib-prefix],
[ --with-lib-prefix[=DIR] search for libraries in DIR/include and DIR/lib
--without-lib-prefix don't search for libraries in includedir and libdir],
[
if test "X$withval" = "Xno"; then
use_additional=no
else
if test "X$withval" = "X"; then
AC_LIB_WITH_FINAL_PREFIX([
eval additional_includedir=\"$includedir\"
eval additional_libdir=\"$libdir\"
])
else
additional_includedir="$withval/include"
additional_libdir="$withval/$acl_libdirstem"
fi
fi
])
if test $use_additional = yes; then
dnl Potentially add $additional_includedir to $CPPFLAGS.
dnl But don't add it
dnl 1. if it's the standard /usr/include,
dnl 2. if it's already present in $CPPFLAGS,
dnl 3. if it's /usr/local/include and we are using GCC on Linux,
dnl 4. if it doesn't exist as a directory.
if test "X$additional_includedir" != "X/usr/include"; then
haveit=
for x in $CPPFLAGS; do
AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
if test "X$x" = "X-I$additional_includedir"; then
haveit=yes
break
fi
done
if test -z "$haveit"; then
if test "X$additional_includedir" = "X/usr/local/include"; then
if test -n "$GCC"; then
case $host_os in
linux* | gnu* | k*bsd*-gnu) haveit=yes;;
esac
fi
fi
if test -z "$haveit"; then
if test -d "$additional_includedir"; then
dnl Really add $additional_includedir to $CPPFLAGS.
CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }-I$additional_includedir"
fi
fi
fi
fi
dnl Potentially add $additional_libdir to $LDFLAGS.
dnl But don't add it
dnl 1. if it's the standard /usr/lib,
dnl 2. if it's already present in $LDFLAGS,
dnl 3. if it's /usr/local/lib and we are using GCC on Linux,
dnl 4. if it doesn't exist as a directory.
if test "X$additional_libdir" != "X/usr/$acl_libdirstem"; then
haveit=
for x in $LDFLAGS; do
AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
if test "X$x" = "X-L$additional_libdir"; then
haveit=yes
break
fi
done
if test -z "$haveit"; then
if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem"; then
if test -n "$GCC"; then
case $host_os in
linux*) haveit=yes;;
esac
fi
fi
if test -z "$haveit"; then
if test -d "$additional_libdir"; then
dnl Really add $additional_libdir to $LDFLAGS.
LDFLAGS="${LDFLAGS}${LDFLAGS:+ }-L$additional_libdir"
fi
fi
fi
fi
fi
])
dnl AC_LIB_PREPARE_PREFIX creates variables acl_final_prefix,
dnl acl_final_exec_prefix, containing the values to which $prefix and
dnl $exec_prefix will expand at the end of the configure script.
AC_DEFUN([AC_LIB_PREPARE_PREFIX],
[
dnl Unfortunately, prefix and exec_prefix get only finally determined
dnl at the end of configure.
if test "X$prefix" = "XNONE"; then
acl_final_prefix="$ac_default_prefix"
else
acl_final_prefix="$prefix"
fi
if test "X$exec_prefix" = "XNONE"; then
acl_final_exec_prefix='${prefix}'
else
acl_final_exec_prefix="$exec_prefix"
fi
acl_save_prefix="$prefix"
prefix="$acl_final_prefix"
eval acl_final_exec_prefix=\"$acl_final_exec_prefix\"
prefix="$acl_save_prefix"
])
dnl AC_LIB_WITH_FINAL_PREFIX([statement]) evaluates statement, with the
dnl variables prefix and exec_prefix bound to the values they will have
dnl at the end of the configure script.
AC_DEFUN([AC_LIB_WITH_FINAL_PREFIX],
[
acl_save_prefix="$prefix"
prefix="$acl_final_prefix"
acl_save_exec_prefix="$exec_prefix"
exec_prefix="$acl_final_exec_prefix"
$1
exec_prefix="$acl_save_exec_prefix"
prefix="$acl_save_prefix"
])
dnl AC_LIB_PREPARE_MULTILIB creates
dnl - a variable acl_libdirstem, containing the basename of the libdir, either
dnl "lib" or "lib64" or "lib/64",
dnl - a variable acl_libdirstem2, as a secondary possible value for
dnl acl_libdirstem, either the same as acl_libdirstem or "lib/sparcv9" or
dnl "lib/amd64".
AC_DEFUN([AC_LIB_PREPARE_MULTILIB],
[
dnl There is no formal standard regarding lib and lib64.
dnl On glibc systems, the current practice is that on a system supporting
dnl 32-bit and 64-bit instruction sets or ABIs, 64-bit libraries go under
dnl $prefix/lib64 and 32-bit libraries go under $prefix/lib. We determine
dnl the compiler's default mode by looking at the compiler's library search
dnl path. If at least one of its elements ends in /lib64 or points to a
dnl directory whose absolute pathname ends in /lib64, we assume a 64-bit ABI.
dnl Otherwise we use the default, namely "lib".
dnl On Solaris systems, the current practice is that on a system supporting
dnl 32-bit and 64-bit instruction sets or ABIs, 64-bit libraries go under
dnl $prefix/lib/64 (which is a symlink to either $prefix/lib/sparcv9 or
dnl $prefix/lib/amd64) and 32-bit libraries go under $prefix/lib.
AC_REQUIRE([AC_CANONICAL_HOST])
acl_libdirstem=lib
acl_libdirstem2=
case "$host_os" in
solaris*)
dnl See Solaris 10 Software Developer Collection > Solaris 64-bit Developer's Guide > The Development Environment
dnl <http://docs.sun.com/app/docs/doc/816-5138/dev-env?l=en&a=view>.
dnl "Portable Makefiles should refer to any library directories using the 64 symbolic link."
dnl But we want to recognize the sparcv9 or amd64 subdirectory also if the
dnl symlink is missing, so we set acl_libdirstem2 too.
AC_CACHE_CHECK([for 64-bit host], [gl_cv_solaris_64bit],
[AC_EGREP_CPP([sixtyfour bits], [
#ifdef _LP64
sixtyfour bits
#endif
], [gl_cv_solaris_64bit=yes], [gl_cv_solaris_64bit=no])
])
if test $gl_cv_solaris_64bit = yes; then
acl_libdirstem=lib/64
case "$host_cpu" in
sparc*) acl_libdirstem2=lib/sparcv9 ;;
i*86 | x86_64) acl_libdirstem2=lib/amd64 ;;
esac
fi
;;
*)
searchpath=`(LC_ALL=C $CC -print-search-dirs) 2>/dev/null | sed -n -e 's,^libraries: ,,p' | sed -e 's,^=,,'`
if test -n "$searchpath"; then
acl_save_IFS="${IFS= }"; IFS=":"
for searchdir in $searchpath; do
if test -d "$searchdir"; then
case "$searchdir" in
*/lib64/ | */lib64 ) acl_libdirstem=lib64 ;;
*/../ | */.. )
# Better ignore directories of this form. They are misleading.
;;
*) searchdir=`cd "$searchdir" && pwd`
case "$searchdir" in
*/lib64 ) acl_libdirstem=lib64 ;;
esac ;;
esac
fi
done
IFS="$acl_save_IFS"
fi
;;
esac
test -n "$acl_libdirstem2" || acl_libdirstem2="$acl_libdirstem"
])

42
gnulib/import/m4/lock.m4 Normal file
View File

@ -0,0 +1,42 @@
# lock.m4 serial 13 (gettext-0.18.2)
dnl Copyright (C) 2005-2016 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
dnl From Bruno Haible.
AC_DEFUN([gl_LOCK],
[
AC_REQUIRE([gl_THREADLIB])
if test "$gl_threads_api" = posix; then
# OSF/1 4.0 and Mac OS X 10.1 lack the pthread_rwlock_t type and the
# pthread_rwlock_* functions.
AC_CHECK_TYPE([pthread_rwlock_t],
[AC_DEFINE([HAVE_PTHREAD_RWLOCK], [1],
[Define if the POSIX multithreading library has read/write locks.])],
[],
[#include <pthread.h>])
# glibc defines PTHREAD_MUTEX_RECURSIVE as enum, not as a macro.
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM(
[[#include <pthread.h>]],
[[
#if __FreeBSD__ == 4
error "No, in FreeBSD 4.0 recursive mutexes actually don't work."
#elif (defined __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ \
&& __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1070)
error "No, in Mac OS X < 10.7 recursive mutexes actually don't work."
#else
int x = (int)PTHREAD_MUTEX_RECURSIVE;
return !x;
#endif
]])],
[AC_DEFINE([HAVE_PTHREAD_MUTEX_RECURSIVE], [1],
[Define if the <pthread.h> defines PTHREAD_MUTEX_RECURSIVE.])])
fi
gl_PREREQ_LOCK
])
# Prerequisites of lib/glthread/lock.c.
AC_DEFUN([gl_PREREQ_LOCK], [:])

View File

@ -0,0 +1,187 @@
# strerror_r.m4 serial 18
dnl Copyright (C) 2002, 2007-2016 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
AC_DEFUN([gl_FUNC_STRERROR_R],
[
AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
AC_REQUIRE([gl_FUNC_STRERROR_R_WORKS])
dnl Persuade Solaris <string.h> to declare strerror_r().
AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
dnl Some systems don't declare strerror_r() if _THREAD_SAFE and _REENTRANT
dnl are not defined.
AC_CHECK_DECL([strerror_r],
[HAVE_DECL_STRERROR_R=1], [HAVE_DECL_STRERROR_R=0])
AC_DEFINE_UNQUOTED([HAVE_DECL_STRERROR_R_ORIG], [$HAVE_DECL_STRERROR_R],
[Define to 1 if you have the declaration of 'strerror_r' in the system include files, or to 0 otherwise.])
if test $ac_cv_func_strerror_r = yes; then
if test "$ERRNO_H:$REPLACE_STRERROR_0" = :0; then
if test $gl_cv_func_strerror_r_posix_signature = yes; then
case "$gl_cv_func_strerror_r_works" in
dnl The system's strerror_r has bugs. Replace it.
*no) REPLACE_STRERROR_R=1 ;;
esac
else
dnl The system's strerror_r() has a wrong signature. Replace it.
REPLACE_STRERROR_R=1
fi
else
dnl The system's strerror_r() cannot know about the new errno values we
dnl add to <errno.h>, or any fix for strerror(0). Replace it.
REPLACE_STRERROR_R=1
fi
fi
# Overwrite the findings of AC_FUNC_STRERROR_R (for code that uses that).
AC_REQUIRE([AC_FUNC_STRERROR_R])
])
# If this module is in use, we unconditionally want POSIX semantics; so
# replace autoconf's macro with a version that does not probe
AC_DEFUN([AC_FUNC_STRERROR_R], [
AC_DEFINE([HAVE_DECL_STRERROR_R], [1],
[Define to 1, since you should have the declaration of strerror_r.])
AC_DEFINE([HAVE_STRERROR_R], [1],
[Define to 1, since you should have the function strerror_r.])
AC_DEFINE([STRERROR_R_CHAR_P], [0],
[Define to 0, since strerror_r should not return char *.])
])
# Prerequisites of lib/strerror_r.c.
AC_DEFUN([gl_PREREQ_STRERROR_R], [
dnl glibc >= 2.3.4 and cygwin 1.7.9 have a function __xpg_strerror_r.
AC_CHECK_FUNCS_ONCE([__xpg_strerror_r])
AC_CHECK_FUNCS_ONCE([catgets])
AC_CHECK_FUNCS_ONCE([snprintf])
])
# Detect if strerror_r works, but without affecting whether a replacement
# strerror_r will be used.
AC_DEFUN([gl_FUNC_STRERROR_R_WORKS],
[
AC_REQUIRE([gl_HEADER_ERRNO_H])
AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
AC_REQUIRE([gl_FUNC_STRERROR_0])
AC_CHECK_FUNC([strerror_r])
if test $ac_cv_func_strerror_r = yes; then
if test "$ERRNO_H:$REPLACE_STRERROR_0" = :0; then
dnl The POSIX prototype is: int strerror_r (int, char *, size_t);
dnl glibc, Cygwin: char *strerror_r (int, char *, size_t);
dnl AIX 5.1, OSF/1 5.1: int strerror_r (int, char *, int);
AC_CACHE_CHECK([for strerror_r with POSIX signature],
[gl_cv_func_strerror_r_posix_signature],
[AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(
[[#include <string.h>
int strerror_r (int, char *, size_t);
]],
[])],
[gl_cv_func_strerror_r_posix_signature=yes],
[gl_cv_func_strerror_r_posix_signature=no])
])
if test $gl_cv_func_strerror_r_posix_signature = yes; then
dnl AIX 6.1 strerror_r fails by returning -1, not an error number.
dnl HP-UX 11.31 strerror_r always fails when the buffer length argument
dnl is less than 80.
dnl FreeBSD 8.s strerror_r claims failure on 0
dnl Mac OS X 10.5 strerror_r treats 0 like -1
dnl Solaris 10 strerror_r corrupts errno on failure
AC_CACHE_CHECK([whether strerror_r works],
[gl_cv_func_strerror_r_works],
[AC_RUN_IFELSE(
[AC_LANG_PROGRAM(
[[#include <errno.h>
#include <string.h>
]],
[[int result = 0;
char buf[79];
if (strerror_r (EACCES, buf, 0) < 0)
result |= 1;
errno = 0;
if (strerror_r (EACCES, buf, sizeof buf) != 0)
result |= 2;
strcpy (buf, "Unknown");
if (strerror_r (0, buf, sizeof buf) != 0)
result |= 4;
if (errno)
result |= 8;
if (strstr (buf, "nknown") || strstr (buf, "ndefined"))
result |= 0x10;
errno = 0;
*buf = 0;
if (strerror_r (-3, buf, sizeof buf) < 0)
result |= 0x20;
if (errno)
result |= 0x40;
if (!*buf)
result |= 0x80;
return result;
]])],
[gl_cv_func_strerror_r_works=yes],
[gl_cv_func_strerror_r_works=no],
[
changequote(,)dnl
case "$host_os" in
# Guess no on AIX.
aix*) gl_cv_func_strerror_r_works="guessing no";;
# Guess no on HP-UX.
hpux*) gl_cv_func_strerror_r_works="guessing no";;
# Guess no on BSD variants.
*bsd*) gl_cv_func_strerror_r_works="guessing no";;
# Guess yes otherwise.
*) gl_cv_func_strerror_r_works="guessing yes";;
esac
changequote([,])dnl
])
])
else
dnl The system's strerror() has a wrong signature.
dnl glibc >= 2.3.4 and cygwin 1.7.9 have a function __xpg_strerror_r.
AC_CHECK_FUNCS_ONCE([__xpg_strerror_r])
dnl In glibc < 2.14, __xpg_strerror_r does not populate buf on failure.
dnl In cygwin < 1.7.10, __xpg_strerror_r clobbers strerror's buffer.
if test $ac_cv_func___xpg_strerror_r = yes; then
AC_CACHE_CHECK([whether __xpg_strerror_r works],
[gl_cv_func_strerror_r_works],
[AC_RUN_IFELSE(
[AC_LANG_PROGRAM(
[[#include <errno.h>
#include <string.h>
extern
#ifdef __cplusplus
"C"
#endif
int __xpg_strerror_r(int, char *, size_t);
]],
[[int result = 0;
char buf[256] = "^";
char copy[256];
char *str = strerror (-1);
strcpy (copy, str);
if (__xpg_strerror_r (-2, buf, 1) == 0)
result |= 1;
if (*buf)
result |= 2;
__xpg_strerror_r (-2, buf, 256);
if (strcmp (str, copy))
result |= 4;
return result;
]])],
[gl_cv_func_strerror_r_works=yes],
[gl_cv_func_strerror_r_works=no],
[dnl Guess no on all platforms that have __xpg_strerror_r,
dnl at least until fixed glibc and cygwin are more common.
gl_cv_func_strerror_r_works="guessing no"
])
])
fi
fi
fi
fi
])

View File

@ -0,0 +1,389 @@
# threadlib.m4 serial 11 (gettext-0.18.2)
dnl Copyright (C) 2005-2016 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
dnl From Bruno Haible.
dnl gl_THREADLIB
dnl ------------
dnl Tests for a multithreading library to be used.
dnl If the configure.ac contains a definition of the gl_THREADLIB_DEFAULT_NO
dnl (it must be placed before the invocation of gl_THREADLIB_EARLY!), then the
dnl default is 'no', otherwise it is system dependent. In both cases, the user
dnl can change the choice through the options --enable-threads=choice or
dnl --disable-threads.
dnl Defines at most one of the macros USE_POSIX_THREADS, USE_SOLARIS_THREADS,
dnl USE_PTH_THREADS, USE_WINDOWS_THREADS
dnl Sets the variables LIBTHREAD and LTLIBTHREAD to the linker options for use
dnl in a Makefile (LIBTHREAD for use without libtool, LTLIBTHREAD for use with
dnl libtool).
dnl Sets the variables LIBMULTITHREAD and LTLIBMULTITHREAD similarly, for
dnl programs that really need multithread functionality. The difference
dnl between LIBTHREAD and LIBMULTITHREAD is that on platforms supporting weak
dnl symbols, typically LIBTHREAD is empty whereas LIBMULTITHREAD is not.
dnl Adds to CPPFLAGS the flag -D_REENTRANT or -D_THREAD_SAFE if needed for
dnl multithread-safe programs.
AC_DEFUN([gl_THREADLIB_EARLY],
[
AC_REQUIRE([gl_THREADLIB_EARLY_BODY])
])
dnl The guts of gl_THREADLIB_EARLY. Needs to be expanded only once.
AC_DEFUN([gl_THREADLIB_EARLY_BODY],
[
dnl Ordering constraints: This macro modifies CPPFLAGS in a way that
dnl influences the result of the autoconf tests that test for *_unlocked
dnl declarations, on AIX 5 at least. Therefore it must come early.
AC_BEFORE([$0], [gl_FUNC_GLIBC_UNLOCKED_IO])dnl
AC_BEFORE([$0], [gl_ARGP])dnl
AC_REQUIRE([AC_CANONICAL_HOST])
dnl _GNU_SOURCE is needed for pthread_rwlock_t on glibc systems.
dnl AC_USE_SYSTEM_EXTENSIONS was introduced in autoconf 2.60 and obsoletes
dnl AC_GNU_SOURCE.
m4_ifdef([AC_USE_SYSTEM_EXTENSIONS],
[AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])],
[AC_REQUIRE([AC_GNU_SOURCE])])
dnl Check for multithreading.
m4_ifdef([gl_THREADLIB_DEFAULT_NO],
[m4_divert_text([DEFAULTS], [gl_use_threads_default=no])],
[m4_divert_text([DEFAULTS], [gl_use_threads_default=])])
AC_ARG_ENABLE([threads],
AC_HELP_STRING([--enable-threads={posix|solaris|pth|windows}], [specify multithreading API])m4_ifdef([gl_THREADLIB_DEFAULT_NO], [], [
AC_HELP_STRING([--disable-threads], [build without multithread safety])]),
[gl_use_threads=$enableval],
[if test -n "$gl_use_threads_default"; then
gl_use_threads="$gl_use_threads_default"
else
changequote(,)dnl
case "$host_os" in
dnl Disable multithreading by default on OSF/1, because it interferes
dnl with fork()/exec(): When msgexec is linked with -lpthread, its
dnl child process gets an endless segmentation fault inside execvp().
dnl Disable multithreading by default on Cygwin 1.5.x, because it has
dnl bugs that lead to endless loops or crashes. See
dnl <http://cygwin.com/ml/cygwin/2009-08/msg00283.html>.
osf*) gl_use_threads=no ;;
cygwin*)
case `uname -r` in
1.[0-5].*) gl_use_threads=no ;;
*) gl_use_threads=yes ;;
esac
;;
*) gl_use_threads=yes ;;
esac
changequote([,])dnl
fi
])
if test "$gl_use_threads" = yes || test "$gl_use_threads" = posix; then
# For using <pthread.h>:
case "$host_os" in
osf*)
# On OSF/1, the compiler needs the flag -D_REENTRANT so that it
# groks <pthread.h>. cc also understands the flag -pthread, but
# we don't use it because 1. gcc-2.95 doesn't understand -pthread,
# 2. putting a flag into CPPFLAGS that has an effect on the linker
# causes the AC_LINK_IFELSE test below to succeed unexpectedly,
# leading to wrong values of LIBTHREAD and LTLIBTHREAD.
CPPFLAGS="$CPPFLAGS -D_REENTRANT"
;;
esac
# Some systems optimize for single-threaded programs by default, and
# need special flags to disable these optimizations. For example, the
# definition of 'errno' in <errno.h>.
case "$host_os" in
aix* | freebsd*) CPPFLAGS="$CPPFLAGS -D_THREAD_SAFE" ;;
solaris*) CPPFLAGS="$CPPFLAGS -D_REENTRANT" ;;
esac
fi
])
dnl The guts of gl_THREADLIB. Needs to be expanded only once.
AC_DEFUN([gl_THREADLIB_BODY],
[
AC_REQUIRE([gl_THREADLIB_EARLY_BODY])
gl_threads_api=none
LIBTHREAD=
LTLIBTHREAD=
LIBMULTITHREAD=
LTLIBMULTITHREAD=
if test "$gl_use_threads" != no; then
dnl Check whether the compiler and linker support weak declarations.
AC_CACHE_CHECK([whether imported symbols can be declared weak],
[gl_cv_have_weak],
[gl_cv_have_weak=no
dnl First, test whether the compiler accepts it syntactically.
AC_LINK_IFELSE(
[AC_LANG_PROGRAM(
[[extern void xyzzy ();
#pragma weak xyzzy]],
[[xyzzy();]])],
[gl_cv_have_weak=maybe])
if test $gl_cv_have_weak = maybe; then
dnl Second, test whether it actually works. On Cygwin 1.7.2, with
dnl gcc 4.3, symbols declared weak always evaluate to the address 0.
AC_RUN_IFELSE(
[AC_LANG_SOURCE([[
#include <stdio.h>
#pragma weak fputs
int main ()
{
return (fputs == NULL);
}]])],
[gl_cv_have_weak=yes],
[gl_cv_have_weak=no],
[dnl When cross-compiling, assume that only ELF platforms support
dnl weak symbols.
AC_EGREP_CPP([Extensible Linking Format],
[#ifdef __ELF__
Extensible Linking Format
#endif
],
[gl_cv_have_weak="guessing yes"],
[gl_cv_have_weak="guessing no"])
])
fi
])
if test "$gl_use_threads" = yes || test "$gl_use_threads" = posix; then
# On OSF/1, the compiler needs the flag -pthread or -D_REENTRANT so that
# it groks <pthread.h>. It's added above, in gl_THREADLIB_EARLY_BODY.
AC_CHECK_HEADER([pthread.h],
[gl_have_pthread_h=yes], [gl_have_pthread_h=no])
if test "$gl_have_pthread_h" = yes; then
# Other possible tests:
# -lpthreads (FSU threads, PCthreads)
# -lgthreads
gl_have_pthread=
# Test whether both pthread_mutex_lock and pthread_mutexattr_init exist
# in libc. IRIX 6.5 has the first one in both libc and libpthread, but
# the second one only in libpthread, and lock.c needs it.
#
# If -pthread works, prefer it to -lpthread, since Ubuntu 14.04
# needs -pthread for some reason. See:
# http://lists.gnu.org/archive/html/bug-gnulib/2014-09/msg00023.html
save_LIBS=$LIBS
for gl_pthread in '' '-pthread'; do
LIBS="$LIBS $gl_pthread"
AC_LINK_IFELSE(
[AC_LANG_PROGRAM(
[[#include <pthread.h>
pthread_mutex_t m;
pthread_mutexattr_t ma;
]],
[[pthread_mutex_lock (&m);
pthread_mutexattr_init (&ma);]])],
[gl_have_pthread=yes
LIBTHREAD=$gl_pthread LTLIBTHREAD=$gl_pthread
LIBMULTITHREAD=$gl_pthread LTLIBMULTITHREAD=$gl_pthread])
LIBS=$save_LIBS
test -n "$gl_have_pthread" && break
done
# Test for libpthread by looking for pthread_kill. (Not pthread_self,
# since it is defined as a macro on OSF/1.)
if test -n "$gl_have_pthread" && test -z "$LIBTHREAD"; then
# The program links fine without libpthread. But it may actually
# need to link with libpthread in order to create multiple threads.
AC_CHECK_LIB([pthread], [pthread_kill],
[LIBMULTITHREAD=-lpthread LTLIBMULTITHREAD=-lpthread
# On Solaris and HP-UX, most pthread functions exist also in libc.
# Therefore pthread_in_use() needs to actually try to create a
# thread: pthread_create from libc will fail, whereas
# pthread_create will actually create a thread.
case "$host_os" in
solaris* | hpux*)
AC_DEFINE([PTHREAD_IN_USE_DETECTION_HARD], [1],
[Define if the pthread_in_use() detection is hard.])
esac
])
elif test -z "$gl_have_pthread"; then
# Some library is needed. Try libpthread and libc_r.
AC_CHECK_LIB([pthread], [pthread_kill],
[gl_have_pthread=yes
LIBTHREAD=-lpthread LTLIBTHREAD=-lpthread
LIBMULTITHREAD=-lpthread LTLIBMULTITHREAD=-lpthread])
if test -z "$gl_have_pthread"; then
# For FreeBSD 4.
AC_CHECK_LIB([c_r], [pthread_kill],
[gl_have_pthread=yes
LIBTHREAD=-lc_r LTLIBTHREAD=-lc_r
LIBMULTITHREAD=-lc_r LTLIBMULTITHREAD=-lc_r])
fi
fi
if test -n "$gl_have_pthread"; then
gl_threads_api=posix
AC_DEFINE([USE_POSIX_THREADS], [1],
[Define if the POSIX multithreading library can be used.])
if test -n "$LIBMULTITHREAD" || test -n "$LTLIBMULTITHREAD"; then
if case "$gl_cv_have_weak" in *yes) true;; *) false;; esac; then
AC_DEFINE([USE_POSIX_THREADS_WEAK], [1],
[Define if references to the POSIX multithreading library should be made weak.])
LIBTHREAD=
LTLIBTHREAD=
fi
fi
fi
fi
fi
if test -z "$gl_have_pthread"; then
if test "$gl_use_threads" = yes || test "$gl_use_threads" = solaris; then
gl_have_solaristhread=
gl_save_LIBS="$LIBS"
LIBS="$LIBS -lthread"
AC_LINK_IFELSE(
[AC_LANG_PROGRAM(
[[
#include <thread.h>
#include <synch.h>
]],
[[thr_self();]])],
[gl_have_solaristhread=yes])
LIBS="$gl_save_LIBS"
if test -n "$gl_have_solaristhread"; then
gl_threads_api=solaris
LIBTHREAD=-lthread
LTLIBTHREAD=-lthread
LIBMULTITHREAD="$LIBTHREAD"
LTLIBMULTITHREAD="$LTLIBTHREAD"
AC_DEFINE([USE_SOLARIS_THREADS], [1],
[Define if the old Solaris multithreading library can be used.])
if case "$gl_cv_have_weak" in *yes) true;; *) false;; esac; then
AC_DEFINE([USE_SOLARIS_THREADS_WEAK], [1],
[Define if references to the old Solaris multithreading library should be made weak.])
LIBTHREAD=
LTLIBTHREAD=
fi
fi
fi
fi
if test "$gl_use_threads" = pth; then
gl_save_CPPFLAGS="$CPPFLAGS"
AC_LIB_LINKFLAGS([pth])
gl_have_pth=
gl_save_LIBS="$LIBS"
LIBS="$LIBS $LIBPTH"
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([[#include <pth.h>]], [[pth_self();]])],
[gl_have_pth=yes])
LIBS="$gl_save_LIBS"
if test -n "$gl_have_pth"; then
gl_threads_api=pth
LIBTHREAD="$LIBPTH"
LTLIBTHREAD="$LTLIBPTH"
LIBMULTITHREAD="$LIBTHREAD"
LTLIBMULTITHREAD="$LTLIBTHREAD"
AC_DEFINE([USE_PTH_THREADS], [1],
[Define if the GNU Pth multithreading library can be used.])
if test -n "$LIBMULTITHREAD" || test -n "$LTLIBMULTITHREAD"; then
if case "$gl_cv_have_weak" in *yes) true;; *) false;; esac; then
AC_DEFINE([USE_PTH_THREADS_WEAK], [1],
[Define if references to the GNU Pth multithreading library should be made weak.])
LIBTHREAD=
LTLIBTHREAD=
fi
fi
else
CPPFLAGS="$gl_save_CPPFLAGS"
fi
fi
if test -z "$gl_have_pthread"; then
case "$gl_use_threads" in
yes | windows | win32) # The 'win32' is for backward compatibility.
if { case "$host_os" in
mingw*) true;;
*) false;;
esac
}; then
gl_threads_api=windows
AC_DEFINE([USE_WINDOWS_THREADS], [1],
[Define if the native Windows multithreading API can be used.])
fi
;;
esac
fi
fi
AC_MSG_CHECKING([for multithread API to use])
AC_MSG_RESULT([$gl_threads_api])
AC_SUBST([LIBTHREAD])
AC_SUBST([LTLIBTHREAD])
AC_SUBST([LIBMULTITHREAD])
AC_SUBST([LTLIBMULTITHREAD])
])
AC_DEFUN([gl_THREADLIB],
[
AC_REQUIRE([gl_THREADLIB_EARLY])
AC_REQUIRE([gl_THREADLIB_BODY])
])
dnl gl_DISABLE_THREADS
dnl ------------------
dnl Sets the gl_THREADLIB default so that threads are not used by default.
dnl The user can still override it at installation time, by using the
dnl configure option '--enable-threads'.
AC_DEFUN([gl_DISABLE_THREADS], [
m4_divert_text([INIT_PREPARE], [gl_use_threads_default=no])
])
dnl Survey of platforms:
dnl
dnl Platform Available Compiler Supports test-lock
dnl flavours option weak result
dnl --------------- --------- --------- -------- ---------
dnl Linux 2.4/glibc posix -lpthread Y OK
dnl
dnl GNU Hurd/glibc posix
dnl
dnl Ubuntu 14.04 posix -pthread Y OK
dnl
dnl FreeBSD 5.3 posix -lc_r Y
dnl posix -lkse ? Y
dnl posix -lpthread ? Y
dnl posix -lthr Y
dnl
dnl FreeBSD 5.2 posix -lc_r Y
dnl posix -lkse Y
dnl posix -lthr Y
dnl
dnl FreeBSD 4.0,4.10 posix -lc_r Y OK
dnl
dnl NetBSD 1.6 --
dnl
dnl OpenBSD 3.4 posix -lpthread Y OK
dnl
dnl Mac OS X 10.[123] posix -lpthread Y OK
dnl
dnl Solaris 7,8,9 posix -lpthread Y Sol 7,8: 0.0; Sol 9: OK
dnl solaris -lthread Y Sol 7,8: 0.0; Sol 9: OK
dnl
dnl HP-UX 11 posix -lpthread N (cc) OK
dnl Y (gcc)
dnl
dnl IRIX 6.5 posix -lpthread Y 0.5
dnl
dnl AIX 4.3,5.1 posix -lpthread N AIX 4: 0.5; AIX 5: OK
dnl
dnl OSF/1 4.0,5.1 posix -pthread (cc) N OK
dnl -lpthread (gcc) Y
dnl
dnl Cygwin posix -lpthread Y OK
dnl
dnl Any of the above pth -lpth 0.0
dnl
dnl Mingw windows N OK
dnl
dnl BeOS 5 --
dnl
dnl The test-lock result shows what happens if in test-lock.c EXPLICIT_YIELD is
dnl turned off:
dnl OK if all three tests terminate OK,
dnl 0.5 if the first test terminates OK but the second one loops endlessly,
dnl 0.0 if the first test already loops endlessly.

338
gnulib/import/strerror_r.c Normal file
View File

@ -0,0 +1,338 @@
/* strerror_r.c --- POSIX compatible system error routine
Copyright (C) 2010-2016 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 <http://www.gnu.org/licenses/>. */
/* Written by Bruno Haible <bruno@clisp.org>, 2010. */
#include <config.h>
/* Enable declaration of sys_nerr and sys_errlist in <errno.h> on NetBSD. */
#define _NETBSD_SOURCE 1
/* Specification. */
#include <string.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include "strerror-override.h"
#if (__GLIBC__ >= 2 || defined __UCLIBC__ || defined __CYGWIN__) && HAVE___XPG_STRERROR_R /* glibc >= 2.3.4, cygwin >= 1.7.9 */
# define USE_XPG_STRERROR_R 1
extern
#ifdef __cplusplus
"C"
#endif
int __xpg_strerror_r (int errnum, char *buf, size_t buflen);
#elif HAVE_DECL_STRERROR_R_ORIG && !(__GLIBC__ >= 2 || defined __UCLIBC__ || defined __CYGWIN__)
/* The system's strerror_r function is OK, except that its third argument
is 'int', not 'size_t', or its return type is wrong. */
# include <limits.h>
# define USE_SYSTEM_STRERROR_R 1
#else /* (__GLIBC__ >= 2 || defined __UCLIBC__ || defined __CYGWIN__ ? !HAVE___XPG_STRERROR_R : !HAVE_DECL_STRERROR_R) */
/* Use the system's strerror(). Exclude glibc and cygwin because the
system strerror_r has the wrong return type, and cygwin 1.7.9
strerror_r clobbers strerror. */
# undef strerror
# define USE_SYSTEM_STRERROR 1
# if defined __NetBSD__ || defined __hpux || ((defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__) || defined __sgi || (defined __sun && !defined _LP64) || defined __CYGWIN__
/* No locking needed. */
/* Get catgets internationalization functions. */
# if HAVE_CATGETS
# include <nl_types.h>
# endif
#ifdef __cplusplus
extern "C" {
#endif
/* Get sys_nerr, sys_errlist on HP-UX (otherwise only declared in C++ mode).
Get sys_nerr, sys_errlist on IRIX (otherwise only declared with _SGIAPI). */
# if defined __hpux || defined __sgi
extern int sys_nerr;
extern char *sys_errlist[];
# endif
/* Get sys_nerr on Solaris. */
# if defined __sun && !defined _LP64
extern int sys_nerr;
# endif
#ifdef __cplusplus
}
#endif
# else
# include "glthread/lock.h"
/* This lock protects the buffer returned by strerror(). We assume that
no other uses of strerror() exist in the program. */
gl_lock_define_initialized(static, strerror_lock)
# endif
#endif
/* On MSVC, there is no snprintf() function, just a _snprintf().
It is of lower quality, but sufficient for the simple use here.
We only have to make sure to NUL terminate the result (_snprintf
does not NUL terminate, like strncpy). */
#if !HAVE_SNPRINTF
static int
local_snprintf (char *buf, size_t buflen, const char *format, ...)
{
va_list args;
int result;
va_start (args, format);
result = _vsnprintf (buf, buflen, format, args);
va_end (args);
if (buflen > 0 && (result < 0 || result >= buflen))
buf[buflen - 1] = '\0';
return result;
}
# define snprintf local_snprintf
#endif
/* Copy as much of MSG into BUF as possible, without corrupting errno.
Return 0 if MSG fit in BUFLEN, otherwise return ERANGE. */
static int
safe_copy (char *buf, size_t buflen, const char *msg)
{
size_t len = strlen (msg);
int ret;
if (len < buflen)
{
/* Although POSIX allows memcpy() to corrupt errno, we don't
know of any implementation where this is a real problem. */
memcpy (buf, msg, len + 1);
ret = 0;
}
else
{
memcpy (buf, msg, buflen - 1);
buf[buflen - 1] = '\0';
ret = ERANGE;
}
return ret;
}
int
strerror_r (int errnum, char *buf, size_t buflen)
#undef strerror_r
{
/* Filter this out now, so that rest of this replacement knows that
there is room for a non-empty message and trailing NUL. */
if (buflen <= 1)
{
if (buflen)
*buf = '\0';
return ERANGE;
}
*buf = '\0';
/* Check for gnulib overrides. */
{
char const *msg = strerror_override (errnum);
if (msg)
return safe_copy (buf, buflen, msg);
}
{
int ret;
int saved_errno = errno;
#if USE_XPG_STRERROR_R
{
ret = __xpg_strerror_r (errnum, buf, buflen);
if (ret < 0)
ret = errno;
if (!*buf)
{
/* glibc 2.13 would not touch buf on err, so we have to fall
back to GNU strerror_r which always returns a thread-safe
untruncated string to (partially) copy into our buf. */
safe_copy (buf, buflen, strerror_r (errnum, buf, buflen));
}
}
#elif USE_SYSTEM_STRERROR_R
if (buflen > INT_MAX)
buflen = INT_MAX;
# ifdef __hpux
/* On HP-UX 11.31, strerror_r always fails when buflen < 80; it
also fails to change buf on EINVAL. */
{
char stackbuf[80];
if (buflen < sizeof stackbuf)
{
ret = strerror_r (errnum, stackbuf, sizeof stackbuf);
if (ret == 0)
ret = safe_copy (buf, buflen, stackbuf);
}
else
ret = strerror_r (errnum, buf, buflen);
}
# else
ret = strerror_r (errnum, buf, buflen);
/* Some old implementations may return (-1, EINVAL) instead of EINVAL. */
if (ret < 0)
ret = errno;
# endif
# ifdef _AIX
/* AIX returns 0 rather than ERANGE when truncating strings; try
again until we are sure we got the entire string. */
if (!ret && strlen (buf) == buflen - 1)
{
char stackbuf[STACKBUF_LEN];
size_t len;
strerror_r (errnum, stackbuf, sizeof stackbuf);
len = strlen (stackbuf);
/* STACKBUF_LEN should have been large enough. */
if (len + 1 == sizeof stackbuf)
abort ();
if (buflen <= len)
ret = ERANGE;
}
# else
/* Solaris 10 does not populate buf on ERANGE. OpenBSD 4.7
truncates early on ERANGE rather than return a partial integer.
We prefer the maximal string. We set buf[0] earlier, and we
know of no implementation that modifies buf to be an
unterminated string, so this strlen should be portable in
practice (rather than pulling in a safer strnlen). */
if (ret == ERANGE && strlen (buf) < buflen - 1)
{
char stackbuf[STACKBUF_LEN];
/* STACKBUF_LEN should have been large enough. */
if (strerror_r (errnum, stackbuf, sizeof stackbuf) == ERANGE)
abort ();
safe_copy (buf, buflen, stackbuf);
}
# endif
#else /* USE_SYSTEM_STRERROR */
/* Try to do what strerror (errnum) does, but without clobbering the
buffer used by strerror(). */
# if defined __NetBSD__ || defined __hpux || ((defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__) || defined __CYGWIN__ /* NetBSD, HP-UX, native Windows, Cygwin */
/* NetBSD: sys_nerr, sys_errlist are declared through _NETBSD_SOURCE
and <errno.h> above.
HP-UX: sys_nerr, sys_errlist are declared explicitly above.
native Windows: sys_nerr, sys_errlist are declared in <stdlib.h>.
Cygwin: sys_nerr, sys_errlist are declared in <errno.h>. */
if (errnum >= 0 && errnum < sys_nerr)
{
# if HAVE_CATGETS && (defined __NetBSD__ || defined __hpux)
# if defined __NetBSD__
nl_catd catd = catopen ("libc", NL_CAT_LOCALE);
const char *errmsg =
(catd != (nl_catd)-1
? catgets (catd, 1, errnum, sys_errlist[errnum])
: sys_errlist[errnum]);
# endif
# if defined __hpux
nl_catd catd = catopen ("perror", NL_CAT_LOCALE);
const char *errmsg =
(catd != (nl_catd)-1
? catgets (catd, 1, 1 + errnum, sys_errlist[errnum])
: sys_errlist[errnum]);
# endif
# else
const char *errmsg = sys_errlist[errnum];
# endif
if (errmsg == NULL || *errmsg == '\0')
ret = EINVAL;
else
ret = safe_copy (buf, buflen, errmsg);
# if HAVE_CATGETS && (defined __NetBSD__ || defined __hpux)
if (catd != (nl_catd)-1)
catclose (catd);
# endif
}
else
ret = EINVAL;
# elif defined __sgi || (defined __sun && !defined _LP64) /* IRIX, Solaris <= 9 32-bit */
/* For a valid error number, the system's strerror() function returns
a pointer to a not copied string, not to a buffer. */
if (errnum >= 0 && errnum < sys_nerr)
{
char *errmsg = strerror (errnum);
if (errmsg == NULL || *errmsg == '\0')
ret = EINVAL;
else
ret = safe_copy (buf, buflen, errmsg);
}
else
ret = EINVAL;
# else
gl_lock_lock (strerror_lock);
{
char *errmsg = strerror (errnum);
/* For invalid error numbers, strerror() on
- IRIX 6.5 returns NULL,
- HP-UX 11 returns an empty string. */
if (errmsg == NULL || *errmsg == '\0')
ret = EINVAL;
else
ret = safe_copy (buf, buflen, errmsg);
}
gl_lock_unlock (strerror_lock);
# endif
#endif
if (ret == EINVAL && !*buf)
snprintf (buf, buflen, "Unknown error %d", errnum);
errno = saved_errno;
return ret;
}
}

View File

@ -55,6 +55,7 @@ IMPORTED_GNULIB_MODULES="\
setenv \
signal-h \
strchrnul \
strerror_r-posix \
strstr \
strtok_r \
sys_stat \