mirror of https://github.com/GOSTSec/sgminer
Con Kolivas
14 years ago
34 changed files with 4221 additions and 478 deletions
@ -0,0 +1,26 @@ |
|||||||
|
/* A C macro for declaring that specific arguments must not be NULL.
|
||||||
|
Copyright (C) 2009-2011 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/>. */
|
||||||
|
|
||||||
|
/* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools
|
||||||
|
that the values passed as arguments n, ..., m must be non-NULL pointers. |
||||||
|
n = 1 stands for the first argument, n = 2 for the second argument etc. */ |
||||||
|
#ifndef _GL_ARG_NONNULL |
||||||
|
# if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || __GNUC__ > 3 |
||||||
|
# define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params)) |
||||||
|
# else |
||||||
|
# define _GL_ARG_NONNULL(params) |
||||||
|
# endif |
||||||
|
#endif |
@ -1,3 +1,19 @@ |
|||||||
|
/* C++ compatible function declaration macros.
|
||||||
|
Copyright (C) 2010-2011 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/>. */
|
||||||
|
|
||||||
#ifndef _GL_CXXDEFS_H |
#ifndef _GL_CXXDEFS_H |
||||||
#define _GL_CXXDEFS_H |
#define _GL_CXXDEFS_H |
||||||
|
|
@ -1,9 +0,0 @@ |
|||||||
/Makefile.am |
|
||||||
/dummy.c |
|
||||||
/memchr.c |
|
||||||
/memchr.valgrind |
|
||||||
/memmem.c |
|
||||||
/stddef.in.h |
|
||||||
/stdint.in.h |
|
||||||
/str-two-way.h |
|
||||||
/string.in.h |
|
@ -0,0 +1,313 @@ |
|||||||
|
## DO NOT EDIT! GENERATED AUTOMATICALLY!
|
||||||
|
## Process this file with automake to produce Makefile.in.
|
||||||
|
# Copyright (C) 2002-2011 Free Software Foundation, Inc.
|
||||||
|
#
|
||||||
|
# This file is free software, distributed under the terms of the GNU
|
||||||
|
# General Public License. As a special exception to the GNU General
|
||||||
|
# Public License, this file may be distributed as part of a program
|
||||||
|
# that contains a configuration script generated by Autoconf, under
|
||||||
|
# the same distribution terms as the rest of that program.
|
||||||
|
#
|
||||||
|
# Generated by gnulib-tool.
|
||||||
|
# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=. --no-conditional-dependencies --no-libtool --macro-prefix=gl memmem
|
||||||
|
|
||||||
|
AUTOMAKE_OPTIONS = 1.5 gnits |
||||||
|
|
||||||
|
SUBDIRS = |
||||||
|
noinst_HEADERS = |
||||||
|
noinst_LIBRARIES = |
||||||
|
noinst_LTLIBRARIES = |
||||||
|
EXTRA_DIST = |
||||||
|
BUILT_SOURCES = |
||||||
|
SUFFIXES = |
||||||
|
MOSTLYCLEANFILES = core *.stackdump |
||||||
|
MOSTLYCLEANDIRS = |
||||||
|
CLEANFILES = |
||||||
|
DISTCLEANFILES = |
||||||
|
MAINTAINERCLEANFILES = |
||||||
|
|
||||||
|
AM_CPPFLAGS = |
||||||
|
AM_CFLAGS = |
||||||
|
|
||||||
|
noinst_LIBRARIES += libgnu.a |
||||||
|
|
||||||
|
libgnu_a_SOURCES = |
||||||
|
libgnu_a_LIBADD = $(gl_LIBOBJS) |
||||||
|
libgnu_a_DEPENDENCIES = $(gl_LIBOBJS) |
||||||
|
EXTRA_libgnu_a_SOURCES = |
||||||
|
|
||||||
|
## begin gnulib module arg-nonnull
|
||||||
|
|
||||||
|
# The BUILT_SOURCES created by this Makefile snippet are not used via #include
|
||||||
|
# statements but through direct file reference. Therefore this snippet must be
|
||||||
|
# present in all Makefile.am that need it. This is ensured by the applicability
|
||||||
|
# 'all' defined above.
|
||||||
|
|
||||||
|
BUILT_SOURCES += arg-nonnull.h |
||||||
|
# The arg-nonnull.h that gets inserted into generated .h files is the same as
|
||||||
|
# build-aux/arg-nonnull.h, except that it has the copyright header cut off.
|
||||||
|
arg-nonnull.h: $(top_srcdir)/./arg-nonnull.h |
||||||
|
$(AM_V_GEN)rm -f $@-t $@ && \
|
||||||
|
sed -n -e '/GL_ARG_NONNULL/,$$p' \
|
||||||
|
< $(top_srcdir)/./arg-nonnull.h \
|
||||||
|
> $@-t && \
|
||||||
|
mv $@-t $@ |
||||||
|
MOSTLYCLEANFILES += arg-nonnull.h arg-nonnull.h-t |
||||||
|
|
||||||
|
ARG_NONNULL_H=arg-nonnull.h |
||||||
|
|
||||||
|
EXTRA_DIST += $(top_srcdir)/./arg-nonnull.h |
||||||
|
|
||||||
|
## end gnulib module arg-nonnull
|
||||||
|
|
||||||
|
## begin gnulib module c++defs
|
||||||
|
|
||||||
|
# The BUILT_SOURCES created by this Makefile snippet are not used via #include
|
||||||
|
# statements but through direct file reference. Therefore this snippet must be
|
||||||
|
# present in all Makefile.am that need it. This is ensured by the applicability
|
||||||
|
# 'all' defined above.
|
||||||
|
|
||||||
|
BUILT_SOURCES += c++defs.h |
||||||
|
# The c++defs.h that gets inserted into generated .h files is the same as
|
||||||
|
# build-aux/c++defs.h, except that it has the copyright header cut off.
|
||||||
|
c++defs.h: $(top_srcdir)/./c++defs.h |
||||||
|
$(AM_V_GEN)rm -f $@-t $@ && \
|
||||||
|
sed -n -e '/_GL_CXXDEFS/,$$p' \
|
||||||
|
< $(top_srcdir)/./c++defs.h \
|
||||||
|
> $@-t && \
|
||||||
|
mv $@-t $@ |
||||||
|
MOSTLYCLEANFILES += c++defs.h c++defs.h-t |
||||||
|
|
||||||
|
CXXDEFS_H=c++defs.h |
||||||
|
|
||||||
|
EXTRA_DIST += $(top_srcdir)/./c++defs.h |
||||||
|
|
||||||
|
## end gnulib module c++defs
|
||||||
|
|
||||||
|
## begin gnulib module memchr
|
||||||
|
|
||||||
|
|
||||||
|
EXTRA_DIST += memchr.c memchr.valgrind |
||||||
|
|
||||||
|
EXTRA_libgnu_a_SOURCES += memchr.c |
||||||
|
|
||||||
|
## end gnulib module memchr
|
||||||
|
|
||||||
|
## begin gnulib module memmem-simple
|
||||||
|
|
||||||
|
|
||||||
|
EXTRA_DIST += memmem.c str-two-way.h |
||||||
|
|
||||||
|
EXTRA_libgnu_a_SOURCES += memmem.c |
||||||
|
|
||||||
|
## end gnulib module memmem-simple
|
||||||
|
|
||||||
|
## begin gnulib module stddef
|
||||||
|
|
||||||
|
BUILT_SOURCES += $(STDDEF_H) |
||||||
|
|
||||||
|
# We need the following in order to create <stddef.h> when the system
|
||||||
|
# doesn't have one that works with the given compiler.
|
||||||
|
if GL_GENERATE_STDDEF_H |
||||||
|
stddef.h: stddef.in.h $(top_builddir)/config.status |
||||||
|
$(AM_V_GEN)rm -f $@-t $@ && \
|
||||||
|
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
|
||||||
|
sed -e 's|@''GUARD_PREFIX''@|GL|g' \
|
||||||
|
-e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
|
||||||
|
-e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
|
||||||
|
-e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
|
||||||
|
-e 's|@''NEXT_STDDEF_H''@|$(NEXT_STDDEF_H)|g' \
|
||||||
|
-e 's|@''HAVE_WCHAR_T''@|$(HAVE_WCHAR_T)|g' \
|
||||||
|
-e 's|@''REPLACE_NULL''@|$(REPLACE_NULL)|g' \
|
||||||
|
< $(srcdir)/stddef.in.h; \
|
||||||
|
} > $@-t && \
|
||||||
|
mv $@-t $@ |
||||||
|
else |
||||||
|
stddef.h: $(top_builddir)/config.status |
||||||
|
rm -f $@ |
||||||
|
endif |
||||||
|
MOSTLYCLEANFILES += stddef.h stddef.h-t |
||||||
|
|
||||||
|
EXTRA_DIST += stddef.in.h |
||||||
|
|
||||||
|
## end gnulib module stddef
|
||||||
|
|
||||||
|
## begin gnulib module stdint
|
||||||
|
|
||||||
|
BUILT_SOURCES += $(STDINT_H) |
||||||
|
|
||||||
|
# We need the following in order to create <stdint.h> when the system
|
||||||
|
# doesn't have one that works with the given compiler.
|
||||||
|
if GL_GENERATE_STDINT_H |
||||||
|
stdint.h: stdint.in.h $(top_builddir)/config.status |
||||||
|
$(AM_V_GEN)rm -f $@-t $@ && \
|
||||||
|
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
|
||||||
|
sed -e 's|@''GUARD_PREFIX''@|GL|g' \
|
||||||
|
-e 's/@''HAVE_STDINT_H''@/$(HAVE_STDINT_H)/g' \
|
||||||
|
-e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
|
||||||
|
-e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
|
||||||
|
-e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
|
||||||
|
-e 's|@''NEXT_STDINT_H''@|$(NEXT_STDINT_H)|g' \
|
||||||
|
-e 's/@''HAVE_SYS_TYPES_H''@/$(HAVE_SYS_TYPES_H)/g' \
|
||||||
|
-e 's/@''HAVE_INTTYPES_H''@/$(HAVE_INTTYPES_H)/g' \
|
||||||
|
-e 's/@''HAVE_SYS_INTTYPES_H''@/$(HAVE_SYS_INTTYPES_H)/g' \
|
||||||
|
-e 's/@''HAVE_SYS_BITYPES_H''@/$(HAVE_SYS_BITYPES_H)/g' \
|
||||||
|
-e 's/@''HAVE_WCHAR_H''@/$(HAVE_WCHAR_H)/g' \
|
||||||
|
-e 's/@''HAVE_LONG_LONG_INT''@/$(HAVE_LONG_LONG_INT)/g' \
|
||||||
|
-e 's/@''HAVE_UNSIGNED_LONG_LONG_INT''@/$(HAVE_UNSIGNED_LONG_LONG_INT)/g' \
|
||||||
|
-e 's/@''APPLE_UNIVERSAL_BUILD''@/$(APPLE_UNIVERSAL_BUILD)/g' \
|
||||||
|
-e 's/@''BITSIZEOF_PTRDIFF_T''@/$(BITSIZEOF_PTRDIFF_T)/g' \
|
||||||
|
-e 's/@''PTRDIFF_T_SUFFIX''@/$(PTRDIFF_T_SUFFIX)/g' \
|
||||||
|
-e 's/@''BITSIZEOF_SIG_ATOMIC_T''@/$(BITSIZEOF_SIG_ATOMIC_T)/g' \
|
||||||
|
-e 's/@''HAVE_SIGNED_SIG_ATOMIC_T''@/$(HAVE_SIGNED_SIG_ATOMIC_T)/g' \
|
||||||
|
-e 's/@''SIG_ATOMIC_T_SUFFIX''@/$(SIG_ATOMIC_T_SUFFIX)/g' \
|
||||||
|
-e 's/@''BITSIZEOF_SIZE_T''@/$(BITSIZEOF_SIZE_T)/g' \
|
||||||
|
-e 's/@''SIZE_T_SUFFIX''@/$(SIZE_T_SUFFIX)/g' \
|
||||||
|
-e 's/@''BITSIZEOF_WCHAR_T''@/$(BITSIZEOF_WCHAR_T)/g' \
|
||||||
|
-e 's/@''HAVE_SIGNED_WCHAR_T''@/$(HAVE_SIGNED_WCHAR_T)/g' \
|
||||||
|
-e 's/@''WCHAR_T_SUFFIX''@/$(WCHAR_T_SUFFIX)/g' \
|
||||||
|
-e 's/@''BITSIZEOF_WINT_T''@/$(BITSIZEOF_WINT_T)/g' \
|
||||||
|
-e 's/@''HAVE_SIGNED_WINT_T''@/$(HAVE_SIGNED_WINT_T)/g' \
|
||||||
|
-e 's/@''WINT_T_SUFFIX''@/$(WINT_T_SUFFIX)/g' \
|
||||||
|
< $(srcdir)/stdint.in.h; \
|
||||||
|
} > $@-t && \
|
||||||
|
mv $@-t $@ |
||||||
|
else |
||||||
|
stdint.h: $(top_builddir)/config.status |
||||||
|
rm -f $@ |
||||||
|
endif |
||||||
|
MOSTLYCLEANFILES += stdint.h stdint.h-t |
||||||
|
|
||||||
|
EXTRA_DIST += stdint.in.h |
||||||
|
|
||||||
|
## end gnulib module stdint
|
||||||
|
|
||||||
|
## begin gnulib module string
|
||||||
|
|
||||||
|
BUILT_SOURCES += string.h |
||||||
|
|
||||||
|
# We need the following in order to create <string.h> when the system
|
||||||
|
# doesn't have one that works with the given compiler.
|
||||||
|
string.h: string.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) |
||||||
|
$(AM_V_GEN)rm -f $@-t $@ && \
|
||||||
|
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
|
||||||
|
sed -e 's|@''GUARD_PREFIX''@|GL|g' \
|
||||||
|
-e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
|
||||||
|
-e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
|
||||||
|
-e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
|
||||||
|
-e 's|@''NEXT_STRING_H''@|$(NEXT_STRING_H)|g' \
|
||||||
|
-e 's/@''GNULIB_MBSLEN''@/$(GNULIB_MBSLEN)/g' \
|
||||||
|
-e 's/@''GNULIB_MBSNLEN''@/$(GNULIB_MBSNLEN)/g' \
|
||||||
|
-e 's/@''GNULIB_MBSCHR''@/$(GNULIB_MBSCHR)/g' \
|
||||||
|
-e 's/@''GNULIB_MBSRCHR''@/$(GNULIB_MBSRCHR)/g' \
|
||||||
|
-e 's/@''GNULIB_MBSSTR''@/$(GNULIB_MBSSTR)/g' \
|
||||||
|
-e 's/@''GNULIB_MBSCASECMP''@/$(GNULIB_MBSCASECMP)/g' \
|
||||||
|
-e 's/@''GNULIB_MBSNCASECMP''@/$(GNULIB_MBSNCASECMP)/g' \
|
||||||
|
-e 's/@''GNULIB_MBSPCASECMP''@/$(GNULIB_MBSPCASECMP)/g' \
|
||||||
|
-e 's/@''GNULIB_MBSCASESTR''@/$(GNULIB_MBSCASESTR)/g' \
|
||||||
|
-e 's/@''GNULIB_MBSCSPN''@/$(GNULIB_MBSCSPN)/g' \
|
||||||
|
-e 's/@''GNULIB_MBSPBRK''@/$(GNULIB_MBSPBRK)/g' \
|
||||||
|
-e 's/@''GNULIB_MBSSPN''@/$(GNULIB_MBSSPN)/g' \
|
||||||
|
-e 's/@''GNULIB_MBSSEP''@/$(GNULIB_MBSSEP)/g' \
|
||||||
|
-e 's/@''GNULIB_MBSTOK_R''@/$(GNULIB_MBSTOK_R)/g' \
|
||||||
|
-e 's/@''GNULIB_MEMCHR''@/$(GNULIB_MEMCHR)/g' \
|
||||||
|
-e 's/@''GNULIB_MEMMEM''@/$(GNULIB_MEMMEM)/g' \
|
||||||
|
-e 's/@''GNULIB_MEMPCPY''@/$(GNULIB_MEMPCPY)/g' \
|
||||||
|
-e 's/@''GNULIB_MEMRCHR''@/$(GNULIB_MEMRCHR)/g' \
|
||||||
|
-e 's/@''GNULIB_RAWMEMCHR''@/$(GNULIB_RAWMEMCHR)/g' \
|
||||||
|
-e 's/@''GNULIB_STPCPY''@/$(GNULIB_STPCPY)/g' \
|
||||||
|
-e 's/@''GNULIB_STPNCPY''@/$(GNULIB_STPNCPY)/g' \
|
||||||
|
-e 's/@''GNULIB_STRCHRNUL''@/$(GNULIB_STRCHRNUL)/g' \
|
||||||
|
-e 's/@''GNULIB_STRDUP''@/$(GNULIB_STRDUP)/g' \
|
||||||
|
-e 's/@''GNULIB_STRNCAT''@/$(GNULIB_STRNCAT)/g' \
|
||||||
|
-e 's/@''GNULIB_STRNDUP''@/$(GNULIB_STRNDUP)/g' \
|
||||||
|
-e 's/@''GNULIB_STRNLEN''@/$(GNULIB_STRNLEN)/g' \
|
||||||
|
-e 's/@''GNULIB_STRPBRK''@/$(GNULIB_STRPBRK)/g' \
|
||||||
|
-e 's/@''GNULIB_STRSEP''@/$(GNULIB_STRSEP)/g' \
|
||||||
|
-e 's/@''GNULIB_STRSTR''@/$(GNULIB_STRSTR)/g' \
|
||||||
|
-e 's/@''GNULIB_STRCASESTR''@/$(GNULIB_STRCASESTR)/g' \
|
||||||
|
-e 's/@''GNULIB_STRTOK_R''@/$(GNULIB_STRTOK_R)/g' \
|
||||||
|
-e 's/@''GNULIB_STRERROR''@/$(GNULIB_STRERROR)/g' \
|
||||||
|
-e 's/@''GNULIB_STRERROR_R''@/$(GNULIB_STRERROR_R)/g' \
|
||||||
|
-e 's/@''GNULIB_STRSIGNAL''@/$(GNULIB_STRSIGNAL)/g' \
|
||||||
|
-e 's/@''GNULIB_STRVERSCMP''@/$(GNULIB_STRVERSCMP)/g' \
|
||||||
|
< $(srcdir)/string.in.h | \
|
||||||
|
sed -e 's|@''HAVE_MBSLEN''@|$(HAVE_MBSLEN)|g' \
|
||||||
|
-e 's|@''HAVE_MEMCHR''@|$(HAVE_MEMCHR)|g' \
|
||||||
|
-e 's|@''HAVE_DECL_MEMMEM''@|$(HAVE_DECL_MEMMEM)|g' \
|
||||||
|
-e 's|@''HAVE_MEMPCPY''@|$(HAVE_MEMPCPY)|g' \
|
||||||
|
-e 's|@''HAVE_DECL_MEMRCHR''@|$(HAVE_DECL_MEMRCHR)|g' \
|
||||||
|
-e 's|@''HAVE_RAWMEMCHR''@|$(HAVE_RAWMEMCHR)|g' \
|
||||||
|
-e 's|@''HAVE_STPCPY''@|$(HAVE_STPCPY)|g' \
|
||||||
|
-e 's|@''HAVE_STPNCPY''@|$(HAVE_STPNCPY)|g' \
|
||||||
|
-e 's|@''HAVE_STRCHRNUL''@|$(HAVE_STRCHRNUL)|g' \
|
||||||
|
-e 's|@''HAVE_DECL_STRDUP''@|$(HAVE_DECL_STRDUP)|g' \
|
||||||
|
-e 's|@''HAVE_DECL_STRNDUP''@|$(HAVE_DECL_STRNDUP)|g' \
|
||||||
|
-e 's|@''HAVE_DECL_STRNLEN''@|$(HAVE_DECL_STRNLEN)|g' \
|
||||||
|
-e 's|@''HAVE_STRPBRK''@|$(HAVE_STRPBRK)|g' \
|
||||||
|
-e 's|@''HAVE_STRSEP''@|$(HAVE_STRSEP)|g' \
|
||||||
|
-e 's|@''HAVE_STRCASESTR''@|$(HAVE_STRCASESTR)|g' \
|
||||||
|
-e 's|@''HAVE_DECL_STRTOK_R''@|$(HAVE_DECL_STRTOK_R)|g' \
|
||||||
|
-e 's|@''HAVE_DECL_STRERROR_R''@|$(HAVE_DECL_STRERROR_R)|g' \
|
||||||
|
-e 's|@''HAVE_DECL_STRSIGNAL''@|$(HAVE_DECL_STRSIGNAL)|g' \
|
||||||
|
-e 's|@''HAVE_STRVERSCMP''@|$(HAVE_STRVERSCMP)|g' \
|
||||||
|
-e 's|@''REPLACE_STPNCPY''@|$(REPLACE_STPNCPY)|g' \
|
||||||
|
-e 's|@''REPLACE_MEMCHR''@|$(REPLACE_MEMCHR)|g' \
|
||||||
|
-e 's|@''REPLACE_MEMMEM''@|$(REPLACE_MEMMEM)|g' \
|
||||||
|
-e 's|@''REPLACE_STRCASESTR''@|$(REPLACE_STRCASESTR)|g' \
|
||||||
|
-e 's|@''REPLACE_STRCHRNUL''@|$(REPLACE_STRCHRNUL)|g' \
|
||||||
|
-e 's|@''REPLACE_STRDUP''@|$(REPLACE_STRDUP)|g' \
|
||||||
|
-e 's|@''REPLACE_STRSTR''@|$(REPLACE_STRSTR)|g' \
|
||||||
|
-e 's|@''REPLACE_STRERROR''@|$(REPLACE_STRERROR)|g' \
|
||||||
|
-e 's|@''REPLACE_STRERROR_R''@|$(REPLACE_STRERROR_R)|g' \
|
||||||
|
-e 's|@''REPLACE_STRNCAT''@|$(REPLACE_STRNCAT)|g' \
|
||||||
|
-e 's|@''REPLACE_STRNDUP''@|$(REPLACE_STRNDUP)|g' \
|
||||||
|
-e 's|@''REPLACE_STRNLEN''@|$(REPLACE_STRNLEN)|g' \
|
||||||
|
-e 's|@''REPLACE_STRSIGNAL''@|$(REPLACE_STRSIGNAL)|g' \
|
||||||
|
-e 's|@''REPLACE_STRTOK_R''@|$(REPLACE_STRTOK_R)|g' \
|
||||||
|
-e 's|@''UNDEFINE_STRTOK_R''@|$(UNDEFINE_STRTOK_R)|g' \
|
||||||
|
-e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
|
||||||
|
-e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
|
||||||
|
-e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)'; \
|
||||||
|
< $(srcdir)/string.in.h; \
|
||||||
|
} > $@-t && \
|
||||||
|
mv $@-t $@ |
||||||
|
MOSTLYCLEANFILES += string.h string.h-t |
||||||
|
|
||||||
|
EXTRA_DIST += string.in.h |
||||||
|
|
||||||
|
## end gnulib module string
|
||||||
|
|
||||||
|
## begin gnulib module warn-on-use
|
||||||
|
|
||||||
|
BUILT_SOURCES += warn-on-use.h |
||||||
|
# The warn-on-use.h that gets inserted into generated .h files is the same as
|
||||||
|
# build-aux/warn-on-use.h, except that it has the copyright header cut off.
|
||||||
|
warn-on-use.h: $(top_srcdir)/./warn-on-use.h |
||||||
|
$(AM_V_GEN)rm -f $@-t $@ && \
|
||||||
|
sed -n -e '/^.ifndef/,$$p' \
|
||||||
|
< $(top_srcdir)/./warn-on-use.h \
|
||||||
|
> $@-t && \
|
||||||
|
mv $@-t $@ |
||||||
|
MOSTLYCLEANFILES += warn-on-use.h warn-on-use.h-t |
||||||
|
|
||||||
|
WARN_ON_USE_H=warn-on-use.h |
||||||
|
|
||||||
|
EXTRA_DIST += $(top_srcdir)/./warn-on-use.h |
||||||
|
|
||||||
|
## end gnulib module warn-on-use
|
||||||
|
|
||||||
|
## begin gnulib module dummy
|
||||||
|
|
||||||
|
libgnu_a_SOURCES += dummy.c |
||||||
|
|
||||||
|
## end gnulib module dummy
|
||||||
|
|
||||||
|
|
||||||
|
mostlyclean-local: mostlyclean-generic |
||||||
|
@for dir in '' $(MOSTLYCLEANDIRS); do \
|
||||||
|
if test -n "$$dir" && test -d $$dir; then \
|
||||||
|
echo "rmdir $$dir"; rmdir $$dir; \
|
||||||
|
fi; \
|
||||||
|
done; \
|
||||||
|
: |
@ -1,10 +0,0 @@ |
|||||||
/* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools
|
|
||||||
that the values passed as arguments n, ..., m must be non-NULL pointers. |
|
||||||
n = 1 stands for the first argument, n = 2 for the second argument etc. */ |
|
||||||
#ifndef _GL_ARG_NONNULL |
|
||||||
# if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || __GNUC__ > 3 |
|
||||||
# define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params)) |
|
||||||
# else |
|
||||||
# define _GL_ARG_NONNULL(params) |
|
||||||
# endif |
|
||||||
#endif |
|
@ -0,0 +1,42 @@ |
|||||||
|
/* A dummy file, to prevent empty libraries from breaking builds.
|
||||||
|
Copyright (C) 2004, 2007, 2009-2011 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/>. */
|
||||||
|
|
||||||
|
/* Some systems, reportedly OpenBSD and Mac OS X, refuse to create
|
||||||
|
libraries without any object files. You might get an error like: |
||||||
|
|
||||||
|
> ar cru .libs/libgl.a |
||||||
|
> ar: no archive members specified |
||||||
|
|
||||||
|
Compiling this file, and adding its object file to the library, will |
||||||
|
prevent the library from being empty. */ |
||||||
|
|
||||||
|
/* Some systems, such as Solaris with cc 5.0, refuse to work with libraries
|
||||||
|
that don't export any symbol. You might get an error like: |
||||||
|
|
||||||
|
> cc ... libgnu.a |
||||||
|
> ild: (bad file) garbled symbol table in archive ../gllib/libgnu.a |
||||||
|
|
||||||
|
Compiling this file, and adding its object file to the library, will |
||||||
|
prevent the library from exporting no symbols. */ |
||||||
|
|
||||||
|
#ifdef __sun |
||||||
|
/* This declaration ensures that the library will export at least 1 symbol. */ |
||||||
|
int gl_dummy_symbol; |
||||||
|
#else |
||||||
|
/* This declaration is solely to ensure that after preprocessing
|
||||||
|
this file is never empty. */ |
||||||
|
typedef int dummy; |
||||||
|
#endif |
@ -0,0 +1,172 @@ |
|||||||
|
/* Copyright (C) 1991, 1993, 1996-1997, 1999-2000, 2003-2004, 2006, 2008-2011
|
||||||
|
Free Software Foundation, Inc. |
||||||
|
|
||||||
|
Based on strlen implementation by Torbjorn Granlund (tege@sics.se), |
||||||
|
with help from Dan Sahlin (dan@sics.se) and |
||||||
|
commentary by Jim Blandy (jimb@ai.mit.edu); |
||||||
|
adaptation to memchr suggested by Dick Karpinski (dick@cca.ucsf.edu), |
||||||
|
and implemented by Roland McGrath (roland@ai.mit.edu). |
||||||
|
|
||||||
|
NOTE: The canonical source of this file is maintained with the GNU C Library. |
||||||
|
Bugs can be reported to bug-glibc@prep.ai.mit.edu. |
||||||
|
|
||||||
|
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 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/>. */
|
||||||
|
|
||||||
|
#ifndef _LIBC |
||||||
|
# include <config.h> |
||||||
|
#endif |
||||||
|
|
||||||
|
#include <string.h> |
||||||
|
|
||||||
|
#include <stddef.h> |
||||||
|
|
||||||
|
#if defined _LIBC |
||||||
|
# include <memcopy.h> |
||||||
|
#else |
||||||
|
# define reg_char char |
||||||
|
#endif |
||||||
|
|
||||||
|
#include <limits.h> |
||||||
|
|
||||||
|
#if HAVE_BP_SYM_H || defined _LIBC |
||||||
|
# include <bp-sym.h> |
||||||
|
#else |
||||||
|
# define BP_SYM(sym) sym |
||||||
|
#endif |
||||||
|
|
||||||
|
#undef __memchr |
||||||
|
#ifdef _LIBC |
||||||
|
# undef memchr |
||||||
|
#endif |
||||||
|
|
||||||
|
#ifndef weak_alias |
||||||
|
# define __memchr memchr |
||||||
|
#endif |
||||||
|
|
||||||
|
/* Search no more than N bytes of S for C. */ |
||||||
|
void * |
||||||
|
__memchr (void const *s, int c_in, size_t n) |
||||||
|
{ |
||||||
|
/* On 32-bit hardware, choosing longword to be a 32-bit unsigned
|
||||||
|
long instead of a 64-bit uintmax_t tends to give better |
||||||
|
performance. On 64-bit hardware, unsigned long is generally 64 |
||||||
|
bits already. Change this typedef to experiment with |
||||||
|
performance. */ |
||||||
|
typedef unsigned long int longword; |
||||||
|
|
||||||
|
const unsigned char *char_ptr; |
||||||
|
const longword *longword_ptr; |
||||||
|
longword repeated_one; |
||||||
|
longword repeated_c; |
||||||
|
unsigned reg_char c; |
||||||
|
|
||||||
|
c = (unsigned char) c_in; |
||||||
|
|
||||||
|
/* Handle the first few bytes by reading one byte at a time.
|
||||||
|
Do this until CHAR_PTR is aligned on a longword boundary. */ |
||||||
|
for (char_ptr = (const unsigned char *) s; |
||||||
|
n > 0 && (size_t) char_ptr % sizeof (longword) != 0; |
||||||
|
--n, ++char_ptr) |
||||||
|
if (*char_ptr == c) |
||||||
|
return (void *) char_ptr; |
||||||
|
|
||||||
|
longword_ptr = (const longword *) char_ptr; |
||||||
|
|
||||||
|
/* All these elucidatory comments refer to 4-byte longwords,
|
||||||
|
but the theory applies equally well to any size longwords. */ |
||||||
|
|
||||||
|
/* Compute auxiliary longword values:
|
||||||
|
repeated_one is a value which has a 1 in every byte. |
||||||
|
repeated_c has c in every byte. */ |
||||||
|
repeated_one = 0x01010101; |
||||||
|
repeated_c = c | (c << 8); |
||||||
|
repeated_c |= repeated_c << 16; |
||||||
|
if (0xffffffffU < (longword) -1) |
||||||
|
{ |
||||||
|
repeated_one |= repeated_one << 31 << 1; |
||||||
|
repeated_c |= repeated_c << 31 << 1; |
||||||
|
if (8 < sizeof (longword)) |
||||||
|
{ |
||||||
|
size_t i; |
||||||
|
|
||||||
|
for (i = 64; i < sizeof (longword) * 8; i *= 2) |
||||||
|
{ |
||||||
|
repeated_one |= repeated_one << i; |
||||||
|
repeated_c |= repeated_c << i; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/* Instead of the traditional loop which tests each byte, we will test a
|
||||||
|
longword at a time. The tricky part is testing if *any of the four* |
||||||
|
bytes in the longword in question are equal to c. We first use an xor |
||||||
|
with repeated_c. This reduces the task to testing whether *any of the |
||||||
|
four* bytes in longword1 is zero. |
||||||
|
|
||||||
|
We compute tmp = |
||||||
|
((longword1 - repeated_one) & ~longword1) & (repeated_one << 7). |
||||||
|
That is, we perform the following operations: |
||||||
|
1. Subtract repeated_one. |
||||||
|
2. & ~longword1. |
||||||
|
3. & a mask consisting of 0x80 in every byte. |
||||||
|
Consider what happens in each byte: |
||||||
|
- If a byte of longword1 is zero, step 1 and 2 transform it into 0xff, |
||||||
|
and step 3 transforms it into 0x80. A carry can also be propagated |
||||||
|
to more significant bytes. |
||||||
|
- If a byte of longword1 is nonzero, let its lowest 1 bit be at |
||||||
|
position k (0 <= k <= 7); so the lowest k bits are 0. After step 1, |
||||||
|
the byte ends in a single bit of value 0 and k bits of value 1. |
||||||
|
After step 2, the result is just k bits of value 1: 2^k - 1. After |
||||||
|
step 3, the result is 0. And no carry is produced. |
||||||
|
So, if longword1 has only non-zero bytes, tmp is zero. |
||||||
|
Whereas if longword1 has a zero byte, call j the position of the least |
||||||
|
significant zero byte. Then the result has a zero at positions 0, ..., |
||||||
|
j-1 and a 0x80 at position j. We cannot predict the result at the more |
||||||
|
significant bytes (positions j+1..3), but it does not matter since we |
||||||
|
already have a non-zero bit at position 8*j+7. |
||||||
|
|
||||||
|
So, the test whether any byte in longword1 is zero is equivalent to |
||||||
|
testing whether tmp is nonzero. */ |
||||||
|
|
||||||
|
while (n >= sizeof (longword)) |
||||||
|
{ |
||||||
|
longword longword1 = *longword_ptr ^ repeated_c; |
||||||
|
|
||||||
|
if ((((longword1 - repeated_one) & ~longword1) |
||||||
|
& (repeated_one << 7)) != 0) |
||||||
|
break; |
||||||
|
longword_ptr++; |
||||||
|
n -= sizeof (longword); |
||||||
|
} |
||||||
|
|
||||||
|
char_ptr = (const unsigned char *) longword_ptr; |
||||||
|
|
||||||
|
/* At this point, we know that either n < sizeof (longword), or one of the
|
||||||
|
sizeof (longword) bytes starting at char_ptr is == c. On little-endian |
||||||
|
machines, we could determine the first such byte without any further |
||||||
|
memory accesses, just by looking at the tmp result from the last loop |
||||||
|
iteration. But this does not work on big-endian machines. Choose code |
||||||
|
that works in both cases. */ |
||||||
|
|
||||||
|
for (; n > 0; --n, ++char_ptr) |
||||||
|
{ |
||||||
|
if (*char_ptr == c) |
||||||
|
return (void *) char_ptr; |
||||||
|
} |
||||||
|
|
||||||
|
return NULL; |
||||||
|
} |
||||||
|
#ifdef weak_alias |
||||||
|
weak_alias (__memchr, BP_SYM (memchr)) |
||||||
|
#endif |
@ -0,0 +1,14 @@ |
|||||||
|
# Suppress a valgrind message about use of uninitialized memory in memchr(). |
||||||
|
# POSIX states that when the character is found, memchr must not read extra |
||||||
|
# bytes in an overestimated length (for example, where memchr is used to |
||||||
|
# implement strnlen). However, we use a safe word read to provide a speedup. |
||||||
|
{ |
||||||
|
memchr-value4 |
||||||
|
Memcheck:Value4 |
||||||
|
fun:rpl_memchr |
||||||
|
} |
||||||
|
{ |
||||||
|
memchr-value8 |
||||||
|
Memcheck:Value8 |
||||||
|
fun:rpl_memchr |
||||||
|
} |
@ -0,0 +1,76 @@ |
|||||||
|
/* Copyright (C) 1991-1994, 1996-1998, 2000, 2004, 2007-2011 Free Software
|
||||||
|
Foundation, Inc. |
||||||
|
This file is part of the GNU C Library. |
||||||
|
|
||||||
|
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, write to the Free Software Foundation, |
||||||
|
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ |
||||||
|
|
||||||
|
/* This particular implementation was written by Eric Blake, 2008. */ |
||||||
|
|
||||||
|
#ifndef _LIBC |
||||||
|
# include <config.h> |
||||||
|
#endif |
||||||
|
|
||||||
|
/* Specification of memmem. */ |
||||||
|
#include <string.h> |
||||||
|
|
||||||
|
#ifndef _LIBC |
||||||
|
# define __builtin_expect(expr, val) (expr) |
||||||
|
#endif |
||||||
|
|
||||||
|
#define RETURN_TYPE void * |
||||||
|
#define AVAILABLE(h, h_l, j, n_l) ((j) <= (h_l) - (n_l)) |
||||||
|
#include "str-two-way.h" |
||||||
|
|
||||||
|
/* Return the first occurrence of NEEDLE in HAYSTACK. Return HAYSTACK
|
||||||
|
if NEEDLE_LEN is 0, otherwise NULL if NEEDLE is not found in |
||||||
|
HAYSTACK. */ |
||||||
|
void * |
||||||
|
memmem (const void *haystack_start, size_t haystack_len, |
||||||
|
const void *needle_start, size_t needle_len) |
||||||
|
{ |
||||||
|
/* Abstract memory is considered to be an array of 'unsigned char' values,
|
||||||
|
not an array of 'char' values. See ISO C 99 section 6.2.6.1. */ |
||||||
|
const unsigned char *haystack = (const unsigned char *) haystack_start; |
||||||
|
const unsigned char *needle = (const unsigned char *) needle_start; |
||||||
|
|
||||||
|
if (needle_len == 0) |
||||||
|
/* The first occurrence of the empty string is deemed to occur at
|
||||||
|
the beginning of the string. */ |
||||||
|
return (void *) haystack; |
||||||
|
|
||||||
|
/* Sanity check, otherwise the loop might search through the whole
|
||||||
|
memory. */ |
||||||
|
if (__builtin_expect (haystack_len < needle_len, 0)) |
||||||
|
return NULL; |
||||||
|
|
||||||
|
/* Use optimizations in memchr when possible, to reduce the search
|
||||||
|
size of haystack using a linear algorithm with a smaller |
||||||
|
coefficient. However, avoid memchr for long needles, since we |
||||||
|
can often achieve sublinear performance. */ |
||||||
|
if (needle_len < LONG_NEEDLE_THRESHOLD) |
||||||
|
{ |
||||||
|
haystack = memchr (haystack, *needle, haystack_len); |
||||||
|
if (!haystack || __builtin_expect (needle_len == 1, 0)) |
||||||
|
return (void *) haystack; |
||||||
|
haystack_len -= haystack - (const unsigned char *) haystack_start; |
||||||
|
if (haystack_len < needle_len) |
||||||
|
return NULL; |
||||||
|
return two_way_short_needle (haystack, haystack_len, needle, needle_len); |
||||||
|
} |
||||||
|
else |
||||||
|
return two_way_long_needle (haystack, haystack_len, needle, needle_len); |
||||||
|
} |
||||||
|
|
||||||
|
#undef LONG_NEEDLE_THRESHOLD |
@ -0,0 +1,87 @@ |
|||||||
|
/* A substitute for POSIX 2008 <stddef.h>, for platforms that have issues.
|
||||||
|
|
||||||
|
Copyright (C) 2009-2011 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, write to the Free Software Foundation, |
||||||
|
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ |
||||||
|
|
||||||
|
/* Written by Eric Blake. */ |
||||||
|
|
||||||
|
/*
|
||||||
|
* POSIX 2008 <stddef.h> for platforms that have issues. |
||||||
|
* <http://www.opengroup.org/susv3xbd/stddef.h.html>
|
||||||
|
*/ |
||||||
|
|
||||||
|
#if __GNUC__ >= 3 |
||||||
|
@PRAGMA_SYSTEM_HEADER@ |
||||||
|
#endif |
||||||
|
@PRAGMA_COLUMNS@ |
||||||
|
|
||||||
|
#if defined __need_wchar_t || defined __need_size_t \ |
||||||
|
|| defined __need_ptrdiff_t || defined __need_NULL \ |
||||||
|
|| defined __need_wint_t |
||||||
|
/* Special invocation convention inside gcc header files. In
|
||||||
|
particular, gcc provides a version of <stddef.h> that blindly |
||||||
|
redefines NULL even when __need_wint_t was defined, even though |
||||||
|
wint_t is not normally provided by <stddef.h>. Hence, we must |
||||||
|
remember if special invocation has ever been used to obtain wint_t, |
||||||
|
in which case we need to clean up NULL yet again. */ |
||||||
|
|
||||||
|
# if !(defined _@GUARD_PREFIX@_STDDEF_H && defined _GL_STDDEF_WINT_T) |
||||||
|
# ifdef __need_wint_t |
||||||
|
# undef _@GUARD_PREFIX@_STDDEF_H |
||||||
|
# define _GL_STDDEF_WINT_T |
||||||
|
# endif |
||||||
|
# @INCLUDE_NEXT@ @NEXT_STDDEF_H@ |
||||||
|
# endif |
||||||
|
|
||||||
|
#else |
||||||
|
/* Normal invocation convention. */ |
||||||
|
|
||||||
|
# ifndef _@GUARD_PREFIX@_STDDEF_H |
||||||
|
|
||||||
|
/* The include_next requires a split double-inclusion guard. */ |
||||||
|
|
||||||
|
# @INCLUDE_NEXT@ @NEXT_STDDEF_H@ |
||||||
|
|
||||||
|
# ifndef _@GUARD_PREFIX@_STDDEF_H |
||||||
|
# define _@GUARD_PREFIX@_STDDEF_H |
||||||
|
|
||||||
|
/* On NetBSD 5.0, the definition of NULL lacks proper parentheses. */ |
||||||
|
#if @REPLACE_NULL@ |
||||||
|
# undef NULL |
||||||
|
# ifdef __cplusplus |
||||||
|
/* ISO C++ says that the macro NULL must expand to an integer constant
|
||||||
|
expression, hence '((void *) 0)' is not allowed in C++. */ |
||||||
|
# if __GNUG__ >= 3 |
||||||
|
/* GNU C++ has a __null macro that behaves like an integer ('int' or
|
||||||
|
'long') but has the same size as a pointer. Use that, to avoid |
||||||
|
warnings. */ |
||||||
|
# define NULL __null |
||||||
|
# else |
||||||
|
# define NULL 0L |
||||||
|
# endif |
||||||
|
# else |
||||||
|
# define NULL ((void *) 0) |
||||||
|
# endif |
||||||
|
#endif |
||||||
|
|
||||||
|
/* Some platforms lack wchar_t. */ |
||||||
|
#if !@HAVE_WCHAR_T@ |
||||||
|
# define wchar_t int |
||||||
|
#endif |
||||||
|
|
||||||
|
# endif /* _@GUARD_PREFIX@_STDDEF_H */ |
||||||
|
# endif /* _@GUARD_PREFIX@_STDDEF_H */ |
||||||
|
#endif /* __need_XXX */ |
@ -0,0 +1,592 @@ |
|||||||
|
/* Copyright (C) 2001-2002, 2004-2011 Free Software Foundation, Inc.
|
||||||
|
Written by Paul Eggert, Bruno Haible, Sam Steingold, Peter Burwood. |
||||||
|
This file is part of gnulib. |
||||||
|
|
||||||
|
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, write to the Free Software Foundation, |
||||||
|
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ |
||||||
|
|
||||||
|
/*
|
||||||
|
* ISO C 99 <stdint.h> for platforms that lack it. |
||||||
|
* <http://www.opengroup.org/susv3xbd/stdint.h.html>
|
||||||
|
*/ |
||||||
|
|
||||||
|
#ifndef _@GUARD_PREFIX@_STDINT_H |
||||||
|
|
||||||
|
#if __GNUC__ >= 3 |
||||||
|
@PRAGMA_SYSTEM_HEADER@ |
||||||
|
#endif |
||||||
|
@PRAGMA_COLUMNS@ |
||||||
|
|
||||||
|
/* When including a system file that in turn includes <inttypes.h>,
|
||||||
|
use the system <inttypes.h>, not our substitute. This avoids |
||||||
|
problems with (for example) VMS, whose <sys/bitypes.h> includes |
||||||
|
<inttypes.h>. */ |
||||||
|
#define _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H |
||||||
|
|
||||||
|
/* Get those types that are already defined in other system include
|
||||||
|
files, so that we can "#define int8_t signed char" below without |
||||||
|
worrying about a later system include file containing a "typedef |
||||||
|
signed char int8_t;" that will get messed up by our macro. Our |
||||||
|
macros should all be consistent with the system versions, except |
||||||
|
for the "fast" types and macros, which we recommend against using |
||||||
|
in public interfaces due to compiler differences. */ |
||||||
|
|
||||||
|
#if @HAVE_STDINT_H@ |
||||||
|
# if defined __sgi && ! defined __c99 |
||||||
|
/* Bypass IRIX's <stdint.h> if in C89 mode, since it merely annoys users
|
||||||
|
with "This header file is to be used only for c99 mode compilations" |
||||||
|
diagnostics. */ |
||||||
|
# define __STDINT_H__ |
||||||
|
# endif |
||||||
|
/* Other systems may have an incomplete or buggy <stdint.h>.
|
||||||
|
Include it before <inttypes.h>, since any "#include <stdint.h>" |
||||||
|
in <inttypes.h> would reinclude us, skipping our contents because |
||||||
|
_@GUARD_PREFIX@_STDINT_H is defined. |
||||||
|
The include_next requires a split double-inclusion guard. */ |
||||||
|
# @INCLUDE_NEXT@ @NEXT_STDINT_H@ |
||||||
|
#endif |
||||||
|
|
||||||
|
#if ! defined _@GUARD_PREFIX@_STDINT_H && ! defined _GL_JUST_INCLUDE_SYSTEM_STDINT_H |
||||||
|
#define _@GUARD_PREFIX@_STDINT_H |
||||||
|
|
||||||
|
/* <sys/types.h> defines some of the stdint.h types as well, on glibc,
|
||||||
|
IRIX 6.5, and OpenBSD 3.8 (via <machine/types.h>). |
||||||
|
AIX 5.2 <sys/types.h> isn't needed and causes troubles. |
||||||
|
MacOS X 10.4.6 <sys/types.h> includes <stdint.h> (which is us), but |
||||||
|
relies on the system <stdint.h> definitions, so include |
||||||
|
<sys/types.h> after @NEXT_STDINT_H@. */ |
||||||
|
#if @HAVE_SYS_TYPES_H@ && ! defined _AIX |
||||||
|
# include <sys/types.h> |
||||||
|
#endif |
||||||
|
|
||||||
|
/* Get LONG_MIN, LONG_MAX, ULONG_MAX. */ |
||||||
|
#include <limits.h> |
||||||
|
|
||||||
|
#if @HAVE_INTTYPES_H@ |
||||||
|
/* In OpenBSD 3.8, <inttypes.h> includes <machine/types.h>, which defines
|
||||||
|
int{8,16,32,64}_t, uint{8,16,32,64}_t and __BIT_TYPES_DEFINED__. |
||||||
|
<inttypes.h> also defines intptr_t and uintptr_t. */ |
||||||
|
# include <inttypes.h> |
||||||
|
#elif @HAVE_SYS_INTTYPES_H@ |
||||||
|
/* Solaris 7 <sys/inttypes.h> has the types except the *_fast*_t types, and
|
||||||
|
the macros except for *_FAST*_*, INTPTR_MIN, PTRDIFF_MIN, PTRDIFF_MAX. */ |
||||||
|
# include <sys/inttypes.h> |
||||||
|
#endif |
||||||
|
|
||||||
|
#if @HAVE_SYS_BITYPES_H@ && ! defined __BIT_TYPES_DEFINED__ |
||||||
|
/* Linux libc4 >= 4.6.7 and libc5 have a <sys/bitypes.h> that defines
|
||||||
|
int{8,16,32,64}_t and __BIT_TYPES_DEFINED__. In libc5 >= 5.2.2 it is |
||||||
|
included by <sys/types.h>. */ |
||||||
|
# include <sys/bitypes.h> |
||||||
|
#endif |
||||||
|
|
||||||
|
#undef _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H |
||||||
|
|
||||||
|
/* Minimum and maximum values for an integer type under the usual assumption.
|
||||||
|
Return an unspecified value if BITS == 0, adding a check to pacify |
||||||
|
picky compilers. */ |
||||||
|
|
||||||
|
#define _STDINT_MIN(signed, bits, zero) \ |
||||||
|
((signed) ? (- ((zero) + 1) << ((bits) ? (bits) - 1 : 0)) : (zero)) |
||||||
|
|
||||||
|
#define _STDINT_MAX(signed, bits, zero) \ |
||||||
|
((signed) \ |
||||||
|
? ~ _STDINT_MIN (signed, bits, zero) \ |
||||||
|
: /* The expression for the unsigned case. The subtraction of (signed) \
|
||||||
|
is a nop in the unsigned case and avoids "signed integer overflow" \ |
||||||
|
warnings in the signed case. */ \ |
||||||
|
((((zero) + 1) << ((bits) ? (bits) - 1 - (signed) : 0)) - 1) * 2 + 1) |
||||||
|
|
||||||
|
#if !GNULIB_defined_stdint_types |
||||||
|
|
||||||
|
/* 7.18.1.1. Exact-width integer types */ |
||||||
|
|
||||||
|
/* Here we assume a standard architecture where the hardware integer
|
||||||
|
types have 8, 16, 32, optionally 64 bits. */ |
||||||
|
|
||||||
|
#undef int8_t |
||||||
|
#undef uint8_t |
||||||
|
typedef signed char gl_int8_t; |
||||||
|
typedef unsigned char gl_uint8_t; |
||||||
|
#define int8_t gl_int8_t |
||||||
|
#define uint8_t gl_uint8_t |
||||||
|
|
||||||
|
#undef int16_t |
||||||
|
#undef uint16_t |
||||||
|
typedef short int gl_int16_t; |
||||||
|
typedef unsigned short int gl_uint16_t; |
||||||
|
#define int16_t gl_int16_t |
||||||
|
#define uint16_t gl_uint16_t |
||||||
|
|
||||||
|
#undef int32_t |
||||||
|
#undef uint32_t |
||||||
|
typedef int gl_int32_t; |
||||||
|
typedef unsigned int gl_uint32_t; |
||||||
|
#define int32_t gl_int32_t |
||||||
|
#define uint32_t gl_uint32_t |
||||||
|
|
||||||
|
/* If the system defines INT64_MAX, assume int64_t works. That way,
|
||||||
|
if the underlying platform defines int64_t to be a 64-bit long long |
||||||
|
int, the code below won't mistakenly define it to be a 64-bit long |
||||||
|
int, which would mess up C++ name mangling. We must use #ifdef |
||||||
|
rather than #if, to avoid an error with HP-UX 10.20 cc. */ |
||||||
|
|
||||||
|
#ifdef INT64_MAX |
||||||
|
# define GL_INT64_T |
||||||
|
#else |
||||||
|
/* Do not undefine int64_t if gnulib is not being used with 64-bit
|
||||||
|
types, since otherwise it breaks platforms like Tandem/NSK. */ |
||||||
|
# if LONG_MAX >> 31 >> 31 == 1 |
||||||
|
# undef int64_t |
||||||
|
typedef long int gl_int64_t; |
||||||
|
# define int64_t gl_int64_t |
||||||
|
# define GL_INT64_T |
||||||
|
# elif defined _MSC_VER |
||||||
|
# undef int64_t |
||||||
|
typedef __int64 gl_int64_t; |
||||||
|
# define int64_t gl_int64_t |
||||||
|
# define GL_INT64_T |
||||||
|
# elif @HAVE_LONG_LONG_INT@ |
||||||
|
# undef int64_t |
||||||
|
typedef long long int gl_int64_t; |
||||||
|
# define int64_t gl_int64_t |
||||||
|
# define GL_INT64_T |
||||||
|
# endif |
||||||
|
#endif |
||||||
|
|
||||||
|
#ifdef UINT64_MAX |
||||||
|
# define GL_UINT64_T |
||||||
|
#else |
||||||
|
# if ULONG_MAX >> 31 >> 31 >> 1 == 1 |
||||||
|
# undef uint64_t |
||||||
|
typedef unsigned long int gl_uint64_t; |
||||||
|
# define uint64_t gl_uint64_t |
||||||
|
# define GL_UINT64_T |
||||||
|
# elif defined _MSC_VER |
||||||
|
# undef uint64_t |
||||||
|
typedef unsigned __int64 gl_uint64_t; |
||||||
|
# define uint64_t gl_uint64_t |
||||||
|
# define GL_UINT64_T |
||||||
|
# elif @HAVE_UNSIGNED_LONG_LONG_INT@ |
||||||
|
# undef uint64_t |
||||||
|
typedef unsigned long long int gl_uint64_t; |
||||||
|
# define uint64_t gl_uint64_t |
||||||
|
# define GL_UINT64_T |
||||||
|
# endif |
||||||
|
#endif |
||||||
|
|
||||||
|
/* Avoid collision with Solaris 2.5.1 <pthread.h> etc. */ |
||||||
|
#define _UINT8_T |
||||||
|
#define _UINT32_T |
||||||
|
#define _UINT64_T |
||||||
|
|
||||||
|
|
||||||
|
/* 7.18.1.2. Minimum-width integer types */ |
||||||
|
|
||||||
|
/* Here we assume a standard architecture where the hardware integer
|
||||||
|
types have 8, 16, 32, optionally 64 bits. Therefore the leastN_t types |
||||||
|
are the same as the corresponding N_t types. */ |
||||||
|
|
||||||
|
#undef int_least8_t |
||||||
|
#undef uint_least8_t |
||||||
|
#undef int_least16_t |
||||||
|
#undef uint_least16_t |
||||||
|
#undef int_least32_t |
||||||
|
#undef uint_least32_t |
||||||
|
#undef int_least64_t |
||||||
|
#undef uint_least64_t |
||||||
|
#define int_least8_t int8_t |
||||||
|
#define uint_least8_t uint8_t |
||||||
|
#define int_least16_t int16_t |
||||||
|
#define uint_least16_t uint16_t |
||||||
|
#define int_least32_t int32_t |
||||||
|
#define uint_least32_t uint32_t |
||||||
|
#ifdef GL_INT64_T |
||||||
|
# define int_least64_t int64_t |
||||||
|
#endif |
||||||
|
#ifdef GL_UINT64_T |
||||||
|
# define uint_least64_t uint64_t |
||||||
|
#endif |
||||||
|
|
||||||
|
/* 7.18.1.3. Fastest minimum-width integer types */ |
||||||
|
|
||||||
|
/* Note: Other <stdint.h> substitutes may define these types differently.
|
||||||
|
It is not recommended to use these types in public header files. */ |
||||||
|
|
||||||
|
/* Here we assume a standard architecture where the hardware integer
|
||||||
|
types have 8, 16, 32, optionally 64 bits. Therefore the fastN_t types |
||||||
|
are taken from the same list of types. Assume that 'long int' |
||||||
|
is fast enough for all narrower integers. */ |
||||||
|
|
||||||
|
#undef int_fast8_t |
||||||
|
#undef uint_fast8_t |
||||||
|
#undef int_fast16_t |
||||||
|
#undef uint_fast16_t |
||||||
|
#undef int_fast32_t |
||||||
|
#undef uint_fast32_t |
||||||
|
#undef int_fast64_t |
||||||
|
#undef uint_fast64_t |
||||||
|
typedef long int gl_int_fast8_t; |
||||||
|
typedef unsigned long int gl_uint_fast8_t; |
||||||
|
typedef long int gl_int_fast16_t; |
||||||
|
typedef unsigned long int gl_uint_fast16_t; |
||||||
|
typedef long int gl_int_fast32_t; |
||||||
|
typedef unsigned long int gl_uint_fast32_t; |
||||||
|
#define int_fast8_t gl_int_fast8_t |
||||||
|
#define uint_fast8_t gl_uint_fast8_t |
||||||
|
#define int_fast16_t gl_int_fast16_t |
||||||
|
#define uint_fast16_t gl_uint_fast16_t |
||||||
|
#define int_fast32_t gl_int_fast32_t |
||||||
|
#define uint_fast32_t gl_uint_fast32_t |
||||||
|
#ifdef GL_INT64_T |
||||||
|
# define int_fast64_t int64_t |
||||||
|
#endif |
||||||
|
#ifdef GL_UINT64_T |
||||||
|
# define uint_fast64_t uint64_t |
||||||
|
#endif |
||||||
|
|
||||||
|
/* 7.18.1.4. Integer types capable of holding object pointers */ |
||||||
|
|
||||||
|
#undef intptr_t |
||||||
|
#undef uintptr_t |
||||||
|
typedef long int gl_intptr_t; |
||||||
|
typedef unsigned long int gl_uintptr_t; |
||||||
|
#define intptr_t gl_intptr_t |
||||||
|
#define uintptr_t gl_uintptr_t |
||||||
|
|
||||||
|
/* 7.18.1.5. Greatest-width integer types */ |
||||||
|
|
||||||
|
/* Note: These types are compiler dependent. It may be unwise to use them in
|
||||||
|
public header files. */ |
||||||
|
|
||||||
|
#undef intmax_t |
||||||
|
#if @HAVE_LONG_LONG_INT@ && LONG_MAX >> 30 == 1 |
||||||
|
typedef long long int gl_intmax_t; |
||||||
|
# define intmax_t gl_intmax_t |
||||||
|
#elif defined GL_INT64_T |
||||||
|
# define intmax_t int64_t |
||||||
|
#else |
||||||
|
typedef long int gl_intmax_t; |
||||||
|
# define intmax_t gl_intmax_t |
||||||
|
#endif |
||||||
|
|
||||||
|
#undef uintmax_t |
||||||
|
#if @HAVE_UNSIGNED_LONG_LONG_INT@ && ULONG_MAX >> 31 == 1 |
||||||
|
typedef unsigned long long int gl_uintmax_t; |
||||||
|
# define uintmax_t gl_uintmax_t |
||||||
|
#elif defined GL_UINT64_T |
||||||
|
# define uintmax_t uint64_t |
||||||
|
#else |
||||||
|
typedef unsigned long int gl_uintmax_t; |
||||||
|
# define uintmax_t gl_uintmax_t |
||||||
|
#endif |
||||||
|
|
||||||
|
/* Verify that intmax_t and uintmax_t have the same size. Too much code
|
||||||
|
breaks if this is not the case. If this check fails, the reason is likely |
||||||
|
to be found in the autoconf macros. */ |
||||||
|
typedef int _verify_intmax_size[sizeof (intmax_t) == sizeof (uintmax_t) |
||||||
|
? 1 : -1]; |
||||||
|
|
||||||
|
#define GNULIB_defined_stdint_types 1 |
||||||
|
#endif /* !GNULIB_defined_stdint_types */ |
||||||
|
|
||||||
|
/* 7.18.2. Limits of specified-width integer types */ |
||||||
|
|
||||||
|
#if ! defined __cplusplus || defined __STDC_LIMIT_MACROS |
||||||
|
|
||||||
|
/* 7.18.2.1. Limits of exact-width integer types */ |
||||||
|
|
||||||
|
/* Here we assume a standard architecture where the hardware integer
|
||||||
|
types have 8, 16, 32, optionally 64 bits. */ |
||||||
|
|
||||||
|
#undef INT8_MIN |
||||||
|
#undef INT8_MAX |
||||||
|
#undef UINT8_MAX |
||||||
|
#define INT8_MIN (~ INT8_MAX) |
||||||
|
#define INT8_MAX 127 |
||||||
|
#define UINT8_MAX 255 |
||||||
|
|
||||||
|
#undef INT16_MIN |
||||||
|
#undef INT16_MAX |
||||||
|
#undef UINT16_MAX |
||||||
|
#define INT16_MIN (~ INT16_MAX) |
||||||
|
#define INT16_MAX 32767 |
||||||
|
#define UINT16_MAX 65535 |
||||||
|
|
||||||
|
#undef INT32_MIN |
||||||
|
#undef INT32_MAX |
||||||
|
#undef UINT32_MAX |
||||||
|
#define INT32_MIN (~ INT32_MAX) |
||||||
|
#define INT32_MAX 2147483647 |
||||||
|
#define UINT32_MAX 4294967295U |
||||||
|
|
||||||
|
#if defined GL_INT64_T && ! defined INT64_MAX |
||||||
|
/* Prefer (- INTMAX_C (1) << 63) over (~ INT64_MAX) because SunPRO C 5.0
|
||||||
|
evaluates the latter incorrectly in preprocessor expressions. */ |
||||||
|
# define INT64_MIN (- INTMAX_C (1) << 63) |
||||||
|
# define INT64_MAX INTMAX_C (9223372036854775807) |
||||||
|
#endif |
||||||
|
|
||||||
|
#if defined GL_UINT64_T && ! defined UINT64_MAX |
||||||
|
# define UINT64_MAX UINTMAX_C (18446744073709551615) |
||||||
|
#endif |
||||||
|
|
||||||
|
/* 7.18.2.2. Limits of minimum-width integer types */ |
||||||
|
|
||||||
|
/* Here we assume a standard architecture where the hardware integer
|
||||||
|
types have 8, 16, 32, optionally 64 bits. Therefore the leastN_t types |
||||||
|
are the same as the corresponding N_t types. */ |
||||||
|
|
||||||
|
#undef INT_LEAST8_MIN |
||||||
|
#undef INT_LEAST8_MAX |
||||||
|
#undef UINT_LEAST8_MAX |
||||||
|
#define INT_LEAST8_MIN INT8_MIN |
||||||
|
#define INT_LEAST8_MAX INT8_MAX |
||||||
|
#define UINT_LEAST8_MAX UINT8_MAX |
||||||
|
|
||||||
|
#undef INT_LEAST16_MIN |
||||||
|
#undef INT_LEAST16_MAX |
||||||
|
#undef UINT_LEAST16_MAX |
||||||
|
#define INT_LEAST16_MIN INT16_MIN |
||||||
|
#define INT_LEAST16_MAX INT16_MAX |
||||||
|
#define UINT_LEAST16_MAX UINT16_MAX |
||||||
|
|
||||||
|
#undef INT_LEAST32_MIN |
||||||
|
#undef INT_LEAST32_MAX |
||||||
|
#undef UINT_LEAST32_MAX |
||||||
|
#define INT_LEAST32_MIN INT32_MIN |
||||||
|
#define INT_LEAST32_MAX INT32_MAX |
||||||
|
#define UINT_LEAST32_MAX UINT32_MAX |
||||||
|
|
||||||
|
#undef INT_LEAST64_MIN |
||||||
|
#undef INT_LEAST64_MAX |
||||||
|
#ifdef GL_INT64_T |
||||||
|
# define INT_LEAST64_MIN INT64_MIN |
||||||
|
# define INT_LEAST64_MAX INT64_MAX |
||||||
|
#endif |
||||||
|
|
||||||
|
#undef UINT_LEAST64_MAX |
||||||
|
#ifdef GL_UINT64_T |
||||||
|
# define UINT_LEAST64_MAX UINT64_MAX |
||||||
|
#endif |
||||||
|
|
||||||
|
/* 7.18.2.3. Limits of fastest minimum-width integer types */ |
||||||
|
|
||||||
|
/* Here we assume a standard architecture where the hardware integer
|
||||||
|
types have 8, 16, 32, optionally 64 bits. Therefore the fastN_t types |
||||||
|
are taken from the same list of types. */ |
||||||
|
|
||||||
|
#undef INT_FAST8_MIN |
||||||
|
#undef INT_FAST8_MAX |
||||||
|
#undef UINT_FAST8_MAX |
||||||
|
#define INT_FAST8_MIN LONG_MIN |
||||||
|
#define INT_FAST8_MAX LONG_MAX |
||||||
|
#define UINT_FAST8_MAX ULONG_MAX |
||||||
|
|
||||||
|
#undef INT_FAST16_MIN |
||||||
|
#undef INT_FAST16_MAX |
||||||
|
#undef UINT_FAST16_MAX |
||||||
|
#define INT_FAST16_MIN LONG_MIN |
||||||
|
#define INT_FAST16_MAX LONG_MAX |
||||||
|
#define UINT_FAST16_MAX ULONG_MAX |
||||||
|
|
||||||
|
#undef INT_FAST32_MIN |
||||||
|
#undef INT_FAST32_MAX |
||||||
|
#undef UINT_FAST32_MAX |
||||||
|
#define INT_FAST32_MIN LONG_MIN |
||||||
|
#define INT_FAST32_MAX LONG_MAX |
||||||
|
#define UINT_FAST32_MAX ULONG_MAX |
||||||
|
|
||||||
|
#undef INT_FAST64_MIN |
||||||
|
#undef INT_FAST64_MAX |
||||||
|
#ifdef GL_INT64_T |
||||||
|
# define INT_FAST64_MIN INT64_MIN |
||||||
|
# define INT_FAST64_MAX INT64_MAX |
||||||
|
#endif |
||||||
|
|
||||||
|
#undef UINT_FAST64_MAX |
||||||
|
#ifdef GL_UINT64_T |
||||||
|
# define UINT_FAST64_MAX UINT64_MAX |
||||||
|
#endif |
||||||
|
|
||||||
|
/* 7.18.2.4. Limits of integer types capable of holding object pointers */ |
||||||
|
|
||||||
|
#undef INTPTR_MIN |
||||||
|
#undef INTPTR_MAX |
||||||
|
#undef UINTPTR_MAX |
||||||
|
#define INTPTR_MIN LONG_MIN |
||||||
|
#define INTPTR_MAX LONG_MAX |
||||||
|
#define UINTPTR_MAX ULONG_MAX |
||||||
|
|
||||||
|
/* 7.18.2.5. Limits of greatest-width integer types */ |
||||||
|
|
||||||
|
#undef INTMAX_MIN |
||||||
|
#undef INTMAX_MAX |
||||||
|
#ifdef INT64_MAX |
||||||
|
# define INTMAX_MIN INT64_MIN |
||||||
|
# define INTMAX_MAX INT64_MAX |
||||||
|
#else |
||||||
|
# define INTMAX_MIN INT32_MIN |
||||||
|
# define INTMAX_MAX INT32_MAX |
||||||
|
#endif |
||||||
|
|
||||||
|
#undef UINTMAX_MAX |
||||||
|
#ifdef UINT64_MAX |
||||||
|
# define UINTMAX_MAX UINT64_MAX |
||||||
|
#else |
||||||
|
# define UINTMAX_MAX UINT32_MAX |
||||||
|
#endif |
||||||
|
|
||||||
|
/* 7.18.3. Limits of other integer types */ |
||||||
|
|
||||||
|
/* ptrdiff_t limits */ |
||||||
|
#undef PTRDIFF_MIN |
||||||
|
#undef PTRDIFF_MAX |
||||||
|
#if @APPLE_UNIVERSAL_BUILD@ |
||||||
|
# ifdef _LP64 |
||||||
|
# define PTRDIFF_MIN _STDINT_MIN (1, 64, 0l) |
||||||
|
# define PTRDIFF_MAX _STDINT_MAX (1, 64, 0l) |
||||||
|
# else |
||||||
|
# define PTRDIFF_MIN _STDINT_MIN (1, 32, 0) |
||||||
|
# define PTRDIFF_MAX _STDINT_MAX (1, 32, 0) |
||||||
|
# endif |
||||||
|
#else |
||||||
|
# define PTRDIFF_MIN \ |
||||||
|
_STDINT_MIN (1, @BITSIZEOF_PTRDIFF_T@, 0@PTRDIFF_T_SUFFIX@) |
||||||
|
# define PTRDIFF_MAX \ |
||||||
|
_STDINT_MAX (1, @BITSIZEOF_PTRDIFF_T@, 0@PTRDIFF_T_SUFFIX@) |
||||||
|
#endif |
||||||
|
|
||||||
|
/* sig_atomic_t limits */ |
||||||
|
#undef SIG_ATOMIC_MIN |
||||||
|
#undef SIG_ATOMIC_MAX |
||||||
|
#define SIG_ATOMIC_MIN \ |
||||||
|
_STDINT_MIN (@HAVE_SIGNED_SIG_ATOMIC_T@, @BITSIZEOF_SIG_ATOMIC_T@, \ |
||||||
|
0@SIG_ATOMIC_T_SUFFIX@) |
||||||
|
#define SIG_ATOMIC_MAX \ |
||||||
|
_STDINT_MAX (@HAVE_SIGNED_SIG_ATOMIC_T@, @BITSIZEOF_SIG_ATOMIC_T@, \ |
||||||
|
0@SIG_ATOMIC_T_SUFFIX@) |
||||||
|
|
||||||
|
|
||||||
|
/* size_t limit */ |
||||||
|
#undef SIZE_MAX |
||||||
|
#if @APPLE_UNIVERSAL_BUILD@ |
||||||
|
# ifdef _LP64 |
||||||
|
# define SIZE_MAX _STDINT_MAX (0, 64, 0ul) |
||||||
|
# else |
||||||
|
# define SIZE_MAX _STDINT_MAX (0, 32, 0ul) |
||||||
|
# endif |
||||||
|
#else |
||||||
|
# define SIZE_MAX _STDINT_MAX (0, @BITSIZEOF_SIZE_T@, 0@SIZE_T_SUFFIX@) |
||||||
|
#endif |
||||||
|
|
||||||
|
/* wchar_t limits */ |
||||||
|
/* Get WCHAR_MIN, WCHAR_MAX.
|
||||||
|
This include is not on the top, above, because on OSF/1 4.0 we have a |
||||||
|
sequence of nested includes |
||||||
|
<wchar.h> -> <stdio.h> -> <getopt.h> -> <stdlib.h>, and the latter includes |
||||||
|
<stdint.h> and assumes its types are already defined. */ |
||||||
|
#if @HAVE_WCHAR_H@ && ! (defined WCHAR_MIN && defined WCHAR_MAX) |
||||||
|
/* BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
|
||||||
|
included before <wchar.h>. */ |
||||||
|
# include <stddef.h> |
||||||
|
# include <stdio.h> |
||||||
|
# include <time.h> |
||||||
|
# define _GL_JUST_INCLUDE_SYSTEM_WCHAR_H |
||||||
|
# include <wchar.h> |
||||||
|
# undef _GL_JUST_INCLUDE_SYSTEM_WCHAR_H |
||||||
|
#endif |
||||||
|
#undef WCHAR_MIN |
||||||
|
#undef WCHAR_MAX |
||||||
|
#define WCHAR_MIN \ |
||||||
|
_STDINT_MIN (@HAVE_SIGNED_WCHAR_T@, @BITSIZEOF_WCHAR_T@, 0@WCHAR_T_SUFFIX@) |
||||||
|
#define WCHAR_MAX \ |
||||||
|
_STDINT_MAX (@HAVE_SIGNED_WCHAR_T@, @BITSIZEOF_WCHAR_T@, 0@WCHAR_T_SUFFIX@) |
||||||
|
|
||||||
|
/* wint_t limits */ |
||||||
|
#undef WINT_MIN |
||||||
|
#undef WINT_MAX |
||||||
|
#define WINT_MIN \ |
||||||
|
_STDINT_MIN (@HAVE_SIGNED_WINT_T@, @BITSIZEOF_WINT_T@, 0@WINT_T_SUFFIX@) |
||||||
|
#define WINT_MAX \ |
||||||
|
_STDINT_MAX (@HAVE_SIGNED_WINT_T@, @BITSIZEOF_WINT_T@, 0@WINT_T_SUFFIX@) |
||||||
|
|
||||||
|
#endif /* !defined __cplusplus || defined __STDC_LIMIT_MACROS */ |
||||||
|
|
||||||
|
/* 7.18.4. Macros for integer constants */ |
||||||
|
|
||||||
|
#if ! defined __cplusplus || defined __STDC_CONSTANT_MACROS |
||||||
|
|
||||||
|
/* 7.18.4.1. Macros for minimum-width integer constants */ |
||||||
|
/* According to ISO C 99 Technical Corrigendum 1 */ |
||||||
|
|
||||||
|
/* Here we assume a standard architecture where the hardware integer
|
||||||
|
types have 8, 16, 32, optionally 64 bits, and int is 32 bits. */ |
||||||
|
|
||||||
|
#undef INT8_C |
||||||
|
#undef UINT8_C |
||||||
|
#define INT8_C(x) x |
||||||
|
#define UINT8_C(x) x |
||||||
|
|
||||||
|
#undef INT16_C |
||||||
|
#undef UINT16_C |
||||||
|
#define INT16_C(x) x |
||||||
|
#define UINT16_C(x) x |
||||||
|
|
||||||
|
#undef INT32_C |
||||||
|
#undef UINT32_C |
||||||
|
#define INT32_C(x) x |
||||||
|
#define UINT32_C(x) x ## U |
||||||
|
|
||||||
|
#undef INT64_C |
||||||
|
#undef UINT64_C |
||||||
|
#if LONG_MAX >> 31 >> 31 == 1 |
||||||
|
# define INT64_C(x) x##L |
||||||
|
#elif defined _MSC_VER |
||||||
|
# define INT64_C(x) x##i64 |
||||||
|
#elif @HAVE_LONG_LONG_INT@ |
||||||
|
# define INT64_C(x) x##LL |
||||||
|
#endif |
||||||
|
#if ULONG_MAX >> 31 >> 31 >> 1 == 1 |
||||||
|
# define UINT64_C(x) x##UL |
||||||
|
#elif defined _MSC_VER |
||||||
|
# define UINT64_C(x) x##ui64 |
||||||
|
#elif @HAVE_UNSIGNED_LONG_LONG_INT@ |
||||||
|
# define UINT64_C(x) x##ULL |
||||||
|
#endif |
||||||
|
|
||||||
|
/* 7.18.4.2. Macros for greatest-width integer constants */ |
||||||
|
|
||||||
|
#undef INTMAX_C |
||||||
|
#if @HAVE_LONG_LONG_INT@ && LONG_MAX >> 30 == 1 |
||||||
|
# define INTMAX_C(x) x##LL |
||||||
|
#elif defined GL_INT64_T |
||||||
|
# define INTMAX_C(x) INT64_C(x) |
||||||
|
#else |
||||||
|
# define INTMAX_C(x) x##L |
||||||
|
#endif |
||||||
|
|
||||||
|
#undef UINTMAX_C |
||||||
|
#if @HAVE_UNSIGNED_LONG_LONG_INT@ && ULONG_MAX >> 31 == 1 |
||||||
|
# define UINTMAX_C(x) x##ULL |
||||||
|
#elif defined GL_UINT64_T |
||||||
|
# define UINTMAX_C(x) UINT64_C(x) |
||||||
|
#else |
||||||
|
# define UINTMAX_C(x) x##UL |
||||||
|
#endif |
||||||
|
|
||||||
|
#endif /* !defined __cplusplus || defined __STDC_CONSTANT_MACROS */ |
||||||
|
|
||||||
|
#endif /* _@GUARD_PREFIX@_STDINT_H */ |
||||||
|
#endif /* !defined _@GUARD_PREFIX@_STDINT_H && !defined _GL_JUST_INCLUDE_SYSTEM_STDINT_H */ |
@ -0,0 +1,453 @@ |
|||||||
|
/* Byte-wise substring search, using the Two-Way algorithm.
|
||||||
|
Copyright (C) 2008-2011 Free Software Foundation, Inc. |
||||||
|
This file is part of the GNU C Library. |
||||||
|
Written by Eric Blake <ebb9@byu.net>, 2008. |
||||||
|
|
||||||
|
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, write to the Free Software Foundation, |
||||||
|
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ |
||||||
|
|
||||||
|
/* Before including this file, you need to include <config.h> and
|
||||||
|
<string.h>, and define: |
||||||
|
RESULT_TYPE A macro that expands to the return type. |
||||||
|
AVAILABLE(h, h_l, j, n_l) |
||||||
|
A macro that returns nonzero if there are |
||||||
|
at least N_L bytes left starting at H[J]. |
||||||
|
H is 'unsigned char *', H_L, J, and N_L |
||||||
|
are 'size_t'; H_L is an lvalue. For |
||||||
|
NUL-terminated searches, H_L can be |
||||||
|
modified each iteration to avoid having |
||||||
|
to compute the end of H up front. |
||||||
|
|
||||||
|
For case-insensitivity, you may optionally define: |
||||||
|
CMP_FUNC(p1, p2, l) A macro that returns 0 iff the first L |
||||||
|
characters of P1 and P2 are equal. |
||||||
|
CANON_ELEMENT(c) A macro that canonicalizes an element right after |
||||||
|
it has been fetched from one of the two strings. |
||||||
|
The argument is an 'unsigned char'; the result |
||||||
|
must be an 'unsigned char' as well. |
||||||
|
|
||||||
|
This file undefines the macros documented above, and defines |
||||||
|
LONG_NEEDLE_THRESHOLD. |
||||||
|
*/ |
||||||
|
|
||||||
|
#include <limits.h> |
||||||
|
#include <stdint.h> |
||||||
|
|
||||||
|
/* We use the Two-Way string matching algorithm (also known as
|
||||||
|
Chrochemore-Perrin), which guarantees linear complexity with |
||||||
|
constant space. Additionally, for long needles, we also use a bad |
||||||
|
character shift table similar to the Boyer-Moore algorithm to |
||||||
|
achieve improved (potentially sub-linear) performance. |
||||||
|
|
||||||
|
See http://www-igm.univ-mlv.fr/~lecroq/string/node26.html#SECTION00260,
|
||||||
|
http://en.wikipedia.org/wiki/Boyer-Moore_string_search_algorithm,
|
||||||
|
http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.34.6641&rep=rep1&type=pdf
|
||||||
|
*/ |
||||||
|
|
||||||
|
/* Point at which computing a bad-byte shift table is likely to be
|
||||||
|
worthwhile. Small needles should not compute a table, since it |
||||||
|
adds (1 << CHAR_BIT) + NEEDLE_LEN computations of preparation for a |
||||||
|
speedup no greater than a factor of NEEDLE_LEN. The larger the |
||||||
|
needle, the better the potential performance gain. On the other |
||||||
|
hand, on non-POSIX systems with CHAR_BIT larger than eight, the |
||||||
|
memory required for the table is prohibitive. */ |
||||||
|
#if CHAR_BIT < 10 |
||||||
|
# define LONG_NEEDLE_THRESHOLD 32U |
||||||
|
#else |
||||||
|
# define LONG_NEEDLE_THRESHOLD SIZE_MAX |
||||||
|
#endif |
||||||
|
|
||||||
|
#ifndef MAX |
||||||
|
# define MAX(a, b) ((a < b) ? (b) : (a)) |
||||||
|
#endif |
||||||
|
|
||||||
|
#ifndef CANON_ELEMENT |
||||||
|
# define CANON_ELEMENT(c) c |
||||||
|
#endif |
||||||
|
#ifndef CMP_FUNC |
||||||
|
# define CMP_FUNC memcmp |
||||||
|
#endif |
||||||
|
|
||||||
|
/* Perform a critical factorization of NEEDLE, of length NEEDLE_LEN.
|
||||||
|
Return the index of the first byte in the right half, and set |
||||||
|
*PERIOD to the global period of the right half. |
||||||
|
|
||||||
|
The global period of a string is the smallest index (possibly its |
||||||
|
length) at which all remaining bytes in the string are repetitions |
||||||
|
of the prefix (the last repetition may be a subset of the prefix). |
||||||
|
|
||||||
|
When NEEDLE is factored into two halves, a local period is the |
||||||
|
length of the smallest word that shares a suffix with the left half |
||||||
|
and shares a prefix with the right half. All factorizations of a |
||||||
|
non-empty NEEDLE have a local period of at least 1 and no greater |
||||||
|
than NEEDLE_LEN. |
||||||
|
|
||||||
|
A critical factorization has the property that the local period |
||||||
|
equals the global period. All strings have at least one critical |
||||||
|
factorization with the left half smaller than the global period. |
||||||
|
And while some strings have more than one critical factorization, |
||||||
|
it is provable that with an ordered alphabet, at least one of the |
||||||
|
critical factorizations corresponds to a maximal suffix. |
||||||
|
|
||||||
|
Given an ordered alphabet, a critical factorization can be computed |
||||||
|
in linear time, with 2 * NEEDLE_LEN comparisons, by computing the |
||||||
|
shorter of two ordered maximal suffixes. The ordered maximal |
||||||
|
suffixes are determined by lexicographic comparison while tracking |
||||||
|
periodicity. */ |
||||||
|
static size_t |
||||||
|
critical_factorization (const unsigned char *needle, size_t needle_len, |
||||||
|
size_t *period) |
||||||
|
{ |
||||||
|
/* Index of last byte of left half, or SIZE_MAX. */ |
||||||
|
size_t max_suffix, max_suffix_rev; |
||||||
|
size_t j; /* Index into NEEDLE for current candidate suffix. */ |
||||||
|
size_t k; /* Offset into current period. */ |
||||||
|
size_t p; /* Intermediate period. */ |
||||||
|
unsigned char a, b; /* Current comparison bytes. */ |
||||||
|
|
||||||
|
/* Special case NEEDLE_LEN of 1 or 2 (all callers already filtered
|
||||||
|
out 0-length needles. */ |
||||||
|
if (needle_len < 3) |
||||||
|
{ |
||||||
|
*period = 1; |
||||||
|
return needle_len - 1; |
||||||
|
} |
||||||
|
|
||||||
|
/* Invariants:
|
||||||
|
0 <= j < NEEDLE_LEN - 1 |
||||||
|
-1 <= max_suffix{,_rev} < j (treating SIZE_MAX as if it were signed) |
||||||
|
min(max_suffix, max_suffix_rev) < global period of NEEDLE |
||||||
|
1 <= p <= global period of NEEDLE |
||||||
|
p == global period of the substring NEEDLE[max_suffix{,_rev}+1...j] |
||||||
|
1 <= k <= p |
||||||
|
*/ |
||||||
|
|
||||||
|
/* Perform lexicographic search. */ |
||||||
|
max_suffix = SIZE_MAX; |
||||||
|
j = 0; |
||||||
|
k = p = 1; |
||||||
|
while (j + k < needle_len) |
||||||
|
{ |
||||||
|
a = CANON_ELEMENT (needle[j + k]); |
||||||
|
b = CANON_ELEMENT (needle[max_suffix + k]); |
||||||
|
if (a < b) |
||||||
|
{ |
||||||
|
/* Suffix is smaller, period is entire prefix so far. */ |
||||||
|
j += k; |
||||||
|
k = 1; |
||||||
|
p = j - max_suffix; |
||||||
|
} |
||||||
|
else if (a == b) |
||||||
|
{ |
||||||
|
/* Advance through repetition of the current period. */ |
||||||
|
if (k != p) |
||||||
|
++k; |
||||||
|
else |
||||||
|
{ |
||||||
|
j += p; |
||||||
|
k = 1; |
||||||
|
} |
||||||
|
} |
||||||
|
else /* b < a */ |
||||||
|
{ |
||||||
|
/* Suffix is larger, start over from current location. */ |
||||||
|
max_suffix = j++; |
||||||
|
k = p = 1; |
||||||
|
} |
||||||
|
} |
||||||
|
*period = p; |
||||||
|
|
||||||
|
/* Perform reverse lexicographic search. */ |
||||||
|
max_suffix_rev = SIZE_MAX; |
||||||
|
j = 0; |
||||||
|
k = p = 1; |
||||||
|
while (j + k < needle_len) |
||||||
|
{ |
||||||
|
a = CANON_ELEMENT (needle[j + k]); |
||||||
|
b = CANON_ELEMENT (needle[max_suffix_rev + k]); |
||||||
|
if (b < a) |
||||||
|
{ |
||||||
|
/* Suffix is smaller, period is entire prefix so far. */ |
||||||
|
j += k; |
||||||
|
k = 1; |
||||||
|
p = j - max_suffix_rev; |
||||||
|
} |
||||||
|
else if (a == b) |
||||||
|
{ |
||||||
|
/* Advance through repetition of the current period. */ |
||||||
|
if (k != p) |
||||||
|
++k; |
||||||
|
else |
||||||
|
{ |
||||||
|
j += p; |
||||||
|
k = 1; |
||||||
|
} |
||||||
|
} |
||||||
|
else /* a < b */ |
||||||
|
{ |
||||||
|
/* Suffix is larger, start over from current location. */ |
||||||
|
max_suffix_rev = j++; |
||||||
|
k = p = 1; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/* Choose the shorter suffix. Return the index of the first byte of
|
||||||
|
the right half, rather than the last byte of the left half. |
||||||
|
|
||||||
|
For some examples, 'banana' has two critical factorizations, both |
||||||
|
exposed by the two lexicographic extreme suffixes of 'anana' and |
||||||
|
'nana', where both suffixes have a period of 2. On the other |
||||||
|
hand, with 'aab' and 'bba', both strings have a single critical |
||||||
|
factorization of the last byte, with the suffix having a period |
||||||
|
of 1. While the maximal lexicographic suffix of 'aab' is 'b', |
||||||
|
the maximal lexicographic suffix of 'bba' is 'ba', which is not a |
||||||
|
critical factorization. Conversely, the maximal reverse |
||||||
|
lexicographic suffix of 'a' works for 'bba', but not 'ab' for |
||||||
|
'aab'. The shorter suffix of the two will always be a critical |
||||||
|
factorization. */ |
||||||
|
if (max_suffix_rev + 1 < max_suffix + 1) |
||||||
|
return max_suffix + 1; |
||||||
|
*period = p; |
||||||
|
return max_suffix_rev + 1; |
||||||
|
} |
||||||
|
|
||||||
|
/* Return the first location of non-empty NEEDLE within HAYSTACK, or
|
||||||
|
NULL. HAYSTACK_LEN is the minimum known length of HAYSTACK. This |
||||||
|
method is optimized for NEEDLE_LEN < LONG_NEEDLE_THRESHOLD. |
||||||
|
Performance is guaranteed to be linear, with an initialization cost |
||||||
|
of 2 * NEEDLE_LEN comparisons. |
||||||
|
|
||||||
|
If AVAILABLE does not modify HAYSTACK_LEN (as in memmem), then at |
||||||
|
most 2 * HAYSTACK_LEN - NEEDLE_LEN comparisons occur in searching. |
||||||
|
If AVAILABLE modifies HAYSTACK_LEN (as in strstr), then at most 3 * |
||||||
|
HAYSTACK_LEN - NEEDLE_LEN comparisons occur in searching. */ |
||||||
|
static RETURN_TYPE |
||||||
|
two_way_short_needle (const unsigned char *haystack, size_t haystack_len, |
||||||
|
const unsigned char *needle, size_t needle_len) |
||||||
|
{ |
||||||
|
size_t i; /* Index into current byte of NEEDLE. */ |
||||||
|
size_t j; /* Index into current window of HAYSTACK. */ |
||||||
|
size_t period; /* The period of the right half of needle. */ |
||||||
|
size_t suffix; /* The index of the right half of needle. */ |
||||||
|
|
||||||
|
/* Factor the needle into two halves, such that the left half is
|
||||||
|
smaller than the global period, and the right half is |
||||||
|
periodic (with a period as large as NEEDLE_LEN - suffix). */ |
||||||
|
suffix = critical_factorization (needle, needle_len, &period); |
||||||
|
|
||||||
|
/* Perform the search. Each iteration compares the right half
|
||||||
|
first. */ |
||||||
|
if (CMP_FUNC (needle, needle + period, suffix) == 0) |
||||||
|
{ |
||||||
|
/* Entire needle is periodic; a mismatch in the left half can
|
||||||
|
only advance by the period, so use memory to avoid rescanning |
||||||
|
known occurrences of the period in the right half. */ |
||||||
|
size_t memory = 0; |
||||||
|
j = 0; |
||||||
|
while (AVAILABLE (haystack, haystack_len, j, needle_len)) |
||||||
|
{ |
||||||
|
/* Scan for matches in right half. */ |
||||||
|
i = MAX (suffix, memory); |
||||||
|
while (i < needle_len && (CANON_ELEMENT (needle[i]) |
||||||
|
== CANON_ELEMENT (haystack[i + j]))) |
||||||
|
++i; |
||||||
|
if (needle_len <= i) |
||||||
|
{ |
||||||
|
/* Scan for matches in left half. */ |
||||||
|
i = suffix - 1; |
||||||
|
while (memory < i + 1 && (CANON_ELEMENT (needle[i]) |
||||||
|
== CANON_ELEMENT (haystack[i + j]))) |
||||||
|
--i; |
||||||
|
if (i + 1 < memory + 1) |
||||||
|
return (RETURN_TYPE) (haystack + j); |
||||||
|
/* No match, so remember how many repetitions of period
|
||||||
|
on the right half were scanned. */ |
||||||
|
j += period; |
||||||
|
memory = needle_len - period; |
||||||
|
} |
||||||
|
else |
||||||
|
{ |
||||||
|
j += i - suffix + 1; |
||||||
|
memory = 0; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
else |
||||||
|
{ |
||||||
|
/* The two halves of needle are distinct; no extra memory is
|
||||||
|
required, and any mismatch results in a maximal shift. */ |
||||||
|
period = MAX (suffix, needle_len - suffix) + 1; |
||||||
|
j = 0; |
||||||
|
while (AVAILABLE (haystack, haystack_len, j, needle_len)) |
||||||
|
{ |
||||||
|
/* Scan for matches in right half. */ |
||||||
|
i = suffix; |
||||||
|
while (i < needle_len && (CANON_ELEMENT (needle[i]) |
||||||
|
== CANON_ELEMENT (haystack[i + j]))) |
||||||
|
++i; |
||||||
|
if (needle_len <= i) |
||||||
|
{ |
||||||
|
/* Scan for matches in left half. */ |
||||||
|
i = suffix - 1; |
||||||
|
while (i != SIZE_MAX && (CANON_ELEMENT (needle[i]) |
||||||
|
== CANON_ELEMENT (haystack[i + j]))) |
||||||
|
--i; |
||||||
|
if (i == SIZE_MAX) |
||||||
|
return (RETURN_TYPE) (haystack + j); |
||||||
|
j += period; |
||||||
|
} |
||||||
|
else |
||||||
|
j += i - suffix + 1; |
||||||
|
} |
||||||
|
} |
||||||
|
return NULL; |
||||||
|
} |
||||||
|
|
||||||
|
/* Return the first location of non-empty NEEDLE within HAYSTACK, or
|
||||||
|
NULL. HAYSTACK_LEN is the minimum known length of HAYSTACK. This |
||||||
|
method is optimized for LONG_NEEDLE_THRESHOLD <= NEEDLE_LEN. |
||||||
|
Performance is guaranteed to be linear, with an initialization cost |
||||||
|
of 3 * NEEDLE_LEN + (1 << CHAR_BIT) operations. |
||||||
|
|
||||||
|
If AVAILABLE does not modify HAYSTACK_LEN (as in memmem), then at |
||||||
|
most 2 * HAYSTACK_LEN - NEEDLE_LEN comparisons occur in searching, |
||||||
|
and sublinear performance O(HAYSTACK_LEN / NEEDLE_LEN) is possible. |
||||||
|
If AVAILABLE modifies HAYSTACK_LEN (as in strstr), then at most 3 * |
||||||
|
HAYSTACK_LEN - NEEDLE_LEN comparisons occur in searching, and |
||||||
|
sublinear performance is not possible. */ |
||||||
|
static RETURN_TYPE |
||||||
|
two_way_long_needle (const unsigned char *haystack, size_t haystack_len, |
||||||
|
const unsigned char *needle, size_t needle_len) |
||||||
|
{ |
||||||
|
size_t i; /* Index into current byte of NEEDLE. */ |
||||||
|
size_t j; /* Index into current window of HAYSTACK. */ |
||||||
|
size_t period; /* The period of the right half of needle. */ |
||||||
|
size_t suffix; /* The index of the right half of needle. */ |
||||||
|
size_t shift_table[1U << CHAR_BIT]; /* See below. */ |
||||||
|
|
||||||
|
/* Factor the needle into two halves, such that the left half is
|
||||||
|
smaller than the global period, and the right half is |
||||||
|
periodic (with a period as large as NEEDLE_LEN - suffix). */ |
||||||
|
suffix = critical_factorization (needle, needle_len, &period); |
||||||
|
|
||||||
|
/* Populate shift_table. For each possible byte value c,
|
||||||
|
shift_table[c] is the distance from the last occurrence of c to |
||||||
|
the end of NEEDLE, or NEEDLE_LEN if c is absent from the NEEDLE. |
||||||
|
shift_table[NEEDLE[NEEDLE_LEN - 1]] contains the only 0. */ |
||||||
|
for (i = 0; i < 1U << CHAR_BIT; i++) |
||||||
|
shift_table[i] = needle_len; |
||||||
|
for (i = 0; i < needle_len; i++) |
||||||
|
shift_table[CANON_ELEMENT (needle[i])] = needle_len - i - 1; |
||||||
|
|
||||||
|
/* Perform the search. Each iteration compares the right half
|
||||||
|
first. */ |
||||||
|
if (CMP_FUNC (needle, needle + period, suffix) == 0) |
||||||
|
{ |
||||||
|
/* Entire needle is periodic; a mismatch in the left half can
|
||||||
|
only advance by the period, so use memory to avoid rescanning |
||||||
|
known occurrences of the period in the right half. */ |
||||||
|
size_t memory = 0; |
||||||
|
size_t shift; |
||||||
|
j = 0; |
||||||
|
while (AVAILABLE (haystack, haystack_len, j, needle_len)) |
||||||
|
{ |
||||||
|
/* Check the last byte first; if it does not match, then
|
||||||
|
shift to the next possible match location. */ |
||||||
|
shift = shift_table[CANON_ELEMENT (haystack[j + needle_len - 1])]; |
||||||
|
if (0 < shift) |
||||||
|
{ |
||||||
|
if (memory && shift < period) |
||||||
|
{ |
||||||
|
/* Since needle is periodic, but the last period has
|
||||||
|
a byte out of place, there can be no match until |
||||||
|
after the mismatch. */ |
||||||
|
shift = needle_len - period; |
||||||
|
} |
||||||
|
memory = 0; |
||||||
|
j += shift; |
||||||
|
continue; |
||||||
|
} |
||||||
|
/* Scan for matches in right half. The last byte has
|
||||||
|
already been matched, by virtue of the shift table. */ |
||||||
|
i = MAX (suffix, memory); |
||||||
|
while (i < needle_len - 1 && (CANON_ELEMENT (needle[i]) |
||||||
|
== CANON_ELEMENT (haystack[i + j]))) |
||||||
|
++i; |
||||||
|
if (needle_len - 1 <= i) |
||||||
|
{ |
||||||
|
/* Scan for matches in left half. */ |
||||||
|
i = suffix - 1; |
||||||
|
while (memory < i + 1 && (CANON_ELEMENT (needle[i]) |
||||||
|
== CANON_ELEMENT (haystack[i + j]))) |
||||||
|
--i; |
||||||
|
if (i + 1 < memory + 1) |
||||||
|
return (RETURN_TYPE) (haystack + j); |
||||||
|
/* No match, so remember how many repetitions of period
|
||||||
|
on the right half were scanned. */ |
||||||
|
j += period; |
||||||
|
memory = needle_len - period; |
||||||
|
} |
||||||
|
else |
||||||
|
{ |
||||||
|
j += i - suffix + 1; |
||||||
|
memory = 0; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
else |
||||||
|
{ |
||||||
|
/* The two halves of needle are distinct; no extra memory is
|
||||||
|
required, and any mismatch results in a maximal shift. */ |
||||||
|
size_t shift; |
||||||
|
period = MAX (suffix, needle_len - suffix) + 1; |
||||||
|
j = 0; |
||||||
|
while (AVAILABLE (haystack, haystack_len, j, needle_len)) |
||||||
|
{ |
||||||
|
/* Check the last byte first; if it does not match, then
|
||||||
|
shift to the next possible match location. */ |
||||||
|
shift = shift_table[CANON_ELEMENT (haystack[j + needle_len - 1])]; |
||||||
|
if (0 < shift) |
||||||
|
{ |
||||||
|
j += shift; |
||||||
|
continue; |
||||||
|
} |
||||||
|
/* Scan for matches in right half. The last byte has
|
||||||
|
already been matched, by virtue of the shift table. */ |
||||||
|
i = suffix; |
||||||
|
while (i < needle_len - 1 && (CANON_ELEMENT (needle[i]) |
||||||
|
== CANON_ELEMENT (haystack[i + j]))) |
||||||
|
++i; |
||||||
|
if (needle_len - 1 <= i) |
||||||
|
{ |
||||||
|
/* Scan for matches in left half. */ |
||||||
|
i = suffix - 1; |
||||||
|
while (i != SIZE_MAX && (CANON_ELEMENT (needle[i]) |
||||||
|
== CANON_ELEMENT (haystack[i + j]))) |
||||||
|
--i; |
||||||
|
if (i == SIZE_MAX) |
||||||
|
return (RETURN_TYPE) (haystack + j); |
||||||
|
j += period; |
||||||
|
} |
||||||
|
else |
||||||
|
j += i - suffix + 1; |
||||||
|
} |
||||||
|
} |
||||||
|
return NULL; |
||||||
|
} |
||||||
|
|
||||||
|
#undef AVAILABLE |
||||||
|
#undef CANON_ELEMENT |
||||||
|
#undef CMP_FUNC |
||||||
|
#undef MAX |
||||||
|
#undef RETURN_TYPE |
@ -1,46 +0,0 @@ |
|||||||
#ifndef _GL_WARN_ON_USE |
|
||||||
|
|
||||||
# if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) |
|
||||||
/* A compiler attribute is available in gcc versions 4.3.0 and later. */ |
|
||||||
# define _GL_WARN_ON_USE(function, message) \ |
|
||||||
extern __typeof__ (function) function __attribute__ ((__warning__ (message))) |
|
||||||
# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING |
|
||||||
/* Verify the existence of the function. */ |
|
||||||
# define _GL_WARN_ON_USE(function, message) \ |
|
||||||
extern __typeof__ (function) function |
|
||||||
# else /* Unsupported. */ |
|
||||||
# define _GL_WARN_ON_USE(function, message) \ |
|
||||||
_GL_WARN_EXTERN_C int _gl_warn_on_use |
|
||||||
# endif |
|
||||||
#endif |
|
||||||
|
|
||||||
/* _GL_WARN_ON_USE_CXX (function, rettype, parameters_and_attributes, "string")
|
|
||||||
is like _GL_WARN_ON_USE (function, "string"), except that the function is |
|
||||||
declared with the given prototype, consisting of return type, parameters, |
|
||||||
and attributes. |
|
||||||
This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does |
|
||||||
not work in this case. */ |
|
||||||
#ifndef _GL_WARN_ON_USE_CXX |
|
||||||
# if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) |
|
||||||
# define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ |
|
||||||
extern rettype function parameters_and_attributes \ |
|
||||||
__attribute__ ((__warning__ (msg))) |
|
||||||
# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING |
|
||||||
/* Verify the existence of the function. */ |
|
||||||
# define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ |
|
||||||
extern rettype function parameters_and_attributes |
|
||||||
# else /* Unsupported. */ |
|
||||||
# define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ |
|
||||||
_GL_WARN_EXTERN_C int _gl_warn_on_use |
|
||||||
# endif |
|
||||||
#endif |
|
||||||
|
|
||||||
/* _GL_WARN_EXTERN_C declaration;
|
|
||||||
performs the declaration with C linkage. */ |
|
||||||
#ifndef _GL_WARN_EXTERN_C |
|
||||||
# if defined __cplusplus |
|
||||||
# define _GL_WARN_EXTERN_C extern "C" |
|
||||||
# else |
|
||||||
# define _GL_WARN_EXTERN_C extern |
|
||||||
# endif |
|
||||||
#endif |
|
@ -1,17 +0,0 @@ |
|||||||
/00gnulib.m4 |
|
||||||
/extensions.m4 |
|
||||||
/gnulib-common.m4 |
|
||||||
/gnulib-comp.m4 |
|
||||||
/gnulib-tool.m4 |
|
||||||
/include_next.m4 |
|
||||||
/longlong.m4 |
|
||||||
/memchr.m4 |
|
||||||
/memmem.m4 |
|
||||||
/mmap-anon.m4 |
|
||||||
/multiarch.m4 |
|
||||||
/onceonly.m4 |
|
||||||
/stddef_h.m4 |
|
||||||
/stdint.m4 |
|
||||||
/string_h.m4 |
|
||||||
/warn-on-use.m4 |
|
||||||
/wchar_t.m4 |
|
@ -0,0 +1,30 @@ |
|||||||
|
# 00gnulib.m4 serial 2 |
||||||
|
dnl Copyright (C) 2009-2011 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 This file must be named something that sorts before all other |
||||||
|
dnl gnulib-provided .m4 files. It is needed until such time as we can |
||||||
|
dnl assume Autoconf 2.64, with its improved AC_DEFUN_ONCE semantics. |
||||||
|
|
||||||
|
# AC_DEFUN_ONCE([NAME], VALUE) |
||||||
|
# ---------------------------- |
||||||
|
# Define NAME to expand to VALUE on the first use (whether by direct |
||||||
|
# expansion, or by AC_REQUIRE), and to nothing on all subsequent uses. |
||||||
|
# Avoid bugs in AC_REQUIRE in Autoconf 2.63 and earlier. This |
||||||
|
# definition is slower than the version in Autoconf 2.64, because it |
||||||
|
# can only use interfaces that existed since 2.59; but it achieves the |
||||||
|
# same effect. Quoting is necessary to avoid confusing Automake. |
||||||
|
m4_version_prereq([2.63.263], [], |
||||||
|
[m4_define([AC][_DEFUN_ONCE], |
||||||
|
[AC][_DEFUN([$1], |
||||||
|
[AC_REQUIRE([_gl_DEFUN_ONCE([$1])], |
||||||
|
[m4_indir([_gl_DEFUN_ONCE([$1])])])])]dnl |
||||||
|
[AC][_DEFUN([_gl_DEFUN_ONCE([$1])], [$2])])]) |
||||||
|
|
||||||
|
# gl_00GNULIB |
||||||
|
# ----------- |
||||||
|
# Witness macro that this file has been included. Needed to force |
||||||
|
# Automake to include this file prior to all other gnulib .m4 files. |
||||||
|
AC_DEFUN([gl_00GNULIB]) |
@ -0,0 +1,118 @@ |
|||||||
|
# serial 9 -*- Autoconf -*- |
||||||
|
# Enable extensions on systems that normally disable them. |
||||||
|
|
||||||
|
# Copyright (C) 2003, 2006-2011 Free Software Foundation, Inc. |
||||||
|
# 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. |
||||||
|
|
||||||
|
# This definition of AC_USE_SYSTEM_EXTENSIONS is stolen from CVS |
||||||
|
# Autoconf. Perhaps we can remove this once we can assume Autoconf |
||||||
|
# 2.62 or later everywhere, but since CVS Autoconf mutates rapidly |
||||||
|
# enough in this area it's likely we'll need to redefine |
||||||
|
# AC_USE_SYSTEM_EXTENSIONS for quite some time. |
||||||
|
|
||||||
|
# If autoconf reports a warning |
||||||
|
# warning: AC_COMPILE_IFELSE was called before AC_USE_SYSTEM_EXTENSIONS |
||||||
|
# or warning: AC_RUN_IFELSE was called before AC_USE_SYSTEM_EXTENSIONS |
||||||
|
# the fix is |
||||||
|
# 1) to ensure that AC_USE_SYSTEM_EXTENSIONS is never directly invoked |
||||||
|
# but always AC_REQUIREd, |
||||||
|
# 2) to ensure that for each occurrence of |
||||||
|
# AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) |
||||||
|
# or |
||||||
|
# AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) |
||||||
|
# the corresponding gnulib module description has 'extensions' among |
||||||
|
# its dependencies. This will ensure that the gl_USE_SYSTEM_EXTENSIONS |
||||||
|
# invocation occurs in gl_EARLY, not in gl_INIT. |
||||||
|
|
||||||
|
# AC_USE_SYSTEM_EXTENSIONS |
||||||
|
# ------------------------ |
||||||
|
# Enable extensions on systems that normally disable them, |
||||||
|
# typically due to standards-conformance issues. |
||||||
|
# Remember that #undef in AH_VERBATIM gets replaced with #define by |
||||||
|
# AC_DEFINE. The goal here is to define all known feature-enabling |
||||||
|
# macros, then, if reports of conflicts are made, disable macros that |
||||||
|
# cause problems on some platforms (such as __EXTENSIONS__). |
||||||
|
AC_DEFUN_ONCE([AC_USE_SYSTEM_EXTENSIONS], |
||||||
|
[AC_BEFORE([$0], [AC_COMPILE_IFELSE])dnl |
||||||
|
AC_BEFORE([$0], [AC_RUN_IFELSE])dnl |
||||||
|
|
||||||
|
AC_REQUIRE([AC_CANONICAL_HOST]) |
||||||
|
|
||||||
|
AC_CHECK_HEADER([minix/config.h], [MINIX=yes], [MINIX=]) |
||||||
|
if test "$MINIX" = yes; then |
||||||
|
AC_DEFINE([_POSIX_SOURCE], [1], |
||||||
|
[Define to 1 if you need to in order for `stat' and other |
||||||
|
things to work.]) |
||||||
|
AC_DEFINE([_POSIX_1_SOURCE], [2], |
||||||
|
[Define to 2 if the system does not provide POSIX.1 features |
||||||
|
except with this defined.]) |
||||||
|
AC_DEFINE([_MINIX], [1], |
||||||
|
[Define to 1 if on MINIX.]) |
||||||
|
fi |
||||||
|
|
||||||
|
dnl HP-UX 11.11 defines mbstate_t only if _XOPEN_SOURCE is defined to 500, |
||||||
|
dnl regardless of whether the flags -Ae or _D_HPUX_SOURCE=1 are already |
||||||
|
dnl provided. |
||||||
|
case "$host_os" in |
||||||
|
hpux*) |
||||||
|
AC_DEFINE([_XOPEN_SOURCE], [500], |
||||||
|
[Define to 500 only on HP-UX.]) |
||||||
|
;; |
||||||
|
esac |
||||||
|
|
||||||
|
AH_VERBATIM([__EXTENSIONS__], |
||||||
|
[/* Enable extensions on AIX 3, Interix. */ |
||||||
|
#ifndef _ALL_SOURCE |
||||||
|
# undef _ALL_SOURCE |
||||||
|
#endif |
||||||
|
/* Enable GNU extensions on systems that have them. */ |
||||||
|
#ifndef _GNU_SOURCE |
||||||
|
# undef _GNU_SOURCE |
||||||
|
#endif |
||||||
|
/* Enable threading extensions on Solaris. */ |
||||||
|
#ifndef _POSIX_PTHREAD_SEMANTICS |
||||||
|
# undef _POSIX_PTHREAD_SEMANTICS |
||||||
|
#endif |
||||||
|
/* Enable extensions on HP NonStop. */ |
||||||
|
#ifndef _TANDEM_SOURCE |
||||||
|
# undef _TANDEM_SOURCE |
||||||
|
#endif |
||||||
|
/* Enable general extensions on Solaris. */ |
||||||
|
#ifndef __EXTENSIONS__ |
||||||
|
# undef __EXTENSIONS__ |
||||||
|
#endif |
||||||
|
]) |
||||||
|
AC_CACHE_CHECK([whether it is safe to define __EXTENSIONS__], |
||||||
|
[ac_cv_safe_to_define___extensions__], |
||||||
|
[AC_COMPILE_IFELSE( |
||||||
|
[AC_LANG_PROGRAM([[ |
||||||
|
# define __EXTENSIONS__ 1 |
||||||
|
]AC_INCLUDES_DEFAULT])], |
||||||
|
[ac_cv_safe_to_define___extensions__=yes], |
||||||
|
[ac_cv_safe_to_define___extensions__=no])]) |
||||||
|
test $ac_cv_safe_to_define___extensions__ = yes && |
||||||
|
AC_DEFINE([__EXTENSIONS__]) |
||||||
|
AC_DEFINE([_ALL_SOURCE]) |
||||||
|
AC_DEFINE([_GNU_SOURCE]) |
||||||
|
AC_DEFINE([_POSIX_PTHREAD_SEMANTICS]) |
||||||
|
AC_DEFINE([_TANDEM_SOURCE]) |
||||||
|
])# AC_USE_SYSTEM_EXTENSIONS |
||||||
|
|
||||||
|
# gl_USE_SYSTEM_EXTENSIONS |
||||||
|
# ------------------------ |
||||||
|
# Enable extensions on systems that normally disable them, |
||||||
|
# typically due to standards-conformance issues. |
||||||
|
AC_DEFUN_ONCE([gl_USE_SYSTEM_EXTENSIONS], |
||||||
|
[ |
||||||
|
dnl Require this macro before AC_USE_SYSTEM_EXTENSIONS. |
||||||
|
dnl gnulib does not need it. But if it gets required by third-party macros |
||||||
|
dnl after AC_USE_SYSTEM_EXTENSIONS is required, autoconf 2.62..2.63 emit a |
||||||
|
dnl warning: "AC_COMPILE_IFELSE was called before AC_USE_SYSTEM_EXTENSIONS". |
||||||
|
dnl Note: We can do this only for one of the macros AC_AIX, AC_GNU_SOURCE, |
||||||
|
dnl AC_MINIX. If people still use AC_AIX or AC_MINIX, they are out of luck. |
||||||
|
AC_REQUIRE([AC_GNU_SOURCE]) |
||||||
|
|
||||||
|
AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) |
||||||
|
]) |
@ -0,0 +1,282 @@ |
|||||||
|
# gnulib-common.m4 serial 26 |
||||||
|
dnl Copyright (C) 2007-2011 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. |
||||||
|
|
||||||
|
# gl_COMMON |
||||||
|
# is expanded unconditionally through gnulib-tool magic. |
||||||
|
AC_DEFUN([gl_COMMON], [ |
||||||
|
dnl Use AC_REQUIRE here, so that the code is expanded once only. |
||||||
|
AC_REQUIRE([gl_00GNULIB]) |
||||||
|
AC_REQUIRE([gl_COMMON_BODY]) |
||||||
|
]) |
||||||
|
AC_DEFUN([gl_COMMON_BODY], [ |
||||||
|
AH_VERBATIM([isoc99_inline], |
||||||
|
[/* Work around a bug in Apple GCC 4.0.1 build 5465: In C99 mode, it supports |
||||||
|
the ISO C 99 semantics of 'extern inline' (unlike the GNU C semantics of |
||||||
|
earlier versions), but does not display it by setting __GNUC_STDC_INLINE__. |
||||||
|
__APPLE__ && __MACH__ test for MacOS X. |
||||||
|
__APPLE_CC__ tests for the Apple compiler and its version. |
||||||
|
__STDC_VERSION__ tests for the C99 mode. */ |
||||||
|
#if defined __APPLE__ && defined __MACH__ && __APPLE_CC__ >= 5465 && !defined __cplusplus && __STDC_VERSION__ >= 199901L && !defined __GNUC_STDC_INLINE__ |
||||||
|
# define __GNUC_STDC_INLINE__ 1 |
||||||
|
#endif]) |
||||||
|
AH_VERBATIM([unused_parameter], |
||||||
|
[/* Define as a marker that can be attached to declarations that might not |
||||||
|
be used. This helps to reduce warnings, such as from |
||||||
|
GCC -Wunused-parameter. */ |
||||||
|
#if __GNUC__ >= 3 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7) |
||||||
|
# define _GL_UNUSED __attribute__ ((__unused__)) |
||||||
|
#else |
||||||
|
# define _GL_UNUSED |
||||||
|
#endif |
||||||
|
/* The name _UNUSED_PARAMETER_ is an earlier spelling, although the name |
||||||
|
is a misnomer outside of parameter lists. */ |
||||||
|
#define _UNUSED_PARAMETER_ _GL_UNUSED |
||||||
|
|
||||||
|
/* The __pure__ attribute was added in gcc 2.96. */ |
||||||
|
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) |
||||||
|
# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__)) |
||||||
|
#else |
||||||
|
# define _GL_ATTRIBUTE_PURE /* empty */ |
||||||
|
#endif |
||||||
|
|
||||||
|
/* The __const__ attribute was added in gcc 2.95. */ |
||||||
|
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95) |
||||||
|
# define _GL_ATTRIBUTE_CONST __attribute__ ((__const__)) |
||||||
|
#else |
||||||
|
# define _GL_ATTRIBUTE_CONST /* empty */ |
||||||
|
#endif |
||||||
|
]) |
||||||
|
dnl Preparation for running test programs: |
||||||
|
dnl Tell glibc to write diagnostics from -D_FORTIFY_SOURCE=2 to stderr, not |
||||||
|
dnl to /dev/tty, so they can be redirected to log files. Such diagnostics |
||||||
|
dnl arise e.g., in the macros gl_PRINTF_DIRECTIVE_N, gl_SNPRINTF_DIRECTIVE_N. |
||||||
|
LIBC_FATAL_STDERR_=1 |
||||||
|
export LIBC_FATAL_STDERR_ |
||||||
|
]) |
||||||
|
|
||||||
|
# gl_MODULE_INDICATOR_CONDITION |
||||||
|
# expands to a C preprocessor expression that evaluates to 1 or 0, depending |
||||||
|
# whether a gnulib module that has been requested shall be considered present |
||||||
|
# or not. |
||||||
|
m4_define([gl_MODULE_INDICATOR_CONDITION], [1]) |
||||||
|
|
||||||
|
# gl_MODULE_INDICATOR_SET_VARIABLE([modulename]) |
||||||
|
# sets the shell variable that indicates the presence of the given module to |
||||||
|
# a C preprocessor expression that will evaluate to 1. |
||||||
|
AC_DEFUN([gl_MODULE_INDICATOR_SET_VARIABLE], |
||||||
|
[ |
||||||
|
gl_MODULE_INDICATOR_SET_VARIABLE_AUX( |
||||||
|
[GNULIB_[]m4_translit([[$1]], |
||||||
|
[abcdefghijklmnopqrstuvwxyz./-], |
||||||
|
[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])], |
||||||
|
[gl_MODULE_INDICATOR_CONDITION]) |
||||||
|
]) |
||||||
|
|
||||||
|
# gl_MODULE_INDICATOR_SET_VARIABLE_AUX([variable]) |
||||||
|
# modifies the shell variable to include the gl_MODULE_INDICATOR_CONDITION. |
||||||
|
# The shell variable's value is a C preprocessor expression that evaluates |
||||||
|
# to 0 or 1. |
||||||
|
AC_DEFUN([gl_MODULE_INDICATOR_SET_VARIABLE_AUX], |
||||||
|
[ |
||||||
|
m4_if(m4_defn([gl_MODULE_INDICATOR_CONDITION]), [1], |
||||||
|
[ |
||||||
|
dnl Simplify the expression VALUE || 1 to 1. |
||||||
|
$1=1 |
||||||
|
], |
||||||
|
[gl_MODULE_INDICATOR_SET_VARIABLE_AUX_OR([$1], |
||||||
|
[gl_MODULE_INDICATOR_CONDITION])]) |
||||||
|
]) |
||||||
|
|
||||||
|
# gl_MODULE_INDICATOR_SET_VARIABLE_AUX_OR([variable], [condition]) |
||||||
|
# modifies the shell variable to include the given condition. The shell |
||||||
|
# variable's value is a C preprocessor expression that evaluates to 0 or 1. |
||||||
|
AC_DEFUN([gl_MODULE_INDICATOR_SET_VARIABLE_AUX_OR], |
||||||
|
[ |
||||||
|
dnl Simplify the expression 1 || CONDITION to 1. |
||||||
|
if test "$[]$1" != 1; then |
||||||
|
dnl Simplify the expression 0 || CONDITION to CONDITION. |
||||||
|
if test "$[]$1" = 0; then |
||||||
|
$1=$2 |
||||||
|
else |
||||||
|
$1="($[]$1 || $2)" |
||||||
|
fi |
||||||
|
fi |
||||||
|
]) |
||||||
|
|
||||||
|
# gl_MODULE_INDICATOR([modulename]) |
||||||
|
# defines a C macro indicating the presence of the given module |
||||||
|
# in a location where it can be used. |
||||||
|
# | Value | Value | |
||||||
|
# | in lib/ | in tests/ | |
||||||
|
# --------------------------------------------+---------+-----------+ |
||||||
|
# Module present among main modules: | 1 | 1 | |
||||||
|
# --------------------------------------------+---------+-----------+ |
||||||
|
# Module present among tests-related modules: | 0 | 1 | |
||||||
|
# --------------------------------------------+---------+-----------+ |
||||||
|
# Module not present at all: | 0 | 0 | |
||||||
|
# --------------------------------------------+---------+-----------+ |
||||||
|
AC_DEFUN([gl_MODULE_INDICATOR], |
||||||
|
[ |
||||||
|
AC_DEFINE_UNQUOTED([GNULIB_]m4_translit([[$1]], |
||||||
|
[abcdefghijklmnopqrstuvwxyz./-], |
||||||
|
[ABCDEFGHIJKLMNOPQRSTUVWXYZ___]), |
||||||
|
[gl_MODULE_INDICATOR_CONDITION], |
||||||
|
[Define to a C preprocessor expression that evaluates to 1 or 0, |
||||||
|
depending whether the gnulib module $1 shall be considered present.]) |
||||||
|
]) |
||||||
|
|
||||||
|
# gl_MODULE_INDICATOR_FOR_TESTS([modulename]) |
||||||
|
# defines a C macro indicating the presence of the given module |
||||||
|
# in lib or tests. This is useful to determine whether the module |
||||||
|
# should be tested. |
||||||
|
# | Value | Value | |
||||||
|
# | in lib/ | in tests/ | |
||||||
|
# --------------------------------------------+---------+-----------+ |
||||||
|
# Module present among main modules: | 1 | 1 | |
||||||
|
# --------------------------------------------+---------+-----------+ |
||||||
|
# Module present among tests-related modules: | 1 | 1 | |
||||||
|
# --------------------------------------------+---------+-----------+ |
||||||
|
# Module not present at all: | 0 | 0 | |
||||||
|
# --------------------------------------------+---------+-----------+ |
||||||
|
AC_DEFUN([gl_MODULE_INDICATOR_FOR_TESTS], |
||||||
|
[ |
||||||
|
AC_DEFINE([GNULIB_TEST_]m4_translit([[$1]], |
||||||
|
[abcdefghijklmnopqrstuvwxyz./-], |
||||||
|
[ABCDEFGHIJKLMNOPQRSTUVWXYZ___]), [1], |
||||||
|
[Define to 1 when the gnulib module $1 should be tested.]) |
||||||
|
]) |
||||||
|
|
||||||
|
# gl_ASSERT_NO_GNULIB_POSIXCHECK |
||||||
|
# asserts that there will never be a need to #define GNULIB_POSIXCHECK. |
||||||
|
# and thereby enables an optimization of configure and config.h. |
||||||
|
# Used by Emacs. |
||||||
|
AC_DEFUN([gl_ASSERT_NO_GNULIB_POSIXCHECK], |
||||||
|
[ |
||||||
|
dnl Override gl_WARN_ON_USE_PREPARE. |
||||||
|
dnl But hide this definition from 'aclocal'. |
||||||
|
AC_DEFUN([gl_W][ARN_ON_USE_PREPARE], []) |
||||||
|
]) |
||||||
|
|
||||||
|
# gl_ASSERT_NO_GNULIB_TESTS |
||||||
|
# asserts that there will be no gnulib tests in the scope of the configure.ac |
||||||
|
# and thereby enables an optimization of config.h. |
||||||
|
# Used by Emacs. |
||||||
|
AC_DEFUN([gl_ASSERT_NO_GNULIB_TESTS], |
||||||
|
[ |
||||||
|
dnl Override gl_MODULE_INDICATOR_FOR_TESTS. |
||||||
|
AC_DEFUN([gl_MODULE_INDICATOR_FOR_TESTS], []) |
||||||
|
]) |
||||||
|
|
||||||
|
# Test whether <features.h> exists. |
||||||
|
# Set HAVE_FEATURES_H. |
||||||
|
AC_DEFUN([gl_FEATURES_H], |
||||||
|
[ |
||||||
|
AC_CHECK_HEADERS_ONCE([features.h]) |
||||||
|
if test $ac_cv_header_features_h = yes; then |
||||||
|
HAVE_FEATURES_H=1 |
||||||
|
else |
||||||
|
HAVE_FEATURES_H=0 |
||||||
|
fi |
||||||
|
AC_SUBST([HAVE_FEATURES_H]) |
||||||
|
]) |
||||||
|
|
||||||
|
# m4_foreach_w |
||||||
|
# is a backport of autoconf-2.59c's m4_foreach_w. |
||||||
|
# Remove this macro when we can assume autoconf >= 2.60. |
||||||
|
m4_ifndef([m4_foreach_w], |
||||||
|
[m4_define([m4_foreach_w], |
||||||
|
[m4_foreach([$1], m4_split(m4_normalize([$2]), [ ]), [$3])])]) |
||||||
|
|
||||||
|
# AS_VAR_IF(VAR, VALUE, [IF-MATCH], [IF-NOT-MATCH]) |
||||||
|
# ---------------------------------------------------- |
||||||
|
# Backport of autoconf-2.63b's macro. |
||||||
|
# Remove this macro when we can assume autoconf >= 2.64. |
||||||
|
m4_ifndef([AS_VAR_IF], |
||||||
|
[m4_define([AS_VAR_IF], |
||||||
|
[AS_IF([test x"AS_VAR_GET([$1])" = x""$2], [$3], [$4])])]) |
||||||
|
|
||||||
|
# AC_PROG_MKDIR_P |
||||||
|
# is a backport of autoconf-2.60's AC_PROG_MKDIR_P, with a fix |
||||||
|
# for interoperability with automake-1.9.6 from autoconf-2.62. |
||||||
|
# Remove this macro when we can assume autoconf >= 2.62 or |
||||||
|
# autoconf >= 2.60 && automake >= 1.10. |
||||||
|
m4_ifdef([AC_PROG_MKDIR_P], [ |
||||||
|
dnl For automake-1.9.6 && autoconf < 2.62: Ensure MKDIR_P is AC_SUBSTed. |
||||||
|
m4_define([AC_PROG_MKDIR_P], |
||||||
|
m4_defn([AC_PROG_MKDIR_P])[ |
||||||
|
AC_SUBST([MKDIR_P])])], [ |
||||||
|
dnl For autoconf < 2.60: Backport of AC_PROG_MKDIR_P. |
||||||
|
AC_DEFUN_ONCE([AC_PROG_MKDIR_P], |
||||||
|
[AC_REQUIRE([AM_PROG_MKDIR_P])dnl defined by automake |
||||||
|
MKDIR_P='$(mkdir_p)' |
||||||
|
AC_SUBST([MKDIR_P])])]) |
||||||
|
|
||||||
|
# AC_C_RESTRICT |
||||||
|
# This definition overrides the AC_C_RESTRICT macro from autoconf 2.60..2.61, |
||||||
|
# so that mixed use of GNU C and GNU C++ and mixed use of Sun C and Sun C++ |
||||||
|
# works. |
||||||
|
# This definition can be removed once autoconf >= 2.62 can be assumed. |
||||||
|
m4_if(m4_version_compare(m4_defn([m4_PACKAGE_VERSION]),[2.62]),[-1],[ |
||||||
|
AC_DEFUN([AC_C_RESTRICT], |
||||||
|
[AC_CACHE_CHECK([for C/C++ restrict keyword], [ac_cv_c_restrict], |
||||||
|
[ac_cv_c_restrict=no |
||||||
|
# The order here caters to the fact that C++ does not require restrict. |
||||||
|
for ac_kw in __restrict __restrict__ _Restrict restrict; do |
||||||
|
AC_COMPILE_IFELSE([AC_LANG_PROGRAM( |
||||||
|
[[typedef int * int_ptr; |
||||||
|
int foo (int_ptr $ac_kw ip) { |
||||||
|
return ip[0]; |
||||||
|
}]], |
||||||
|
[[int s[1]; |
||||||
|
int * $ac_kw t = s; |
||||||
|
t[0] = 0; |
||||||
|
return foo(t)]])], |
||||||
|
[ac_cv_c_restrict=$ac_kw]) |
||||||
|
test "$ac_cv_c_restrict" != no && break |
||||||
|
done |
||||||
|
]) |
||||||
|
AH_VERBATIM([restrict], |
||||||
|
[/* Define to the equivalent of the C99 'restrict' keyword, or to |
||||||
|
nothing if this is not supported. Do not define if restrict is |
||||||
|
supported directly. */ |
||||||
|
#undef restrict |
||||||
|
/* Work around a bug in Sun C++: it does not support _Restrict, even |
||||||
|
though the corresponding Sun C compiler does, which causes |
||||||
|
"#define restrict _Restrict" in the previous line. Perhaps some future |
||||||
|
version of Sun C++ will work with _Restrict; if so, it'll probably |
||||||
|
define __RESTRICT, just as Sun C does. */ |
||||||
|
#if defined __SUNPRO_CC && !defined __RESTRICT |
||||||
|
# define _Restrict |
||||||
|
#endif]) |
||||||
|
case $ac_cv_c_restrict in |
||||||
|
restrict) ;; |
||||||
|
no) AC_DEFINE([restrict], []) ;; |
||||||
|
*) AC_DEFINE_UNQUOTED([restrict], [$ac_cv_c_restrict]) ;; |
||||||
|
esac |
||||||
|
]) |
||||||
|
]) |
||||||
|
|
||||||
|
# gl_BIGENDIAN |
||||||
|
# is like AC_C_BIGENDIAN, except that it can be AC_REQUIREd. |
||||||
|
# Note that AC_REQUIRE([AC_C_BIGENDIAN]) does not work reliably because some |
||||||
|
# macros invoke AC_C_BIGENDIAN with arguments. |
||||||
|
AC_DEFUN([gl_BIGENDIAN], |
||||||
|
[ |
||||||
|
AC_C_BIGENDIAN |
||||||
|
]) |
||||||
|
|
||||||
|
# gl_CACHE_VAL_SILENT(cache-id, command-to-set-it) |
||||||
|
# is like AC_CACHE_VAL(cache-id, command-to-set-it), except that it does not |
||||||
|
# output a spurious "(cached)" mark in the midst of other configure output. |
||||||
|
# This macro should be used instead of AC_CACHE_VAL when it is not surrounded |
||||||
|
# by an AC_MSG_CHECKING/AC_MSG_RESULT pair. |
||||||
|
AC_DEFUN([gl_CACHE_VAL_SILENT], |
||||||
|
[ |
||||||
|
saved_as_echo_n="$as_echo_n" |
||||||
|
as_echo_n=':' |
||||||
|
AC_CACHE_VAL([$1], [$2]) |
||||||
|
as_echo_n="$saved_as_echo_n" |
||||||
|
]) |
@ -0,0 +1,244 @@ |
|||||||
|
# DO NOT EDIT! GENERATED AUTOMATICALLY! |
||||||
|
# Copyright (C) 2002-2011 Free Software Foundation, Inc. |
||||||
|
# |
||||||
|
# This file is free software, distributed under the terms of the GNU |
||||||
|
# General Public License. As a special exception to the GNU General |
||||||
|
# Public License, this file may be distributed as part of a program |
||||||
|
# that contains a configuration script generated by Autoconf, under |
||||||
|
# the same distribution terms as the rest of that program. |
||||||
|
# |
||||||
|
# Generated by gnulib-tool. |
||||||
|
# |
||||||
|
# This file represents the compiled summary of the specification in |
||||||
|
# gnulib-cache.m4. It lists the computed macro invocations that need |
||||||
|
# to be invoked from configure.ac. |
||||||
|
# In projects that use version control, this file can be treated like |
||||||
|
# other built files. |
||||||
|
|
||||||
|
# This macro should be invoked from ./configure.ac, in the section |
||||||
|
# "Checks for programs", right after AC_PROG_CC, and certainly before |
||||||
|
# any checks for libraries, header files, types and library functions. |
||||||
|
AC_DEFUN([gl_EARLY], |
||||||
|
[ |
||||||
|
m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace |
||||||
|
m4_pattern_allow([^gl_ES$])dnl a valid locale name |
||||||
|
m4_pattern_allow([^gl_LIBOBJS$])dnl a variable |
||||||
|
m4_pattern_allow([^gl_LTLIBOBJS$])dnl a variable |
||||||
|
AC_REQUIRE([AC_PROG_RANLIB]) |
||||||
|
# Code from module arg-nonnull: |
||||||
|
# Code from module c++defs: |
||||||
|
# Code from module extensions: |
||||||
|
AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) |
||||||
|
# Code from module include_next: |
||||||
|
# Code from module memchr: |
||||||
|
# Code from module memmem: |
||||||
|
# Code from module memmem-simple: |
||||||
|
# Code from module multiarch: |
||||||
|
# Code from module stddef: |
||||||
|
# Code from module stdint: |
||||||
|
# Code from module string: |
||||||
|
# Code from module warn-on-use: |
||||||
|
]) |
||||||
|
|
||||||
|
# This macro should be invoked from ./configure.ac, in the section |
||||||
|
# "Check for header files, types and library functions". |
||||||
|
AC_DEFUN([gl_INIT], |
||||||
|
[ |
||||||
|
AM_CONDITIONAL([GL_COND_LIBTOOL], [false]) |
||||||
|
gl_cond_libtool=false |
||||||
|
gl_libdeps= |
||||||
|
gl_ltlibdeps= |
||||||
|
gl_m4_base='m4' |
||||||
|
m4_pushdef([AC_LIBOBJ], m4_defn([gl_LIBOBJ])) |
||||||
|
m4_pushdef([AC_REPLACE_FUNCS], m4_defn([gl_REPLACE_FUNCS])) |
||||||
|
m4_pushdef([AC_LIBSOURCES], m4_defn([gl_LIBSOURCES])) |
||||||
|
m4_pushdef([gl_LIBSOURCES_LIST], []) |
||||||
|
m4_pushdef([gl_LIBSOURCES_DIR], []) |
||||||
|
gl_COMMON |
||||||
|
gl_source_base='lib' |
||||||
|
gl_FUNC_MEMCHR |
||||||
|
if test $HAVE_MEMCHR = 0 || test $REPLACE_MEMCHR = 1; then |
||||||
|
AC_LIBOBJ([memchr]) |
||||||
|
gl_PREREQ_MEMCHR |
||||||
|
fi |
||||||
|
gl_STRING_MODULE_INDICATOR([memchr]) |
||||||
|
gl_FUNC_MEMMEM |
||||||
|
if test $HAVE_MEMMEM = 0 || test $REPLACE_MEMMEM = 1; then |
||||||
|
AC_LIBOBJ([memmem]) |
||||||
|
fi |
||||||
|
gl_FUNC_MEMMEM_SIMPLE |
||||||
|
if test $HAVE_MEMMEM = 0 || test $REPLACE_MEMMEM = 1; then |
||||||
|
AC_LIBOBJ([memmem]) |
||||||
|
fi |
||||||
|
gl_STRING_MODULE_INDICATOR([memmem]) |
||||||
|
gl_MULTIARCH |
||||||
|
gl_STDDEF_H |
||||||
|
gl_STDINT_H |
||||||
|
gl_HEADER_STRING_H |
||||||
|
# End of code from modules |
||||||
|
m4_ifval(gl_LIBSOURCES_LIST, [ |
||||||
|
m4_syscmd([test ! -d ]m4_defn([gl_LIBSOURCES_DIR])[ || |
||||||
|
for gl_file in ]gl_LIBSOURCES_LIST[ ; do |
||||||
|
if test ! -r ]m4_defn([gl_LIBSOURCES_DIR])[/$gl_file ; then |
||||||
|
echo "missing file ]m4_defn([gl_LIBSOURCES_DIR])[/$gl_file" >&2 |
||||||
|
exit 1 |
||||||
|
fi |
||||||
|
done])dnl |
||||||
|
m4_if(m4_sysval, [0], [], |
||||||
|
[AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])]) |
||||||
|
]) |
||||||
|
m4_popdef([gl_LIBSOURCES_DIR]) |
||||||
|
m4_popdef([gl_LIBSOURCES_LIST]) |
||||||
|
m4_popdef([AC_LIBSOURCES]) |
||||||
|
m4_popdef([AC_REPLACE_FUNCS]) |
||||||
|
m4_popdef([AC_LIBOBJ]) |
||||||
|
AC_CONFIG_COMMANDS_PRE([ |
||||||
|
gl_libobjs= |
||||||
|
gl_ltlibobjs= |
||||||
|
if test -n "$gl_LIBOBJS"; then |
||||||
|
# Remove the extension. |
||||||
|
sed_drop_objext='s/\.o$//;s/\.obj$//' |
||||||
|
for i in `for i in $gl_LIBOBJS; do echo "$i"; done | sed -e "$sed_drop_objext" | sort | uniq`; do |
||||||
|
gl_libobjs="$gl_libobjs $i.$ac_objext" |
||||||
|
gl_ltlibobjs="$gl_ltlibobjs $i.lo" |
||||||
|
done |
||||||
|
fi |
||||||
|
AC_SUBST([gl_LIBOBJS], [$gl_libobjs]) |
||||||
|
AC_SUBST([gl_LTLIBOBJS], [$gl_ltlibobjs]) |
||||||
|
]) |
||||||
|
gltests_libdeps= |
||||||
|
gltests_ltlibdeps= |
||||||
|
m4_pushdef([AC_LIBOBJ], m4_defn([gltests_LIBOBJ])) |
||||||
|
m4_pushdef([AC_REPLACE_FUNCS], m4_defn([gltests_REPLACE_FUNCS])) |
||||||
|
m4_pushdef([AC_LIBSOURCES], m4_defn([gltests_LIBSOURCES])) |
||||||
|
m4_pushdef([gltests_LIBSOURCES_LIST], []) |
||||||
|
m4_pushdef([gltests_LIBSOURCES_DIR], []) |
||||||
|
gl_COMMON |
||||||
|
gl_source_base='tests' |
||||||
|
changequote(,)dnl |
||||||
|
gltests_WITNESS=IN_`echo "${PACKAGE-$PACKAGE_TARNAME}" | LC_ALL=C tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ | LC_ALL=C sed -e 's/[^A-Z0-9_]/_/g'`_GNULIB_TESTS |
||||||
|
changequote([, ])dnl |
||||||
|
AC_SUBST([gltests_WITNESS]) |
||||||
|
gl_module_indicator_condition=$gltests_WITNESS |
||||||
|
m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [$gl_module_indicator_condition]) |
||||||
|
m4_popdef([gl_MODULE_INDICATOR_CONDITION]) |
||||||
|
m4_ifval(gltests_LIBSOURCES_LIST, [ |
||||||
|
m4_syscmd([test ! -d ]m4_defn([gltests_LIBSOURCES_DIR])[ || |
||||||
|
for gl_file in ]gltests_LIBSOURCES_LIST[ ; do |
||||||
|
if test ! -r ]m4_defn([gltests_LIBSOURCES_DIR])[/$gl_file ; then |
||||||
|
echo "missing file ]m4_defn([gltests_LIBSOURCES_DIR])[/$gl_file" >&2 |
||||||
|
exit 1 |
||||||
|
fi |
||||||
|
done])dnl |
||||||
|
m4_if(m4_sysval, [0], [], |
||||||
|
[AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])]) |
||||||
|
]) |
||||||
|
m4_popdef([gltests_LIBSOURCES_DIR]) |
||||||
|
m4_popdef([gltests_LIBSOURCES_LIST]) |
||||||
|
m4_popdef([AC_LIBSOURCES]) |
||||||
|
m4_popdef([AC_REPLACE_FUNCS]) |
||||||
|
m4_popdef([AC_LIBOBJ]) |
||||||
|
AC_CONFIG_COMMANDS_PRE([ |
||||||
|
gltests_libobjs= |
||||||
|
gltests_ltlibobjs= |
||||||
|
if test -n "$gltests_LIBOBJS"; then |
||||||
|
# Remove the extension. |
||||||
|
sed_drop_objext='s/\.o$//;s/\.obj$//' |
||||||
|
for i in `for i in $gltests_LIBOBJS; do echo "$i"; done | sed -e "$sed_drop_objext" | sort | uniq`; do |
||||||
|
gltests_libobjs="$gltests_libobjs $i.$ac_objext" |
||||||
|
gltests_ltlibobjs="$gltests_ltlibobjs $i.lo" |
||||||
|
done |
||||||
|
fi |
||||||
|
AC_SUBST([gltests_LIBOBJS], [$gltests_libobjs]) |
||||||
|
AC_SUBST([gltests_LTLIBOBJS], [$gltests_ltlibobjs]) |
||||||
|
]) |
||||||
|
LIBGNU_LIBDEPS="$gl_libdeps" |
||||||
|
AC_SUBST([LIBGNU_LIBDEPS]) |
||||||
|
LIBGNU_LTLIBDEPS="$gl_ltlibdeps" |
||||||
|
AC_SUBST([LIBGNU_LTLIBDEPS]) |
||||||
|
]) |
||||||
|
|
||||||
|
# Like AC_LIBOBJ, except that the module name goes |
||||||
|
# into gl_LIBOBJS instead of into LIBOBJS. |
||||||
|
AC_DEFUN([gl_LIBOBJ], [ |
||||||
|
AS_LITERAL_IF([$1], [gl_LIBSOURCES([$1.c])])dnl |
||||||
|
gl_LIBOBJS="$gl_LIBOBJS $1.$ac_objext" |
||||||
|
]) |
||||||
|
|
||||||
|
# Like AC_REPLACE_FUNCS, except that the module name goes |
||||||
|
# into gl_LIBOBJS instead of into LIBOBJS. |
||||||
|
AC_DEFUN([gl_REPLACE_FUNCS], [ |
||||||
|
m4_foreach_w([gl_NAME], [$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl |
||||||
|
AC_CHECK_FUNCS([$1], , [gl_LIBOBJ($ac_func)]) |
||||||
|
]) |
||||||
|
|
||||||
|
# Like AC_LIBSOURCES, except the directory where the source file is |
||||||
|
# expected is derived from the gnulib-tool parameterization, |
||||||
|
# and alloca is special cased (for the alloca-opt module). |
||||||
|
# We could also entirely rely on EXTRA_lib..._SOURCES. |
||||||
|
AC_DEFUN([gl_LIBSOURCES], [ |
||||||
|
m4_foreach([_gl_NAME], [$1], [ |
||||||
|
m4_if(_gl_NAME, [alloca.c], [], [ |
||||||
|
m4_define([gl_LIBSOURCES_DIR], [lib]) |
||||||
|
m4_append([gl_LIBSOURCES_LIST], _gl_NAME, [ ]) |
||||||
|
]) |
||||||
|
]) |
||||||
|
]) |
||||||
|
|
||||||
|
# Like AC_LIBOBJ, except that the module name goes |
||||||
|
# into gltests_LIBOBJS instead of into LIBOBJS. |
||||||
|
AC_DEFUN([gltests_LIBOBJ], [ |
||||||
|
AS_LITERAL_IF([$1], [gltests_LIBSOURCES([$1.c])])dnl |
||||||
|
gltests_LIBOBJS="$gltests_LIBOBJS $1.$ac_objext" |
||||||
|
]) |
||||||
|
|
||||||
|
# Like AC_REPLACE_FUNCS, except that the module name goes |
||||||
|
# into gltests_LIBOBJS instead of into LIBOBJS. |
||||||
|
AC_DEFUN([gltests_REPLACE_FUNCS], [ |
||||||
|
m4_foreach_w([gl_NAME], [$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl |
||||||
|
AC_CHECK_FUNCS([$1], , [gltests_LIBOBJ($ac_func)]) |
||||||
|
]) |
||||||
|
|
||||||
|
# Like AC_LIBSOURCES, except the directory where the source file is |
||||||
|
# expected is derived from the gnulib-tool parameterization, |
||||||
|
# and alloca is special cased (for the alloca-opt module). |
||||||
|
# We could also entirely rely on EXTRA_lib..._SOURCES. |
||||||
|
AC_DEFUN([gltests_LIBSOURCES], [ |
||||||
|
m4_foreach([_gl_NAME], [$1], [ |
||||||
|
m4_if(_gl_NAME, [alloca.c], [], [ |
||||||
|
m4_define([gltests_LIBSOURCES_DIR], [tests]) |
||||||
|
m4_append([gltests_LIBSOURCES_LIST], _gl_NAME, [ ]) |
||||||
|
]) |
||||||
|
]) |
||||||
|
]) |
||||||
|
|
||||||
|
# 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/arg-nonnull.h |
||||||
|
build-aux/c++defs.h |
||||||
|
build-aux/warn-on-use.h |
||||||
|
lib/dummy.c |
||||||
|
lib/memchr.c |
||||||
|
lib/memchr.valgrind |
||||||
|
lib/memmem.c |
||||||
|
lib/stddef.in.h |
||||||
|
lib/stdint.in.h |
||||||
|
lib/str-two-way.h |
||||||
|
lib/string.in.h |
||||||
|
m4/00gnulib.m4 |
||||||
|
m4/extensions.m4 |
||||||
|
m4/gnulib-common.m4 |
||||||
|
m4/include_next.m4 |
||||||
|
m4/longlong.m4 |
||||||
|
m4/memchr.m4 |
||||||
|
m4/memmem.m4 |
||||||
|
m4/mmap-anon.m4 |
||||||
|
m4/multiarch.m4 |
||||||
|
m4/onceonly.m4 |
||||||
|
m4/stddef_h.m4 |
||||||
|
m4/stdint.m4 |
||||||
|
m4/string_h.m4 |
||||||
|
m4/warn-on-use.m4 |
||||||
|
m4/wchar_t.m4 |
||||||
|
]) |
@ -0,0 +1,57 @@ |
|||||||
|
# gnulib-tool.m4 serial 2 |
||||||
|
dnl Copyright (C) 2004-2005, 2009-2011 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 The following macros need not be invoked explicitly. |
||||||
|
dnl Invoking them does nothing except to declare default arguments |
||||||
|
dnl for "gnulib-tool --import". |
||||||
|
|
||||||
|
dnl Usage: gl_LOCAL_DIR([DIR]) |
||||||
|
AC_DEFUN([gl_LOCAL_DIR], []) |
||||||
|
|
||||||
|
dnl Usage: gl_MODULES([module1 module2 ...]) |
||||||
|
AC_DEFUN([gl_MODULES], []) |
||||||
|
|
||||||
|
dnl Usage: gl_AVOID([module1 module2 ...]) |
||||||
|
AC_DEFUN([gl_AVOID], []) |
||||||
|
|
||||||
|
dnl Usage: gl_SOURCE_BASE([DIR]) |
||||||
|
AC_DEFUN([gl_SOURCE_BASE], []) |
||||||
|
|
||||||
|
dnl Usage: gl_M4_BASE([DIR]) |
||||||
|
AC_DEFUN([gl_M4_BASE], []) |
||||||
|
|
||||||
|
dnl Usage: gl_PO_BASE([DIR]) |
||||||
|
AC_DEFUN([gl_PO_BASE], []) |
||||||
|
|
||||||
|
dnl Usage: gl_DOC_BASE([DIR]) |
||||||
|
AC_DEFUN([gl_DOC_BASE], []) |
||||||
|
|
||||||
|
dnl Usage: gl_TESTS_BASE([DIR]) |
||||||
|
AC_DEFUN([gl_TESTS_BASE], []) |
||||||
|
|
||||||
|
dnl Usage: gl_WITH_TESTS |
||||||
|
AC_DEFUN([gl_WITH_TESTS], []) |
||||||
|
|
||||||
|
dnl Usage: gl_LIB([LIBNAME]) |
||||||
|
AC_DEFUN([gl_LIB], []) |
||||||
|
|
||||||
|
dnl Usage: gl_LGPL or gl_LGPL([VERSION]) |
||||||
|
AC_DEFUN([gl_LGPL], []) |
||||||
|
|
||||||
|
dnl Usage: gl_MAKEFILE_NAME([FILENAME]) |
||||||
|
AC_DEFUN([gl_MAKEFILE_NAME], []) |
||||||
|
|
||||||
|
dnl Usage: gl_LIBTOOL |
||||||
|
AC_DEFUN([gl_LIBTOOL], []) |
||||||
|
|
||||||
|
dnl Usage: gl_MACRO_PREFIX([PREFIX]) |
||||||
|
AC_DEFUN([gl_MACRO_PREFIX], []) |
||||||
|
|
||||||
|
dnl Usage: gl_PO_DOMAIN([DOMAIN]) |
||||||
|
AC_DEFUN([gl_PO_DOMAIN], []) |
||||||
|
|
||||||
|
dnl Usage: gl_VC_FILES([BOOLEAN]) |
||||||
|
AC_DEFUN([gl_VC_FILES], []) |
@ -0,0 +1,244 @@ |
|||||||
|
# include_next.m4 serial 18 |
||||||
|
dnl Copyright (C) 2006-2011 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 Paul Eggert and Derek Price. |
||||||
|
|
||||||
|
dnl Sets INCLUDE_NEXT and PRAGMA_SYSTEM_HEADER. |
||||||
|
dnl |
||||||
|
dnl INCLUDE_NEXT expands to 'include_next' if the compiler supports it, or to |
||||||
|
dnl 'include' otherwise. |
||||||
|
dnl |
||||||
|
dnl INCLUDE_NEXT_AS_FIRST_DIRECTIVE expands to 'include_next' if the compiler |
||||||
|
dnl supports it in the special case that it is the first include directive in |
||||||
|
dnl the given file, or to 'include' otherwise. |
||||||
|
dnl |
||||||
|
dnl PRAGMA_SYSTEM_HEADER can be used in files that contain #include_next, |
||||||
|
dnl so as to avoid GCC warnings when the gcc option -pedantic is used. |
||||||
|
dnl '#pragma GCC system_header' has the same effect as if the file was found |
||||||
|
dnl through the include search path specified with '-isystem' options (as |
||||||
|
dnl opposed to the search path specified with '-I' options). Namely, gcc |
||||||
|
dnl does not warn about some things, and on some systems (Solaris and Interix) |
||||||
|
dnl __STDC__ evaluates to 0 instead of to 1. The latter is an undesired side |
||||||
|
dnl effect; we are therefore careful to use 'defined __STDC__' or '1' instead |
||||||
|
dnl of plain '__STDC__'. |
||||||
|
dnl |
||||||
|
dnl PRAGMA_COLUMNS can be used in files that override system header files, so |
||||||
|
dnl as to avoid compilation errors on HP NonStop systems when the gnulib file |
||||||
|
dnl is included by a system header file that does a "#pragma COLUMNS 80" (which |
||||||
|
dnl has the effect of truncating the lines of that file and all files that it |
||||||
|
dnl includes to 80 columns) and the gnulib file has lines longer than 80 |
||||||
|
dnl columns. |
||||||
|
|
||||||
|
AC_DEFUN([gl_INCLUDE_NEXT], |
||||||
|
[ |
||||||
|
AC_LANG_PREPROC_REQUIRE() |
||||||
|
AC_CACHE_CHECK([whether the preprocessor supports include_next], |
||||||
|
[gl_cv_have_include_next], |
||||||
|
[rm -rf conftestd1a conftestd1b conftestd2 |
||||||
|
mkdir conftestd1a conftestd1b conftestd2 |
||||||
|
dnl IBM C 9.0, 10.1 (original versions, prior to the 2009-01 updates) on |
||||||
|
dnl AIX 6.1 support include_next when used as first preprocessor directive |
||||||
|
dnl in a file, but not when preceded by another include directive. Check |
||||||
|
dnl for this bug by including <stdio.h>. |
||||||
|
dnl Additionally, with this same compiler, include_next is a no-op when |
||||||
|
dnl used in a header file that was included by specifying its absolute |
||||||
|
dnl file name. Despite these two bugs, include_next is used in the |
||||||
|
dnl compiler's <math.h>. By virtue of the second bug, we need to use |
||||||
|
dnl include_next as well in this case. |
||||||
|
cat <<EOF > conftestd1a/conftest.h |
||||||
|
#define DEFINED_IN_CONFTESTD1 |
||||||
|
#include_next <conftest.h> |
||||||
|
#ifdef DEFINED_IN_CONFTESTD2 |
||||||
|
int foo; |
||||||
|
#else |
||||||
|
#error "include_next doesn't work" |
||||||
|
#endif |
||||||
|
EOF |
||||||
|
cat <<EOF > conftestd1b/conftest.h |
||||||
|
#define DEFINED_IN_CONFTESTD1 |
||||||
|
#include <stdio.h> |
||||||
|
#include_next <conftest.h> |
||||||
|
#ifdef DEFINED_IN_CONFTESTD2 |
||||||
|
int foo; |
||||||
|
#else |
||||||
|
#error "include_next doesn't work" |
||||||
|
#endif |
||||||
|
EOF |
||||||
|
cat <<EOF > conftestd2/conftest.h |
||||||
|
#ifndef DEFINED_IN_CONFTESTD1 |
||||||
|
#error "include_next test doesn't work" |
||||||
|
#endif |
||||||
|
#define DEFINED_IN_CONFTESTD2 |
||||||
|
EOF |
||||||
|
gl_save_CPPFLAGS="$CPPFLAGS" |
||||||
|
CPPFLAGS="$gl_save_CPPFLAGS -Iconftestd1b -Iconftestd2" |
||||||
|
dnl We intentionally avoid using AC_LANG_SOURCE here. |
||||||
|
AC_COMPILE_IFELSE([AC_LANG_DEFINES_PROVIDED[#include <conftest.h>]], |
||||||
|
[gl_cv_have_include_next=yes], |
||||||
|
[CPPFLAGS="$gl_save_CPPFLAGS -Iconftestd1a -Iconftestd2" |
||||||
|
AC_COMPILE_IFELSE([AC_LANG_DEFINES_PROVIDED[#include <conftest.h>]], |
||||||
|
[gl_cv_have_include_next=buggy], |
||||||
|
[gl_cv_have_include_next=no]) |
||||||
|
]) |
||||||
|
CPPFLAGS="$gl_save_CPPFLAGS" |
||||||
|
rm -rf conftestd1a conftestd1b conftestd2 |
||||||
|
]) |
||||||
|
PRAGMA_SYSTEM_HEADER= |
||||||
|
if test $gl_cv_have_include_next = yes; then |
||||||
|
INCLUDE_NEXT=include_next |
||||||
|
INCLUDE_NEXT_AS_FIRST_DIRECTIVE=include_next |
||||||
|
if test -n "$GCC"; then |
||||||
|
PRAGMA_SYSTEM_HEADER='#pragma GCC system_header' |
||||||
|
fi |
||||||
|
else |
||||||
|
if test $gl_cv_have_include_next = buggy; then |
||||||
|
INCLUDE_NEXT=include |
||||||
|
INCLUDE_NEXT_AS_FIRST_DIRECTIVE=include_next |
||||||
|
else |
||||||
|
INCLUDE_NEXT=include |
||||||
|
INCLUDE_NEXT_AS_FIRST_DIRECTIVE=include |
||||||
|
fi |
||||||
|
fi |
||||||
|
AC_SUBST([INCLUDE_NEXT]) |
||||||
|
AC_SUBST([INCLUDE_NEXT_AS_FIRST_DIRECTIVE]) |
||||||
|
AC_SUBST([PRAGMA_SYSTEM_HEADER]) |
||||||
|
AC_CACHE_CHECK([whether system header files limit the line length], |
||||||
|
[gl_cv_pragma_columns], |
||||||
|
[dnl HP NonStop systems, which define __TANDEM, have this misfeature. |
||||||
|
AC_EGREP_CPP([choke me], |
||||||
|
[ |
||||||
|
#ifdef __TANDEM |
||||||
|
choke me |
||||||
|
#endif |
||||||
|
], |
||||||
|
[gl_cv_pragma_columns=yes], |
||||||
|
[gl_cv_pragma_columns=no]) |
||||||
|
]) |
||||||
|
if test $gl_cv_pragma_columns = yes; then |
||||||
|
PRAGMA_COLUMNS="#pragma COLUMNS 10000" |
||||||
|
else |
||||||
|
PRAGMA_COLUMNS= |
||||||
|
fi |
||||||
|
AC_SUBST([PRAGMA_COLUMNS]) |
||||||
|
]) |
||||||
|
|
||||||
|
# gl_CHECK_NEXT_HEADERS(HEADER1 HEADER2 ...) |
||||||
|
# ------------------------------------------ |
||||||
|
# For each arg foo.h, if #include_next works, define NEXT_FOO_H to be |
||||||
|
# '<foo.h>'; otherwise define it to be |
||||||
|
# '"///usr/include/foo.h"', or whatever other absolute file name is suitable. |
||||||
|
# Also, if #include_next works as first preprocessing directive in a file, |
||||||
|
# define NEXT_AS_FIRST_DIRECTIVE_FOO_H to be '<foo.h>'; otherwise define it to |
||||||
|
# be |
||||||
|
# '"///usr/include/foo.h"', or whatever other absolute file name is suitable. |
||||||
|
# That way, a header file with the following line: |
||||||
|
# #@INCLUDE_NEXT@ @NEXT_FOO_H@ |
||||||
|
# or |
||||||
|
# #@INCLUDE_NEXT_AS_FIRST_DIRECTIVE@ @NEXT_AS_FIRST_DIRECTIVE_FOO_H@ |
||||||
|
# behaves (after sed substitution) as if it contained |
||||||
|
# #include_next <foo.h> |
||||||
|
# even if the compiler does not support include_next. |
||||||
|
# The three "///" are to pacify Sun C 5.8, which otherwise would say |
||||||
|
# "warning: #include of /usr/include/... may be non-portable". |
||||||
|
# Use `""', not `<>', so that the /// cannot be confused with a C99 comment. |
||||||
|
# Note: This macro assumes that the header file is not empty after |
||||||
|
# preprocessing, i.e. it does not only define preprocessor macros but also |
||||||
|
# provides some type/enum definitions or function/variable declarations. |
||||||
|
# |
||||||
|
# This macro also checks whether each header exists, by invoking |
||||||
|
# AC_CHECK_HEADERS_ONCE or AC_CHECK_HEADERS on each argument. |
||||||
|
AC_DEFUN([gl_CHECK_NEXT_HEADERS], |
||||||
|
[ |
||||||
|
gl_NEXT_HEADERS_INTERNAL([$1], [check]) |
||||||
|
]) |
||||||
|
|
||||||
|
# gl_NEXT_HEADERS(HEADER1 HEADER2 ...) |
||||||
|
# ------------------------------------ |
||||||
|
# Like gl_CHECK_NEXT_HEADERS, except do not check whether the headers exist. |
||||||
|
# This is suitable for headers like <stddef.h> that are standardized by C89 |
||||||
|
# and therefore can be assumed to exist. |
||||||
|
AC_DEFUN([gl_NEXT_HEADERS], |
||||||
|
[ |
||||||
|
gl_NEXT_HEADERS_INTERNAL([$1], [assume]) |
||||||
|
]) |
||||||
|
|
||||||
|
# The guts of gl_CHECK_NEXT_HEADERS and gl_NEXT_HEADERS. |
||||||
|
AC_DEFUN([gl_NEXT_HEADERS_INTERNAL], |
||||||
|
[ |
||||||
|
AC_REQUIRE([gl_INCLUDE_NEXT]) |
||||||
|
AC_REQUIRE([AC_CANONICAL_HOST]) |
||||||
|
|
||||||
|
m4_if([$2], [check], |
||||||
|
[AC_CHECK_HEADERS_ONCE([$1]) |
||||||
|
]) |
||||||
|
|
||||||
|
m4_foreach_w([gl_HEADER_NAME], [$1], |
||||||
|
[AS_VAR_PUSHDEF([gl_next_header], |
||||||
|
[gl_cv_next_]m4_defn([gl_HEADER_NAME])) |
||||||
|
if test $gl_cv_have_include_next = yes; then |
||||||
|
AS_VAR_SET([gl_next_header], ['<'gl_HEADER_NAME'>']) |
||||||
|
else |
||||||
|
AC_CACHE_CHECK( |
||||||
|
[absolute name of <]m4_defn([gl_HEADER_NAME])[>], |
||||||
|
m4_defn([gl_next_header]), |
||||||
|
[m4_if([$2], [check], |
||||||
|
[AS_VAR_PUSHDEF([gl_header_exists], |
||||||
|
[ac_cv_header_]m4_defn([gl_HEADER_NAME])) |
||||||
|
if test AS_VAR_GET(gl_header_exists) = yes; then |
||||||
|
AS_VAR_POPDEF([gl_header_exists]) |
||||||
|
]) |
||||||
|
AC_LANG_CONFTEST( |
||||||
|
[AC_LANG_SOURCE( |
||||||
|
[[#include <]]m4_dquote(m4_defn([gl_HEADER_NAME]))[[>]] |
||||||
|
)]) |
||||||
|
dnl AIX "xlc -E" and "cc -E" omit #line directives for header |
||||||
|
dnl files that contain only a #include of other header files and |
||||||
|
dnl no non-comment tokens of their own. This leads to a failure |
||||||
|
dnl to detect the absolute name of <dirent.h>, <signal.h>, |
||||||
|
dnl <poll.h> and others. The workaround is to force preservation |
||||||
|
dnl of comments through option -C. This ensures all necessary |
||||||
|
dnl #line directives are present. GCC supports option -C as well. |
||||||
|
case "$host_os" in |
||||||
|
aix*) gl_absname_cpp="$ac_cpp -C" ;; |
||||||
|
*) gl_absname_cpp="$ac_cpp" ;; |
||||||
|
esac |
||||||
|
dnl eval is necessary to expand gl_absname_cpp. |
||||||
|
dnl Ultrix and Pyramid sh refuse to redirect output of eval, |
||||||
|
dnl so use subshell. |
||||||
|
AS_VAR_SET([gl_next_header], |
||||||
|
['"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD | |
||||||
|
sed -n '\#/]m4_defn([gl_HEADER_NAME])[#{ |
||||||
|
s#.*"\(.*/]m4_defn([gl_HEADER_NAME])[\)".*#\1# |
||||||
|
s#^/[^/]#//&# |
||||||
|
p |
||||||
|
q |
||||||
|
}'`'"']) |
||||||
|
m4_if([$2], [check], |
||||||
|
[else |
||||||
|
AS_VAR_SET([gl_next_header], ['<'gl_HEADER_NAME'>']) |
||||||
|
fi |
||||||
|
]) |
||||||
|
]) |
||||||
|
fi |
||||||
|
AC_SUBST( |
||||||
|
AS_TR_CPP([NEXT_]m4_defn([gl_HEADER_NAME])), |
||||||
|
[AS_VAR_GET([gl_next_header])]) |
||||||
|
if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then |
||||||
|
# INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next' |
||||||
|
gl_next_as_first_directive='<'gl_HEADER_NAME'>' |
||||||
|
else |
||||||
|
# INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include' |
||||||
|
gl_next_as_first_directive=AS_VAR_GET([gl_next_header]) |
||||||
|
fi |
||||||
|
AC_SUBST( |
||||||
|
AS_TR_CPP([NEXT_AS_FIRST_DIRECTIVE_]m4_defn([gl_HEADER_NAME])), |
||||||
|
[$gl_next_as_first_directive]) |
||||||
|
AS_VAR_POPDEF([gl_next_header])]) |
||||||
|
]) |
||||||
|
|
||||||
|
# Autoconf 2.68 added warnings for our use of AC_COMPILE_IFELSE; |
||||||
|
# this fallback is safe for all earlier autoconf versions. |
||||||
|
m4_define_default([AC_LANG_DEFINES_PROVIDED]) |
@ -0,0 +1,113 @@ |
|||||||
|
# longlong.m4 serial 16 |
||||||
|
dnl Copyright (C) 1999-2007, 2009-2011 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 Paul Eggert. |
||||||
|
|
||||||
|
# Define HAVE_LONG_LONG_INT if 'long long int' works. |
||||||
|
# This fixes a bug in Autoconf 2.61, and can be faster |
||||||
|
# than what's in Autoconf 2.62 through 2.68. |
||||||
|
|
||||||
|
# Note: If the type 'long long int' exists but is only 32 bits large |
||||||
|
# (as on some very old compilers), HAVE_LONG_LONG_INT will not be |
||||||
|
# defined. In this case you can treat 'long long int' like 'long int'. |
||||||
|
|
||||||
|
AC_DEFUN([AC_TYPE_LONG_LONG_INT], |
||||||
|
[ |
||||||
|
AC_REQUIRE([AC_TYPE_UNSIGNED_LONG_LONG_INT]) |
||||||
|
AC_CACHE_CHECK([for long long int], [ac_cv_type_long_long_int], |
||||||
|
[ac_cv_type_long_long_int=yes |
||||||
|
if test "x${ac_cv_prog_cc_c99-no}" = xno; then |
||||||
|
ac_cv_type_long_long_int=$ac_cv_type_unsigned_long_long_int |
||||||
|
if test $ac_cv_type_long_long_int = yes; then |
||||||
|
dnl Catch a bug in Tandem NonStop Kernel (OSS) cc -O circa 2004. |
||||||
|
dnl If cross compiling, assume the bug is not important, since |
||||||
|
dnl nobody cross compiles for this platform as far as we know. |
||||||
|
AC_RUN_IFELSE( |
||||||
|
[AC_LANG_PROGRAM( |
||||||
|
[[@%:@include <limits.h> |
||||||
|
@%:@ifndef LLONG_MAX |
||||||
|
@%:@ define HALF \ |
||||||
|
(1LL << (sizeof (long long int) * CHAR_BIT - 2)) |
||||||
|
@%:@ define LLONG_MAX (HALF - 1 + HALF) |
||||||
|
@%:@endif]], |
||||||
|
[[long long int n = 1; |
||||||
|
int i; |
||||||
|
for (i = 0; ; i++) |
||||||
|
{ |
||||||
|
long long int m = n << i; |
||||||
|
if (m >> i != n) |
||||||
|
return 1; |
||||||
|
if (LLONG_MAX / 2 < m) |
||||||
|
break; |
||||||
|
} |
||||||
|
return 0;]])], |
||||||
|
[], |
||||||
|
[ac_cv_type_long_long_int=no], |
||||||
|
[:]) |
||||||
|
fi |
||||||
|
fi]) |
||||||
|
if test $ac_cv_type_long_long_int = yes; then |
||||||
|
AC_DEFINE([HAVE_LONG_LONG_INT], [1], |
||||||
|
[Define to 1 if the system has the type `long long int'.]) |
||||||
|
fi |
||||||
|
]) |
||||||
|
|
||||||
|
# Define HAVE_UNSIGNED_LONG_LONG_INT if 'unsigned long long int' works. |
||||||
|
# This fixes a bug in Autoconf 2.61, and can be faster |
||||||
|
# than what's in Autoconf 2.62 through 2.68. |
||||||
|
|
||||||
|
# Note: If the type 'unsigned long long int' exists but is only 32 bits |
||||||
|
# large (as on some very old compilers), AC_TYPE_UNSIGNED_LONG_LONG_INT |
||||||
|
# will not be defined. In this case you can treat 'unsigned long long int' |
||||||
|
# like 'unsigned long int'. |
||||||
|
|
||||||
|
AC_DEFUN([AC_TYPE_UNSIGNED_LONG_LONG_INT], |
||||||
|
[ |
||||||
|
AC_CACHE_CHECK([for unsigned long long int], |
||||||
|
[ac_cv_type_unsigned_long_long_int], |
||||||
|
[ac_cv_type_unsigned_long_long_int=yes |
||||||
|
if test "x${ac_cv_prog_cc_c99-no}" = xno; then |
||||||
|
AC_LINK_IFELSE( |
||||||
|
[_AC_TYPE_LONG_LONG_SNIPPET], |
||||||
|
[], |
||||||
|
[ac_cv_type_unsigned_long_long_int=no]) |
||||||
|
fi]) |
||||||
|
if test $ac_cv_type_unsigned_long_long_int = yes; then |
||||||
|
AC_DEFINE([HAVE_UNSIGNED_LONG_LONG_INT], [1], |
||||||
|
[Define to 1 if the system has the type `unsigned long long int'.]) |
||||||
|
fi |
||||||
|
]) |
||||||
|
|
||||||
|
# Expands to a C program that can be used to test for simultaneous support |
||||||
|
# of 'long long' and 'unsigned long long'. We don't want to say that |
||||||
|
# 'long long' is available if 'unsigned long long' is not, or vice versa, |
||||||
|
# because too many programs rely on the symmetry between signed and unsigned |
||||||
|
# integer types (excluding 'bool'). |
||||||
|
AC_DEFUN([_AC_TYPE_LONG_LONG_SNIPPET], |
||||||
|
[ |
||||||
|
AC_LANG_PROGRAM( |
||||||
|
[[/* For now, do not test the preprocessor; as of 2007 there are too many |
||||||
|
implementations with broken preprocessors. Perhaps this can |
||||||
|
be revisited in 2012. In the meantime, code should not expect |
||||||
|
#if to work with literals wider than 32 bits. */ |
||||||
|
/* Test literals. */ |
||||||
|
long long int ll = 9223372036854775807ll; |
||||||
|
long long int nll = -9223372036854775807LL; |
||||||
|
unsigned long long int ull = 18446744073709551615ULL; |
||||||
|
/* Test constant expressions. */ |
||||||
|
typedef int a[((-9223372036854775807LL < 0 && 0 < 9223372036854775807ll) |
||||||
|
? 1 : -1)]; |
||||||
|
typedef int b[(18446744073709551615ULL <= (unsigned long long int) -1 |
||||||
|
? 1 : -1)]; |
||||||
|
int i = 63;]], |
||||||
|
[[/* Test availability of runtime routines for shift and division. */ |
||||||
|
long long int llmax = 9223372036854775807ll; |
||||||
|
unsigned long long int ullmax = 18446744073709551615ull; |
||||||
|
return ((ll << 63) | (ll >> 63) | (ll < i) | (ll > i) |
||||||
|
| (llmax / ll) | (llmax % ll) |
||||||
|
| (ull << 63) | (ull >> 63) | (ull << i) | (ull >> i) |
||||||
|
| (ullmax / ull) | (ullmax % ull));]]) |
||||||
|
]) |
@ -0,0 +1,88 @@ |
|||||||
|
# memchr.m4 serial 12 |
||||||
|
dnl Copyright (C) 2002-2004, 2009-2011 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_ONCE([gl_FUNC_MEMCHR], |
||||||
|
[ |
||||||
|
dnl Check for prerequisites for memory fence checks. |
||||||
|
gl_FUNC_MMAP_ANON |
||||||
|
AC_CHECK_HEADERS_ONCE([sys/mman.h]) |
||||||
|
AC_CHECK_FUNCS_ONCE([mprotect]) |
||||||
|
|
||||||
|
AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS]) |
||||||
|
m4_ifdef([gl_FUNC_MEMCHR_OBSOLETE], [ |
||||||
|
dnl These days, we assume memchr is present. But if support for old |
||||||
|
dnl platforms is desired: |
||||||
|
AC_CHECK_FUNCS_ONCE([memchr]) |
||||||
|
if test $ac_cv_func_memchr = no; then |
||||||
|
HAVE_MEMCHR=0 |
||||||
|
fi |
||||||
|
]) |
||||||
|
if test $HAVE_MEMCHR = 1; then |
||||||
|
# Detect platform-specific bugs in some versions of glibc: |
||||||
|
# memchr should not dereference anything with length 0 |
||||||
|
# http://bugzilla.redhat.com/499689 |
||||||
|
# memchr should not dereference overestimated length after a match |
||||||
|
# http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=521737 |
||||||
|
# http://sourceware.org/bugzilla/show_bug.cgi?id=10162 |
||||||
|
# Assume that memchr works on platforms that lack mprotect. |
||||||
|
AC_CACHE_CHECK([whether memchr works], [gl_cv_func_memchr_works], |
||||||
|
[AC_RUN_IFELSE([AC_LANG_PROGRAM([[ |
||||||
|
#include <string.h> |
||||||
|
#if HAVE_SYS_MMAN_H |
||||||
|
# include <fcntl.h> |
||||||
|
# include <unistd.h> |
||||||
|
# include <sys/types.h> |
||||||
|
# include <sys/mman.h> |
||||||
|
# ifndef MAP_FILE |
||||||
|
# define MAP_FILE 0 |
||||||
|
# endif |
||||||
|
#endif |
||||||
|
]], [[ |
||||||
|
int result = 0; |
||||||
|
char *fence = NULL; |
||||||
|
#if HAVE_SYS_MMAN_H && HAVE_MPROTECT |
||||||
|
# if HAVE_MAP_ANONYMOUS |
||||||
|
const int flags = MAP_ANONYMOUS | MAP_PRIVATE; |
||||||
|
const int fd = -1; |
||||||
|
# else /* !HAVE_MAP_ANONYMOUS */ |
||||||
|
const int flags = MAP_FILE | MAP_PRIVATE; |
||||||
|
int fd = open ("/dev/zero", O_RDONLY, 0666); |
||||||
|
if (fd >= 0) |
||||||
|
# endif |
||||||
|
{ |
||||||
|
int pagesize = getpagesize (); |
||||||
|
char *two_pages = |
||||||
|
(char *) mmap (NULL, 2 * pagesize, PROT_READ | PROT_WRITE, |
||||||
|
flags, fd, 0); |
||||||
|
if (two_pages != (char *)(-1) |
||||||
|
&& mprotect (two_pages + pagesize, pagesize, PROT_NONE) == 0) |
||||||
|
fence = two_pages + pagesize; |
||||||
|
} |
||||||
|
#endif |
||||||
|
if (fence) |
||||||
|
{ |
||||||
|
if (memchr (fence, 0, 0)) |
||||||
|
result |= 1; |
||||||
|
strcpy (fence - 9, "12345678"); |
||||||
|
if (memchr (fence - 9, 0, 79) != fence - 1) |
||||||
|
result |= 2; |
||||||
|
if (memchr (fence - 1, 0, 3) != fence - 1) |
||||||
|
result |= 4; |
||||||
|
} |
||||||
|
return result; |
||||||
|
]])], [gl_cv_func_memchr_works=yes], [gl_cv_func_memchr_works=no], |
||||||
|
[dnl Be pessimistic for now. |
||||||
|
gl_cv_func_memchr_works="guessing no"])]) |
||||||
|
if test "$gl_cv_func_memchr_works" != yes; then |
||||||
|
REPLACE_MEMCHR=1 |
||||||
|
fi |
||||||
|
fi |
||||||
|
]) |
||||||
|
|
||||||
|
# Prerequisites of lib/memchr.c. |
||||||
|
AC_DEFUN([gl_PREREQ_MEMCHR], [ |
||||||
|
AC_CHECK_HEADERS([bp-sym.h]) |
||||||
|
]) |
@ -0,0 +1,145 @@ |
|||||||
|
# memmem.m4 serial 23 |
||||||
|
dnl Copyright (C) 2002-2004, 2007-2011 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 Check that memmem is present and functional. |
||||||
|
AC_DEFUN([gl_FUNC_MEMMEM_SIMPLE], |
||||||
|
[ |
||||||
|
dnl Persuade glibc <string.h> to declare memmem(). |
||||||
|
AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) |
||||||
|
|
||||||
|
AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS]) |
||||||
|
AC_CHECK_FUNCS([memmem]) |
||||||
|
if test $ac_cv_func_memmem = yes; then |
||||||
|
HAVE_MEMMEM=1 |
||||||
|
else |
||||||
|
HAVE_MEMMEM=0 |
||||||
|
fi |
||||||
|
AC_CHECK_DECLS_ONCE([memmem]) |
||||||
|
if test $ac_cv_have_decl_memmem = no; then |
||||||
|
HAVE_DECL_MEMMEM=0 |
||||||
|
else |
||||||
|
dnl Detect http://sourceware.org/bugzilla/show_bug.cgi?id=12092. |
||||||
|
dnl Also check that we handle empty needles correctly. |
||||||
|
AC_CACHE_CHECK([whether memmem works], |
||||||
|
[gl_cv_func_memmem_works_always], |
||||||
|
[AC_RUN_IFELSE([AC_LANG_PROGRAM([[ |
||||||
|
#include <string.h> /* for memmem */ |
||||||
|
#define P "_EF_BF_BD" |
||||||
|
#define HAYSTACK "F_BD_CE_BD" P P P P "_C3_88_20" P P P "_C3_A7_20" P |
||||||
|
#define NEEDLE P P P P P |
||||||
|
]], [[ |
||||||
|
int result = 0; |
||||||
|
if (memmem (HAYSTACK, strlen (HAYSTACK), NEEDLE, strlen (NEEDLE))) |
||||||
|
result |= 1; |
||||||
|
/* Check for empty needle behavior. */ |
||||||
|
{ |
||||||
|
const char *haystack = "AAA"; |
||||||
|
if (memmem (haystack, 3, NULL, 0) != haystack) |
||||||
|
result |= 2; |
||||||
|
} |
||||||
|
return result; |
||||||
|
]])], |
||||||
|
[gl_cv_func_memmem_works_always=yes], |
||||||
|
[gl_cv_func_memmem_works_always=no], |
||||||
|
[dnl glibc 2.9..2.12 and cygwin 1.7.7 have issue #12092 above. |
||||||
|
dnl Also empty needles work on glibc >= 2.1 and cygwin >= 1.7.0. |
||||||
|
dnl uClibc is not affected, since it uses different source code. |
||||||
|
dnl Assume that it works on all other platforms (even if not linear). |
||||||
|
AC_EGREP_CPP([Lucky user], |
||||||
|
[ |
||||||
|
#ifdef __GNU_LIBRARY__ |
||||||
|
#include <features.h> |
||||||
|
#if ((__GLIBC__ == 2 && ((__GLIBC_MINOR > 0 && __GLIBC_MINOR__ < 9) \ |
||||||
|
|| __GLIBC_MINOR__ > 12)) \ |
||||||
|
|| (__GLIBC__ > 2)) \ |
||||||
|
|| defined __UCLIBC__ |
||||||
|
Lucky user |
||||||
|
#endif |
||||||
|
#elif defined __CYGWIN__ |
||||||
|
#include <cygwin/version.h> |
||||||
|
#if CYGWIN_VERSION_DLL_COMBINED > CYGWIN_VERSION_DLL_MAKE_COMBINED (1007, 7) |
||||||
|
Lucky user |
||||||
|
#endif |
||||||
|
#else |
||||||
|
Lucky user |
||||||
|
#endif |
||||||
|
], |
||||||
|
[gl_cv_func_memmem_works_always=yes], |
||||||
|
[gl_cv_func_memmem_works_always="guessing no"]) |
||||||
|
]) |
||||||
|
]) |
||||||
|
if test "$gl_cv_func_memmem_works_always" != yes; then |
||||||
|
REPLACE_MEMMEM=1 |
||||||
|
fi |
||||||
|
fi |
||||||
|
gl_PREREQ_MEMMEM |
||||||
|
]) # gl_FUNC_MEMMEM_SIMPLE |
||||||
|
|
||||||
|
dnl Additionally, check that memmem has linear performance characteristics |
||||||
|
AC_DEFUN([gl_FUNC_MEMMEM], |
||||||
|
[ |
||||||
|
AC_REQUIRE([gl_FUNC_MEMMEM_SIMPLE]) |
||||||
|
if test $HAVE_DECL_MEMMEM = 1 && test $REPLACE_MEMMEM = 0; then |
||||||
|
AC_CACHE_CHECK([whether memmem works in linear time], |
||||||
|
[gl_cv_func_memmem_works_fast], |
||||||
|
[AC_RUN_IFELSE([AC_LANG_PROGRAM([[ |
||||||
|
#include <signal.h> /* for signal */ |
||||||
|
#include <string.h> /* for memmem */ |
||||||
|
#include <stdlib.h> /* for malloc */ |
||||||
|
#include <unistd.h> /* for alarm */ |
||||||
|
static void quit (int sig) { exit (sig + 128); } |
||||||
|
]], [[ |
||||||
|
int result = 0; |
||||||
|
size_t m = 1000000; |
||||||
|
char *haystack = (char *) malloc (2 * m + 1); |
||||||
|
char *needle = (char *) malloc (m + 1); |
||||||
|
/* Failure to compile this test due to missing alarm is okay, |
||||||
|
since all such platforms (mingw) also lack memmem. */ |
||||||
|
signal (SIGALRM, quit); |
||||||
|
alarm (5); |
||||||
|
/* Check for quadratic performance. */ |
||||||
|
if (haystack && needle) |
||||||
|
{ |
||||||
|
memset (haystack, 'A', 2 * m); |
||||||
|
haystack[2 * m] = 'B'; |
||||||
|
memset (needle, 'A', m); |
||||||
|
needle[m] = 'B'; |
||||||
|
if (!memmem (haystack, 2 * m + 1, needle, m + 1)) |
||||||
|
result |= 1; |
||||||
|
} |
||||||
|
return result; |
||||||
|
]])], |
||||||
|
[gl_cv_func_memmem_works_fast=yes], [gl_cv_func_memmem_works_fast=no], |
||||||
|
[dnl Only glibc >= 2.9 and cygwin > 1.7.0 are known to have a |
||||||
|
dnl memmem that works in linear time. |
||||||
|
AC_EGREP_CPP([Lucky user], |
||||||
|
[ |
||||||
|
#include <features.h> |
||||||
|
#ifdef __GNU_LIBRARY__ |
||||||
|
#if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 9) || (__GLIBC__ > 2)) \ |
||||||
|
&& !defined __UCLIBC__ |
||||||
|
Lucky user |
||||||
|
#endif |
||||||
|
#endif |
||||||
|
#ifdef __CYGWIN__ |
||||||
|
#include <cygwin/version.h> |
||||||
|
#if CYGWIN_VERSION_DLL_COMBINED > CYGWIN_VERSION_DLL_MAKE_COMBINED (1007, 0) |
||||||
|
Lucky user |
||||||
|
#endif |
||||||
|
#endif |
||||||
|
], |
||||||
|
[gl_cv_func_memmem_works_fast=yes], |
||||||
|
[gl_cv_func_memmem_works_fast="guessing no"]) |
||||||
|
]) |
||||||
|
]) |
||||||
|
if test "$gl_cv_func_memmem_works_fast" != yes; then |
||||||
|
REPLACE_MEMMEM=1 |
||||||
|
fi |
||||||
|
fi |
||||||
|
]) # gl_FUNC_MEMMEM |
||||||
|
|
||||||
|
# Prerequisites of lib/memmem.c. |
||||||
|
AC_DEFUN([gl_PREREQ_MEMMEM], [:]) |
@ -0,0 +1,55 @@ |
|||||||
|
# mmap-anon.m4 serial 9 |
||||||
|
dnl Copyright (C) 2005, 2007, 2009-2011 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. |
||||||
|
|
||||||
|
# Detect how mmap can be used to create anonymous (not file-backed) memory |
||||||
|
# mappings. |
||||||
|
# - On Linux, AIX, OSF/1, Solaris, Cygwin, Interix, Haiku, both MAP_ANONYMOUS |
||||||
|
# and MAP_ANON exist and have the same value. |
||||||
|
# - On HP-UX, only MAP_ANONYMOUS exists. |
||||||
|
# - On MacOS X, FreeBSD, NetBSD, OpenBSD, only MAP_ANON exists. |
||||||
|
# - On IRIX, neither exists, and a file descriptor opened to /dev/zero must be |
||||||
|
# used. |
||||||
|
|
||||||
|
AC_DEFUN([gl_FUNC_MMAP_ANON], |
||||||
|
[ |
||||||
|
dnl Persuade glibc <sys/mman.h> to define MAP_ANONYMOUS. |
||||||
|
AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) |
||||||
|
|
||||||
|
# Check for mmap(). Don't use AC_FUNC_MMAP, because it checks too much: it |
||||||
|
# fails on HP-UX 11, because MAP_FIXED mappings do not work. But this is |
||||||
|
# irrelevant for anonymous mappings. |
||||||
|
AC_CHECK_FUNC([mmap], [gl_have_mmap=yes], [gl_have_mmap=no]) |
||||||
|
|
||||||
|
# Try to allow MAP_ANONYMOUS. |
||||||
|
gl_have_mmap_anonymous=no |
||||||
|
if test $gl_have_mmap = yes; then |
||||||
|
AC_MSG_CHECKING([for MAP_ANONYMOUS]) |
||||||
|
AC_EGREP_CPP([I cant identify this map.], [ |
||||||
|
#include <sys/mman.h> |
||||||
|
#ifdef MAP_ANONYMOUS |
||||||
|
I cant identify this map. |
||||||
|
#endif |
||||||
|
], |
||||||
|
[gl_have_mmap_anonymous=yes]) |
||||||
|
if test $gl_have_mmap_anonymous != yes; then |
||||||
|
AC_EGREP_CPP([I cant identify this map.], [ |
||||||
|
#include <sys/mman.h> |
||||||
|
#ifdef MAP_ANON |
||||||
|
I cant identify this map. |
||||||
|
#endif |
||||||
|
], |
||||||
|
[AC_DEFINE([MAP_ANONYMOUS], [MAP_ANON], |
||||||
|
[Define to a substitute value for mmap()'s MAP_ANONYMOUS flag.]) |
||||||
|
gl_have_mmap_anonymous=yes]) |
||||||
|
fi |
||||||
|
AC_MSG_RESULT([$gl_have_mmap_anonymous]) |
||||||
|
if test $gl_have_mmap_anonymous = yes; then |
||||||
|
AC_DEFINE([HAVE_MAP_ANONYMOUS], [1], |
||||||
|
[Define to 1 if mmap()'s MAP_ANONYMOUS flag is available after including |
||||||
|
config.h and <sys/mman.h>.]) |
||||||
|
fi |
||||||
|
fi |
||||||
|
]) |
@ -0,0 +1,62 @@ |
|||||||
|
# multiarch.m4 serial 6 |
||||||
|
dnl Copyright (C) 2008-2011 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. |
||||||
|
|
||||||
|
# Determine whether the compiler is or may be producing universal binaries. |
||||||
|
# |
||||||
|
# On MacOS X 10.5 and later systems, the user can create libraries and |
||||||
|
# executables that work on multiple system types--known as "fat" or |
||||||
|
# "universal" binaries--by specifying multiple '-arch' options to the |
||||||
|
# compiler but only a single '-arch' option to the preprocessor. Like |
||||||
|
# this: |
||||||
|
# |
||||||
|
# ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ |
||||||
|
# CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ |
||||||
|
# CPP="gcc -E" CXXCPP="g++ -E" |
||||||
|
# |
||||||
|
# Detect this situation and set APPLE_UNIVERSAL_BUILD accordingly. |
||||||
|
|
||||||
|
AC_DEFUN_ONCE([gl_MULTIARCH], |
||||||
|
[ |
||||||
|
dnl Code similar to autoconf-2.63 AC_C_BIGENDIAN. |
||||||
|
gl_cv_c_multiarch=no |
||||||
|
AC_COMPILE_IFELSE( |
||||||
|
[AC_LANG_SOURCE( |
||||||
|
[[#ifndef __APPLE_CC__ |
||||||
|
not a universal capable compiler |
||||||
|
#endif |
||||||
|
typedef int dummy; |
||||||
|
]])], |
||||||
|
[ |
||||||
|
dnl Check for potential -arch flags. It is not universal unless |
||||||
|
dnl there are at least two -arch flags with different values. |
||||||
|
arch= |
||||||
|
prev= |
||||||
|
for word in ${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS}; do |
||||||
|
if test -n "$prev"; then |
||||||
|
case $word in |
||||||
|
i?86 | x86_64 | ppc | ppc64) |
||||||
|
if test -z "$arch" || test "$arch" = "$word"; then |
||||||
|
arch="$word" |
||||||
|
else |
||||||
|
gl_cv_c_multiarch=yes |
||||||
|
fi |
||||||
|
;; |
||||||
|
esac |
||||||
|
prev= |
||||||
|
else |
||||||
|
if test "x$word" = "x-arch"; then |
||||||
|
prev=arch |
||||||
|
fi |
||||||
|
fi |
||||||
|
done |
||||||
|
]) |
||||||
|
if test $gl_cv_c_multiarch = yes; then |
||||||
|
APPLE_UNIVERSAL_BUILD=1 |
||||||
|
else |
||||||
|
APPLE_UNIVERSAL_BUILD=0 |
||||||
|
fi |
||||||
|
AC_SUBST([APPLE_UNIVERSAL_BUILD]) |
||||||
|
]) |
@ -0,0 +1,91 @@ |
|||||||
|
# onceonly.m4 serial 7 |
||||||
|
dnl Copyright (C) 2002-2003, 2005-2006, 2008-2011 Free Software Foundation, |
||||||
|
dnl Inc. |
||||||
|
dnl This file is free software, distributed under the terms of the GNU |
||||||
|
dnl General Public License. As a special exception to the GNU General |
||||||
|
dnl Public License, this file may be distributed as part of a program |
||||||
|
dnl that contains a configuration script generated by Autoconf, under |
||||||
|
dnl the same distribution terms as the rest of that program. |
||||||
|
|
||||||
|
dnl This file defines some "once only" variants of standard autoconf macros. |
||||||
|
dnl AC_CHECK_HEADERS_ONCE like AC_CHECK_HEADERS |
||||||
|
dnl AC_CHECK_FUNCS_ONCE like AC_CHECK_FUNCS |
||||||
|
dnl AC_CHECK_DECLS_ONCE like AC_CHECK_DECLS |
||||||
|
dnl AC_REQUIRE([AC_FUNC_STRCOLL]) like AC_FUNC_STRCOLL |
||||||
|
dnl The advantage is that the check for each of the headers/functions/decls |
||||||
|
dnl will be put only once into the 'configure' file. It keeps the size of |
||||||
|
dnl the 'configure' file down, and avoids redundant output when 'configure' |
||||||
|
dnl is run. |
||||||
|
dnl The drawback is that the checks cannot be conditionalized. If you write |
||||||
|
dnl if some_condition; then gl_CHECK_HEADERS(stdlib.h); fi |
||||||
|
dnl inside an AC_DEFUNed function, the gl_CHECK_HEADERS macro call expands to |
||||||
|
dnl empty, and the check will be inserted before the body of the AC_DEFUNed |
||||||
|
dnl function. |
||||||
|
|
||||||
|
dnl The original code implemented AC_CHECK_HEADERS_ONCE and AC_CHECK_FUNCS_ONCE |
||||||
|
dnl in terms of AC_DEFUN and AC_REQUIRE. This implementation uses diversions to |
||||||
|
dnl named sections DEFAULTS and INIT_PREPARE in order to check all requested |
||||||
|
dnl headers at once, thus reducing the size of 'configure'. It is known to work |
||||||
|
dnl with autoconf 2.57..2.62 at least . The size reduction is ca. 9%. |
||||||
|
|
||||||
|
dnl Autoconf version 2.59 plus gnulib is required; this file is not needed |
||||||
|
dnl with Autoconf 2.60 or greater. But note that autoconf's implementation of |
||||||
|
dnl AC_CHECK_DECLS_ONCE expects a comma-separated list of symbols as first |
||||||
|
dnl argument! |
||||||
|
AC_PREREQ([2.59]) |
||||||
|
|
||||||
|
# AC_CHECK_HEADERS_ONCE(HEADER1 HEADER2 ...) is a once-only variant of |
||||||
|
# AC_CHECK_HEADERS(HEADER1 HEADER2 ...). |
||||||
|
AC_DEFUN([AC_CHECK_HEADERS_ONCE], [ |
||||||
|
: |
||||||
|
m4_foreach_w([gl_HEADER_NAME], [$1], [ |
||||||
|
AC_DEFUN([gl_CHECK_HEADER_]m4_quote(m4_translit(gl_HEADER_NAME, |
||||||
|
[./-], [___])), [ |
||||||
|
m4_divert_text([INIT_PREPARE], |
||||||
|
[gl_header_list="$gl_header_list gl_HEADER_NAME"]) |
||||||
|
gl_HEADERS_EXPANSION |
||||||
|
AH_TEMPLATE(AS_TR_CPP([HAVE_]m4_defn([gl_HEADER_NAME])), |
||||||
|
[Define to 1 if you have the <]m4_defn([gl_HEADER_NAME])[> header file.]) |
||||||
|
]) |
||||||
|
AC_REQUIRE([gl_CHECK_HEADER_]m4_quote(m4_translit(gl_HEADER_NAME, |
||||||
|
[./-], [___]))) |
||||||
|
]) |
||||||
|
]) |
||||||
|
m4_define([gl_HEADERS_EXPANSION], [ |
||||||
|
m4_divert_text([DEFAULTS], [gl_header_list=]) |
||||||
|
AC_CHECK_HEADERS([$gl_header_list]) |
||||||
|
m4_define([gl_HEADERS_EXPANSION], []) |
||||||
|
]) |
||||||
|
|
||||||
|
# AC_CHECK_FUNCS_ONCE(FUNC1 FUNC2 ...) is a once-only variant of |
||||||
|
# AC_CHECK_FUNCS(FUNC1 FUNC2 ...). |
||||||
|
AC_DEFUN([AC_CHECK_FUNCS_ONCE], [ |
||||||
|
: |
||||||
|
m4_foreach_w([gl_FUNC_NAME], [$1], [ |
||||||
|
AC_DEFUN([gl_CHECK_FUNC_]m4_defn([gl_FUNC_NAME]), [ |
||||||
|
m4_divert_text([INIT_PREPARE], |
||||||
|
[gl_func_list="$gl_func_list gl_FUNC_NAME"]) |
||||||
|
gl_FUNCS_EXPANSION |
||||||
|
AH_TEMPLATE(AS_TR_CPP([HAVE_]m4_defn([gl_FUNC_NAME])), |
||||||
|
[Define to 1 if you have the `]m4_defn([gl_FUNC_NAME])[' function.]) |
||||||
|
]) |
||||||
|
AC_REQUIRE([gl_CHECK_FUNC_]m4_defn([gl_FUNC_NAME])) |
||||||
|
]) |
||||||
|
]) |
||||||
|
m4_define([gl_FUNCS_EXPANSION], [ |
||||||
|
m4_divert_text([DEFAULTS], [gl_func_list=]) |
||||||
|
AC_CHECK_FUNCS([$gl_func_list]) |
||||||
|
m4_define([gl_FUNCS_EXPANSION], []) |
||||||
|
]) |
||||||
|
|
||||||
|
# AC_CHECK_DECLS_ONCE(DECL1 DECL2 ...) is a once-only variant of |
||||||
|
# AC_CHECK_DECLS(DECL1, DECL2, ...). |
||||||
|
AC_DEFUN([AC_CHECK_DECLS_ONCE], [ |
||||||
|
: |
||||||
|
m4_foreach_w([gl_DECL_NAME], [$1], [ |
||||||
|
AC_DEFUN([gl_CHECK_DECL_]m4_defn([gl_DECL_NAME]), [ |
||||||
|
AC_CHECK_DECLS(m4_defn([gl_DECL_NAME])) |
||||||
|
]) |
||||||
|
AC_REQUIRE([gl_CHECK_DECL_]m4_defn([gl_DECL_NAME])) |
||||||
|
]) |
||||||
|
]) |
@ -0,0 +1,47 @@ |
|||||||
|
dnl A placeholder for POSIX 2008 <stddef.h>, for platforms that have issues. |
||||||
|
# stddef_h.m4 serial 4 |
||||||
|
dnl Copyright (C) 2009-2011 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_STDDEF_H], |
||||||
|
[ |
||||||
|
AC_REQUIRE([gl_STDDEF_H_DEFAULTS]) |
||||||
|
AC_REQUIRE([gt_TYPE_WCHAR_T]) |
||||||
|
STDDEF_H= |
||||||
|
if test $gt_cv_c_wchar_t = no; then |
||||||
|
HAVE_WCHAR_T=0 |
||||||
|
STDDEF_H=stddef.h |
||||||
|
fi |
||||||
|
AC_CACHE_CHECK([whether NULL can be used in arbitrary expressions], |
||||||
|
[gl_cv_decl_null_works], |
||||||
|
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stddef.h> |
||||||
|
int test[2 * (sizeof NULL == sizeof (void *)) -1]; |
||||||
|
]])], |
||||||
|
[gl_cv_decl_null_works=yes], |
||||||
|
[gl_cv_decl_null_works=no])]) |
||||||
|
if test $gl_cv_decl_null_works = no; then |
||||||
|
REPLACE_NULL=1 |
||||||
|
STDDEF_H=stddef.h |
||||||
|
fi |
||||||
|
AC_SUBST([STDDEF_H]) |
||||||
|
AM_CONDITIONAL([GL_GENERATE_STDDEF_H], [test -n "$STDDEF_H"]) |
||||||
|
if test -n "$STDDEF_H"; then |
||||||
|
gl_NEXT_HEADERS([stddef.h]) |
||||||
|
fi |
||||||
|
]) |
||||||
|
|
||||||
|
AC_DEFUN([gl_STDDEF_MODULE_INDICATOR], |
||||||
|
[ |
||||||
|
dnl Use AC_REQUIRE here, so that the default settings are expanded once only. |
||||||
|
AC_REQUIRE([gl_STDDEF_H_DEFAULTS]) |
||||||
|
gl_MODULE_INDICATOR_SET_VARIABLE([$1]) |
||||||
|
]) |
||||||
|
|
||||||
|
AC_DEFUN([gl_STDDEF_H_DEFAULTS], |
||||||
|
[ |
||||||
|
dnl Assume proper GNU behavior unless another module says otherwise. |
||||||
|
REPLACE_NULL=0; AC_SUBST([REPLACE_NULL]) |
||||||
|
HAVE_WCHAR_T=1; AC_SUBST([HAVE_WCHAR_T]) |
||||||
|
]) |
@ -0,0 +1,480 @@ |
|||||||
|
# stdint.m4 serial 41 |
||||||
|
dnl Copyright (C) 2001-2011 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 Paul Eggert and Bruno Haible. |
||||||
|
dnl Test whether <stdint.h> is supported or must be substituted. |
||||||
|
|
||||||
|
AC_DEFUN_ONCE([gl_STDINT_H], |
||||||
|
[ |
||||||
|
AC_PREREQ([2.59])dnl |
||||||
|
|
||||||
|
dnl Check for long long int and unsigned long long int. |
||||||
|
AC_REQUIRE([AC_TYPE_LONG_LONG_INT]) |
||||||
|
if test $ac_cv_type_long_long_int = yes; then |
||||||
|
HAVE_LONG_LONG_INT=1 |
||||||
|
else |
||||||
|
HAVE_LONG_LONG_INT=0 |
||||||
|
fi |
||||||
|
AC_SUBST([HAVE_LONG_LONG_INT]) |
||||||
|
AC_REQUIRE([AC_TYPE_UNSIGNED_LONG_LONG_INT]) |
||||||
|
if test $ac_cv_type_unsigned_long_long_int = yes; then |
||||||
|
HAVE_UNSIGNED_LONG_LONG_INT=1 |
||||||
|
else |
||||||
|
HAVE_UNSIGNED_LONG_LONG_INT=0 |
||||||
|
fi |
||||||
|
AC_SUBST([HAVE_UNSIGNED_LONG_LONG_INT]) |
||||||
|
|
||||||
|
dnl Check for <wchar.h>, in the same way as gl_WCHAR_H does. |
||||||
|
AC_CHECK_HEADERS_ONCE([wchar.h]) |
||||||
|
if test $ac_cv_header_wchar_h = yes; then |
||||||
|
HAVE_WCHAR_H=1 |
||||||
|
else |
||||||
|
HAVE_WCHAR_H=0 |
||||||
|
fi |
||||||
|
AC_SUBST([HAVE_WCHAR_H]) |
||||||
|
|
||||||
|
dnl Check for <inttypes.h>. |
||||||
|
dnl AC_INCLUDES_DEFAULT defines $ac_cv_header_inttypes_h. |
||||||
|
if test $ac_cv_header_inttypes_h = yes; then |
||||||
|
HAVE_INTTYPES_H=1 |
||||||
|
else |
||||||
|
HAVE_INTTYPES_H=0 |
||||||
|
fi |
||||||
|
AC_SUBST([HAVE_INTTYPES_H]) |
||||||
|
|
||||||
|
dnl Check for <sys/types.h>. |
||||||
|
dnl AC_INCLUDES_DEFAULT defines $ac_cv_header_sys_types_h. |
||||||
|
if test $ac_cv_header_sys_types_h = yes; then |
||||||
|
HAVE_SYS_TYPES_H=1 |
||||||
|
else |
||||||
|
HAVE_SYS_TYPES_H=0 |
||||||
|
fi |
||||||
|
AC_SUBST([HAVE_SYS_TYPES_H]) |
||||||
|
|
||||||
|
gl_CHECK_NEXT_HEADERS([stdint.h]) |
||||||
|
if test $ac_cv_header_stdint_h = yes; then |
||||||
|
HAVE_STDINT_H=1 |
||||||
|
else |
||||||
|
HAVE_STDINT_H=0 |
||||||
|
fi |
||||||
|
AC_SUBST([HAVE_STDINT_H]) |
||||||
|
|
||||||
|
dnl Now see whether we need a substitute <stdint.h>. |
||||||
|
if test $ac_cv_header_stdint_h = yes; then |
||||||
|
AC_CACHE_CHECK([whether stdint.h conforms to C99], |
||||||
|
[gl_cv_header_working_stdint_h], |
||||||
|
[gl_cv_header_working_stdint_h=no |
||||||
|
AC_COMPILE_IFELSE([ |
||||||
|
AC_LANG_PROGRAM([[ |
||||||
|
#define __STDC_LIMIT_MACROS 1 /* to make it work also in C++ mode */ |
||||||
|
#define __STDC_CONSTANT_MACROS 1 /* to make it work also in C++ mode */ |
||||||
|
#define _GL_JUST_INCLUDE_SYSTEM_STDINT_H 1 /* work if build isn't clean */ |
||||||
|
#include <stdint.h> |
||||||
|
/* Dragonfly defines WCHAR_MIN, WCHAR_MAX only in <wchar.h>. */ |
||||||
|
#if !(defined WCHAR_MIN && defined WCHAR_MAX) |
||||||
|
#error "WCHAR_MIN, WCHAR_MAX not defined in <stdint.h>" |
||||||
|
#endif |
||||||
|
] |
||||||
|
gl_STDINT_INCLUDES |
||||||
|
[ |
||||||
|
#ifdef INT8_MAX |
||||||
|
int8_t a1 = INT8_MAX; |
||||||
|
int8_t a1min = INT8_MIN; |
||||||
|
#endif |
||||||
|
#ifdef INT16_MAX |
||||||
|
int16_t a2 = INT16_MAX; |
||||||
|
int16_t a2min = INT16_MIN; |
||||||
|
#endif |
||||||
|
#ifdef INT32_MAX |
||||||
|
int32_t a3 = INT32_MAX; |
||||||
|
int32_t a3min = INT32_MIN; |
||||||
|
#endif |
||||||
|
#ifdef INT64_MAX |
||||||
|
int64_t a4 = INT64_MAX; |
||||||
|
int64_t a4min = INT64_MIN; |
||||||
|
#endif |
||||||
|
#ifdef UINT8_MAX |
||||||
|
uint8_t b1 = UINT8_MAX; |
||||||
|
#else |
||||||
|
typedef int b1[(unsigned char) -1 != 255 ? 1 : -1]; |
||||||
|
#endif |
||||||
|
#ifdef UINT16_MAX |
||||||
|
uint16_t b2 = UINT16_MAX; |
||||||
|
#endif |
||||||
|
#ifdef UINT32_MAX |
||||||
|
uint32_t b3 = UINT32_MAX; |
||||||
|
#endif |
||||||
|
#ifdef UINT64_MAX |
||||||
|
uint64_t b4 = UINT64_MAX; |
||||||
|
#endif |
||||||
|
int_least8_t c1 = INT8_C (0x7f); |
||||||
|
int_least8_t c1max = INT_LEAST8_MAX; |
||||||
|
int_least8_t c1min = INT_LEAST8_MIN; |
||||||
|
int_least16_t c2 = INT16_C (0x7fff); |
||||||
|
int_least16_t c2max = INT_LEAST16_MAX; |
||||||
|
int_least16_t c2min = INT_LEAST16_MIN; |
||||||
|
int_least32_t c3 = INT32_C (0x7fffffff); |
||||||
|
int_least32_t c3max = INT_LEAST32_MAX; |
||||||
|
int_least32_t c3min = INT_LEAST32_MIN; |
||||||
|
int_least64_t c4 = INT64_C (0x7fffffffffffffff); |
||||||
|
int_least64_t c4max = INT_LEAST64_MAX; |
||||||
|
int_least64_t c4min = INT_LEAST64_MIN; |
||||||
|
uint_least8_t d1 = UINT8_C (0xff); |
||||||
|
uint_least8_t d1max = UINT_LEAST8_MAX; |
||||||
|
uint_least16_t d2 = UINT16_C (0xffff); |
||||||
|
uint_least16_t d2max = UINT_LEAST16_MAX; |
||||||
|
uint_least32_t d3 = UINT32_C (0xffffffff); |
||||||
|
uint_least32_t d3max = UINT_LEAST32_MAX; |
||||||
|
uint_least64_t d4 = UINT64_C (0xffffffffffffffff); |
||||||
|
uint_least64_t d4max = UINT_LEAST64_MAX; |
||||||
|
int_fast8_t e1 = INT_FAST8_MAX; |
||||||
|
int_fast8_t e1min = INT_FAST8_MIN; |
||||||
|
int_fast16_t e2 = INT_FAST16_MAX; |
||||||
|
int_fast16_t e2min = INT_FAST16_MIN; |
||||||
|
int_fast32_t e3 = INT_FAST32_MAX; |
||||||
|
int_fast32_t e3min = INT_FAST32_MIN; |
||||||
|
int_fast64_t e4 = INT_FAST64_MAX; |
||||||
|
int_fast64_t e4min = INT_FAST64_MIN; |
||||||
|
uint_fast8_t f1 = UINT_FAST8_MAX; |
||||||
|
uint_fast16_t f2 = UINT_FAST16_MAX; |
||||||
|
uint_fast32_t f3 = UINT_FAST32_MAX; |
||||||
|
uint_fast64_t f4 = UINT_FAST64_MAX; |
||||||
|
#ifdef INTPTR_MAX |
||||||
|
intptr_t g = INTPTR_MAX; |
||||||
|
intptr_t gmin = INTPTR_MIN; |
||||||
|
#endif |
||||||
|
#ifdef UINTPTR_MAX |
||||||
|
uintptr_t h = UINTPTR_MAX; |
||||||
|
#endif |
||||||
|
intmax_t i = INTMAX_MAX; |
||||||
|
uintmax_t j = UINTMAX_MAX; |
||||||
|
|
||||||
|
#include <limits.h> /* for CHAR_BIT */ |
||||||
|
#define TYPE_MINIMUM(t) \ |
||||||
|
((t) ((t) 0 < (t) -1 ? (t) 0 : ~ TYPE_MAXIMUM (t))) |
||||||
|
#define TYPE_MAXIMUM(t) \ |
||||||
|
((t) ((t) 0 < (t) -1 \ |
||||||
|
? (t) -1 \ |
||||||
|
: ((((t) 1 << (sizeof (t) * CHAR_BIT - 2)) - 1) * 2 + 1))) |
||||||
|
struct s { |
||||||
|
int check_PTRDIFF: |
||||||
|
PTRDIFF_MIN == TYPE_MINIMUM (ptrdiff_t) |
||||||
|
&& PTRDIFF_MAX == TYPE_MAXIMUM (ptrdiff_t) |
||||||
|
? 1 : -1; |
||||||
|
/* Detect bug in FreeBSD 6.0 / ia64. */ |
||||||
|
int check_SIG_ATOMIC: |
||||||
|
SIG_ATOMIC_MIN == TYPE_MINIMUM (sig_atomic_t) |
||||||
|
&& SIG_ATOMIC_MAX == TYPE_MAXIMUM (sig_atomic_t) |
||||||
|
? 1 : -1; |
||||||
|
int check_SIZE: SIZE_MAX == TYPE_MAXIMUM (size_t) ? 1 : -1; |
||||||
|
int check_WCHAR: |
||||||
|
WCHAR_MIN == TYPE_MINIMUM (wchar_t) |
||||||
|
&& WCHAR_MAX == TYPE_MAXIMUM (wchar_t) |
||||||
|
? 1 : -1; |
||||||
|
/* Detect bug in mingw. */ |
||||||
|
int check_WINT: |
||||||
|
WINT_MIN == TYPE_MINIMUM (wint_t) |
||||||
|
&& WINT_MAX == TYPE_MAXIMUM (wint_t) |
||||||
|
? 1 : -1; |
||||||
|
|
||||||
|
/* Detect bugs in glibc 2.4 and Solaris 10 stdint.h, among others. */ |
||||||
|
int check_UINT8_C: |
||||||
|
(-1 < UINT8_C (0)) == (-1 < (uint_least8_t) 0) ? 1 : -1; |
||||||
|
int check_UINT16_C: |
||||||
|
(-1 < UINT16_C (0)) == (-1 < (uint_least16_t) 0) ? 1 : -1; |
||||||
|
|
||||||
|
/* Detect bugs in OpenBSD 3.9 stdint.h. */ |
||||||
|
#ifdef UINT8_MAX |
||||||
|
int check_uint8: (uint8_t) -1 == UINT8_MAX ? 1 : -1; |
||||||
|
#endif |
||||||
|
#ifdef UINT16_MAX |
||||||
|
int check_uint16: (uint16_t) -1 == UINT16_MAX ? 1 : -1; |
||||||
|
#endif |
||||||
|
#ifdef UINT32_MAX |
||||||
|
int check_uint32: (uint32_t) -1 == UINT32_MAX ? 1 : -1; |
||||||
|
#endif |
||||||
|
#ifdef UINT64_MAX |
||||||
|
int check_uint64: (uint64_t) -1 == UINT64_MAX ? 1 : -1; |
||||||
|
#endif |
||||||
|
int check_uint_least8: (uint_least8_t) -1 == UINT_LEAST8_MAX ? 1 : -1; |
||||||
|
int check_uint_least16: (uint_least16_t) -1 == UINT_LEAST16_MAX ? 1 : -1; |
||||||
|
int check_uint_least32: (uint_least32_t) -1 == UINT_LEAST32_MAX ? 1 : -1; |
||||||
|
int check_uint_least64: (uint_least64_t) -1 == UINT_LEAST64_MAX ? 1 : -1; |
||||||
|
int check_uint_fast8: (uint_fast8_t) -1 == UINT_FAST8_MAX ? 1 : -1; |
||||||
|
int check_uint_fast16: (uint_fast16_t) -1 == UINT_FAST16_MAX ? 1 : -1; |
||||||
|
int check_uint_fast32: (uint_fast32_t) -1 == UINT_FAST32_MAX ? 1 : -1; |
||||||
|
int check_uint_fast64: (uint_fast64_t) -1 == UINT_FAST64_MAX ? 1 : -1; |
||||||
|
int check_uintptr: (uintptr_t) -1 == UINTPTR_MAX ? 1 : -1; |
||||||
|
int check_uintmax: (uintmax_t) -1 == UINTMAX_MAX ? 1 : -1; |
||||||
|
int check_size: (size_t) -1 == SIZE_MAX ? 1 : -1; |
||||||
|
}; |
||||||
|
]])], |
||||||
|
[dnl Determine whether the various *_MIN, *_MAX macros are usable |
||||||
|
dnl in preprocessor expression. We could do it by compiling a test |
||||||
|
dnl program for each of these macros. It is faster to run a program |
||||||
|
dnl that inspects the macro expansion. |
||||||
|
dnl This detects a bug on HP-UX 11.23/ia64. |
||||||
|
AC_RUN_IFELSE([ |
||||||
|
AC_LANG_PROGRAM([[ |
||||||
|
#define __STDC_LIMIT_MACROS 1 /* to make it work also in C++ mode */ |
||||||
|
#define __STDC_CONSTANT_MACROS 1 /* to make it work also in C++ mode */ |
||||||
|
#define _GL_JUST_INCLUDE_SYSTEM_STDINT_H 1 /* work if build isn't clean */ |
||||||
|
#include <stdint.h> |
||||||
|
] |
||||||
|
gl_STDINT_INCLUDES |
||||||
|
[ |
||||||
|
#include <stdio.h> |
||||||
|
#include <string.h> |
||||||
|
#define MVAL(macro) MVAL1(macro) |
||||||
|
#define MVAL1(expression) #expression |
||||||
|
static const char *macro_values[] = |
||||||
|
{ |
||||||
|
#ifdef INT8_MAX |
||||||
|
MVAL (INT8_MAX), |
||||||
|
#endif |
||||||
|
#ifdef INT16_MAX |
||||||
|
MVAL (INT16_MAX), |
||||||
|
#endif |
||||||
|
#ifdef INT32_MAX |
||||||
|
MVAL (INT32_MAX), |
||||||
|
#endif |
||||||
|
#ifdef INT64_MAX |
||||||
|
MVAL (INT64_MAX), |
||||||
|
#endif |
||||||
|
#ifdef UINT8_MAX |
||||||
|
MVAL (UINT8_MAX), |
||||||
|
#endif |
||||||
|
#ifdef UINT16_MAX |
||||||
|
MVAL (UINT16_MAX), |
||||||
|
#endif |
||||||
|
#ifdef UINT32_MAX |
||||||
|
MVAL (UINT32_MAX), |
||||||
|
#endif |
||||||
|
#ifdef UINT64_MAX |
||||||
|
MVAL (UINT64_MAX), |
||||||
|
#endif |
||||||
|
NULL |
||||||
|
}; |
||||||
|
]], [[ |
||||||
|
const char **mv; |
||||||
|
for (mv = macro_values; *mv != NULL; mv++) |
||||||
|
{ |
||||||
|
const char *value = *mv; |
||||||
|
/* Test whether it looks like a cast expression. */ |
||||||
|
if (strncmp (value, "((unsigned int)"/*)*/, 15) == 0 |
||||||
|
|| strncmp (value, "((unsigned short)"/*)*/, 17) == 0 |
||||||
|
|| strncmp (value, "((unsigned char)"/*)*/, 16) == 0 |
||||||
|
|| strncmp (value, "((int)"/*)*/, 6) == 0 |
||||||
|
|| strncmp (value, "((signed short)"/*)*/, 15) == 0 |
||||||
|
|| strncmp (value, "((signed char)"/*)*/, 14) == 0) |
||||||
|
return mv - macro_values + 1; |
||||||
|
} |
||||||
|
return 0; |
||||||
|
]])], |
||||||
|
[gl_cv_header_working_stdint_h=yes], |
||||||
|
[], |
||||||
|
[dnl When cross-compiling, assume it works. |
||||||
|
gl_cv_header_working_stdint_h=yes |
||||||
|
]) |
||||||
|
]) |
||||||
|
]) |
||||||
|
fi |
||||||
|
if test "$gl_cv_header_working_stdint_h" = yes; then |
||||||
|
STDINT_H= |
||||||
|
else |
||||||
|
dnl Check for <sys/inttypes.h>, and for |
||||||
|
dnl <sys/bitypes.h> (used in Linux libc4 >= 4.6.7 and libc5). |
||||||
|
AC_CHECK_HEADERS([sys/inttypes.h sys/bitypes.h]) |
||||||
|
if test $ac_cv_header_sys_inttypes_h = yes; then |
||||||
|
HAVE_SYS_INTTYPES_H=1 |
||||||
|
else |
||||||
|
HAVE_SYS_INTTYPES_H=0 |
||||||
|
fi |
||||||
|
AC_SUBST([HAVE_SYS_INTTYPES_H]) |
||||||
|
if test $ac_cv_header_sys_bitypes_h = yes; then |
||||||
|
HAVE_SYS_BITYPES_H=1 |
||||||
|
else |
||||||
|
HAVE_SYS_BITYPES_H=0 |
||||||
|
fi |
||||||
|
AC_SUBST([HAVE_SYS_BITYPES_H]) |
||||||
|
|
||||||
|
gl_STDINT_TYPE_PROPERTIES |
||||||
|
STDINT_H=stdint.h |
||||||
|
fi |
||||||
|
AC_SUBST([STDINT_H]) |
||||||
|
AM_CONDITIONAL([GL_GENERATE_STDINT_H], [test -n "$STDINT_H"]) |
||||||
|
]) |
||||||
|
|
||||||
|
dnl gl_STDINT_BITSIZEOF(TYPES, INCLUDES) |
||||||
|
dnl Determine the size of each of the given types in bits. |
||||||
|
AC_DEFUN([gl_STDINT_BITSIZEOF], |
||||||
|
[ |
||||||
|
dnl Use a shell loop, to avoid bloating configure, and |
||||||
|
dnl - extra AH_TEMPLATE calls, so that autoheader knows what to put into |
||||||
|
dnl config.h.in, |
||||||
|
dnl - extra AC_SUBST calls, so that the right substitutions are made. |
||||||
|
m4_foreach_w([gltype], [$1], |
||||||
|
[AH_TEMPLATE([BITSIZEOF_]m4_translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]), |
||||||
|
[Define to the number of bits in type ']gltype['.])]) |
||||||
|
for gltype in $1 ; do |
||||||
|
AC_CACHE_CHECK([for bit size of $gltype], [gl_cv_bitsizeof_${gltype}], |
||||||
|
[AC_COMPUTE_INT([result], [sizeof ($gltype) * CHAR_BIT], |
||||||
|
[$2 |
||||||
|
#include <limits.h>], [result=unknown]) |
||||||
|
eval gl_cv_bitsizeof_${gltype}=\$result |
||||||
|
]) |
||||||
|
eval result=\$gl_cv_bitsizeof_${gltype} |
||||||
|
if test $result = unknown; then |
||||||
|
dnl Use a nonempty default, because some compilers, such as IRIX 5 cc, |
||||||
|
dnl do a syntax check even on unused #if conditions and give an error |
||||||
|
dnl on valid C code like this: |
||||||
|
dnl #if 0 |
||||||
|
dnl # if > 32 |
||||||
|
dnl # endif |
||||||
|
dnl #endif |
||||||
|
result=0 |
||||||
|
fi |
||||||
|
GLTYPE=`echo "$gltype" | tr 'abcdefghijklmnopqrstuvwxyz ' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_'` |
||||||
|
AC_DEFINE_UNQUOTED([BITSIZEOF_${GLTYPE}], [$result]) |
||||||
|
eval BITSIZEOF_${GLTYPE}=\$result |
||||||
|
done |
||||||
|
m4_foreach_w([gltype], [$1], |
||||||
|
[AC_SUBST([BITSIZEOF_]m4_translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]))]) |
||||||
|
]) |
||||||
|
|
||||||
|
dnl gl_CHECK_TYPES_SIGNED(TYPES, INCLUDES) |
||||||
|
dnl Determine the signedness of each of the given types. |
||||||
|
dnl Define HAVE_SIGNED_TYPE if type is signed. |
||||||
|
AC_DEFUN([gl_CHECK_TYPES_SIGNED], |
||||||
|
[ |
||||||
|
dnl Use a shell loop, to avoid bloating configure, and |
||||||
|
dnl - extra AH_TEMPLATE calls, so that autoheader knows what to put into |
||||||
|
dnl config.h.in, |
||||||
|
dnl - extra AC_SUBST calls, so that the right substitutions are made. |
||||||
|
m4_foreach_w([gltype], [$1], |
||||||
|
[AH_TEMPLATE([HAVE_SIGNED_]m4_translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]), |
||||||
|
[Define to 1 if ']gltype[' is a signed integer type.])]) |
||||||
|
for gltype in $1 ; do |
||||||
|
AC_CACHE_CHECK([whether $gltype is signed], [gl_cv_type_${gltype}_signed], |
||||||
|
[AC_COMPILE_IFELSE( |
||||||
|
[AC_LANG_PROGRAM([$2[ |
||||||
|
int verify[2 * (($gltype) -1 < ($gltype) 0) - 1];]])], |
||||||
|
result=yes, result=no) |
||||||
|
eval gl_cv_type_${gltype}_signed=\$result |
||||||
|
]) |
||||||
|
eval result=\$gl_cv_type_${gltype}_signed |
||||||
|
GLTYPE=`echo $gltype | tr 'abcdefghijklmnopqrstuvwxyz ' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_'` |
||||||
|
if test "$result" = yes; then |
||||||
|
AC_DEFINE_UNQUOTED([HAVE_SIGNED_${GLTYPE}], [1]) |
||||||
|
eval HAVE_SIGNED_${GLTYPE}=1 |
||||||
|
else |
||||||
|
eval HAVE_SIGNED_${GLTYPE}=0 |
||||||
|
fi |
||||||
|
done |
||||||
|
m4_foreach_w([gltype], [$1], |
||||||
|
[AC_SUBST([HAVE_SIGNED_]m4_translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]))]) |
||||||
|
]) |
||||||
|
|
||||||
|
dnl gl_INTEGER_TYPE_SUFFIX(TYPES, INCLUDES) |
||||||
|
dnl Determine the suffix to use for integer constants of the given types. |
||||||
|
dnl Define t_SUFFIX for each such type. |
||||||
|
AC_DEFUN([gl_INTEGER_TYPE_SUFFIX], |
||||||
|
[ |
||||||
|
dnl Use a shell loop, to avoid bloating configure, and |
||||||
|
dnl - extra AH_TEMPLATE calls, so that autoheader knows what to put into |
||||||
|
dnl config.h.in, |
||||||
|
dnl - extra AC_SUBST calls, so that the right substitutions are made. |
||||||
|
m4_foreach_w([gltype], [$1], |
||||||
|
[AH_TEMPLATE(m4_translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_])[_SUFFIX], |
||||||
|
[Define to l, ll, u, ul, ull, etc., as suitable for |
||||||
|
constants of type ']gltype['.])]) |
||||||
|
for gltype in $1 ; do |
||||||
|
AC_CACHE_CHECK([for $gltype integer literal suffix], |
||||||
|
[gl_cv_type_${gltype}_suffix], |
||||||
|
[eval gl_cv_type_${gltype}_suffix=no |
||||||
|
eval result=\$gl_cv_type_${gltype}_signed |
||||||
|
if test "$result" = yes; then |
||||||
|
glsufu= |
||||||
|
else |
||||||
|
glsufu=u |
||||||
|
fi |
||||||
|
for glsuf in "$glsufu" ${glsufu}l ${glsufu}ll ${glsufu}i64; do |
||||||
|
case $glsuf in |
||||||
|
'') gltype1='int';; |
||||||
|
l) gltype1='long int';; |
||||||
|
ll) gltype1='long long int';; |
||||||
|
i64) gltype1='__int64';; |
||||||
|
u) gltype1='unsigned int';; |
||||||
|
ul) gltype1='unsigned long int';; |
||||||
|
ull) gltype1='unsigned long long int';; |
||||||
|
ui64)gltype1='unsigned __int64';; |
||||||
|
esac |
||||||
|
AC_COMPILE_IFELSE( |
||||||
|
[AC_LANG_PROGRAM([$2[ |
||||||
|
extern $gltype foo; |
||||||
|
extern $gltype1 foo;]])], |
||||||
|
[eval gl_cv_type_${gltype}_suffix=\$glsuf]) |
||||||
|
eval result=\$gl_cv_type_${gltype}_suffix |
||||||
|
test "$result" != no && break |
||||||
|
done]) |
||||||
|
GLTYPE=`echo $gltype | tr 'abcdefghijklmnopqrstuvwxyz ' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_'` |
||||||
|
eval result=\$gl_cv_type_${gltype}_suffix |
||||||
|
test "$result" = no && result= |
||||||
|
eval ${GLTYPE}_SUFFIX=\$result |
||||||
|
AC_DEFINE_UNQUOTED([${GLTYPE}_SUFFIX], [$result]) |
||||||
|
done |
||||||
|
m4_foreach_w([gltype], [$1], |
||||||
|
[AC_SUBST(m4_translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_])[_SUFFIX])]) |
||||||
|
]) |
||||||
|
|
||||||
|
dnl gl_STDINT_INCLUDES |
||||||
|
AC_DEFUN([gl_STDINT_INCLUDES], |
||||||
|
[[ |
||||||
|
/* BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be |
||||||
|
included before <wchar.h>. */ |
||||||
|
#include <stddef.h> |
||||||
|
#include <signal.h> |
||||||
|
#if HAVE_WCHAR_H |
||||||
|
# include <stdio.h> |
||||||
|
# include <time.h> |
||||||
|
# include <wchar.h> |
||||||
|
#endif |
||||||
|
]]) |
||||||
|
|
||||||
|
dnl gl_STDINT_TYPE_PROPERTIES |
||||||
|
dnl Compute HAVE_SIGNED_t, BITSIZEOF_t and t_SUFFIX, for all the types t |
||||||
|
dnl of interest to stdint.in.h. |
||||||
|
AC_DEFUN([gl_STDINT_TYPE_PROPERTIES], |
||||||
|
[ |
||||||
|
AC_REQUIRE([gl_MULTIARCH]) |
||||||
|
if test $APPLE_UNIVERSAL_BUILD = 0; then |
||||||
|
gl_STDINT_BITSIZEOF([ptrdiff_t size_t], |
||||||
|
[gl_STDINT_INCLUDES]) |
||||||
|
fi |
||||||
|
gl_STDINT_BITSIZEOF([sig_atomic_t wchar_t wint_t], |
||||||
|
[gl_STDINT_INCLUDES]) |
||||||
|
gl_CHECK_TYPES_SIGNED([sig_atomic_t wchar_t wint_t], |
||||||
|
[gl_STDINT_INCLUDES]) |
||||||
|
gl_cv_type_ptrdiff_t_signed=yes |
||||||
|
gl_cv_type_size_t_signed=no |
||||||
|
if test $APPLE_UNIVERSAL_BUILD = 0; then |
||||||
|
gl_INTEGER_TYPE_SUFFIX([ptrdiff_t size_t], |
||||||
|
[gl_STDINT_INCLUDES]) |
||||||
|
fi |
||||||
|
gl_INTEGER_TYPE_SUFFIX([sig_atomic_t wchar_t wint_t], |
||||||
|
[gl_STDINT_INCLUDES]) |
||||||
|
]) |
||||||
|
|
||||||
|
dnl Autoconf >= 2.61 has AC_COMPUTE_INT built-in. |
||||||
|
dnl Remove this when we can assume autoconf >= 2.61. |
||||||
|
m4_ifdef([AC_COMPUTE_INT], [], [ |
||||||
|
AC_DEFUN([AC_COMPUTE_INT], [_AC_COMPUTE_INT([$2],[$1],[$3],[$4])]) |
||||||
|
]) |
||||||
|
|
||||||
|
# Hey Emacs! |
||||||
|
# Local Variables: |
||||||
|
# indent-tabs-mode: nil |
||||||
|
# End: |
@ -0,0 +1,116 @@ |
|||||||
|
# Configure a GNU-like replacement for <string.h>. |
||||||
|
|
||||||
|
# Copyright (C) 2007-2011 Free Software Foundation, Inc. |
||||||
|
# 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. |
||||||
|
|
||||||
|
# serial 20 |
||||||
|
|
||||||
|
# Written by Paul Eggert. |
||||||
|
|
||||||
|
AC_DEFUN([gl_HEADER_STRING_H], |
||||||
|
[ |
||||||
|
dnl Use AC_REQUIRE here, so that the default behavior below is expanded |
||||||
|
dnl once only, before all statements that occur in other macros. |
||||||
|
AC_REQUIRE([gl_HEADER_STRING_H_BODY]) |
||||||
|
]) |
||||||
|
|
||||||
|
AC_DEFUN([gl_HEADER_STRING_H_BODY], |
||||||
|
[ |
||||||
|
AC_REQUIRE([AC_C_RESTRICT]) |
||||||
|
AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS]) |
||||||
|
gl_NEXT_HEADERS([string.h]) |
||||||
|
|
||||||
|
dnl Check for declarations of anything we want to poison if the |
||||||
|
dnl corresponding gnulib module is not in use, and which is not |
||||||
|
dnl guaranteed by C89. |
||||||
|
gl_WARN_ON_USE_PREPARE([[#include <string.h> |
||||||
|
]], |
||||||
|
[memmem mempcpy memrchr rawmemchr stpcpy stpncpy strchrnul strdup |
||||||
|
strncat strndup strnlen strpbrk strsep strcasestr strtok_r strerror_r |
||||||
|
strsignal strverscmp]) |
||||||
|
]) |
||||||
|
|
||||||
|
AC_DEFUN([gl_STRING_MODULE_INDICATOR], |
||||||
|
[ |
||||||
|
dnl Use AC_REQUIRE here, so that the default settings are expanded once only. |
||||||
|
AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS]) |
||||||
|
gl_MODULE_INDICATOR_SET_VARIABLE([$1]) |
||||||
|
dnl Define it also as a C macro, for the benefit of the unit tests. |
||||||
|
gl_MODULE_INDICATOR_FOR_TESTS([$1]) |
||||||
|
]) |
||||||
|
|
||||||
|
AC_DEFUN([gl_HEADER_STRING_H_DEFAULTS], |
||||||
|
[ |
||||||
|
GNULIB_MEMCHR=0; AC_SUBST([GNULIB_MEMCHR]) |
||||||
|
GNULIB_MEMMEM=0; AC_SUBST([GNULIB_MEMMEM]) |
||||||
|
GNULIB_MEMPCPY=0; AC_SUBST([GNULIB_MEMPCPY]) |
||||||
|
GNULIB_MEMRCHR=0; AC_SUBST([GNULIB_MEMRCHR]) |
||||||
|
GNULIB_RAWMEMCHR=0; AC_SUBST([GNULIB_RAWMEMCHR]) |
||||||
|
GNULIB_STPCPY=0; AC_SUBST([GNULIB_STPCPY]) |
||||||
|
GNULIB_STPNCPY=0; AC_SUBST([GNULIB_STPNCPY]) |
||||||
|
GNULIB_STRCHRNUL=0; AC_SUBST([GNULIB_STRCHRNUL]) |
||||||
|
GNULIB_STRDUP=0; AC_SUBST([GNULIB_STRDUP]) |
||||||
|
GNULIB_STRNCAT=0; AC_SUBST([GNULIB_STRNCAT]) |
||||||
|
GNULIB_STRNDUP=0; AC_SUBST([GNULIB_STRNDUP]) |
||||||
|
GNULIB_STRNLEN=0; AC_SUBST([GNULIB_STRNLEN]) |
||||||
|
GNULIB_STRPBRK=0; AC_SUBST([GNULIB_STRPBRK]) |
||||||
|
GNULIB_STRSEP=0; AC_SUBST([GNULIB_STRSEP]) |
||||||
|
GNULIB_STRSTR=0; AC_SUBST([GNULIB_STRSTR]) |
||||||
|
GNULIB_STRCASESTR=0; AC_SUBST([GNULIB_STRCASESTR]) |
||||||
|
GNULIB_STRTOK_R=0; AC_SUBST([GNULIB_STRTOK_R]) |
||||||
|
GNULIB_MBSLEN=0; AC_SUBST([GNULIB_MBSLEN]) |
||||||
|
GNULIB_MBSNLEN=0; AC_SUBST([GNULIB_MBSNLEN]) |
||||||
|
GNULIB_MBSCHR=0; AC_SUBST([GNULIB_MBSCHR]) |
||||||
|
GNULIB_MBSRCHR=0; AC_SUBST([GNULIB_MBSRCHR]) |
||||||
|
GNULIB_MBSSTR=0; AC_SUBST([GNULIB_MBSSTR]) |
||||||
|
GNULIB_MBSCASECMP=0; AC_SUBST([GNULIB_MBSCASECMP]) |
||||||
|
GNULIB_MBSNCASECMP=0; AC_SUBST([GNULIB_MBSNCASECMP]) |
||||||
|
GNULIB_MBSPCASECMP=0; AC_SUBST([GNULIB_MBSPCASECMP]) |
||||||
|
GNULIB_MBSCASESTR=0; AC_SUBST([GNULIB_MBSCASESTR]) |
||||||
|
GNULIB_MBSCSPN=0; AC_SUBST([GNULIB_MBSCSPN]) |
||||||
|
GNULIB_MBSPBRK=0; AC_SUBST([GNULIB_MBSPBRK]) |
||||||
|
GNULIB_MBSSPN=0; AC_SUBST([GNULIB_MBSSPN]) |
||||||
|
GNULIB_MBSSEP=0; AC_SUBST([GNULIB_MBSSEP]) |
||||||
|
GNULIB_MBSTOK_R=0; AC_SUBST([GNULIB_MBSTOK_R]) |
||||||
|
GNULIB_STRERROR=0; AC_SUBST([GNULIB_STRERROR]) |
||||||
|
GNULIB_STRERROR_R=0; AC_SUBST([GNULIB_STRERROR_R]) |
||||||
|
GNULIB_STRSIGNAL=0; AC_SUBST([GNULIB_STRSIGNAL]) |
||||||
|
GNULIB_STRVERSCMP=0; AC_SUBST([GNULIB_STRVERSCMP]) |
||||||
|
HAVE_MBSLEN=0; AC_SUBST([HAVE_MBSLEN]) |
||||||
|
dnl Assume proper GNU behavior unless another module says otherwise. |
||||||
|
HAVE_MEMCHR=1; AC_SUBST([HAVE_MEMCHR]) |
||||||
|
HAVE_DECL_MEMMEM=1; AC_SUBST([HAVE_DECL_MEMMEM]) |
||||||
|
HAVE_MEMPCPY=1; AC_SUBST([HAVE_MEMPCPY]) |
||||||
|
HAVE_DECL_MEMRCHR=1; AC_SUBST([HAVE_DECL_MEMRCHR]) |
||||||
|
HAVE_RAWMEMCHR=1; AC_SUBST([HAVE_RAWMEMCHR]) |
||||||
|
HAVE_STPCPY=1; AC_SUBST([HAVE_STPCPY]) |
||||||
|
HAVE_STPNCPY=1; AC_SUBST([HAVE_STPNCPY]) |
||||||
|
HAVE_STRCHRNUL=1; AC_SUBST([HAVE_STRCHRNUL]) |
||||||
|
HAVE_DECL_STRDUP=1; AC_SUBST([HAVE_DECL_STRDUP]) |
||||||
|
HAVE_DECL_STRNDUP=1; AC_SUBST([HAVE_DECL_STRNDUP]) |
||||||
|
HAVE_DECL_STRNLEN=1; AC_SUBST([HAVE_DECL_STRNLEN]) |
||||||
|
HAVE_STRPBRK=1; AC_SUBST([HAVE_STRPBRK]) |
||||||
|
HAVE_STRSEP=1; AC_SUBST([HAVE_STRSEP]) |
||||||
|
HAVE_STRCASESTR=1; AC_SUBST([HAVE_STRCASESTR]) |
||||||
|
HAVE_DECL_STRTOK_R=1; AC_SUBST([HAVE_DECL_STRTOK_R]) |
||||||
|
HAVE_DECL_STRERROR_R=1; AC_SUBST([HAVE_DECL_STRERROR_R]) |
||||||
|
HAVE_DECL_STRSIGNAL=1; AC_SUBST([HAVE_DECL_STRSIGNAL]) |
||||||
|
HAVE_STRVERSCMP=1; AC_SUBST([HAVE_STRVERSCMP]) |
||||||
|
REPLACE_MEMCHR=0; AC_SUBST([REPLACE_MEMCHR]) |
||||||
|
REPLACE_MEMMEM=0; AC_SUBST([REPLACE_MEMMEM]) |
||||||
|
REPLACE_STPNCPY=0; AC_SUBST([REPLACE_STPNCPY]) |
||||||
|
REPLACE_STRDUP=0; AC_SUBST([REPLACE_STRDUP]) |
||||||
|
REPLACE_STRSTR=0; AC_SUBST([REPLACE_STRSTR]) |
||||||
|
REPLACE_STRCASESTR=0; AC_SUBST([REPLACE_STRCASESTR]) |
||||||
|
REPLACE_STRCHRNUL=0; AC_SUBST([REPLACE_STRCHRNUL]) |
||||||
|
REPLACE_STRERROR=0; AC_SUBST([REPLACE_STRERROR]) |
||||||
|
REPLACE_STRERROR_R=0; AC_SUBST([REPLACE_STRERROR_R]) |
||||||
|
REPLACE_STRNCAT=0; AC_SUBST([REPLACE_STRNCAT]) |
||||||
|
REPLACE_STRNDUP=0; AC_SUBST([REPLACE_STRNDUP]) |
||||||
|
REPLACE_STRNLEN=0; AC_SUBST([REPLACE_STRNLEN]) |
||||||
|
REPLACE_STRSIGNAL=0; AC_SUBST([REPLACE_STRSIGNAL]) |
||||||
|
REPLACE_STRTOK_R=0; AC_SUBST([REPLACE_STRTOK_R]) |
||||||
|
UNDEFINE_STRTOK_R=0; AC_SUBST([UNDEFINE_STRTOK_R]) |
||||||
|
]) |
@ -0,0 +1,45 @@ |
|||||||
|
# warn-on-use.m4 serial 2 |
||||||
|
dnl Copyright (C) 2010-2011 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. |
||||||
|
|
||||||
|
# gl_WARN_ON_USE_PREPARE(INCLUDES, NAMES) |
||||||
|
# --------------------------------------- |
||||||
|
# For each whitespace-separated element in the list of NAMES, define |
||||||
|
# HAVE_RAW_DECL_name if the function has a declaration among INCLUDES |
||||||
|
# even after being undefined as a macro. |
||||||
|
# |
||||||
|
# See warn-on-use.h for some hints on how to poison function names, as |
||||||
|
# well as ideas on poisoning global variables and macros. NAMES may |
||||||
|
# include global variables, but remember that only functions work with |
||||||
|
# _GL_WARN_ON_USE. Typically, INCLUDES only needs to list a single |
||||||
|
# header, but if the replacement header pulls in other headers because |
||||||
|
# some systems declare functions in the wrong header, then INCLUDES |
||||||
|
# should do likewise. |
||||||
|
# |
||||||
|
# If you assume C89, then it is generally safe to assume declarations |
||||||
|
# for functions declared in that standard (such as gets) without |
||||||
|
# needing gl_WARN_ON_USE_PREPARE. |
||||||
|
AC_DEFUN([gl_WARN_ON_USE_PREPARE], |
||||||
|
[ |
||||||
|
m4_foreach_w([gl_decl], [$2], |
||||||
|
[AH_TEMPLATE([HAVE_RAW_DECL_]AS_TR_CPP(m4_defn([gl_decl])), |
||||||
|
[Define to 1 if ]m4_defn([gl_decl])[ is declared even after |
||||||
|
undefining macros.])])dnl |
||||||
|
for gl_func in m4_flatten([$2]); do |
||||||
|
AS_VAR_PUSHDEF([gl_Symbol], [gl_cv_have_raw_decl_$gl_func])dnl |
||||||
|
AC_CACHE_CHECK([whether $gl_func is declared without a macro], |
||||||
|
gl_Symbol, |
||||||
|
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([$1], |
||||||
|
[@%:@undef $gl_func |
||||||
|
(void) $gl_func;])], |
||||||
|
[AS_VAR_SET(gl_Symbol, [yes])], [AS_VAR_SET(gl_Symbol, [no])])]) |
||||||
|
AS_VAR_IF(gl_Symbol, [yes], |
||||||
|
[AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_RAW_DECL_$gl_func]), [1]) |
||||||
|
dnl shortcut - if the raw declaration exists, then set a cache |
||||||
|
dnl variable to allow skipping any later AC_CHECK_DECL efforts |
||||||
|
eval ac_cv_have_decl_$gl_func=yes]) |
||||||
|
AS_VAR_POPDEF([gl_Symbol])dnl |
||||||
|
done |
||||||
|
]) |
@ -0,0 +1,24 @@ |
|||||||
|
# wchar_t.m4 serial 4 (gettext-0.18.2) |
||||||
|
dnl Copyright (C) 2002-2003, 2008-2011 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 Test whether <stddef.h> has the 'wchar_t' type. |
||||||
|
dnl Prerequisite: AC_PROG_CC |
||||||
|
|
||||||
|
AC_DEFUN([gt_TYPE_WCHAR_T], |
||||||
|
[ |
||||||
|
AC_CACHE_CHECK([for wchar_t], [gt_cv_c_wchar_t], |
||||||
|
[AC_COMPILE_IFELSE( |
||||||
|
[AC_LANG_PROGRAM( |
||||||
|
[[#include <stddef.h> |
||||||
|
wchar_t foo = (wchar_t)'\0';]], |
||||||
|
[[]])], |
||||||
|
[gt_cv_c_wchar_t=yes], |
||||||
|
[gt_cv_c_wchar_t=no])]) |
||||||
|
if test $gt_cv_c_wchar_t = yes; then |
||||||
|
AC_DEFINE([HAVE_WCHAR_T], [1], [Define if you have the 'wchar_t' type.]) |
||||||
|
fi |
||||||
|
]) |
@ -0,0 +1,109 @@ |
|||||||
|
/* A C macro for emitting warnings if a function is used.
|
||||||
|
Copyright (C) 2010-2011 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/>. */
|
||||||
|
|
||||||
|
/* _GL_WARN_ON_USE (function, "literal string") issues a declaration
|
||||||
|
for FUNCTION which will then trigger a compiler warning containing |
||||||
|
the text of "literal string" anywhere that function is called, if |
||||||
|
supported by the compiler. If the compiler does not support this |
||||||
|
feature, the macro expands to an unused extern declaration. |
||||||
|
|
||||||
|
This macro is useful for marking a function as a potential |
||||||
|
portability trap, with the intent that "literal string" include |
||||||
|
instructions on the replacement function that should be used |
||||||
|
instead. However, one of the reasons that a function is a |
||||||
|
portability trap is if it has the wrong signature. Declaring |
||||||
|
FUNCTION with a different signature in C is a compilation error, so |
||||||
|
this macro must use the same type as any existing declaration so |
||||||
|
that programs that avoid the problematic FUNCTION do not fail to |
||||||
|
compile merely because they included a header that poisoned the |
||||||
|
function. But this implies that _GL_WARN_ON_USE is only safe to |
||||||
|
use if FUNCTION is known to already have a declaration. Use of |
||||||
|
this macro implies that there must not be any other macro hiding |
||||||
|
the declaration of FUNCTION; but undefining FUNCTION first is part |
||||||
|
of the poisoning process anyway (although for symbols that are |
||||||
|
provided only via a macro, the result is a compilation error rather |
||||||
|
than a warning containing "literal string"). Also note that in |
||||||
|
C++, it is only safe to use if FUNCTION has no overloads. |
||||||
|
|
||||||
|
For an example, it is possible to poison 'getline' by: |
||||||
|
- adding a call to gl_WARN_ON_USE_PREPARE([[#include <stdio.h>]], |
||||||
|
[getline]) in configure.ac, which potentially defines |
||||||
|
HAVE_RAW_DECL_GETLINE |
||||||
|
- adding this code to a header that wraps the system <stdio.h>: |
||||||
|
#undef getline |
||||||
|
#if HAVE_RAW_DECL_GETLINE |
||||||
|
_GL_WARN_ON_USE (getline, "getline is required by POSIX 2008, but" |
||||||
|
"not universally present; use the gnulib module getline"); |
||||||
|
#endif |
||||||
|
|
||||||
|
It is not possible to directly poison global variables. But it is |
||||||
|
possible to write a wrapper accessor function, and poison that |
||||||
|
(less common usage, like &environ, will cause a compilation error |
||||||
|
rather than issue the nice warning, but the end result of informing |
||||||
|
the developer about their portability problem is still achieved): |
||||||
|
#if HAVE_RAW_DECL_ENVIRON |
||||||
|
static inline char ***rpl_environ (void) { return &environ; } |
||||||
|
_GL_WARN_ON_USE (rpl_environ, "environ is not always properly declared"); |
||||||
|
# undef environ |
||||||
|
# define environ (*rpl_environ ()) |
||||||
|
#endif |
||||||
|
*/ |
||||||
|
#ifndef _GL_WARN_ON_USE |
||||||
|
|
||||||
|
# if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) |
||||||
|
/* A compiler attribute is available in gcc versions 4.3.0 and later. */ |
||||||
|
# define _GL_WARN_ON_USE(function, message) \ |
||||||
|
extern __typeof__ (function) function __attribute__ ((__warning__ (message))) |
||||||
|
# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING |
||||||
|
/* Verify the existence of the function. */ |
||||||
|
# define _GL_WARN_ON_USE(function, message) \ |
||||||
|
extern __typeof__ (function) function |
||||||
|
# else /* Unsupported. */ |
||||||
|
# define _GL_WARN_ON_USE(function, message) \ |
||||||
|
_GL_WARN_EXTERN_C int _gl_warn_on_use |
||||||
|
# endif |
||||||
|
#endif |
||||||
|
|
||||||
|
/* _GL_WARN_ON_USE_CXX (function, rettype, parameters_and_attributes, "string")
|
||||||
|
is like _GL_WARN_ON_USE (function, "string"), except that the function is |
||||||
|
declared with the given prototype, consisting of return type, parameters, |
||||||
|
and attributes. |
||||||
|
This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does |
||||||
|
not work in this case. */ |
||||||
|
#ifndef _GL_WARN_ON_USE_CXX |
||||||
|
# if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) |
||||||
|
# define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ |
||||||
|
extern rettype function parameters_and_attributes \ |
||||||
|
__attribute__ ((__warning__ (msg))) |
||||||
|
# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING |
||||||
|
/* Verify the existence of the function. */ |
||||||
|
# define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ |
||||||
|
extern rettype function parameters_and_attributes |
||||||
|
# else /* Unsupported. */ |
||||||
|
# define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ |
||||||
|
_GL_WARN_EXTERN_C int _gl_warn_on_use |
||||||
|
# endif |
||||||
|
#endif |
||||||
|
|
||||||
|
/* _GL_WARN_EXTERN_C declaration;
|
||||||
|
performs the declaration with C linkage. */ |
||||||
|
#ifndef _GL_WARN_EXTERN_C |
||||||
|
# if defined __cplusplus |
||||||
|
# define _GL_WARN_EXTERN_C extern "C" |
||||||
|
# else |
||||||
|
# define _GL_WARN_EXTERN_C extern |
||||||
|
# endif |
||||||
|
#endif |
Loading…
Reference in new issue