Use Gnulib's `nproc'.
This updates Gnulib to v0.0-4496-g6491120. * m4/gnulib-cache.m4: Add `nproc'.
This commit is contained in:
parent
cb26e97a88
commit
0f00f2c33a
90 changed files with 2524 additions and 680 deletions
|
|
@ -9,7 +9,7 @@
|
|||
# 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=build-aux --lgpl=3 --libtool --macro-prefix=gl --no-vc-files alignof alloca-opt announce-gen autobuild byteswap canonicalize-lgpl duplocale environ extensions flock fpieee full-read full-write func gendocs getaddrinfo git-version-gen gitlog-to-changelog gnu-web-doc-update gnupload havelib iconv_open-utf inet_ntop inet_pton isinf isnan lib-symbol-versions lib-symbol-visibility libunistring locale maintainer-makefile putenv stat-time stdlib strcase strftime striconveh string sys_stat verify version-etc-fsf vsnprintf warnings
|
||||
# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --lgpl=3 --libtool --macro-prefix=gl --no-vc-files alignof alloca-opt announce-gen autobuild byteswap canonicalize-lgpl duplocale environ extensions flock fpieee full-read full-write func gendocs getaddrinfo git-version-gen gitlog-to-changelog gnu-web-doc-update gnupload havelib iconv_open-utf inet_ntop inet_pton isinf isnan lib-symbol-versions lib-symbol-visibility libunistring locale maintainer-makefile nproc putenv stat-time stdlib strcase strftime striconveh string sys_stat verify version-etc-fsf vsnprintf warnings
|
||||
|
||||
AUTOMAKE_OPTIONS = 1.5 gnits subdir-objects
|
||||
|
||||
|
|
@ -36,6 +36,19 @@ libgnu_la_LIBADD = $(gl_LTLIBOBJS)
|
|||
libgnu_la_DEPENDENCIES = $(gl_LTLIBOBJS)
|
||||
EXTRA_libgnu_la_SOURCES =
|
||||
libgnu_la_LDFLAGS = $(AM_LDFLAGS)
|
||||
libgnu_la_LDFLAGS += -no-undefined
|
||||
libgnu_la_LDFLAGS += $(GETADDRINFO_LIB)
|
||||
libgnu_la_LDFLAGS += $(HOSTENT_LIB)
|
||||
libgnu_la_LDFLAGS += $(INET_NTOP_LIB)
|
||||
libgnu_la_LDFLAGS += $(INET_PTON_LIB)
|
||||
libgnu_la_LDFLAGS += $(ISNAND_LIBM)
|
||||
libgnu_la_LDFLAGS += $(ISNANF_LIBM)
|
||||
libgnu_la_LDFLAGS += $(ISNANL_LIBM)
|
||||
libgnu_la_LDFLAGS += $(LIBSOCKET)
|
||||
libgnu_la_LDFLAGS += $(LTLIBICONV)
|
||||
libgnu_la_LDFLAGS += $(LTLIBINTL)
|
||||
libgnu_la_LDFLAGS += $(LTLIBUNISTRING)
|
||||
libgnu_la_LDFLAGS += $(SERVENT_LIB)
|
||||
|
||||
## begin gnulib module alignof
|
||||
|
||||
|
|
@ -105,6 +118,8 @@ arpa/inet.h: arpa_inet.in.h $(WARN_ON_USE_H) $(ARG_NONNULL_H)
|
|||
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
|
||||
sed -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|@''HAVE_FEATURES_H''@|$(HAVE_FEATURES_H)|g' \
|
||||
-e 's|@''NEXT_ARPA_INET_H''@|$(NEXT_ARPA_INET_H)|g' \
|
||||
-e 's|@''HAVE_ARPA_INET_H''@|$(HAVE_ARPA_INET_H)|g' \
|
||||
-e 's|@''GNULIB_INET_NTOP''@|$(GNULIB_INET_NTOP)|g' \
|
||||
|
|
@ -193,6 +208,14 @@ EXTRA_libgnu_la_SOURCES += canonicalize-lgpl.c
|
|||
|
||||
## end gnulib module canonicalize-lgpl
|
||||
|
||||
## begin gnulib module close-hook
|
||||
|
||||
libgnu_la_SOURCES += close-hook.c
|
||||
|
||||
EXTRA_DIST += close-hook.h
|
||||
|
||||
## end gnulib module close-hook
|
||||
|
||||
## begin gnulib module configmake
|
||||
|
||||
# Retrieve values of the variables through 'configure' followed by
|
||||
|
|
@ -274,6 +297,7 @@ errno.h: errno.in.h
|
|||
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
|
||||
sed -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_ERRNO_H''@|$(NEXT_ERRNO_H)|g' \
|
||||
-e 's|@''EMULTIHOP_HIDDEN''@|$(EMULTIHOP_HIDDEN)|g' \
|
||||
-e 's|@''EMULTIHOP_VALUE''@|$(EMULTIHOP_VALUE)|g' \
|
||||
|
|
@ -301,6 +325,7 @@ float.h: float.in.h
|
|||
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
|
||||
sed -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_FLOAT_H''@|$(NEXT_FLOAT_H)|g' \
|
||||
< $(srcdir)/float.in.h; \
|
||||
} > $@-t && \
|
||||
|
|
@ -416,7 +441,9 @@ iconv.h: iconv.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
|
|||
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
|
||||
sed -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_ICONV_H''@|$(NEXT_ICONV_H)|g' \
|
||||
-e 's|@''GNULIB_ICONV''@|$(GNULIB_ICONV)|g' \
|
||||
-e 's|@''ICONV_CONST''@|$(ICONV_CONST)|g' \
|
||||
-e 's|@''REPLACE_ICONV''@|$(REPLACE_ICONV)|g' \
|
||||
-e 's|@''REPLACE_ICONV_OPEN''@|$(REPLACE_ICONV_OPEN)|g' \
|
||||
|
|
@ -626,6 +653,7 @@ locale.h: locale.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
|
|||
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
|
||||
sed -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_LOCALE_H''@|$(NEXT_LOCALE_H)|g' \
|
||||
-e 's|@''GNULIB_DUPLOCALE''@|$(GNULIB_DUPLOCALE)|g' \
|
||||
-e 's|@''HAVE_DUPLOCALE''@|$(HAVE_DUPLOCALE)|g' \
|
||||
|
|
@ -686,6 +714,7 @@ math.h: math.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
|
|||
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
|
||||
sed -e 's|@''INCLUDE_NEXT_AS_FIRST_DIRECTIVE''@|$(INCLUDE_NEXT_AS_FIRST_DIRECTIVE)|g' \
|
||||
-e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
|
||||
-e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
|
||||
-e 's|@''NEXT_AS_FIRST_DIRECTIVE_MATH_H''@|$(NEXT_AS_FIRST_DIRECTIVE_MATH_H)|g' \
|
||||
-e 's|@''GNULIB_ACOSL''@|$(GNULIB_ACOSL)|g' \
|
||||
-e 's|@''GNULIB_ASINL''@|$(GNULIB_ASINL)|g' \
|
||||
|
|
@ -828,6 +857,7 @@ netdb.h: netdb.in.h $(ARG_NONNULL_H) $(WARN_ON_USE_H)
|
|||
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
|
||||
sed -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_NETDB_H''@|$(NEXT_NETDB_H)|g' \
|
||||
-e 's|@''HAVE_NETDB_H''@|$(HAVE_NETDB_H)|g' \
|
||||
-e 's|@''GNULIB_GETADDRINFO''@|$(GNULIB_GETADDRINFO)|g' \
|
||||
|
|
@ -859,6 +889,7 @@ netinet/in.h: netinet_in.in.h
|
|||
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
|
||||
sed -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_NETINET_IN_H''@|$(NEXT_NETINET_IN_H)|g' \
|
||||
-e 's|@''HAVE_NETINET_IN_H''@|$(HAVE_NETINET_IN_H)|g' \
|
||||
< $(srcdir)/netinet_in.in.h; \
|
||||
|
|
@ -871,6 +902,14 @@ EXTRA_DIST += netinet_in.in.h
|
|||
|
||||
## end gnulib module netinet_in
|
||||
|
||||
## begin gnulib module nproc
|
||||
|
||||
libgnu_la_SOURCES += nproc.c
|
||||
|
||||
EXTRA_DIST += nproc.h
|
||||
|
||||
## end gnulib module nproc
|
||||
|
||||
## begin gnulib module pathmax
|
||||
|
||||
|
||||
|
|
@ -929,6 +968,14 @@ EXTRA_libgnu_la_SOURCES += snprintf.c
|
|||
|
||||
## end gnulib module snprintf
|
||||
|
||||
## begin gnulib module sockets
|
||||
|
||||
libgnu_la_SOURCES += sockets.h sockets.c
|
||||
|
||||
EXTRA_DIST += w32sock.h
|
||||
|
||||
## end gnulib module sockets
|
||||
|
||||
## begin gnulib module stat
|
||||
|
||||
|
||||
|
|
@ -956,6 +1003,7 @@ stdarg.h: stdarg.in.h
|
|||
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
|
||||
sed -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_STDARG_H''@|$(NEXT_STDARG_H)|g' \
|
||||
< $(srcdir)/stdarg.in.h; \
|
||||
} > $@-t && \
|
||||
|
|
@ -995,6 +1043,7 @@ stddef.h: stddef.in.h
|
|||
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
|
||||
sed -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' \
|
||||
|
|
@ -1019,6 +1068,7 @@ stdint.h: stdint.in.h
|
|||
sed -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' \
|
||||
|
|
@ -1060,6 +1110,7 @@ stdio.h: stdio.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
|
|||
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
|
||||
sed -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_STDIO_H''@|$(NEXT_STDIO_H)|g' \
|
||||
-e 's|@''GNULIB_DPRINTF''@|$(GNULIB_DPRINTF)|g' \
|
||||
-e 's|@''GNULIB_FCLOSE''@|$(GNULIB_FCLOSE)|g' \
|
||||
|
|
@ -1170,6 +1221,7 @@ stdlib.h: stdlib.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
|
|||
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
|
||||
sed -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_STDLIB_H''@|$(NEXT_STDLIB_H)|g' \
|
||||
-e 's|@''GNULIB__EXIT''@|$(GNULIB__EXIT)|g' \
|
||||
-e 's|@''GNULIB_ATOLL''@|$(GNULIB_ATOLL)|g' \
|
||||
|
|
@ -1194,6 +1246,7 @@ stdlib.h: stdlib.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
|
|||
-e 's|@''GNULIB_STRTOD''@|$(GNULIB_STRTOD)|g' \
|
||||
-e 's|@''GNULIB_STRTOLL''@|$(GNULIB_STRTOLL)|g' \
|
||||
-e 's|@''GNULIB_STRTOULL''@|$(GNULIB_STRTOULL)|g' \
|
||||
-e 's|@''GNULIB_SYSTEM_POSIX''@|$(GNULIB_SYSTEM_POSIX)|g' \
|
||||
-e 's|@''GNULIB_UNLOCKPT''@|$(GNULIB_UNLOCKPT)|g' \
|
||||
-e 's|@''GNULIB_UNSETENV''@|$(GNULIB_UNSETENV)|g' \
|
||||
-e 's|@''HAVE__EXIT''@|$(HAVE__EXIT)|g' \
|
||||
|
|
@ -1289,6 +1342,7 @@ string.h: string.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
|
|||
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
|
||||
sed -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' \
|
||||
|
|
@ -1322,6 +1376,7 @@ string.h: string.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
|
|||
-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 | \
|
||||
|
|
@ -1341,6 +1396,7 @@ string.h: string.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
|
|||
-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' \
|
||||
|
|
@ -1350,6 +1406,7 @@ string.h: string.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
|
|||
-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' \
|
||||
|
|
@ -1379,6 +1436,7 @@ strings.h: strings.in.h $(WARN_ON_USE_H) $(ARG_NONNULL_H)
|
|||
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
|
||||
sed -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_STRINGS_H''@|$(NEXT_STRINGS_H)|g' \
|
||||
-e 's|@''HAVE_STRCASECMP''@|$(HAVE_STRCASECMP)|g' \
|
||||
-e 's|@''HAVE_DECL_STRNCASECMP''@|$(HAVE_DECL_STRNCASECMP)|g' \
|
||||
|
|
@ -1406,6 +1464,7 @@ sys/file.h: sys_file.in.h $(WARN_ON_USE_H)
|
|||
sed -e 's/@''HAVE_SYS_FILE_H''@/$(HAVE_SYS_FILE_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_SYS_FILE_H''@|$(NEXT_SYS_FILE_H)|g' \
|
||||
-e 's/@''HAVE_FLOCK''@/$(HAVE_FLOCK)/g' \
|
||||
-e 's/@''GNULIB_FLOCK''@/$(GNULIB_FLOCK)/g' \
|
||||
|
|
@ -1432,6 +1491,7 @@ sys/socket.h: sys_socket.in.h $(CXXDEFS_H) $(WARN_ON_USE_H) $(ARG_NONNULL_H)
|
|||
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
|
||||
sed -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_SYS_SOCKET_H''@|$(NEXT_SYS_SOCKET_H)|g' \
|
||||
-e 's|@''HAVE_SYS_SOCKET_H''@|$(HAVE_SYS_SOCKET_H)|g' \
|
||||
-e 's|@''GNULIB_CLOSE''@|$(GNULIB_CLOSE)|g' \
|
||||
|
|
@ -1453,6 +1513,7 @@ sys/socket.h: sys_socket.in.h $(CXXDEFS_H) $(WARN_ON_USE_H) $(ARG_NONNULL_H)
|
|||
-e 's|@''HAVE_WINSOCK2_H''@|$(HAVE_WINSOCK2_H)|g' \
|
||||
-e 's|@''HAVE_WS2TCPIP_H''@|$(HAVE_WS2TCPIP_H)|g' \
|
||||
-e 's|@''HAVE_STRUCT_SOCKADDR_STORAGE''@|$(HAVE_STRUCT_SOCKADDR_STORAGE)|g' \
|
||||
-e 's|@''HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY''@|$(HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY)|g' \
|
||||
-e 's|@''HAVE_SA_FAMILY_T''@|$(HAVE_SA_FAMILY_T)|g' \
|
||||
-e 's|@''HAVE_ACCEPT4''@|$(HAVE_ACCEPT4)|g' \
|
||||
-e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
|
||||
|
|
@ -1480,6 +1541,7 @@ sys/stat.h: sys_stat.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
|
|||
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
|
||||
sed -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_SYS_STAT_H''@|$(NEXT_SYS_STAT_H)|g' \
|
||||
-e 's|@''GNULIB_FCHMODAT''@|$(GNULIB_FCHMODAT)|g' \
|
||||
-e 's|@''GNULIB_FSTATAT''@|$(GNULIB_FSTATAT)|g' \
|
||||
|
|
@ -1537,6 +1599,7 @@ time.h: time.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
|
|||
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
|
||||
sed -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_TIME_H''@|$(NEXT_TIME_H)|g' \
|
||||
-e 's|@''GNULIB_MKTIME''@|$(GNULIB_MKTIME)|g' \
|
||||
-e 's|@''GNULIB_NANOSLEEP''@|$(GNULIB_NANOSLEEP)|g' \
|
||||
|
|
@ -1587,6 +1650,7 @@ unistd.h: unistd.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
|
|||
sed -e 's|@''HAVE_UNISTD_H''@|$(HAVE_UNISTD_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_UNISTD_H''@|$(NEXT_UNISTD_H)|g' \
|
||||
-e 's|@''GNULIB_CHOWN''@|$(GNULIB_CHOWN)|g' \
|
||||
-e 's|@''GNULIB_CLOSE''@|$(GNULIB_CLOSE)|g' \
|
||||
|
|
@ -1638,7 +1702,6 @@ unistd.h: unistd.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
|
|||
-e 's|@''HAVE_FCHOWNAT''@|$(HAVE_FCHOWNAT)|g' \
|
||||
-e 's|@''HAVE_FSYNC''@|$(HAVE_FSYNC)|g' \
|
||||
-e 's|@''HAVE_FTRUNCATE''@|$(HAVE_FTRUNCATE)|g' \
|
||||
-e 's|@''HAVE_GETDOMAINNAME''@|$(HAVE_GETDOMAINNAME)|g' \
|
||||
-e 's|@''HAVE_GETDTABLESIZE''@|$(HAVE_GETDTABLESIZE)|g' \
|
||||
-e 's|@''HAVE_GETGROUPS''@|$(HAVE_GETGROUPS)|g' \
|
||||
-e 's|@''HAVE_GETHOSTNAME''@|$(HAVE_GETHOSTNAME)|g' \
|
||||
|
|
@ -1659,6 +1722,7 @@ unistd.h: unistd.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
|
|||
-e 's|@''HAVE_UNLINKAT''@|$(HAVE_UNLINKAT)|g' \
|
||||
-e 's|@''HAVE_USLEEP''@|$(HAVE_USLEEP)|g' \
|
||||
-e 's|@''HAVE_DECL_ENVIRON''@|$(HAVE_DECL_ENVIRON)|g' \
|
||||
-e 's|@''HAVE_DECL_GETDOMAINNAME''@|$(HAVE_DECL_GETDOMAINNAME)|g' \
|
||||
-e 's|@''HAVE_DECL_GETLOGIN_R''@|$(HAVE_DECL_GETLOGIN_R)|g' \
|
||||
-e 's|@''HAVE_DECL_GETPAGESIZE''@|$(HAVE_DECL_GETPAGESIZE)|g' \
|
||||
-e 's|@''HAVE_DECL_GETUSERSHELL''@|$(HAVE_DECL_GETUSERSHELL)|g' \
|
||||
|
|
@ -1670,6 +1734,7 @@ unistd.h: unistd.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
|
|||
-e 's|@''REPLACE_DUP2''@|$(REPLACE_DUP2)|g' \
|
||||
-e 's|@''REPLACE_FCHOWNAT''@|$(REPLACE_FCHOWNAT)|g' \
|
||||
-e 's|@''REPLACE_GETCWD''@|$(REPLACE_GETCWD)|g' \
|
||||
-e 's|@''REPLACE_GETDOMAINNAME''@|$(REPLACE_GETDOMAINNAME)|g' \
|
||||
-e 's|@''REPLACE_GETGROUPS''@|$(REPLACE_GETGROUPS)|g' \
|
||||
-e 's|@''REPLACE_GETPAGESIZE''@|$(REPLACE_GETPAGESIZE)|g' \
|
||||
-e 's|@''REPLACE_LCHOWN''@|$(REPLACE_LCHOWN)|g' \
|
||||
|
|
@ -1877,6 +1942,8 @@ wchar.h: wchar.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
|
|||
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
|
||||
sed -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|@''HAVE_FEATURES_H''@|$(HAVE_FEATURES_H)|g' \
|
||||
-e 's|@''NEXT_WCHAR_H''@|$(NEXT_WCHAR_H)|g' \
|
||||
-e 's|@''HAVE_WCHAR_H''@|$(HAVE_WCHAR_H)|g' \
|
||||
-e 's|@''GNULIB_BTOWC''@|$(GNULIB_BTOWC)|g' \
|
||||
|
|
|
|||
|
|
@ -21,6 +21,11 @@
|
|||
#if __GNUC__ >= 3
|
||||
@PRAGMA_SYSTEM_HEADER@
|
||||
#endif
|
||||
@PRAGMA_COLUMNS@
|
||||
|
||||
#if @HAVE_FEATURES_H@
|
||||
# include <features.h> /* for __GLIBC__ */
|
||||
#endif
|
||||
|
||||
/* Gnulib's sys/socket.h is responsible for pulling in winsock2.h etc
|
||||
under MinGW.
|
||||
|
|
|
|||
91
lib/close-hook.c
Normal file
91
lib/close-hook.c
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
/* Hook for making the close() function extensible.
|
||||
Copyright (C) 2009, 2010 Free Software Foundation, Inc.
|
||||
Written by Bruno Haible <bruno@clisp.org>, 2009.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU Lesser 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
/* Specification. */
|
||||
#include "close-hook.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#undef close
|
||||
|
||||
|
||||
/* Currently, this entire code is only needed for the handling of sockets
|
||||
on native Windows platforms. */
|
||||
#if WINDOWS_SOCKETS
|
||||
|
||||
/* The first and last link in the doubly linked list.
|
||||
Initially the list is empty. */
|
||||
static struct close_hook anchor = { &anchor, &anchor, NULL };
|
||||
|
||||
int
|
||||
execute_close_hooks (int fd, const struct close_hook *remaining_list)
|
||||
{
|
||||
if (remaining_list == &anchor)
|
||||
/* End of list reached. */
|
||||
return close (fd);
|
||||
else
|
||||
return remaining_list->private_fn (fd, remaining_list->private_next);
|
||||
}
|
||||
|
||||
int
|
||||
execute_all_close_hooks (int fd)
|
||||
{
|
||||
return execute_close_hooks (fd, anchor.private_next);
|
||||
}
|
||||
|
||||
void
|
||||
register_close_hook (close_hook_fn hook, struct close_hook *link)
|
||||
{
|
||||
if (link->private_next == NULL && link->private_prev == NULL)
|
||||
{
|
||||
/* Add the link to the doubly linked list. */
|
||||
link->private_next = anchor.private_next;
|
||||
link->private_prev = &anchor;
|
||||
link->private_fn = hook;
|
||||
anchor.private_next->private_prev = link;
|
||||
anchor.private_next = link;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* The link is already in use. */
|
||||
if (link->private_fn != hook)
|
||||
abort ();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
unregister_close_hook (struct close_hook *link)
|
||||
{
|
||||
struct close_hook *next = link->private_next;
|
||||
struct close_hook *prev = link->private_prev;
|
||||
|
||||
if (next != NULL && prev != NULL)
|
||||
{
|
||||
/* The link is in use. Remove it from the doubly linked list. */
|
||||
prev->private_next = next;
|
||||
next->private_prev = prev;
|
||||
/* Clear the link, to mark it unused. */
|
||||
link->private_next = NULL;
|
||||
link->private_prev = NULL;
|
||||
link->private_fn = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
72
lib/close-hook.h
Normal file
72
lib/close-hook.h
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
/* Hook for making the close() function extensible.
|
||||
Copyright (C) 2009, 2010 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU Lesser 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
|
||||
#ifndef CLOSE_HOOK_H
|
||||
#define CLOSE_HOOK_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* Currently, this entire code is only needed for the handling of sockets
|
||||
on native Windows platforms. */
|
||||
#if WINDOWS_SOCKETS
|
||||
|
||||
|
||||
/* An element of the list of close hooks.
|
||||
The fields of this structure are considered private. */
|
||||
struct close_hook
|
||||
{
|
||||
/* Doubly linked list. */
|
||||
struct close_hook *private_next;
|
||||
struct close_hook *private_prev;
|
||||
/* Function that treats the types of FD that it knows about and calls
|
||||
execute_close_hooks (FD, REMAINING_LIST) as a fallback. */
|
||||
int (*private_fn) (int fd, const struct close_hook *remaining_list);
|
||||
};
|
||||
|
||||
/* This type of function closes FD, applying special knowledge for the FD
|
||||
types it knows about, and calls execute_close_hooks (FD, REMAINING_LIST)
|
||||
for the other FD types. */
|
||||
typedef int (*close_hook_fn) (int fd, const struct close_hook *remaining_list);
|
||||
|
||||
/* Execute the close hooks in REMAINING_LIST.
|
||||
Return 0 or -1, like close() would do. */
|
||||
extern int execute_close_hooks (int fd, const struct close_hook *remaining_list);
|
||||
|
||||
/* Execute all close hooks.
|
||||
Return 0 or -1, like close() would do. */
|
||||
extern int execute_all_close_hooks (int fd);
|
||||
|
||||
/* Add a function to the list of close hooks.
|
||||
The LINK variable points to a piece of memory which is guaranteed to be
|
||||
accessible until the corresponding call to unregister_close_hook. */
|
||||
extern void register_close_hook (close_hook_fn hook, struct close_hook *link);
|
||||
|
||||
/* Removes a function from the list of close hooks. */
|
||||
extern void unregister_close_hook (struct close_hook *link);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* CLOSE_HOOK_H */
|
||||
|
|
@ -21,6 +21,7 @@
|
|||
#if __GNUC__ >= 3
|
||||
@PRAGMA_SYSTEM_HEADER@
|
||||
#endif
|
||||
@PRAGMA_COLUMNS@
|
||||
|
||||
/* The include_next requires a split double-inclusion guard. */
|
||||
#@INCLUDE_NEXT@ @NEXT_ERRNO_H@
|
||||
|
|
@ -98,6 +99,7 @@
|
|||
|
||||
/* On OpenBSD 4.0 and on native Windows, the macros ENOMSG, EIDRM, ENOLINK,
|
||||
EPROTO, EMULTIHOP, EBADMSG, EOVERFLOW, ENOTSUP, ECANCELED are not defined.
|
||||
Likewise, on NonStop Kernel, EDQUOT is not defined.
|
||||
Define them here. Values >= 2000 seem safe to use: Solaris ESTALE = 151,
|
||||
HP-UX EWOULDBLOCK = 246, IRIX EDQUOT = 1133.
|
||||
|
||||
|
|
@ -150,6 +152,11 @@
|
|||
# define GNULIB_defined_ESTALE 1
|
||||
# endif
|
||||
|
||||
# ifndef EDQUOT
|
||||
# define EDQUOT 2010
|
||||
# define GNULIB_defined_EDQUOT 1
|
||||
# endif
|
||||
|
||||
# ifndef ECANCELED
|
||||
# define ECANCELED 2008
|
||||
# define GNULIB_defined_ECANCELED 1
|
||||
|
|
|
|||
|
|
@ -141,8 +141,8 @@
|
|||
#define SIZEOF_LDBL ((LDBL_TOTAL_BIT + CHAR_BIT - 1) / CHAR_BIT)
|
||||
|
||||
/* Verify that SIZEOF_FLT <= sizeof (float) etc. */
|
||||
typedef int verify_sizeof_flt[2 * (SIZEOF_FLT <= sizeof (float)) - 1];
|
||||
typedef int verify_sizeof_dbl[2 * (SIZEOF_DBL <= sizeof (double)) - 1];
|
||||
typedef int verify_sizeof_ldbl[2 * (SIZEOF_LDBL <= sizeof (long double)) - 1];
|
||||
typedef int verify_sizeof_flt[SIZEOF_FLT <= sizeof (float) ? 1 : -1];
|
||||
typedef int verify_sizeof_dbl[SIZEOF_DBL <= sizeof (double) ? 1 : - 1];
|
||||
typedef int verify_sizeof_ldbl[SIZEOF_LDBL <= sizeof (long double) ? 1 : - 1];
|
||||
|
||||
#endif /* _FLOATPLUS_H */
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
#if __GNUC__ >= 3
|
||||
@PRAGMA_SYSTEM_HEADER@
|
||||
#endif
|
||||
@PRAGMA_COLUMNS@
|
||||
|
||||
/* The include_next requires a split double-inclusion guard. */
|
||||
#@INCLUDE_NEXT@ @NEXT_FLOAT_H@
|
||||
|
|
|
|||
|
|
@ -59,6 +59,9 @@
|
|||
# define WIN32_NATIVE
|
||||
#endif
|
||||
|
||||
/* gl_sockets_startup */
|
||||
#include "sockets.h"
|
||||
|
||||
#ifdef WIN32_NATIVE
|
||||
typedef int (WSAAPI *getaddrinfo_func) (const char*, const char*,
|
||||
const struct addrinfo*,
|
||||
|
|
@ -101,6 +104,8 @@ use_win32_p (void)
|
|||
return 0;
|
||||
}
|
||||
|
||||
gl_sockets_startup (SOCKETS_1_1);
|
||||
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@
|
|||
it now, to make later inclusions of <libintl.h> a NOP. */
|
||||
#if defined(__cplusplus) && defined(__GNUG__) && (__GNUC__ >= 3)
|
||||
# include <cstdlib>
|
||||
# if (__GLIBC__ >= 2) || _GLIBCXX_HAVE_LIBINTL_H
|
||||
# if (__GLIBC__ >= 2 && !defined __UCLIBC__) || _GLIBCXX_HAVE_LIBINTL_H
|
||||
# include <libintl.h>
|
||||
# endif
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
#if __GNUC__ >= 3
|
||||
@PRAGMA_SYSTEM_HEADER@
|
||||
#endif
|
||||
@PRAGMA_COLUMNS@
|
||||
|
||||
/* The include_next requires a split double-inclusion guard. */
|
||||
#@INCLUDE_NEXT@ @NEXT_ICONV_H@
|
||||
|
|
@ -35,22 +36,24 @@
|
|||
/* The definition of _GL_WARN_ON_USE is copied here. */
|
||||
|
||||
|
||||
#if @REPLACE_ICONV_OPEN@
|
||||
#if @GNULIB_ICONV@
|
||||
# if @REPLACE_ICONV_OPEN@
|
||||
/* An iconv_open wrapper that supports the IANA standardized encoding names
|
||||
("ISO-8859-1" etc.) as far as possible. */
|
||||
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
|
||||
# define iconv_open rpl_iconv_open
|
||||
# endif
|
||||
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
|
||||
# define iconv_open rpl_iconv_open
|
||||
# endif
|
||||
_GL_FUNCDECL_RPL (iconv_open, iconv_t,
|
||||
(const char *tocode, const char *fromcode)
|
||||
_GL_ARG_NONNULL ((1, 2)));
|
||||
_GL_CXXALIAS_RPL (iconv_open, iconv_t,
|
||||
(const char *tocode, const char *fromcode));
|
||||
#else
|
||||
# else
|
||||
_GL_CXXALIAS_SYS (iconv_open, iconv_t,
|
||||
(const char *tocode, const char *fromcode));
|
||||
#endif
|
||||
# endif
|
||||
_GL_CXXALIASWARN (iconv_open);
|
||||
#endif
|
||||
|
||||
#if @REPLACE_ICONV_UTF@
|
||||
/* Special constants for supporting UTF-{16,32}{BE,LE} encodings.
|
||||
|
|
@ -65,10 +68,11 @@ _GL_CXXALIASWARN (iconv_open);
|
|||
# define _ICONV_UTF32LE_UTF8 (iconv_t)(-168)
|
||||
#endif
|
||||
|
||||
#if @REPLACE_ICONV@
|
||||
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
|
||||
# define iconv rpl_iconv
|
||||
# endif
|
||||
#if @GNULIB_ICONV@
|
||||
# if @REPLACE_ICONV@
|
||||
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
|
||||
# define iconv rpl_iconv
|
||||
# endif
|
||||
_GL_FUNCDECL_RPL (iconv, size_t,
|
||||
(iconv_t cd,
|
||||
@ICONV_CONST@ char **inbuf, size_t *inbytesleft,
|
||||
|
|
@ -77,24 +81,30 @@ _GL_CXXALIAS_RPL (iconv, size_t,
|
|||
(iconv_t cd,
|
||||
@ICONV_CONST@ char **inbuf, size_t *inbytesleft,
|
||||
char **outbuf, size_t *outbytesleft));
|
||||
#else
|
||||
# else
|
||||
_GL_CXXALIAS_SYS (iconv, size_t,
|
||||
(iconv_t cd,
|
||||
@ICONV_CONST@ char **inbuf, size_t *inbytesleft,
|
||||
char **outbuf, size_t *outbytesleft));
|
||||
#endif
|
||||
_GL_CXXALIASWARN (iconv);
|
||||
|
||||
#if @REPLACE_ICONV@
|
||||
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
|
||||
# define iconv_close rpl_iconv_close
|
||||
# endif
|
||||
_GL_CXXALIASWARN (iconv);
|
||||
# ifndef ICONV_CONST
|
||||
# define ICONV_CONST @ICONV_CONST@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if @GNULIB_ICONV@
|
||||
# if @REPLACE_ICONV@
|
||||
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
|
||||
# define iconv_close rpl_iconv_close
|
||||
# endif
|
||||
_GL_FUNCDECL_RPL (iconv_close, int, (iconv_t cd));
|
||||
_GL_CXXALIAS_RPL (iconv_close, int, (iconv_t cd));
|
||||
#else
|
||||
# else
|
||||
_GL_CXXALIAS_SYS (iconv_close, int, (iconv_t cd));
|
||||
#endif
|
||||
# endif
|
||||
_GL_CXXALIASWARN (iconv_close);
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* _GL_ICONV_H */
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@
|
|||
* WARNING: Don't even consider trying to compile this on a system where
|
||||
* sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX.
|
||||
*/
|
||||
typedef int verify_int_size[2 * sizeof (int) - 7];
|
||||
typedef int verify_int_size[4 <= sizeof (int) ? 1 : -1];
|
||||
|
||||
static const char *inet_ntop4 (const unsigned char *src, char *dst, socklen_t size);
|
||||
#if HAVE_IPV6
|
||||
|
|
|
|||
|
|
@ -117,8 +117,9 @@ FUNC (DOUBLE x)
|
|||
# else
|
||||
/* Be careful to not do any floating-point operation on x, such as x == x,
|
||||
because x may be a signaling NaN. */
|
||||
# if defined __SUNPRO_C || defined __DECC || (defined __sgi && !defined __GNUC__)
|
||||
/* The Sun C 5.0 compilers and the Compaq (ex-DEC) 6.4 compilers don't
|
||||
# if defined __TINYC__ || defined __SUNPRO_C || defined __DECC \
|
||||
|| (defined __sgi && !defined __GNUC__) || defined __ICC
|
||||
/* The Sun C 5.0, Intel ICC 10.0, and Compaq (ex-DEC) 6.4 compilers don't
|
||||
recognize the initializers as constant expressions. The latter compiler
|
||||
also fails when constant-folding 0.0 / 0.0 even when constant-folding is
|
||||
not required. The SGI MIPSpro C compiler complains about "floating-point
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
#if __GNUC__ >= 3
|
||||
@PRAGMA_SYSTEM_HEADER@
|
||||
#endif
|
||||
@PRAGMA_COLUMNS@
|
||||
|
||||
/* The include_next requires a split double-inclusion guard. */
|
||||
#@INCLUDE_NEXT@ @NEXT_LOCALE_H@
|
||||
|
|
|
|||
|
|
@ -21,6 +21,8 @@
|
|||
/* Specification. */
|
||||
#include "malloca.h"
|
||||
|
||||
#include "verify.h"
|
||||
|
||||
/* Use the system functions, not the gnulib overrides in this file. */
|
||||
#undef malloc
|
||||
|
||||
|
|
@ -53,8 +55,7 @@ struct preliminary_header { void *next; char room[MAGIC_SIZE]; };
|
|||
#define HEADER_SIZE \
|
||||
(((sizeof (struct preliminary_header) + sa_alignment_max - 1) / sa_alignment_max) * sa_alignment_max)
|
||||
struct header { void *next; char room[HEADER_SIZE - sizeof (struct preliminary_header) + MAGIC_SIZE]; };
|
||||
/* Verify that HEADER_SIZE == sizeof (struct header). */
|
||||
typedef int verify1[2 * (HEADER_SIZE == sizeof (struct header)) - 1];
|
||||
verify (HEADER_SIZE == sizeof (struct header));
|
||||
/* We make the hash table quite big, so that during lookups the probability
|
||||
of empty hash buckets is quite high. There is no need to make the hash
|
||||
table resizable, because when the hash table gets filled so much that the
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
#if __GNUC__ >= 3
|
||||
@PRAGMA_SYSTEM_HEADER@
|
||||
#endif
|
||||
@PRAGMA_COLUMNS@
|
||||
|
||||
/* The include_next requires a split double-inclusion guard. */
|
||||
#@INCLUDE_NEXT_AS_FIRST_DIRECTIVE@ @NEXT_AS_FIRST_DIRECTIVE_MATH_H@
|
||||
|
|
@ -609,7 +610,8 @@ _GL_EXTERN_C int isnanf (float x);
|
|||
This function is a gnulib extension, unlike isnan() which applied only
|
||||
to 'double' numbers earlier but now is a type-generic macro. */
|
||||
# if @HAVE_ISNAND@
|
||||
/* The original <math.h> included above provides a declaration of isnan macro. */
|
||||
/* The original <math.h> included above provides a declaration of isnan
|
||||
macro. */
|
||||
# if __GNUC__ >= 4
|
||||
/* GCC 4.0 and newer provides three built-ins for isnan. */
|
||||
# undef isnand
|
||||
|
|
@ -629,7 +631,8 @@ _GL_EXTERN_C int isnand (double x);
|
|||
#if @GNULIB_ISNANL@
|
||||
/* Test for NaN for 'long double' numbers. */
|
||||
# if @HAVE_ISNANL@
|
||||
/* The original <math.h> included above provides a declaration of isnan macro or (older) isnanl function. */
|
||||
/* The original <math.h> included above provides a declaration of isnan
|
||||
macro or (older) isnanl function. */
|
||||
# if __GNUC__ >= 4
|
||||
/* GCC 4.0 and newer provides three built-ins for isnan. */
|
||||
# undef isnanl
|
||||
|
|
@ -701,11 +704,13 @@ _GL_EXTERN_C int gl_signbitf (float arg);
|
|||
_GL_EXTERN_C int gl_signbitd (double arg);
|
||||
_GL_EXTERN_C int gl_signbitl (long double arg);
|
||||
# if __GNUC__ >= 2 && !__STRICT_ANSI__
|
||||
# define _GL_NUM_UINT_WORDS(type) \
|
||||
((sizeof (type) + sizeof (unsigned int) - 1) / sizeof (unsigned int))
|
||||
# if defined FLT_SIGNBIT_WORD && defined FLT_SIGNBIT_BIT && !defined gl_signbitf
|
||||
# define gl_signbitf_OPTIMIZED_MACRO
|
||||
# define gl_signbitf(arg) \
|
||||
({ union { float _value; \
|
||||
unsigned int _word[(sizeof (float) + sizeof (unsigned int) - 1) / sizeof (unsigned int)]; \
|
||||
unsigned int _word[_GL_NUM_UINT_WORDS (float)]; \
|
||||
} _m; \
|
||||
_m._value = (arg); \
|
||||
(_m._word[FLT_SIGNBIT_WORD] >> FLT_SIGNBIT_BIT) & 1; \
|
||||
|
|
@ -714,8 +719,8 @@ _GL_EXTERN_C int gl_signbitl (long double arg);
|
|||
# if defined DBL_SIGNBIT_WORD && defined DBL_SIGNBIT_BIT && !defined gl_signbitd
|
||||
# define gl_signbitd_OPTIMIZED_MACRO
|
||||
# define gl_signbitd(arg) \
|
||||
({ union { double _value; \
|
||||
unsigned int _word[(sizeof (double) + sizeof (unsigned int) - 1) / sizeof (unsigned int)]; \
|
||||
({ union { double _value; \
|
||||
unsigned int _word[_GL_NUM_UINT_WORDS (double)]; \
|
||||
} _m; \
|
||||
_m._value = (arg); \
|
||||
(_m._word[DBL_SIGNBIT_WORD] >> DBL_SIGNBIT_BIT) & 1; \
|
||||
|
|
@ -725,10 +730,10 @@ _GL_EXTERN_C int gl_signbitl (long double arg);
|
|||
# define gl_signbitl_OPTIMIZED_MACRO
|
||||
# define gl_signbitl(arg) \
|
||||
({ union { long double _value; \
|
||||
unsigned int _word[(sizeof (long double) + sizeof (unsigned int) - 1) / sizeof (unsigned int)]; \
|
||||
unsigned int _word[_GL_NUM_UINT_WORDS (long double)]; \
|
||||
} _m; \
|
||||
_m._value = (arg); \
|
||||
(_m._word[LDBL_SIGNBIT_WORD] >> LDBL_SIGNBIT_BIT) & 1; \
|
||||
(_m._word[LDBL_SIGNBIT_WORD] >> LDBL_SIGNBIT_BIT) & 1; \
|
||||
})
|
||||
# endif
|
||||
# endif
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
|
|||
|
||||
/* Here m > 0. */
|
||||
|
||||
# if __GLIBC__
|
||||
# if __GLIBC__ || defined __UCLIBC__
|
||||
/* Work around bug <http://sourceware.org/bugzilla/show_bug.cgi?id=9674> */
|
||||
mbtowc (NULL, NULL, 0);
|
||||
# endif
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@
|
|||
#if __GNUC__ >= 3
|
||||
@PRAGMA_SYSTEM_HEADER@
|
||||
#endif
|
||||
@PRAGMA_COLUMNS@
|
||||
|
||||
#if @HAVE_NETDB_H@
|
||||
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
#if __GNUC__ >= 3
|
||||
@PRAGMA_SYSTEM_HEADER@
|
||||
#endif
|
||||
@PRAGMA_COLUMNS@
|
||||
|
||||
#if @HAVE_NETINET_IN_H@
|
||||
|
||||
|
|
|
|||
358
lib/nproc.c
Normal file
358
lib/nproc.c
Normal file
|
|
@ -0,0 +1,358 @@
|
|||
/* Detect the number of processors.
|
||||
|
||||
Copyright (C) 2009-2010 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2, 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser 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 Glen Lenker and Bruno Haible. */
|
||||
|
||||
#include <config.h>
|
||||
#include "nproc.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#if HAVE_PTHREAD_GETAFFINITY_NP && 0
|
||||
# include <pthread.h>
|
||||
# include <sched.h>
|
||||
#endif
|
||||
#if HAVE_SCHED_GETAFFINITY_LIKE_GLIBC || HAVE_SCHED_GETAFFINITY_NP
|
||||
# include <sched.h>
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#if HAVE_SYS_PSTAT_H
|
||||
# include <sys/pstat.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_SYS_SYSMP_H
|
||||
# include <sys/sysmp.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_SYS_PARAM_H
|
||||
# include <sys/param.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_SYS_SYSCTL_H
|
||||
# include <sys/sysctl.h>
|
||||
#endif
|
||||
|
||||
#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
|
||||
# define WIN32_LEAN_AND_MEAN
|
||||
# include <windows.h>
|
||||
#endif
|
||||
|
||||
#include "c-ctype.h"
|
||||
|
||||
#define ARRAY_SIZE(a) (sizeof (a) / sizeof ((a)[0]))
|
||||
|
||||
/* Return the number of processors available to the current process, based
|
||||
on a modern system call that returns the "affinity" between the current
|
||||
process and each CPU. Return 0 if unknown or if such a system call does
|
||||
not exist. */
|
||||
static unsigned long
|
||||
num_processors_via_affinity_mask (void)
|
||||
{
|
||||
/* glibc >= 2.3.3 with NPTL and NetBSD 5 have pthread_getaffinity_np,
|
||||
but with different APIs. Also it requires linking with -lpthread.
|
||||
Therefore this code is not enabled.
|
||||
glibc >= 2.3.4 has sched_getaffinity whereas NetBSD 5 has
|
||||
sched_getaffinity_np. */
|
||||
#if HAVE_PTHREAD_GETAFFINITY_NP && defined __GLIBC__ && 0
|
||||
{
|
||||
cpu_set_t set;
|
||||
|
||||
if (pthread_getaffinity_np (pthread_self (), sizeof (set), &set) == 0)
|
||||
{
|
||||
unsigned long count;
|
||||
|
||||
# ifdef CPU_COUNT
|
||||
/* glibc >= 2.6 has the CPU_COUNT macro. */
|
||||
count = CPU_COUNT (&set);
|
||||
# else
|
||||
size_t i;
|
||||
|
||||
count = 0;
|
||||
for (i = 0; i < CPU_SETSIZE; i++)
|
||||
if (CPU_ISSET (i, &set))
|
||||
count++;
|
||||
# endif
|
||||
if (count > 0)
|
||||
return count;
|
||||
}
|
||||
}
|
||||
#elif HAVE_PTHREAD_GETAFFINITY_NP && defined __NetBSD__ && 0
|
||||
{
|
||||
cpuset_t *set;
|
||||
|
||||
set = cpuset_create ();
|
||||
if (set != NULL)
|
||||
{
|
||||
unsigned long count = 0;
|
||||
|
||||
if (pthread_getaffinity_np (pthread_self (), cpuset_size (set), set)
|
||||
== 0)
|
||||
{
|
||||
cpuid_t i;
|
||||
|
||||
for (i = 0;; i++)
|
||||
{
|
||||
int ret = cpuset_isset (i, set);
|
||||
if (ret < 0)
|
||||
break;
|
||||
if (ret > 0)
|
||||
count++;
|
||||
}
|
||||
}
|
||||
cpuset_destroy (set);
|
||||
if (count > 0)
|
||||
return count;
|
||||
}
|
||||
}
|
||||
#elif HAVE_SCHED_GETAFFINITY_LIKE_GLIBC /* glibc >= 2.3.4 */
|
||||
{
|
||||
cpu_set_t set;
|
||||
|
||||
if (sched_getaffinity (0, sizeof (set), &set) == 0)
|
||||
{
|
||||
unsigned long count;
|
||||
|
||||
# ifdef CPU_COUNT
|
||||
/* glibc >= 2.6 has the CPU_COUNT macro. */
|
||||
count = CPU_COUNT (&set);
|
||||
# else
|
||||
size_t i;
|
||||
|
||||
count = 0;
|
||||
for (i = 0; i < CPU_SETSIZE; i++)
|
||||
if (CPU_ISSET (i, &set))
|
||||
count++;
|
||||
# endif
|
||||
if (count > 0)
|
||||
return count;
|
||||
}
|
||||
}
|
||||
#elif HAVE_SCHED_GETAFFINITY_NP /* NetBSD >= 5 */
|
||||
{
|
||||
cpuset_t *set;
|
||||
|
||||
set = cpuset_create ();
|
||||
if (set != NULL)
|
||||
{
|
||||
unsigned long count = 0;
|
||||
|
||||
if (sched_getaffinity_np (getpid (), cpuset_size (set), set) == 0)
|
||||
{
|
||||
cpuid_t i;
|
||||
|
||||
for (i = 0;; i++)
|
||||
{
|
||||
int ret = cpuset_isset (i, set);
|
||||
if (ret < 0)
|
||||
break;
|
||||
if (ret > 0)
|
||||
count++;
|
||||
}
|
||||
}
|
||||
cpuset_destroy (set);
|
||||
if (count > 0)
|
||||
return count;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
|
||||
{ /* This works on native Windows platforms. */
|
||||
DWORD_PTR process_mask;
|
||||
DWORD_PTR system_mask;
|
||||
|
||||
if (GetProcessAffinityMask (GetCurrentProcess (),
|
||||
&process_mask, &system_mask))
|
||||
{
|
||||
DWORD_PTR mask = process_mask;
|
||||
unsigned long count = 0;
|
||||
|
||||
for (; mask != 0; mask = mask >> 1)
|
||||
if (mask & 1)
|
||||
count++;
|
||||
if (count > 0)
|
||||
return count;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned long int
|
||||
num_processors (enum nproc_query query)
|
||||
{
|
||||
if (query == NPROC_CURRENT_OVERRIDABLE)
|
||||
{
|
||||
/* Test the environment variable OMP_NUM_THREADS, recognized also by all
|
||||
programs that are based on OpenMP. The OpenMP spec says that the
|
||||
value assigned to the environment variable "may have leading and
|
||||
trailing white space". */
|
||||
const char *envvalue = getenv ("OMP_NUM_THREADS");
|
||||
|
||||
if (envvalue != NULL)
|
||||
{
|
||||
while (*envvalue != '\0' && c_isspace (*envvalue))
|
||||
envvalue++;
|
||||
/* Convert it from decimal to 'unsigned long'. */
|
||||
if (c_isdigit (*envvalue))
|
||||
{
|
||||
char *endptr = NULL;
|
||||
unsigned long int value = strtoul (envvalue, &endptr, 10);
|
||||
|
||||
if (endptr != NULL)
|
||||
{
|
||||
while (*endptr != '\0' && c_isspace (*endptr))
|
||||
endptr++;
|
||||
if (*endptr == '\0')
|
||||
return (value > 0 ? value : 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
query = NPROC_CURRENT;
|
||||
}
|
||||
/* Here query is one of NPROC_ALL, NPROC_CURRENT. */
|
||||
|
||||
/* On systems with a modern affinity mask system call, we have
|
||||
sysconf (_SC_NPROCESSORS_CONF)
|
||||
>= sysconf (_SC_NPROCESSORS_ONLN)
|
||||
>= num_processors_via_affinity_mask ()
|
||||
The first number is the number of CPUs configured in the system.
|
||||
The second number is the number of CPUs available to the scheduler.
|
||||
The third number is the number of CPUs available to the current process.
|
||||
|
||||
Note! On Linux systems with glibc, the first and second number come from
|
||||
the /sys and /proc file systems (see
|
||||
glibc/sysdeps/unix/sysv/linux/getsysstats.c).
|
||||
In some situations these file systems are not mounted, and the sysconf
|
||||
call returns 1, which does not reflect the reality. */
|
||||
|
||||
if (query == NPROC_CURRENT)
|
||||
{
|
||||
/* Try the modern affinity mask system call. */
|
||||
{
|
||||
unsigned long nprocs = num_processors_via_affinity_mask ();
|
||||
|
||||
if (nprocs > 0)
|
||||
return nprocs;
|
||||
}
|
||||
|
||||
#if defined _SC_NPROCESSORS_ONLN
|
||||
{ /* This works on glibc, MacOS X 10.5, FreeBSD, AIX, OSF/1, Solaris,
|
||||
Cygwin, Haiku. */
|
||||
long int nprocs = sysconf (_SC_NPROCESSORS_ONLN);
|
||||
if (nprocs > 0)
|
||||
return nprocs;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else /* query == NPROC_ALL */
|
||||
{
|
||||
#if defined _SC_NPROCESSORS_CONF
|
||||
{ /* This works on glibc, MacOS X 10.5, FreeBSD, AIX, OSF/1, Solaris,
|
||||
Cygwin, Haiku. */
|
||||
long int nprocs = sysconf (_SC_NPROCESSORS_CONF);
|
||||
|
||||
# if __GLIBC__ >= 2 && defined __linux__
|
||||
/* On Linux systems with glibc, this information comes from the /sys and
|
||||
/proc file systems (see glibc/sysdeps/unix/sysv/linux/getsysstats.c).
|
||||
In some situations these file systems are not mounted, and the
|
||||
sysconf call returns 1. But we wish to guarantee that
|
||||
num_processors (NPROC_ALL) >= num_processors (NPROC_CURRENT). */
|
||||
if (nprocs == 1)
|
||||
{
|
||||
unsigned long nprocs_current = num_processors_via_affinity_mask ();
|
||||
|
||||
if (nprocs_current > 0)
|
||||
nprocs = nprocs_current;
|
||||
}
|
||||
# endif
|
||||
|
||||
if (nprocs > 0)
|
||||
return nprocs;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#if HAVE_PSTAT_GETDYNAMIC
|
||||
{ /* This works on HP-UX. */
|
||||
struct pst_dynamic psd;
|
||||
if (pstat_getdynamic (&psd, sizeof psd, 1, 0) >= 0)
|
||||
{
|
||||
/* The field psd_proc_cnt contains the number of active processors.
|
||||
In newer releases of HP-UX 11, the field psd_max_proc_cnt includes
|
||||
deactivated processors. */
|
||||
if (query == NPROC_CURRENT)
|
||||
{
|
||||
if (psd.psd_proc_cnt > 0)
|
||||
return psd.psd_proc_cnt;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (psd.psd_max_proc_cnt > 0)
|
||||
return psd.psd_max_proc_cnt;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if HAVE_SYSMP && defined MP_NAPROCS && defined MP_NPROCS
|
||||
{ /* This works on IRIX. */
|
||||
/* MP_NPROCS yields the number of installed processors.
|
||||
MP_NAPROCS yields the number of processors available to unprivileged
|
||||
processes. */
|
||||
int nprocs =
|
||||
sysmp (query == NPROC_CURRENT && getpid () != 0
|
||||
? MP_NAPROCS
|
||||
: MP_NPROCS);
|
||||
if (nprocs > 0)
|
||||
return nprocs;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Finally, as fallback, use the APIs that don't distinguish between
|
||||
NPROC_CURRENT and NPROC_ALL. */
|
||||
|
||||
#if HAVE_SYSCTL && defined HW_NCPU
|
||||
{ /* This works on MacOS X, FreeBSD, NetBSD, OpenBSD. */
|
||||
int nprocs;
|
||||
size_t len = sizeof (nprocs);
|
||||
static int mib[2] = { CTL_HW, HW_NCPU };
|
||||
|
||||
if (sysctl (mib, ARRAY_SIZE (mib), &nprocs, &len, NULL, 0) == 0
|
||||
&& len == sizeof (nprocs)
|
||||
&& 0 < nprocs)
|
||||
return nprocs;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
|
||||
{ /* This works on native Windows platforms. */
|
||||
SYSTEM_INFO system_info;
|
||||
GetSystemInfo (&system_info);
|
||||
if (0 < system_info.dwNumberOfProcessors)
|
||||
return system_info.dwNumberOfProcessors;
|
||||
}
|
||||
#endif
|
||||
|
||||
return 1;
|
||||
}
|
||||
47
lib/nproc.h
Normal file
47
lib/nproc.h
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
/* Detect the number of processors.
|
||||
|
||||
Copyright (C) 2009, 2010 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2, 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser 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 Glen Lenker and Bruno Haible. */
|
||||
|
||||
/* Allow the use in C++ code. */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* A "processor" in this context means a thread execution unit, that is either
|
||||
- an execution core in a (possibly multi-core) chip, in a (possibly multi-
|
||||
chip) module, in a single computer, or
|
||||
- a thread execution unit inside a core
|
||||
(hyper-threading, see <http://en.wikipedia.org/wiki/Hyper-threading>).
|
||||
Which of the two definitions is used, is unspecified. */
|
||||
|
||||
enum nproc_query
|
||||
{
|
||||
NPROC_ALL, /* total number of processors */
|
||||
NPROC_CURRENT, /* processors available to the current process */
|
||||
NPROC_CURRENT_OVERRIDABLE /* likewise, but overridable through the
|
||||
OMP_NUM_THREADS environment variable */
|
||||
};
|
||||
|
||||
/* Return the total number of processors. The result is guaranteed to
|
||||
be at least 1. */
|
||||
extern unsigned long int num_processors (enum nproc_query query);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* C++ */
|
||||
|
|
@ -206,6 +206,13 @@ PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, arguments *a)
|
|||
dp->flags |= FLAG_ZERO;
|
||||
cp++;
|
||||
}
|
||||
#if __GLIBC__ >= 2 && !defined __UCLIBC__
|
||||
else if (*cp == 'I')
|
||||
{
|
||||
dp->flags |= FLAG_LOCALIZED;
|
||||
cp++;
|
||||
}
|
||||
#endif
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,6 +23,10 @@
|
|||
ENABLE_UNISTDIO Set to 1 to enable the unistdio extensions.
|
||||
STATIC Set to 'static' to declare the function static. */
|
||||
|
||||
#if HAVE_FEATURES_H
|
||||
# include <features.h> /* for __GLIBC__, __UCLIBC__ */
|
||||
#endif
|
||||
|
||||
#include "printf-args.h"
|
||||
|
||||
|
||||
|
|
@ -33,6 +37,9 @@
|
|||
#define FLAG_SPACE 8 /* space flag */
|
||||
#define FLAG_ALT 16 /* # flag */
|
||||
#define FLAG_ZERO 32
|
||||
#if __GLIBC__ >= 2 && !defined __UCLIBC__
|
||||
# define FLAG_LOCALIZED 64 /* I flag, uses localized digits */
|
||||
#endif
|
||||
|
||||
/* arg_index value indicating that no argument is consumed. */
|
||||
#define ARG_NONE (~(size_t)0)
|
||||
|
|
|
|||
118
lib/sockets.c
Normal file
118
lib/sockets.c
Normal file
|
|
@ -0,0 +1,118 @@
|
|||
/* sockets.c --- wrappers for Windows socket functions
|
||||
|
||||
Copyright (C) 2008-2010 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
/* Written by Simon Josefsson */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
/* Specification. */
|
||||
#include "sockets.h"
|
||||
|
||||
#if WINDOWS_SOCKETS
|
||||
|
||||
/* This includes winsock2.h on MinGW. */
|
||||
# include <sys/socket.h>
|
||||
|
||||
# include "close-hook.h"
|
||||
|
||||
/* Get set_winsock_errno, FD_TO_SOCKET etc. */
|
||||
# include "w32sock.h"
|
||||
|
||||
static int
|
||||
close_fd_maybe_socket (int fd, const struct close_hook *remaining_list)
|
||||
{
|
||||
SOCKET sock;
|
||||
WSANETWORKEVENTS ev;
|
||||
|
||||
/* Test whether fd refers to a socket. */
|
||||
sock = FD_TO_SOCKET (fd);
|
||||
ev.lNetworkEvents = 0xDEADBEEF;
|
||||
WSAEnumNetworkEvents (sock, NULL, &ev);
|
||||
if (ev.lNetworkEvents != 0xDEADBEEF)
|
||||
{
|
||||
/* fd refers to a socket. */
|
||||
/* FIXME: other applications, like squid, use an undocumented
|
||||
_free_osfhnd free function. But this is not enough: The 'osfile'
|
||||
flags for fd also needs to be cleared, but it is hard to access it.
|
||||
Instead, here we just close twice the file descriptor. */
|
||||
if (closesocket (sock))
|
||||
{
|
||||
set_winsock_errno ();
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* This call frees the file descriptor and does a
|
||||
CloseHandle ((HANDLE) _get_osfhandle (fd)), which fails. */
|
||||
_close (fd);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
/* Some other type of file descriptor. */
|
||||
return execute_close_hooks (fd, remaining_list);
|
||||
}
|
||||
|
||||
static struct close_hook close_sockets_hook;
|
||||
|
||||
static int initialized_sockets_version /* = 0 */;
|
||||
|
||||
#endif /* WINDOWS_SOCKETS */
|
||||
|
||||
int
|
||||
gl_sockets_startup (int version _GL_UNUSED)
|
||||
{
|
||||
#if WINDOWS_SOCKETS
|
||||
if (version > initialized_sockets_version)
|
||||
{
|
||||
WSADATA data;
|
||||
int err;
|
||||
|
||||
err = WSAStartup (version, &data);
|
||||
if (err != 0)
|
||||
return 1;
|
||||
|
||||
if (data.wVersion < version)
|
||||
return 2;
|
||||
|
||||
if (initialized_sockets_version == 0)
|
||||
register_close_hook (close_fd_maybe_socket, &close_sockets_hook);
|
||||
|
||||
initialized_sockets_version = version;
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
gl_sockets_cleanup (void)
|
||||
{
|
||||
#if WINDOWS_SOCKETS
|
||||
int err;
|
||||
|
||||
initialized_sockets_version = 0;
|
||||
|
||||
unregister_close_hook (&close_sockets_hook);
|
||||
|
||||
err = WSACleanup ();
|
||||
if (err != 0)
|
||||
return 1;
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
51
lib/sockets.h
Normal file
51
lib/sockets.h
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
/* sockets.h - wrappers for Windows socket functions
|
||||
|
||||
Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
/* Written by Simon Josefsson */
|
||||
|
||||
#ifndef SOCKETS_H
|
||||
# define SOCKETS_H 1
|
||||
|
||||
#define SOCKETS_1_0 0x100 /* don't use - does not work on Windows XP */
|
||||
#define SOCKETS_1_1 0x101
|
||||
#define SOCKETS_2_0 0x200 /* don't use - does not work on Windows XP */
|
||||
#define SOCKETS_2_1 0x201
|
||||
#define SOCKETS_2_2 0x202
|
||||
|
||||
int gl_sockets_startup (int version);
|
||||
int gl_sockets_cleanup (void);
|
||||
|
||||
/* This function is useful it you create a socket using gnulib's
|
||||
Winsock wrappers but needs to pass on the socket handle to some
|
||||
other library that only accepts sockets. */
|
||||
#if WINDOWS_SOCKETS
|
||||
|
||||
#include <sys/socket.h>
|
||||
|
||||
static inline SOCKET
|
||||
gl_fd_to_handle (int fd)
|
||||
{
|
||||
return _get_osfhandle (fd);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#define gl_fd_to_handle(x) (x)
|
||||
|
||||
#endif /* WINDOWS_SOCKETS */
|
||||
|
||||
#endif /* SOCKETS_H */
|
||||
|
|
@ -20,6 +20,7 @@
|
|||
#if __GNUC__ >= 3
|
||||
@PRAGMA_SYSTEM_HEADER@
|
||||
#endif
|
||||
@PRAGMA_COLUMNS@
|
||||
|
||||
/* The include_next requires a split double-inclusion guard. */
|
||||
#@INCLUDE_NEXT@ @NEXT_STDARG_H@
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@
|
|||
#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 \
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@
|
|||
#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
|
||||
|
|
@ -133,40 +134,53 @@ 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. */
|
||||
|
||||
#if 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
|
||||
# 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
|
||||
# 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
|
||||
# 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
|
||||
# define int64_t gl_int64_t
|
||||
# define GL_INT64_T
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if ULONG_MAX >> 31 >> 31 >> 1 == 1
|
||||
# undef uint64_t
|
||||
#if 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
|
||||
# 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
|
||||
# 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
|
||||
# define uint64_t gl_uint64_t
|
||||
# define GL_UINT64_T
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Avoid collision with Solaris 2.5.1 <pthread.h> etc. */
|
||||
|
|
@ -278,7 +292,8 @@ typedef unsigned long int gl_uintmax_t;
|
|||
/* 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[2 * (sizeof (intmax_t) == sizeof (uintmax_t)) - 1];
|
||||
typedef int _verify_intmax_size[sizeof (intmax_t) == sizeof (uintmax_t)
|
||||
? 1 : -1];
|
||||
|
||||
/* 7.18.2. Limits of specified-width integer types */
|
||||
|
||||
|
|
@ -310,17 +325,14 @@ typedef int _verify_intmax_size[2 * (sizeof (intmax_t) == sizeof (uintmax_t)) -
|
|||
#define INT32_MAX 2147483647
|
||||
#define UINT32_MAX 4294967295U
|
||||
|
||||
#undef INT64_MIN
|
||||
#undef INT64_MAX
|
||||
#ifdef GL_INT64_T
|
||||
#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
|
||||
|
||||
#undef UINT64_MAX
|
||||
#ifdef GL_UINT64_T
|
||||
#if defined GL_UINT64_T && ! defined UINT64_MAX
|
||||
# define UINT64_MAX UINTMAX_C (18446744073709551615)
|
||||
#endif
|
||||
|
||||
|
|
@ -475,8 +487,9 @@ typedef int _verify_intmax_size[2 * (sizeof (intmax_t) == sizeof (uintmax_t)) -
|
|||
|
||||
/* 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
|
||||
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 ! (defined WCHAR_MIN && defined WCHAR_MAX)
|
||||
# define _GL_JUST_INCLUDE_SYSTEM_WCHAR_H
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
#if __GNUC__ >= 3
|
||||
@PRAGMA_SYSTEM_HEADER@
|
||||
#endif
|
||||
@PRAGMA_COLUMNS@
|
||||
|
||||
#if defined __need_FILE || defined __need___FILE
|
||||
/* Special invocation convention inside glibc header files. */
|
||||
|
|
@ -56,6 +57,13 @@
|
|||
# endif
|
||||
#endif
|
||||
|
||||
/* Solaris 10 declares renameat in <unistd.h>, not in <stdio.h>. */
|
||||
/* But in any case avoid namespace pollution on glibc systems. */
|
||||
#if (@GNULIB_RENAMEAT@ || defined GNULIB_POSIXCHECK) && defined __sun \
|
||||
&& ! defined __GLIBC__
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
|
||||
/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
|
||||
|
||||
|
|
@ -265,7 +273,8 @@ _GL_CXXALIASWARN (freopen);
|
|||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef freopen
|
||||
/* Assume freopen is always declared. */
|
||||
_GL_WARN_ON_USE (freopen, "freopen on Win32 platforms is not POSIX compatible - "
|
||||
_GL_WARN_ON_USE (freopen,
|
||||
"freopen on Win32 platforms is not POSIX compatible - "
|
||||
"use gnulib module freopen for portability");
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
#if __GNUC__ >= 3
|
||||
@PRAGMA_SYSTEM_HEADER@
|
||||
#endif
|
||||
@PRAGMA_COLUMNS@
|
||||
|
||||
#if defined __need_malloc_and_calloc
|
||||
/* Special invocation convention inside glibc header files. */
|
||||
|
|
@ -38,6 +39,11 @@
|
|||
/* NetBSD 5.0 mis-defines NULL. */
|
||||
#include <stddef.h>
|
||||
|
||||
/* MirBSD 10 defines WEXITSTATUS in <sys/wait.h>, not in <stdlib.h>. */
|
||||
#if @GNULIB_SYSTEM_POSIX@ && !defined WEXITSTATUS
|
||||
# include <sys/wait.h>
|
||||
#endif
|
||||
|
||||
/* Solaris declares getloadavg() in <sys/loadavg.h>. */
|
||||
#if (@GNULIB_GETLOADAVG@ || defined GNULIB_POSIXCHECK) && @HAVE_SYS_LOADAVG_H@
|
||||
# include <sys/loadavg.h>
|
||||
|
|
@ -55,6 +61,9 @@
|
|||
#endif
|
||||
|
||||
#if !@HAVE_STRUCT_RANDOM_DATA@
|
||||
/* Define 'struct random_data'.
|
||||
But allow multiple gnulib generated <stdlib.h> replacements to coexist. */
|
||||
# if !GNULIB_defined_struct_random_data
|
||||
struct random_data
|
||||
{
|
||||
int32_t *fptr; /* Front pointer. */
|
||||
|
|
@ -65,6 +74,8 @@ struct random_data
|
|||
int rand_sep; /* Distance between front and rear. */
|
||||
int32_t *end_ptr; /* Pointer behind state table. */
|
||||
};
|
||||
# define GNULIB_defined_struct_random_data 1
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if (@GNULIB_MKSTEMP@ || @GNULIB_GETSUBOPT@ || defined GNULIB_POSIXCHECK) && ! defined __GLIBC__ && !((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)
|
||||
|
|
@ -172,7 +183,8 @@ _GL_CXXALIASWARN (canonicalize_file_name);
|
|||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef canonicalize_file_name
|
||||
# if HAVE_RAW_DECL_CANONICALIZE_FILE_NAME
|
||||
_GL_WARN_ON_USE (canonicalize_file_name, "canonicalize_file_name is unportable - "
|
||||
_GL_WARN_ON_USE (canonicalize_file_name,
|
||||
"canonicalize_file_name is unportable - "
|
||||
"use gnulib module canonicalize-lgpl for portability");
|
||||
# endif
|
||||
#endif
|
||||
|
|
@ -675,7 +687,7 @@ _GL_CXXALIASWARN (unlockpt);
|
|||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef unlockpt
|
||||
# if HAVE_RAW_DECL_UNLOCKPT
|
||||
_GL_WARN_ON_USE (ptsname, "unlockpt is not portable - "
|
||||
_GL_WARN_ON_USE (unlockpt, "unlockpt is not portable - "
|
||||
"use gnulib module unlockpt for portability");
|
||||
# endif
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -52,7 +52,8 @@ iconveh_open (const char *to_codeset, const char *from_codeset, iconveh_t *cdp)
|
|||
iconv_t cd2;
|
||||
|
||||
/* Avoid glibc-2.1 bug with EUC-KR. */
|
||||
# if (__GLIBC__ - 0 == 2 && __GLIBC_MINOR__ - 0 <= 1) && !defined _LIBICONV_VERSION
|
||||
# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ <= 1) && !defined __UCLIBC__) \
|
||||
&& !defined _LIBICONV_VERSION
|
||||
if (c_strcasecmp (from_codeset, "EUC-KR") == 0
|
||||
|| c_strcasecmp (to_codeset, "EUC-KR") == 0)
|
||||
{
|
||||
|
|
@ -79,7 +80,9 @@ iconveh_open (const char *to_codeset, const char *from_codeset, iconveh_t *cdp)
|
|||
}
|
||||
|
||||
if (STRCASEEQ (to_codeset, "UTF-8", 'U','T','F','-','8',0,0,0,0)
|
||||
# if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2) || __GLIBC__ > 2 || _LIBICONV_VERSION >= 0x0105
|
||||
# if (((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2) || __GLIBC__ > 2) \
|
||||
&& !defined __UCLIBC__) \
|
||||
|| _LIBICONV_VERSION >= 0x0105
|
||||
|| c_strcasecmp (to_codeset, "UTF-8//TRANSLIT") == 0
|
||||
# endif
|
||||
)
|
||||
|
|
@ -136,7 +139,7 @@ iconveh_close (const iconveh_t *cd)
|
|||
/* iconv_carefully is like iconv, except that it stops as soon as it encounters
|
||||
a conversion error, and it returns in *INCREMENTED a boolean telling whether
|
||||
it has incremented the input pointers past the error location. */
|
||||
# if !defined _LIBICONV_VERSION && !defined __GLIBC__
|
||||
# if !defined _LIBICONV_VERSION && !(defined __GLIBC__ && !defined __UCLIBC__)
|
||||
/* Irix iconv() inserts a NUL byte if it cannot convert.
|
||||
NetBSD iconv() inserts a question mark if it cannot convert.
|
||||
Only GNU libiconv and GNU libc are known to prefer to fail rather
|
||||
|
|
@ -244,7 +247,7 @@ iconv_carefully_1 (iconv_t cd,
|
|||
|
||||
*inbuf = inptr;
|
||||
*inbytesleft = inptr_end - inptr;
|
||||
# if !defined _LIBICONV_VERSION && !defined __GLIBC__
|
||||
# if !defined _LIBICONV_VERSION && !(defined __GLIBC__ && !defined __UCLIBC__)
|
||||
/* Irix iconv() inserts a NUL byte if it cannot convert.
|
||||
NetBSD iconv() inserts a question mark if it cannot convert.
|
||||
Only GNU libiconv and GNU libc are known to prefer to fail rather
|
||||
|
|
@ -403,7 +406,8 @@ mem_cd_iconveh_internal (const char *src, size_t srclen,
|
|||
|
||||
/* Avoid glibc-2.1 bug and Solaris 2.7-2.9 bug. */
|
||||
# if defined _LIBICONV_VERSION \
|
||||
|| !((__GLIBC__ - 0 == 2 && __GLIBC_MINOR__ - 0 <= 1) || defined __sun)
|
||||
|| !(((__GLIBC__ == 2 && __GLIBC_MINOR__ <= 1) && !defined __UCLIBC__) \
|
||||
|| defined __sun)
|
||||
/* Set to the initial state. */
|
||||
iconv (cd, NULL, NULL, NULL, NULL);
|
||||
# endif
|
||||
|
|
@ -531,7 +535,8 @@ mem_cd_iconveh_internal (const char *src, size_t srclen,
|
|||
/* Now get the conversion state back to the initial state.
|
||||
But avoid glibc-2.1 bug and Solaris 2.7 bug. */
|
||||
#if defined _LIBICONV_VERSION \
|
||||
|| !((__GLIBC__ == 2 && __GLIBC_MINOR__ <= 1) || defined __sun)
|
||||
|| !(((__GLIBC__ == 2 && __GLIBC_MINOR__ <= 1) && !defined __UCLIBC__) \
|
||||
|| defined __sun)
|
||||
for (;;)
|
||||
{
|
||||
char *outptr = result + length;
|
||||
|
|
@ -606,7 +611,8 @@ mem_cd_iconveh_internal (const char *src, size_t srclen,
|
|||
|
||||
/* Avoid glibc-2.1 bug and Solaris 2.7-2.9 bug. */
|
||||
# if defined _LIBICONV_VERSION \
|
||||
|| !((__GLIBC__ - 0 == 2 && __GLIBC_MINOR__ - 0 <= 1) || defined __sun)
|
||||
|| !(((__GLIBC__ == 2 && __GLIBC_MINOR__ <= 1) && !defined __UCLIBC__) \
|
||||
|| defined __sun)
|
||||
/* Set to the initial state. */
|
||||
if (cd1 != (iconv_t)(-1))
|
||||
iconv (cd1, NULL, NULL, NULL, NULL);
|
||||
|
|
@ -658,7 +664,8 @@ mem_cd_iconveh_internal (const char *src, size_t srclen,
|
|||
/* Now get the conversion state of CD1 back to the initial state.
|
||||
But avoid glibc-2.1 bug and Solaris 2.7 bug. */
|
||||
# if defined _LIBICONV_VERSION \
|
||||
|| !((__GLIBC__ == 2 && __GLIBC_MINOR__ <= 1) || defined __sun)
|
||||
|| !(((__GLIBC__ == 2 && __GLIBC_MINOR__ <= 1) && !defined __UCLIBC__) \
|
||||
|| defined __sun)
|
||||
if (cd1 != (iconv_t)(-1))
|
||||
res1 = iconv (cd1, NULL, NULL, &out1ptr, &out1size);
|
||||
else
|
||||
|
|
@ -740,7 +747,8 @@ mem_cd_iconveh_internal (const char *src, size_t srclen,
|
|||
/* Now get the conversion state of CD1 back to the initial
|
||||
state. But avoid glibc-2.1 bug and Solaris 2.7 bug. */
|
||||
# if defined _LIBICONV_VERSION \
|
||||
|| !((__GLIBC__ == 2 && __GLIBC_MINOR__ <= 1) || defined __sun)
|
||||
|| !(((__GLIBC__ == 2 && __GLIBC_MINOR__ <= 1) && !defined __UCLIBC__) \
|
||||
|| defined __sun)
|
||||
if (cd2 != (iconv_t)(-1))
|
||||
res2 = iconv (cd2, NULL, NULL, &out2ptr, &out2size);
|
||||
else
|
||||
|
|
@ -883,7 +891,7 @@ mem_cd_iconveh_internal (const char *src, size_t srclen,
|
|||
}
|
||||
length = out2ptr - result;
|
||||
}
|
||||
# if !defined _LIBICONV_VERSION && !defined __GLIBC__
|
||||
# if !defined _LIBICONV_VERSION && !(defined __GLIBC__ && !defined __UCLIBC__)
|
||||
/* Irix iconv() inserts a NUL byte if it cannot convert.
|
||||
NetBSD iconv() inserts a question mark if it cannot
|
||||
convert.
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ extern "C" {
|
|||
|
||||
#if HAVE_ICONV
|
||||
|
||||
/* An conversion descriptor for use by the iconveh functions. */
|
||||
/* A conversion descriptor for use by the iconveh functions. */
|
||||
typedef struct
|
||||
{
|
||||
/* Conversion descriptor from FROM_CODESET to TO_CODESET, or (iconv_t)(-1)
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
#if __GNUC__ >= 3
|
||||
@PRAGMA_SYSTEM_HEADER@
|
||||
#endif
|
||||
@PRAGMA_COLUMNS@
|
||||
|
||||
/* The include_next requires a split double-inclusion guard. */
|
||||
#@INCLUDE_NEXT@ @NEXT_STRING_H@
|
||||
|
|
@ -49,6 +50,12 @@
|
|||
# define _GL_ATTRIBUTE_PURE /* empty */
|
||||
#endif
|
||||
|
||||
/* NetBSD 5.0 declares strsignal in <unistd.h>, not in <string.h>. */
|
||||
/* But in any case avoid namespace pollution on glibc systems. */
|
||||
#if (@GNULIB_STRSIGNAL@ || defined GNULIB_POSIXCHECK) && defined __NetBSD__ \
|
||||
&& ! defined __GLIBC__
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
|
||||
|
||||
|
|
@ -80,7 +87,7 @@ _GL_CXXALIAS_SYS_CAST2 (memchr,
|
|||
void *, (void const *__s, int __c, size_t __n),
|
||||
void const *, (void const *__s, int __c, size_t __n));
|
||||
# endif
|
||||
# if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 10 \
|
||||
# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
|
||||
&& (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
|
||||
_GL_CXXALIASWARN1 (memchr, void *, (void *__s, int __c, size_t __n));
|
||||
_GL_CXXALIASWARN1 (memchr, void const *,
|
||||
|
|
@ -165,7 +172,7 @@ _GL_FUNCDECL_SYS (memrchr, void *, (void const *, int, size_t)
|
|||
_GL_CXXALIAS_SYS_CAST2 (memrchr,
|
||||
void *, (void const *, int, size_t),
|
||||
void const *, (void const *, int, size_t));
|
||||
# if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 10 \
|
||||
# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
|
||||
&& (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
|
||||
_GL_CXXALIASWARN1 (memrchr, void *, (void *, int, size_t));
|
||||
_GL_CXXALIASWARN1 (memrchr, void const *, (void const *, int, size_t));
|
||||
|
|
@ -195,7 +202,7 @@ _GL_FUNCDECL_SYS (rawmemchr, void *, (void const *__s, int __c_in)
|
|||
_GL_CXXALIAS_SYS_CAST2 (rawmemchr,
|
||||
void *, (void const *__s, int __c_in),
|
||||
void const *, (void const *__s, int __c_in));
|
||||
# if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 10 \
|
||||
# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
|
||||
&& (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
|
||||
_GL_CXXALIASWARN1 (rawmemchr, void *, (void *__s, int __c_in));
|
||||
_GL_CXXALIASWARN1 (rawmemchr, void const *, (void const *__s, int __c_in));
|
||||
|
|
@ -286,7 +293,7 @@ _GL_FUNCDECL_SYS (strchrnul, char *, (char const *__s, int __c_in)
|
|||
_GL_CXXALIAS_SYS_CAST2 (strchrnul,
|
||||
char *, (char const *__s, int __c_in),
|
||||
char const *, (char const *__s, int __c_in));
|
||||
# if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 10 \
|
||||
# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
|
||||
&& (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
|
||||
_GL_CXXALIASWARN1 (strchrnul, char *, (char *__s, int __c_in));
|
||||
_GL_CXXALIASWARN1 (strchrnul, char const *, (char const *__s, int __c_in));
|
||||
|
|
@ -432,7 +439,7 @@ _GL_FUNCDECL_SYS (strpbrk, char *, (char const *__s, char const *__accept)
|
|||
_GL_CXXALIAS_SYS_CAST2 (strpbrk,
|
||||
char *, (char const *__s, char const *__accept),
|
||||
const char *, (char const *__s, char const *__accept));
|
||||
# if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 10 \
|
||||
# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
|
||||
&& (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
|
||||
_GL_CXXALIASWARN1 (strpbrk, char *, (char *__s, char const *__accept));
|
||||
_GL_CXXALIASWARN1 (strpbrk, char const *,
|
||||
|
|
@ -534,7 +541,7 @@ _GL_CXXALIAS_SYS_CAST2 (strstr,
|
|||
char *, (const char *haystack, const char *needle),
|
||||
const char *, (const char *haystack, const char *needle));
|
||||
# endif
|
||||
# if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 10 \
|
||||
# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
|
||||
&& (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
|
||||
_GL_CXXALIASWARN1 (strstr, char *, (char *haystack, const char *needle));
|
||||
_GL_CXXALIASWARN1 (strstr, const char *,
|
||||
|
|
@ -583,7 +590,7 @@ _GL_CXXALIAS_SYS_CAST2 (strcasestr,
|
|||
char *, (const char *haystack, const char *needle),
|
||||
const char *, (const char *haystack, const char *needle));
|
||||
# endif
|
||||
# if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 10 \
|
||||
# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
|
||||
&& (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
|
||||
_GL_CXXALIASWARN1 (strcasestr, char *, (char *haystack, const char *needle));
|
||||
_GL_CXXALIASWARN1 (strcasestr, const char *,
|
||||
|
|
@ -895,6 +902,35 @@ _GL_WARN_ON_USE (strerror, "strerror is unportable - "
|
|||
"use gnulib module strerror to guarantee non-NULL result");
|
||||
#endif
|
||||
|
||||
/* Map any int, typically from errno, into an error message. Multithread-safe.
|
||||
Uses the POSIX declaration, not the glibc declaration. */
|
||||
#if @GNULIB_STRERROR_R@
|
||||
# if @REPLACE_STRERROR_R@
|
||||
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
|
||||
# undef strerror_r
|
||||
# define strerror_r rpl_strerror_r
|
||||
# endif
|
||||
_GL_FUNCDECL_RPL (strerror_r, int, (int errnum, char *buf, size_t buflen)
|
||||
_GL_ARG_NONNULL ((2)));
|
||||
_GL_CXXALIAS_RPL (strerror_r, int, (int errnum, char *buf, size_t buflen));
|
||||
# else
|
||||
# if !@HAVE_DECL_STRERROR_R@
|
||||
_GL_FUNCDECL_SYS (strerror_r, int, (int errnum, char *buf, size_t buflen)
|
||||
_GL_ARG_NONNULL ((2)));
|
||||
# endif
|
||||
_GL_CXXALIAS_SYS (strerror_r, int, (int errnum, char *buf, size_t buflen));
|
||||
# endif
|
||||
# if @HAVE_DECL_STRERROR_R@
|
||||
_GL_CXXALIASWARN (strerror_r);
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef strerror_r
|
||||
# if HAVE_RAW_DECL_STRERROR_R
|
||||
_GL_WARN_ON_USE (strerror_r, "strerror_r is unportable - "
|
||||
"use gnulib module strerror_r-posix for portability");
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if @GNULIB_STRSIGNAL@
|
||||
# if @REPLACE_STRSIGNAL@
|
||||
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
#if __GNUC__ >= 3
|
||||
@PRAGMA_SYSTEM_HEADER@
|
||||
#endif
|
||||
@PRAGMA_COLUMNS@
|
||||
|
||||
/* The include_next requires a split double-inclusion guard. */
|
||||
#@INCLUDE_NEXT@ @NEXT_STRINGS_H@
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@
|
|||
#if __GNUC__ >= 3
|
||||
@PRAGMA_SYSTEM_HEADER@
|
||||
#endif
|
||||
@PRAGMA_COLUMNS@
|
||||
|
||||
/* The include_next requires a split double-inclusion guard. */
|
||||
#if @HAVE_SYS_FILE_H@
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@
|
|||
#if __GNUC__ >= 3
|
||||
@PRAGMA_SYSTEM_HEADER@
|
||||
#endif
|
||||
@PRAGMA_COLUMNS@
|
||||
|
||||
#if defined _GL_ALREADY_INCLUDING_SYS_SOCKET_H
|
||||
/* Special invocation convention:
|
||||
|
|
@ -69,7 +70,14 @@
|
|||
typedef unsigned short sa_family_t;
|
||||
#endif
|
||||
|
||||
#if !@HAVE_STRUCT_SOCKADDR_STORAGE@
|
||||
#if @HAVE_STRUCT_SOCKADDR_STORAGE@
|
||||
/* Make the 'struct sockaddr_storage' field 'ss_family' visible on AIX 7.1. */
|
||||
# if !@HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY@
|
||||
# ifndef ss_family
|
||||
# define ss_family __ss_family
|
||||
# endif
|
||||
# endif
|
||||
#else
|
||||
# include <alignof.h>
|
||||
/* Code taken from glibc sysdeps/unix/sysv/linux/bits/socket.h on
|
||||
2009-05-08, licensed under LGPLv2.1+, plus portability fixes. */
|
||||
|
|
@ -122,8 +130,8 @@ struct sockaddr_storage
|
|||
adding AC_DEFINE(WINVER, 0x0501) to configure.ac. Note that your
|
||||
code may not run on older Windows releases then. My Windows 2000
|
||||
box was not able to run the code, for example. The situation is
|
||||
slightly confusing because:
|
||||
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winsock/winsock/getaddrinfo_2.asp
|
||||
slightly confusing because
|
||||
<http://msdn.microsoft.com/en-us/library/ms738520>
|
||||
suggests that getaddrinfo should be available on all Windows
|
||||
releases. */
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@
|
|||
#if __GNUC__ >= 3
|
||||
@PRAGMA_SYSTEM_HEADER@
|
||||
#endif
|
||||
@PRAGMA_COLUMNS@
|
||||
|
||||
#if defined __need_system_sys_stat_h
|
||||
/* Special invocation convention. */
|
||||
|
|
@ -594,7 +595,8 @@ _GL_WARN_ON_USE (mknodat, "mknodat is not portable - "
|
|||
# else /* !_LARGE_FILES */
|
||||
# define stat(name, st) rpl_stat (name, st)
|
||||
# endif /* !_LARGE_FILES */
|
||||
_GL_EXTERN_C int stat (const char *name, struct stat *buf) _GL_ARG_NONNULL ((1, 2));
|
||||
_GL_EXTERN_C int stat (const char *name, struct stat *buf)
|
||||
_GL_ARG_NONNULL ((1, 2));
|
||||
# endif
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef stat
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
#if __GNUC__ >= 3
|
||||
@PRAGMA_SYSTEM_HEADER@
|
||||
#endif
|
||||
@PRAGMA_COLUMNS@
|
||||
|
||||
/* Don't get in the way of glibc when it includes time.h merely to
|
||||
declare a few standard symbols, rather than to declare all the
|
||||
|
|
@ -83,6 +84,15 @@ struct timespec
|
|||
# endif
|
||||
# endif
|
||||
|
||||
/* Per http://austingroupbugs.net/view.php?id=327, POSIX requires
|
||||
time_t to be an integer type, even though C99 permits floating
|
||||
point. We don't know of any implementation that uses floating
|
||||
point, and it is much easier to write code that doesn't have to
|
||||
worry about that corner case, so we force the issue. */
|
||||
struct __time_t_must_be_integral {
|
||||
unsigned int __floating_time_t_unsupported : (time_t) 1;
|
||||
};
|
||||
|
||||
/* Sleep for at least RQTP seconds unless interrupted, If interrupted,
|
||||
return -1 and store the remaining time into RMTP. See
|
||||
<http://www.opengroup.org/susv3xsh/nanosleep.html>. */
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
#if __GNUC__ >= 3
|
||||
@PRAGMA_SYSTEM_HEADER@
|
||||
#endif
|
||||
@PRAGMA_COLUMNS@
|
||||
|
||||
/* Special invocation convention:
|
||||
- On mingw, several headers, including <winsock2.h>, include <unistd.h>,
|
||||
|
|
@ -60,14 +61,16 @@
|
|||
/* Cygwin 1.7.1 declares symlinkat in <stdio.h>, not in <unistd.h>. */
|
||||
/* But avoid namespace pollution on glibc systems. */
|
||||
#if (!(defined SEEK_CUR && defined SEEK_END && defined SEEK_SET) \
|
||||
|| (@GNULIB_SYMLINKAT@ || defined GNULIB_POSIXCHECK)) \
|
||||
|| ((@GNULIB_SYMLINKAT@ || defined GNULIB_POSIXCHECK) \
|
||||
&& defined __CYGWIN__)) \
|
||||
&& ! defined __GLIBC__
|
||||
# include <stdio.h>
|
||||
#endif
|
||||
|
||||
/* Cygwin 1.7.1 declares unlinkat in <fcntl.h>, not in <unistd.h>. */
|
||||
/* But avoid namespace pollution on glibc systems. */
|
||||
#if (@GNULIB_UNLINKAT@ || defined GNULIB_POSIXCHECK) && ! defined __GLIBC__
|
||||
#if (@GNULIB_UNLINKAT@ || defined GNULIB_POSIXCHECK) && defined __CYGWIN__ \
|
||||
&& ! defined __GLIBC__
|
||||
# include <fcntl.h>
|
||||
#endif
|
||||
|
||||
|
|
@ -85,6 +88,13 @@
|
|||
# include <io.h>
|
||||
#endif
|
||||
|
||||
/* AIX and OSF/1 5.1 declare getdomainname in <netdb.h>, not in <unistd.h>. */
|
||||
/* But avoid namespace pollution on glibc systems. */
|
||||
#if @GNULIB_GETDOMAINNAME@ && (defined _AIX || defined __osf__) \
|
||||
&& !defined __GLIBC__
|
||||
# include <netdb.h>
|
||||
#endif
|
||||
|
||||
#if (@GNULIB_WRITE@ || @GNULIB_READLINK@ || @GNULIB_READLINKAT@ \
|
||||
|| @GNULIB_PREAD@ || @GNULIB_PWRITE@ || defined GNULIB_POSIXCHECK)
|
||||
/* Get ssize_t. */
|
||||
|
|
@ -548,13 +558,21 @@ _GL_WARN_ON_USE (getcwd, "getcwd is unportable - "
|
|||
Null terminate it if the name is shorter than LEN.
|
||||
If the NIS domain name is longer than LEN, set errno = EINVAL and return -1.
|
||||
Return 0 if successful, otherwise set errno and return -1. */
|
||||
# if !@HAVE_GETDOMAINNAME@
|
||||
# if @REPLACE_GETDOMAINNAME@
|
||||
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
|
||||
# undef getdomainname
|
||||
# define getdomainname rpl_getdomainname
|
||||
# endif
|
||||
_GL_FUNCDECL_RPL (getdomainname, int, (char *name, size_t len)
|
||||
_GL_ARG_NONNULL ((1)));
|
||||
_GL_CXXALIAS_RPL (getdomainname, int, (char *name, size_t len));
|
||||
# else
|
||||
# if !@HAVE_DECL_GETDOMAINNAME@
|
||||
_GL_FUNCDECL_SYS (getdomainname, int, (char *name, size_t len)
|
||||
_GL_ARG_NONNULL ((1)));
|
||||
# endif
|
||||
_GL_CXXALIAS_SYS (getdomainname, int, (char *name, size_t len));
|
||||
# endif
|
||||
/* Need to cast, because on MacOS X 10.5 systems, the second parameter is
|
||||
int len. */
|
||||
_GL_CXXALIAS_SYS_CAST (getdomainname, int, (char *name, size_t len));
|
||||
_GL_CXXALIASWARN (getdomainname);
|
||||
#elif defined GNULIB_POSIXCHECK
|
||||
# undef getdomainname
|
||||
|
|
|
|||
|
|
@ -134,7 +134,7 @@ extern int
|
|||
/* The variants with _safe suffix are safe, even if the library is compiled
|
||||
without --enable-safety. */
|
||||
|
||||
#ifdef GNULIB_UNISTR_U8_MBTOUC_UNSAFE
|
||||
#if GNULIB_UNISTR_U8_MBTOUC_UNSAFE || HAVE_LIBUNISTRING
|
||||
# if !HAVE_INLINE
|
||||
extern int
|
||||
u8_mbtouc_unsafe (ucs4_t *puc, const uint8_t *s, size_t n);
|
||||
|
|
@ -157,7 +157,7 @@ u8_mbtouc_unsafe (ucs4_t *puc, const uint8_t *s, size_t n)
|
|||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef GNULIB_UNISTR_U16_MBTOUC_UNSAFE
|
||||
#if GNULIB_UNISTR_U16_MBTOUC_UNSAFE || HAVE_LIBUNISTRING
|
||||
# if !HAVE_INLINE
|
||||
extern int
|
||||
u16_mbtouc_unsafe (ucs4_t *puc, const uint16_t *s, size_t n);
|
||||
|
|
@ -180,7 +180,7 @@ u16_mbtouc_unsafe (ucs4_t *puc, const uint16_t *s, size_t n)
|
|||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef GNULIB_UNISTR_U32_MBTOUC_UNSAFE
|
||||
#if GNULIB_UNISTR_U32_MBTOUC_UNSAFE || HAVE_LIBUNISTRING
|
||||
# if !HAVE_INLINE
|
||||
extern int
|
||||
u32_mbtouc_unsafe (ucs4_t *puc, const uint32_t *s, size_t n);
|
||||
|
|
@ -205,7 +205,7 @@ u32_mbtouc_unsafe (ucs4_t *puc,
|
|||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef GNULIB_UNISTR_U8_MBTOUC
|
||||
#if GNULIB_UNISTR_U8_MBTOUC || HAVE_LIBUNISTRING
|
||||
# if !HAVE_INLINE
|
||||
extern int
|
||||
u8_mbtouc (ucs4_t *puc, const uint8_t *s, size_t n);
|
||||
|
|
@ -228,7 +228,7 @@ u8_mbtouc (ucs4_t *puc, const uint8_t *s, size_t n)
|
|||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef GNULIB_UNISTR_U16_MBTOUC
|
||||
#if GNULIB_UNISTR_U16_MBTOUC || HAVE_LIBUNISTRING
|
||||
# if !HAVE_INLINE
|
||||
extern int
|
||||
u16_mbtouc (ucs4_t *puc, const uint16_t *s, size_t n);
|
||||
|
|
@ -251,7 +251,7 @@ u16_mbtouc (ucs4_t *puc, const uint16_t *s, size_t n)
|
|||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef GNULIB_UNISTR_U32_MBTOUC
|
||||
#if GNULIB_UNISTR_U32_MBTOUC || HAVE_LIBUNISTRING
|
||||
# if !HAVE_INLINE
|
||||
extern int
|
||||
u32_mbtouc (ucs4_t *puc, const uint32_t *s, size_t n);
|
||||
|
|
@ -279,17 +279,17 @@ u32_mbtouc (ucs4_t *puc, const uint32_t *s, size_t n _GL_UNUSED_PARAMETER)
|
|||
/* Similar to u*_mbtouc(), except that the return value gives more details
|
||||
about the failure, similar to mbrtowc(). */
|
||||
|
||||
#ifdef GNULIB_UNISTR_U8_MBTOUCR
|
||||
#if GNULIB_UNISTR_U8_MBTOUCR || HAVE_LIBUNISTRING
|
||||
extern int
|
||||
u8_mbtoucr (ucs4_t *puc, const uint8_t *s, size_t n);
|
||||
#endif
|
||||
|
||||
#ifdef GNULIB_UNISTR_U16_MBTOUCR
|
||||
#if GNULIB_UNISTR_U16_MBTOUCR || HAVE_LIBUNISTRING
|
||||
extern int
|
||||
u16_mbtoucr (ucs4_t *puc, const uint16_t *s, size_t n);
|
||||
#endif
|
||||
|
||||
#ifdef GNULIB_UNISTR_U32_MBTOUCR
|
||||
#if GNULIB_UNISTR_U32_MBTOUCR || HAVE_LIBUNISTRING
|
||||
extern int
|
||||
u32_mbtoucr (ucs4_t *puc, const uint32_t *s, size_t n);
|
||||
#endif
|
||||
|
|
@ -300,7 +300,7 @@ extern int
|
|||
/* Similar to wctomb(), except that s must not be NULL, and the argument n
|
||||
must be specified. */
|
||||
|
||||
#ifdef GNULIB_UNISTR_U8_UCTOMB
|
||||
#if GNULIB_UNISTR_U8_UCTOMB || HAVE_LIBUNISTRING
|
||||
/* Auxiliary function, also used by u8_chr, u8_strchr, u8_strrchr. */
|
||||
extern int
|
||||
u8_uctomb_aux (uint8_t *s, ucs4_t uc, int n);
|
||||
|
|
@ -322,7 +322,7 @@ u8_uctomb (uint8_t *s, ucs4_t uc, int n)
|
|||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef GNULIB_UNISTR_U16_UCTOMB
|
||||
#if GNULIB_UNISTR_U16_UCTOMB || HAVE_LIBUNISTRING
|
||||
/* Auxiliary function, also used by u16_chr, u16_strchr, u16_strrchr. */
|
||||
extern int
|
||||
u16_uctomb_aux (uint16_t *s, ucs4_t uc, int n);
|
||||
|
|
@ -344,7 +344,7 @@ u16_uctomb (uint16_t *s, ucs4_t uc, int n)
|
|||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef GNULIB_UNISTR_U32_UCTOMB
|
||||
#if GNULIB_UNISTR_U32_UCTOMB || HAVE_LIBUNISTRING
|
||||
# if !HAVE_INLINE
|
||||
extern int
|
||||
u32_uctomb (uint32_t *s, ucs4_t uc, int n);
|
||||
|
|
@ -559,8 +559,15 @@ extern uint32_t *
|
|||
|
||||
/* Compare S1 and S2. */
|
||||
/* Similar to strcmp(), wcscmp(). */
|
||||
#ifdef __sun
|
||||
/* Avoid a collision with the u8_strcmp() function in Solaris 11 libc. */
|
||||
extern int
|
||||
u8_strcmp_gnu (const uint8_t *s1, const uint8_t *s2);
|
||||
# define u8_strcmp u8_strcmp_gnu
|
||||
#else
|
||||
extern int
|
||||
u8_strcmp (const uint8_t *s1, const uint8_t *s2);
|
||||
#endif
|
||||
extern int
|
||||
u16_strcmp (const uint16_t *s1, const uint16_t *s2);
|
||||
extern int
|
||||
|
|
|
|||
|
|
@ -45,21 +45,32 @@ u8_mbtouc_aux (ucs4_t *puc, const uint8_t *s, size_t n)
|
|||
{
|
||||
/* incomplete multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return n;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else if (c < 0xf0)
|
||||
{
|
||||
if (n >= 3)
|
||||
{
|
||||
if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
|
||||
&& (c >= 0xe1 || s[1] >= 0xa0)
|
||||
&& (c != 0xed || s[1] < 0xa0))
|
||||
if ((s[1] ^ 0x80) < 0x40)
|
||||
{
|
||||
*puc = ((unsigned int) (c & 0x0f) << 12)
|
||||
| ((unsigned int) (s[1] ^ 0x80) << 6)
|
||||
| (unsigned int) (s[2] ^ 0x80);
|
||||
return 3;
|
||||
if ((s[2] ^ 0x80) < 0x40)
|
||||
{
|
||||
if ((c >= 0xe1 || s[1] >= 0xa0)
|
||||
&& (c != 0xed || s[1] < 0xa0))
|
||||
{
|
||||
*puc = ((unsigned int) (c & 0x0f) << 12)
|
||||
| ((unsigned int) (s[1] ^ 0x80) << 6)
|
||||
| (unsigned int) (s[2] ^ 0x80);
|
||||
return 3;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return 3;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return 2;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
}
|
||||
|
|
@ -67,26 +78,45 @@ u8_mbtouc_aux (ucs4_t *puc, const uint8_t *s, size_t n)
|
|||
{
|
||||
/* incomplete multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return n;
|
||||
if (n == 1 || (s[1] ^ 0x80) >= 0x40)
|
||||
return 1;
|
||||
else
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
else if (c < 0xf8)
|
||||
{
|
||||
if (n >= 4)
|
||||
{
|
||||
if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
|
||||
&& (s[3] ^ 0x80) < 0x40
|
||||
&& (c >= 0xf1 || s[1] >= 0x90)
|
||||
#if 1
|
||||
&& (c < 0xf4 || (c == 0xf4 && s[1] < 0x90))
|
||||
#endif
|
||||
)
|
||||
if ((s[1] ^ 0x80) < 0x40)
|
||||
{
|
||||
*puc = ((unsigned int) (c & 0x07) << 18)
|
||||
| ((unsigned int) (s[1] ^ 0x80) << 12)
|
||||
| ((unsigned int) (s[2] ^ 0x80) << 6)
|
||||
| (unsigned int) (s[3] ^ 0x80);
|
||||
return 4;
|
||||
if ((s[2] ^ 0x80) < 0x40)
|
||||
{
|
||||
if ((s[3] ^ 0x80) < 0x40)
|
||||
{
|
||||
if ((c >= 0xf1 || s[1] >= 0x90)
|
||||
#if 1
|
||||
&& (c < 0xf4 || (c == 0xf4 && s[1] < 0x90))
|
||||
#endif
|
||||
)
|
||||
{
|
||||
*puc = ((unsigned int) (c & 0x07) << 18)
|
||||
| ((unsigned int) (s[1] ^ 0x80) << 12)
|
||||
| ((unsigned int) (s[2] ^ 0x80) << 6)
|
||||
| (unsigned int) (s[3] ^ 0x80);
|
||||
return 4;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return 4;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return 3;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return 2;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
}
|
||||
|
|
@ -94,7 +124,12 @@ u8_mbtouc_aux (ucs4_t *puc, const uint8_t *s, size_t n)
|
|||
{
|
||||
/* incomplete multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return n;
|
||||
if (n == 1 || (s[1] ^ 0x80) >= 0x40)
|
||||
return 1;
|
||||
else if (n == 2 || (s[2] ^ 0x80) >= 0x40)
|
||||
return 2;
|
||||
else
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
#if 0
|
||||
|
|
@ -102,16 +137,37 @@ u8_mbtouc_aux (ucs4_t *puc, const uint8_t *s, size_t n)
|
|||
{
|
||||
if (n >= 5)
|
||||
{
|
||||
if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
|
||||
&& (s[3] ^ 0x80) < 0x40 && (s[4] ^ 0x80) < 0x40
|
||||
&& (c >= 0xf9 || s[1] >= 0x88))
|
||||
if ((s[1] ^ 0x80) < 0x40)
|
||||
{
|
||||
*puc = ((unsigned int) (c & 0x03) << 24)
|
||||
| ((unsigned int) (s[1] ^ 0x80) << 18)
|
||||
| ((unsigned int) (s[2] ^ 0x80) << 12)
|
||||
| ((unsigned int) (s[3] ^ 0x80) << 6)
|
||||
| (unsigned int) (s[4] ^ 0x80);
|
||||
return 5;
|
||||
if ((s[2] ^ 0x80) < 0x40)
|
||||
{
|
||||
if ((s[3] ^ 0x80) < 0x40)
|
||||
{
|
||||
if ((s[4] ^ 0x80) < 0x40)
|
||||
{
|
||||
if (c >= 0xf9 || s[1] >= 0x88)
|
||||
{
|
||||
*puc = ((unsigned int) (c & 0x03) << 24)
|
||||
| ((unsigned int) (s[1] ^ 0x80) << 18)
|
||||
| ((unsigned int) (s[2] ^ 0x80) << 12)
|
||||
| ((unsigned int) (s[3] ^ 0x80) << 6)
|
||||
| (unsigned int) (s[4] ^ 0x80);
|
||||
return 5;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return 5;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return 4;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return 3;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
return 2;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
}
|
||||
|
|
@ -126,18 +182,44 @@ u8_mbtouc_aux (ucs4_t *puc, const uint8_t *s, size_t n)
|
|||
{
|
||||
if (n >= 6)
|
||||
{
|
||||
if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
|
||||
&& (s[3] ^ 0x80) < 0x40 && (s[4] ^ 0x80) < 0x40
|
||||
&& (s[5] ^ 0x80) < 0x40
|
||||
&& (c >= 0xfd || s[1] >= 0x84))
|
||||
if ((s[1] ^ 0x80) < 0x40)
|
||||
{
|
||||
*puc = ((unsigned int) (c & 0x01) << 30)
|
||||
| ((unsigned int) (s[1] ^ 0x80) << 24)
|
||||
| ((unsigned int) (s[2] ^ 0x80) << 18)
|
||||
| ((unsigned int) (s[3] ^ 0x80) << 12)
|
||||
| ((unsigned int) (s[4] ^ 0x80) << 6)
|
||||
| (unsigned int) (s[5] ^ 0x80);
|
||||
return 6;
|
||||
if ((s[2] ^ 0x80) < 0x40)
|
||||
{
|
||||
if ((s[3] ^ 0x80) < 0x40)
|
||||
{
|
||||
if ((s[4] ^ 0x80) < 0x40)
|
||||
{
|
||||
if ((s[5] ^ 0x80) < 0x40)
|
||||
{
|
||||
if (c >= 0xfd || s[1] >= 0x84)
|
||||
{
|
||||
*puc = ((unsigned int) (c & 0x01) << 30)
|
||||
| ((unsigned int) (s[1] ^ 0x80) << 24)
|
||||
| ((unsigned int) (s[2] ^ 0x80) << 18)
|
||||
| ((unsigned int) (s[3] ^ 0x80) << 12)
|
||||
| ((unsigned int) (s[4] ^ 0x80) << 6)
|
||||
| (unsigned int) (s[5] ^ 0x80);
|
||||
return 6;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return 6;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return 5;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return 4;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return 3;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
return 2;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,13 +41,15 @@ u8_mbtouc_unsafe_aux (ucs4_t *puc, const uint8_t *s, size_t n)
|
|||
| (unsigned int) (s[1] ^ 0x80);
|
||||
return 2;
|
||||
}
|
||||
#if CONFIG_UNICODE_SAFETY
|
||||
/* invalid multibyte character */
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
/* incomplete multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return n;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else if (c < 0xf0)
|
||||
|
|
@ -55,23 +57,39 @@ u8_mbtouc_unsafe_aux (ucs4_t *puc, const uint8_t *s, size_t n)
|
|||
if (n >= 3)
|
||||
{
|
||||
#if CONFIG_UNICODE_SAFETY
|
||||
if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
|
||||
&& (c >= 0xe1 || s[1] >= 0xa0)
|
||||
&& (c != 0xed || s[1] < 0xa0))
|
||||
#endif
|
||||
if ((s[1] ^ 0x80) < 0x40)
|
||||
{
|
||||
*puc = ((unsigned int) (c & 0x0f) << 12)
|
||||
| ((unsigned int) (s[1] ^ 0x80) << 6)
|
||||
| (unsigned int) (s[2] ^ 0x80);
|
||||
return 3;
|
||||
if ((s[2] ^ 0x80) < 0x40)
|
||||
{
|
||||
if ((c >= 0xe1 || s[1] >= 0xa0)
|
||||
&& (c != 0xed || s[1] < 0xa0))
|
||||
#endif
|
||||
{
|
||||
*puc = ((unsigned int) (c & 0x0f) << 12)
|
||||
| ((unsigned int) (s[1] ^ 0x80) << 6)
|
||||
| (unsigned int) (s[2] ^ 0x80);
|
||||
return 3;
|
||||
}
|
||||
#if CONFIG_UNICODE_SAFETY
|
||||
/* invalid multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return 3;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return 2;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
/* incomplete multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return n;
|
||||
if (n == 1 || (s[1] ^ 0x80) >= 0x40)
|
||||
return 1;
|
||||
else
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
else if (c < 0xf8)
|
||||
|
|
@ -79,28 +97,51 @@ u8_mbtouc_unsafe_aux (ucs4_t *puc, const uint8_t *s, size_t n)
|
|||
if (n >= 4)
|
||||
{
|
||||
#if CONFIG_UNICODE_SAFETY
|
||||
if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
|
||||
&& (s[3] ^ 0x80) < 0x40
|
||||
&& (c >= 0xf1 || s[1] >= 0x90)
|
||||
#if 1
|
||||
&& (c < 0xf4 || (c == 0xf4 && s[1] < 0x90))
|
||||
#endif
|
||||
)
|
||||
#endif
|
||||
if ((s[1] ^ 0x80) < 0x40)
|
||||
{
|
||||
*puc = ((unsigned int) (c & 0x07) << 18)
|
||||
| ((unsigned int) (s[1] ^ 0x80) << 12)
|
||||
| ((unsigned int) (s[2] ^ 0x80) << 6)
|
||||
| (unsigned int) (s[3] ^ 0x80);
|
||||
return 4;
|
||||
if ((s[2] ^ 0x80) < 0x40)
|
||||
{
|
||||
if ((s[3] ^ 0x80) < 0x40)
|
||||
{
|
||||
if ((c >= 0xf1 || s[1] >= 0x90)
|
||||
#if 1
|
||||
&& (c < 0xf4 || (c == 0xf4 && s[1] < 0x90))
|
||||
#endif
|
||||
)
|
||||
#endif
|
||||
{
|
||||
*puc = ((unsigned int) (c & 0x07) << 18)
|
||||
| ((unsigned int) (s[1] ^ 0x80) << 12)
|
||||
| ((unsigned int) (s[2] ^ 0x80) << 6)
|
||||
| (unsigned int) (s[3] ^ 0x80);
|
||||
return 4;
|
||||
}
|
||||
#if CONFIG_UNICODE_SAFETY
|
||||
/* invalid multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return 4;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return 3;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return 2;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
/* incomplete multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return n;
|
||||
if (n == 1 || (s[1] ^ 0x80) >= 0x40)
|
||||
return 1;
|
||||
else if (n == 2 || (s[2] ^ 0x80) >= 0x40)
|
||||
return 2;
|
||||
else
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
#if 0
|
||||
|
|
@ -109,19 +150,42 @@ u8_mbtouc_unsafe_aux (ucs4_t *puc, const uint8_t *s, size_t n)
|
|||
if (n >= 5)
|
||||
{
|
||||
#if CONFIG_UNICODE_SAFETY
|
||||
if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
|
||||
&& (s[3] ^ 0x80) < 0x40 && (s[4] ^ 0x80) < 0x40
|
||||
&& (c >= 0xf9 || s[1] >= 0x88))
|
||||
#endif
|
||||
if ((s[1] ^ 0x80) < 0x40)
|
||||
{
|
||||
*puc = ((unsigned int) (c & 0x03) << 24)
|
||||
| ((unsigned int) (s[1] ^ 0x80) << 18)
|
||||
| ((unsigned int) (s[2] ^ 0x80) << 12)
|
||||
| ((unsigned int) (s[3] ^ 0x80) << 6)
|
||||
| (unsigned int) (s[4] ^ 0x80);
|
||||
return 5;
|
||||
if ((s[2] ^ 0x80) < 0x40)
|
||||
{
|
||||
if ((s[3] ^ 0x80) < 0x40)
|
||||
{
|
||||
if ((s[4] ^ 0x80) < 0x40)
|
||||
{
|
||||
if (c >= 0xf9 || s[1] >= 0x88)
|
||||
#endif
|
||||
{
|
||||
*puc = ((unsigned int) (c & 0x03) << 24)
|
||||
| ((unsigned int) (s[1] ^ 0x80) << 18)
|
||||
| ((unsigned int) (s[2] ^ 0x80) << 12)
|
||||
| ((unsigned int) (s[3] ^ 0x80) << 6)
|
||||
| (unsigned int) (s[4] ^ 0x80);
|
||||
return 5;
|
||||
}
|
||||
#if CONFIG_UNICODE_SAFETY
|
||||
/* invalid multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return 5;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return 4;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return 3;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
return 2;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -135,21 +199,49 @@ u8_mbtouc_unsafe_aux (ucs4_t *puc, const uint8_t *s, size_t n)
|
|||
if (n >= 6)
|
||||
{
|
||||
#if CONFIG_UNICODE_SAFETY
|
||||
if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
|
||||
&& (s[3] ^ 0x80) < 0x40 && (s[4] ^ 0x80) < 0x40
|
||||
&& (s[5] ^ 0x80) < 0x40
|
||||
&& (c >= 0xfd || s[1] >= 0x84))
|
||||
#endif
|
||||
if ((s[1] ^ 0x80) < 0x40)
|
||||
{
|
||||
*puc = ((unsigned int) (c & 0x01) << 30)
|
||||
| ((unsigned int) (s[1] ^ 0x80) << 24)
|
||||
| ((unsigned int) (s[2] ^ 0x80) << 18)
|
||||
| ((unsigned int) (s[3] ^ 0x80) << 12)
|
||||
| ((unsigned int) (s[4] ^ 0x80) << 6)
|
||||
| (unsigned int) (s[5] ^ 0x80);
|
||||
return 6;
|
||||
if ((s[2] ^ 0x80) < 0x40)
|
||||
{
|
||||
if ((s[3] ^ 0x80) < 0x40)
|
||||
{
|
||||
if ((s[4] ^ 0x80) < 0x40)
|
||||
{
|
||||
if ((s[5] ^ 0x80) < 0x40)
|
||||
{
|
||||
if (c >= 0xfd || s[1] >= 0x84)
|
||||
#endif
|
||||
{
|
||||
*puc = ((unsigned int) (c & 0x01) << 30)
|
||||
| ((unsigned int) (s[1] ^ 0x80) << 24)
|
||||
| ((unsigned int) (s[2] ^ 0x80) << 18)
|
||||
| ((unsigned int) (s[3] ^ 0x80) << 12)
|
||||
| ((unsigned int) (s[4] ^ 0x80) << 6)
|
||||
| (unsigned int) (s[5] ^ 0x80);
|
||||
return 6;
|
||||
}
|
||||
#if CONFIG_UNICODE_SAFETY
|
||||
/* invalid multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return 6;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return 5;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return 4;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return 3;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
return 2;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -52,13 +52,15 @@ u8_mbtouc_unsafe (ucs4_t *puc, const uint8_t *s, size_t n)
|
|||
| (unsigned int) (s[1] ^ 0x80);
|
||||
return 2;
|
||||
}
|
||||
#if CONFIG_UNICODE_SAFETY
|
||||
/* invalid multibyte character */
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
/* incomplete multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return n;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else if (c < 0xf0)
|
||||
|
|
@ -66,23 +68,39 @@ u8_mbtouc_unsafe (ucs4_t *puc, const uint8_t *s, size_t n)
|
|||
if (n >= 3)
|
||||
{
|
||||
#if CONFIG_UNICODE_SAFETY
|
||||
if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
|
||||
&& (c >= 0xe1 || s[1] >= 0xa0)
|
||||
&& (c != 0xed || s[1] < 0xa0))
|
||||
#endif
|
||||
if ((s[1] ^ 0x80) < 0x40)
|
||||
{
|
||||
*puc = ((unsigned int) (c & 0x0f) << 12)
|
||||
| ((unsigned int) (s[1] ^ 0x80) << 6)
|
||||
| (unsigned int) (s[2] ^ 0x80);
|
||||
return 3;
|
||||
if ((s[2] ^ 0x80) < 0x40)
|
||||
{
|
||||
if ((c >= 0xe1 || s[1] >= 0xa0)
|
||||
&& (c != 0xed || s[1] < 0xa0))
|
||||
#endif
|
||||
{
|
||||
*puc = ((unsigned int) (c & 0x0f) << 12)
|
||||
| ((unsigned int) (s[1] ^ 0x80) << 6)
|
||||
| (unsigned int) (s[2] ^ 0x80);
|
||||
return 3;
|
||||
}
|
||||
#if CONFIG_UNICODE_SAFETY
|
||||
/* invalid multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return 3;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return 2;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
/* incomplete multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return n;
|
||||
if (n == 1 || (s[1] ^ 0x80) >= 0x40)
|
||||
return 1;
|
||||
else
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
else if (c < 0xf8)
|
||||
|
|
@ -90,28 +108,51 @@ u8_mbtouc_unsafe (ucs4_t *puc, const uint8_t *s, size_t n)
|
|||
if (n >= 4)
|
||||
{
|
||||
#if CONFIG_UNICODE_SAFETY
|
||||
if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
|
||||
&& (s[3] ^ 0x80) < 0x40
|
||||
&& (c >= 0xf1 || s[1] >= 0x90)
|
||||
#if 1
|
||||
&& (c < 0xf4 || (c == 0xf4 && s[1] < 0x90))
|
||||
#endif
|
||||
)
|
||||
#endif
|
||||
if ((s[1] ^ 0x80) < 0x40)
|
||||
{
|
||||
*puc = ((unsigned int) (c & 0x07) << 18)
|
||||
| ((unsigned int) (s[1] ^ 0x80) << 12)
|
||||
| ((unsigned int) (s[2] ^ 0x80) << 6)
|
||||
| (unsigned int) (s[3] ^ 0x80);
|
||||
return 4;
|
||||
if ((s[2] ^ 0x80) < 0x40)
|
||||
{
|
||||
if ((s[3] ^ 0x80) < 0x40)
|
||||
{
|
||||
if ((c >= 0xf1 || s[1] >= 0x90)
|
||||
#if 1
|
||||
&& (c < 0xf4 || (c == 0xf4 && s[1] < 0x90))
|
||||
#endif
|
||||
)
|
||||
#endif
|
||||
{
|
||||
*puc = ((unsigned int) (c & 0x07) << 18)
|
||||
| ((unsigned int) (s[1] ^ 0x80) << 12)
|
||||
| ((unsigned int) (s[2] ^ 0x80) << 6)
|
||||
| (unsigned int) (s[3] ^ 0x80);
|
||||
return 4;
|
||||
}
|
||||
#if CONFIG_UNICODE_SAFETY
|
||||
/* invalid multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return 4;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return 3;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return 2;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
/* incomplete multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return n;
|
||||
if (n == 1 || (s[1] ^ 0x80) >= 0x40)
|
||||
return 1;
|
||||
else if (n == 2 || (s[2] ^ 0x80) >= 0x40)
|
||||
return 2;
|
||||
else
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
#if 0
|
||||
|
|
@ -120,19 +161,42 @@ u8_mbtouc_unsafe (ucs4_t *puc, const uint8_t *s, size_t n)
|
|||
if (n >= 5)
|
||||
{
|
||||
#if CONFIG_UNICODE_SAFETY
|
||||
if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
|
||||
&& (s[3] ^ 0x80) < 0x40 && (s[4] ^ 0x80) < 0x40
|
||||
&& (c >= 0xf9 || s[1] >= 0x88))
|
||||
#endif
|
||||
if ((s[1] ^ 0x80) < 0x40)
|
||||
{
|
||||
*puc = ((unsigned int) (c & 0x03) << 24)
|
||||
| ((unsigned int) (s[1] ^ 0x80) << 18)
|
||||
| ((unsigned int) (s[2] ^ 0x80) << 12)
|
||||
| ((unsigned int) (s[3] ^ 0x80) << 6)
|
||||
| (unsigned int) (s[4] ^ 0x80);
|
||||
return 5;
|
||||
if ((s[2] ^ 0x80) < 0x40)
|
||||
{
|
||||
if ((s[3] ^ 0x80) < 0x40)
|
||||
{
|
||||
if ((s[4] ^ 0x80) < 0x40)
|
||||
{
|
||||
if (c >= 0xf9 || s[1] >= 0x88)
|
||||
#endif
|
||||
{
|
||||
*puc = ((unsigned int) (c & 0x03) << 24)
|
||||
| ((unsigned int) (s[1] ^ 0x80) << 18)
|
||||
| ((unsigned int) (s[2] ^ 0x80) << 12)
|
||||
| ((unsigned int) (s[3] ^ 0x80) << 6)
|
||||
| (unsigned int) (s[4] ^ 0x80);
|
||||
return 5;
|
||||
}
|
||||
#if CONFIG_UNICODE_SAFETY
|
||||
/* invalid multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return 5;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return 4;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return 3;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
return 2;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -146,21 +210,49 @@ u8_mbtouc_unsafe (ucs4_t *puc, const uint8_t *s, size_t n)
|
|||
if (n >= 6)
|
||||
{
|
||||
#if CONFIG_UNICODE_SAFETY
|
||||
if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
|
||||
&& (s[3] ^ 0x80) < 0x40 && (s[4] ^ 0x80) < 0x40
|
||||
&& (s[5] ^ 0x80) < 0x40
|
||||
&& (c >= 0xfd || s[1] >= 0x84))
|
||||
#endif
|
||||
if ((s[1] ^ 0x80) < 0x40)
|
||||
{
|
||||
*puc = ((unsigned int) (c & 0x01) << 30)
|
||||
| ((unsigned int) (s[1] ^ 0x80) << 24)
|
||||
| ((unsigned int) (s[2] ^ 0x80) << 18)
|
||||
| ((unsigned int) (s[3] ^ 0x80) << 12)
|
||||
| ((unsigned int) (s[4] ^ 0x80) << 6)
|
||||
| (unsigned int) (s[5] ^ 0x80);
|
||||
return 6;
|
||||
if ((s[2] ^ 0x80) < 0x40)
|
||||
{
|
||||
if ((s[3] ^ 0x80) < 0x40)
|
||||
{
|
||||
if ((s[4] ^ 0x80) < 0x40)
|
||||
{
|
||||
if ((s[5] ^ 0x80) < 0x40)
|
||||
{
|
||||
if (c >= 0xfd || s[1] >= 0x84)
|
||||
#endif
|
||||
{
|
||||
*puc = ((unsigned int) (c & 0x01) << 30)
|
||||
| ((unsigned int) (s[1] ^ 0x80) << 24)
|
||||
| ((unsigned int) (s[2] ^ 0x80) << 18)
|
||||
| ((unsigned int) (s[3] ^ 0x80) << 12)
|
||||
| ((unsigned int) (s[4] ^ 0x80) << 6)
|
||||
| (unsigned int) (s[5] ^ 0x80);
|
||||
return 6;
|
||||
}
|
||||
#if CONFIG_UNICODE_SAFETY
|
||||
/* invalid multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return 6;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return 5;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return 4;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return 3;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
return 2;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -55,21 +55,32 @@ u8_mbtouc (ucs4_t *puc, const uint8_t *s, size_t n)
|
|||
{
|
||||
/* incomplete multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return n;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else if (c < 0xf0)
|
||||
{
|
||||
if (n >= 3)
|
||||
{
|
||||
if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
|
||||
&& (c >= 0xe1 || s[1] >= 0xa0)
|
||||
&& (c != 0xed || s[1] < 0xa0))
|
||||
if ((s[1] ^ 0x80) < 0x40)
|
||||
{
|
||||
*puc = ((unsigned int) (c & 0x0f) << 12)
|
||||
| ((unsigned int) (s[1] ^ 0x80) << 6)
|
||||
| (unsigned int) (s[2] ^ 0x80);
|
||||
return 3;
|
||||
if ((s[2] ^ 0x80) < 0x40)
|
||||
{
|
||||
if ((c >= 0xe1 || s[1] >= 0xa0)
|
||||
&& (c != 0xed || s[1] < 0xa0))
|
||||
{
|
||||
*puc = ((unsigned int) (c & 0x0f) << 12)
|
||||
| ((unsigned int) (s[1] ^ 0x80) << 6)
|
||||
| (unsigned int) (s[2] ^ 0x80);
|
||||
return 3;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return 3;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return 2;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
}
|
||||
|
|
@ -77,26 +88,45 @@ u8_mbtouc (ucs4_t *puc, const uint8_t *s, size_t n)
|
|||
{
|
||||
/* incomplete multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return n;
|
||||
if (n == 1 || (s[1] ^ 0x80) >= 0x40)
|
||||
return 1;
|
||||
else
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
else if (c < 0xf8)
|
||||
{
|
||||
if (n >= 4)
|
||||
{
|
||||
if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
|
||||
&& (s[3] ^ 0x80) < 0x40
|
||||
&& (c >= 0xf1 || s[1] >= 0x90)
|
||||
#if 1
|
||||
&& (c < 0xf4 || (c == 0xf4 && s[1] < 0x90))
|
||||
#endif
|
||||
)
|
||||
if ((s[1] ^ 0x80) < 0x40)
|
||||
{
|
||||
*puc = ((unsigned int) (c & 0x07) << 18)
|
||||
| ((unsigned int) (s[1] ^ 0x80) << 12)
|
||||
| ((unsigned int) (s[2] ^ 0x80) << 6)
|
||||
| (unsigned int) (s[3] ^ 0x80);
|
||||
return 4;
|
||||
if ((s[2] ^ 0x80) < 0x40)
|
||||
{
|
||||
if ((s[3] ^ 0x80) < 0x40)
|
||||
{
|
||||
if ((c >= 0xf1 || s[1] >= 0x90)
|
||||
#if 1
|
||||
&& (c < 0xf4 || (c == 0xf4 && s[1] < 0x90))
|
||||
#endif
|
||||
)
|
||||
{
|
||||
*puc = ((unsigned int) (c & 0x07) << 18)
|
||||
| ((unsigned int) (s[1] ^ 0x80) << 12)
|
||||
| ((unsigned int) (s[2] ^ 0x80) << 6)
|
||||
| (unsigned int) (s[3] ^ 0x80);
|
||||
return 4;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return 4;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return 3;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return 2;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
}
|
||||
|
|
@ -104,7 +134,12 @@ u8_mbtouc (ucs4_t *puc, const uint8_t *s, size_t n)
|
|||
{
|
||||
/* incomplete multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return n;
|
||||
if (n == 1 || (s[1] ^ 0x80) >= 0x40)
|
||||
return 1;
|
||||
else if (n == 2 || (s[2] ^ 0x80) >= 0x40)
|
||||
return 2;
|
||||
else
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
#if 0
|
||||
|
|
@ -112,16 +147,37 @@ u8_mbtouc (ucs4_t *puc, const uint8_t *s, size_t n)
|
|||
{
|
||||
if (n >= 5)
|
||||
{
|
||||
if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
|
||||
&& (s[3] ^ 0x80) < 0x40 && (s[4] ^ 0x80) < 0x40
|
||||
&& (c >= 0xf9 || s[1] >= 0x88))
|
||||
if ((s[1] ^ 0x80) < 0x40)
|
||||
{
|
||||
*puc = ((unsigned int) (c & 0x03) << 24)
|
||||
| ((unsigned int) (s[1] ^ 0x80) << 18)
|
||||
| ((unsigned int) (s[2] ^ 0x80) << 12)
|
||||
| ((unsigned int) (s[3] ^ 0x80) << 6)
|
||||
| (unsigned int) (s[4] ^ 0x80);
|
||||
return 5;
|
||||
if ((s[2] ^ 0x80) < 0x40)
|
||||
{
|
||||
if ((s[3] ^ 0x80) < 0x40)
|
||||
{
|
||||
if ((s[4] ^ 0x80) < 0x40)
|
||||
{
|
||||
if (c >= 0xf9 || s[1] >= 0x88)
|
||||
{
|
||||
*puc = ((unsigned int) (c & 0x03) << 24)
|
||||
| ((unsigned int) (s[1] ^ 0x80) << 18)
|
||||
| ((unsigned int) (s[2] ^ 0x80) << 12)
|
||||
| ((unsigned int) (s[3] ^ 0x80) << 6)
|
||||
| (unsigned int) (s[4] ^ 0x80);
|
||||
return 5;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return 5;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return 4;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return 3;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
return 2;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
}
|
||||
|
|
@ -136,18 +192,44 @@ u8_mbtouc (ucs4_t *puc, const uint8_t *s, size_t n)
|
|||
{
|
||||
if (n >= 6)
|
||||
{
|
||||
if ((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
|
||||
&& (s[3] ^ 0x80) < 0x40 && (s[4] ^ 0x80) < 0x40
|
||||
&& (s[5] ^ 0x80) < 0x40
|
||||
&& (c >= 0xfd || s[1] >= 0x84))
|
||||
if ((s[1] ^ 0x80) < 0x40)
|
||||
{
|
||||
*puc = ((unsigned int) (c & 0x01) << 30)
|
||||
| ((unsigned int) (s[1] ^ 0x80) << 24)
|
||||
| ((unsigned int) (s[2] ^ 0x80) << 18)
|
||||
| ((unsigned int) (s[3] ^ 0x80) << 12)
|
||||
| ((unsigned int) (s[4] ^ 0x80) << 6)
|
||||
| (unsigned int) (s[5] ^ 0x80);
|
||||
return 6;
|
||||
if ((s[2] ^ 0x80) < 0x40)
|
||||
{
|
||||
if ((s[3] ^ 0x80) < 0x40)
|
||||
{
|
||||
if ((s[4] ^ 0x80) < 0x40)
|
||||
{
|
||||
if ((s[5] ^ 0x80) < 0x40)
|
||||
{
|
||||
if (c >= 0xfd || s[1] >= 0x84)
|
||||
{
|
||||
*puc = ((unsigned int) (c & 0x01) << 30)
|
||||
| ((unsigned int) (s[1] ^ 0x80) << 24)
|
||||
| ((unsigned int) (s[2] ^ 0x80) << 18)
|
||||
| ((unsigned int) (s[3] ^ 0x80) << 12)
|
||||
| ((unsigned int) (s[4] ^ 0x80) << 6)
|
||||
| (unsigned int) (s[5] ^ 0x80);
|
||||
return 6;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return 6;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return 5;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return 4;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
*puc = 0xfffd;
|
||||
return 3;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
return 2;
|
||||
}
|
||||
/* invalid multibyte character */
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
const uint8_t *
|
||||
u8_prev (ucs4_t *puc, const uint8_t *s, const uint8_t *start)
|
||||
{
|
||||
/* Keep in sync with unistr.h and utf8-ucs4.c. */
|
||||
/* Keep in sync with unistr.h and u8-mbtouc-aux.c. */
|
||||
if (s != start)
|
||||
{
|
||||
uint8_t c_1 = s[-1];
|
||||
|
|
|
|||
|
|
@ -88,6 +88,8 @@
|
|||
/* Checked size_t computations. */
|
||||
#include "xsize.h"
|
||||
|
||||
#include "verify.h"
|
||||
|
||||
#if (NEED_PRINTF_DOUBLE || NEED_PRINTF_LONG_DOUBLE) && !defined IN_LIBINTL
|
||||
# include <math.h>
|
||||
# include "float+.h"
|
||||
|
|
@ -277,7 +279,7 @@ decimal_point_char (void)
|
|||
multithread-safe on glibc systems and MacOS X systems, but is not required
|
||||
to be multithread-safe by POSIX. sprintf(), however, is multithread-safe.
|
||||
localeconv() is rarely multithread-safe. */
|
||||
# if HAVE_NL_LANGINFO && (__GLIBC__ || (defined __APPLE__ && defined __MACH__))
|
||||
# if HAVE_NL_LANGINFO && (__GLIBC__ || defined __UCLIBC__ || (defined __APPLE__ && defined __MACH__))
|
||||
point = nl_langinfo (RADIXCHAR);
|
||||
# elif 1
|
||||
char pointbuf[5];
|
||||
|
|
@ -322,11 +324,11 @@ is_infinite_or_zerol (long double x)
|
|||
|
||||
typedef unsigned int mp_limb_t;
|
||||
# define GMP_LIMB_BITS 32
|
||||
typedef int mp_limb_verify[2 * (sizeof (mp_limb_t) * CHAR_BIT == GMP_LIMB_BITS) - 1];
|
||||
verify (sizeof (mp_limb_t) * CHAR_BIT == GMP_LIMB_BITS);
|
||||
|
||||
typedef unsigned long long mp_twolimb_t;
|
||||
# define GMP_TWOLIMB_BITS 64
|
||||
typedef int mp_twolimb_verify[2 * (sizeof (mp_twolimb_t) * CHAR_BIT == GMP_TWOLIMB_BITS) - 1];
|
||||
verify (sizeof (mp_twolimb_t) * CHAR_BIT == GMP_TWOLIMB_BITS);
|
||||
|
||||
/* Representation of a bignum >= 0. */
|
||||
typedef struct
|
||||
|
|
@ -2621,7 +2623,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
|
|||
size_t characters;
|
||||
# if !DCHAR_IS_TCHAR
|
||||
/* This code assumes that TCHAR_T is 'char'. */
|
||||
typedef int TCHAR_T_verify[2 * (sizeof (TCHAR_T) == 1) - 1];
|
||||
verify (sizeof (TCHAR_T) == 1);
|
||||
TCHAR_T *tmpsrc;
|
||||
DCHAR_T *tmpdst;
|
||||
size_t tmpdst_len;
|
||||
|
|
@ -4597,6 +4599,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
|
|||
TCHAR_T *fbp;
|
||||
unsigned int prefix_count;
|
||||
int prefixes[2] IF_LINT (= { 0 });
|
||||
int orig_errno;
|
||||
#if !USE_SNPRINTF
|
||||
size_t tmp_length;
|
||||
TCHAR_T tmpbuf[700];
|
||||
|
|
@ -4751,6 +4754,10 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
|
|||
*fbp++ = ' ';
|
||||
if (flags & FLAG_ALT)
|
||||
*fbp++ = '#';
|
||||
#if __GLIBC__ >= 2 && !defined __UCLIBC__
|
||||
if (flags & FLAG_LOCALIZED)
|
||||
*fbp++ = 'I';
|
||||
#endif
|
||||
if (!pad_ourselves)
|
||||
{
|
||||
if (flags & FLAG_ZERO)
|
||||
|
|
@ -4834,14 +4841,15 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
|
|||
#endif
|
||||
*fbp = dp->conversion;
|
||||
#if USE_SNPRINTF
|
||||
# if !(__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3) || ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__))
|
||||
# if !(((__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)) && !defined __UCLIBC__) || ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__))
|
||||
fbp[1] = '%';
|
||||
fbp[2] = 'n';
|
||||
fbp[3] = '\0';
|
||||
# else
|
||||
/* On glibc2 systems from glibc >= 2.3 - probably also older
|
||||
ones - we know that snprintf's returns value conforms to
|
||||
ISO C 99: the gl_SNPRINTF_DIRECTIVE_N test passes.
|
||||
ones - we know that snprintf's return value conforms to
|
||||
ISO C 99: the tests gl_SNPRINTF_RETVAL_C99 and
|
||||
gl_SNPRINTF_TRUNCATION_C99 pass.
|
||||
Therefore we can avoid using %n in this situation.
|
||||
On glibc2 systems from 2004-10-18 or newer, the use of %n
|
||||
in format strings in writable memory may crash the program
|
||||
|
|
@ -4900,6 +4908,8 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
|
|||
*(TCHAR_T *) (result + length) = '\0';
|
||||
#endif
|
||||
|
||||
orig_errno = errno;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
int count = -1;
|
||||
|
|
@ -5284,8 +5294,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
|
|||
DCHAR_T *tmpdst;
|
||||
size_t tmpdst_len;
|
||||
/* This code assumes that TCHAR_T is 'char'. */
|
||||
typedef int TCHAR_T_verify
|
||||
[2 * (sizeof (TCHAR_T) == 1) - 1];
|
||||
verify (sizeof (TCHAR_T) == 1);
|
||||
# if USE_SNPRINTF
|
||||
tmpsrc = (TCHAR_T *) (result + length);
|
||||
# else
|
||||
|
|
@ -5498,6 +5507,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
|
|||
length += count;
|
||||
break;
|
||||
}
|
||||
errno = orig_errno;
|
||||
#undef pad_ourselves
|
||||
#undef prec_ourselves
|
||||
}
|
||||
|
|
|
|||
61
lib/w32sock.h
Normal file
61
lib/w32sock.h
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
/* w32sock.h --- internal auxilliary functions for Windows socket functions
|
||||
|
||||
Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
/* Written by Paolo Bonzini */
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
/* Get O_RDWR and O_BINARY. */
|
||||
#include <fcntl.h>
|
||||
|
||||
/* Get _get_osfhandle() and _open_osfhandle(). */
|
||||
#include <io.h>
|
||||
|
||||
#define FD_TO_SOCKET(fd) ((SOCKET) _get_osfhandle ((fd)))
|
||||
#define SOCKET_TO_FD(fh) (_open_osfhandle ((long) (fh), O_RDWR | O_BINARY))
|
||||
|
||||
static inline void
|
||||
set_winsock_errno (void)
|
||||
{
|
||||
int err = WSAGetLastError ();
|
||||
|
||||
/* Map some WSAE* errors to the runtime library's error codes. */
|
||||
switch (err)
|
||||
{
|
||||
case WSA_INVALID_HANDLE:
|
||||
errno = EBADF;
|
||||
break;
|
||||
case WSA_NOT_ENOUGH_MEMORY:
|
||||
errno = ENOMEM;
|
||||
break;
|
||||
case WSA_INVALID_PARAMETER:
|
||||
errno = EINVAL;
|
||||
break;
|
||||
case WSAEWOULDBLOCK:
|
||||
errno = EWOULDBLOCK;
|
||||
break;
|
||||
case WSAENAMETOOLONG:
|
||||
errno = ENAMETOOLONG;
|
||||
break;
|
||||
case WSAENOTEMPTY:
|
||||
errno = ENOTEMPTY;
|
||||
break;
|
||||
default:
|
||||
errno = (err > 10000 && err < 10025) ? err - 10000 : err;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -29,6 +29,7 @@
|
|||
#if __GNUC__ >= 3
|
||||
@PRAGMA_SYSTEM_HEADER@
|
||||
#endif
|
||||
@PRAGMA_COLUMNS@
|
||||
|
||||
#if defined __need_mbstate_t || defined __need_wint_t || (defined __hpux && ((defined _INTTYPES_INCLUDED && !defined strtoimax) || defined _GL_JUST_INCLUDE_SYSTEM_WCHAR_H)) || defined _GL_ALREADY_INCLUDING_WCHAR_H
|
||||
/* Special invocation convention:
|
||||
|
|
@ -52,6 +53,10 @@
|
|||
|
||||
#define _GL_ALREADY_INCLUDING_WCHAR_H
|
||||
|
||||
#if @HAVE_FEATURES_H@
|
||||
# include <features.h> /* for __GLIBC__ */
|
||||
#endif
|
||||
|
||||
/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
|
||||
<wchar.h>.
|
||||
BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue