summaryrefslogtreecommitdiff
path: root/gl
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@gnutls.org>2013-07-14 13:52:58 +0200
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2013-07-14 13:53:22 +0200
commit5efa7d64818114bbef4896d3824425917b45e909 (patch)
tree166bb14196a233382b80570c746ae20cf3723fe0 /gl
parent142eddc0b8eb696fcadedd9d9c6f387fafa560f8 (diff)
downloadgnutls-5efa7d64818114bbef4896d3824425917b45e909.tar.gz
updated gnulib
Diffstat (limited to 'gl')
-rw-r--r--gl/Makefile.am2
-rw-r--r--gl/argp-help.c2
-rw-r--r--gl/c-ctype.h3
-rw-r--r--gl/fseeko.c10
-rw-r--r--gl/m4/extensions.m42
-rw-r--r--gl/m4/extern-inline.m417
-rw-r--r--gl/m4/fseeko.m44
-rw-r--r--gl/m4/gnulib-comp.m41
-rw-r--r--gl/m4/lock.m43
-rw-r--r--gl/m4/manywarnings.m46
-rw-r--r--gl/m4/stdalign.m43
-rw-r--r--gl/m4/warnings.m415
-rw-r--r--gl/msvc-inval.c6
-rw-r--r--gl/stdalign.in.h39
-rw-r--r--gl/stdio.in.h14
-rw-r--r--gl/tests/Makefile.am2
-rw-r--r--gl/tests/getcwd-lgpl.c1
-rw-r--r--gl/tests/ignore-value.h13
-rw-r--r--gl/tests/malloca.c29
-rw-r--r--gl/tests/test-getaddrinfo.c5
-rw-r--r--gl/tests/test-snprintf.c2
-rw-r--r--gl/tests/test-sys_socket.c2
-rw-r--r--gl/tests/test-vasnprintf.c2
-rw-r--r--gl/tests/test-vsnprintf.c2
-rw-r--r--gl/vasnprintf.c3
-rw-r--r--gl/verify.h110
26 files changed, 183 insertions, 115 deletions
diff --git a/gl/Makefile.am b/gl/Makefile.am
index 79b79b3ac2..aa74b37133 100644
--- a/gl/Makefile.am
+++ b/gl/Makefile.am
@@ -23,7 +23,7 @@
# Generated by gnulib-tool.
# Reproduce by: gnulib-tool --import --dir=. --local-dir=gl/override --lib=libgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --tests-base=gl/tests --aux-dir=build-aux --with-tests --avoid=alignof-tests --avoid=lock-tests --avoid=lseek-tests --no-conditional-dependencies --libtool --macro-prefix=gl --no-vc-files accept alloca alphasort argp base64 bind byteswap c-ctype close connect error extensions func gendocs getaddrinfo getpass getsubopt gettext gettimeofday hash-pjw-bare havelib iconv iconv_open-utf inet_ntop inet_pton lib-msvc-compat lib-symbol-versions listen maintainer-makefile manywarnings memmem-simple minmax netdb netinet_in pmccabe2html progname read-file recv recvfrom scandir select send sendto servent setsockopt shutdown snprintf socket sockets socklen stdint strcase strndup strtok_r strverscmp sys_socket sys_stat time_r u64 unistd valgrind-tests vasprintf version-etc version-etc-fsf vfprintf-posix vprintf-posix vsnprintf warnings
-AUTOMAKE_OPTIONS = 1.5 gnits subdir-objects
+AUTOMAKE_OPTIONS = 1.9.6 gnits subdir-objects
SUBDIRS =
noinst_HEADERS =
diff --git a/gl/argp-help.c b/gl/argp-help.c
index 354f1e22f5..85def445ed 100644
--- a/gl/argp-help.c
+++ b/gl/argp-help.c
@@ -649,7 +649,7 @@ hol_find_entry (struct hol *hol, const char *name)
return 0;
}
-/* If an entry with the long option NAME occurs in HOL, set it's special
+/* If an entry with the long option NAME occurs in HOL, set its special
sort position to GROUP. */
static void
hol_set_group (struct hol *hol, const char *name, int group)
diff --git a/gl/c-ctype.h b/gl/c-ctype.h
index 3a66440ae9..ad589b5c20 100644
--- a/gl/c-ctype.h
+++ b/gl/c-ctype.h
@@ -136,7 +136,8 @@ extern int c_tolower (int c) _GL_ATTRIBUTE_CONST;
extern int c_toupper (int c) _GL_ATTRIBUTE_CONST;
-#if defined __GNUC__ && defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__ && !defined NO_C_CTYPE_MACROS
+#if (defined __GNUC__ && !defined __STRICT_ANSI__ && defined __OPTIMIZE__ \
+ && !defined __OPTIMIZE_SIZE__ && !defined NO_C_CTYPE_MACROS)
/* ASCII optimizations. */
diff --git a/gl/fseeko.c b/gl/fseeko.c
index 42cd642854..c03be3d0c5 100644
--- a/gl/fseeko.c
+++ b/gl/fseeko.c
@@ -19,7 +19,7 @@
/* Specification. */
#include <stdio.h>
-/* Get off_t and lseek. */
+/* Get off_t, lseek, _POSIX_VERSION. */
#include <unistd.h>
#include "stdio-impl.h"
@@ -99,8 +99,14 @@ fseeko (FILE *fp, off_t offset, int whence)
#elif defined EPLAN9 /* Plan9 */
if (fp->rp == fp->buf
&& fp->wp == fp->buf)
+#elif FUNC_FFLUSH_STDIN < 0 && 200809 <= _POSIX_VERSION
+ /* Cross-compiling to some other system advertising conformance to
+ POSIX.1-2008 or later. Assume fseeko and fflush work as advertised.
+ If this assumption is incorrect, please report the bug to
+ bug-gnulib. */
+ if (0)
#else
- #error "Please port gnulib fseeko.c to your platform! Look at the code in fpurge.c, then report this to bug-gnulib."
+ #error "Please port gnulib fseeko.c to your platform! Look at the code in fseeko.c, then report this to bug-gnulib."
#endif
{
/* We get here when an fflush() call immediately preceded this one (or
diff --git a/gl/m4/extensions.m4 b/gl/m4/extensions.m4
index 07ba376c0e..e30f12206c 100644
--- a/gl/m4/extensions.m4
+++ b/gl/m4/extensions.m4
@@ -6,7 +6,7 @@
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
-# This definition of AC_USE_SYSTEM_EXTENSIONS is stolen from CVS
+# This definition of AC_USE_SYSTEM_EXTENSIONS is stolen from git
# Autoconf. Perhaps we can remove this once we can assume Autoconf
# 2.70 or later everywhere, but since Autoconf mutates rapidly
# enough in this area it's likely we'll need to redefine
diff --git a/gl/m4/extern-inline.m4 b/gl/m4/extern-inline.m4
index 94b46dde07..c4c5e7f221 100644
--- a/gl/m4/extern-inline.m4
+++ b/gl/m4/extern-inline.m4
@@ -8,15 +8,7 @@ dnl with or without modifications, as long as this notice is preserved.
AC_DEFUN([gl_EXTERN_INLINE],
[
AH_VERBATIM([extern_inline],
-[/* _GL_INLINE is a portable alternative to ISO C99 plain 'inline'.
- _GL_EXTERN_INLINE is a portable alternative to 'extern inline'.
- _GL_INLINE_HEADER_BEGIN contains useful stuff to put
- in an include file, before uses of _GL_INLINE.
- It suppresses GCC's bogus "no previous prototype for 'FOO'" diagnostic,
- when FOO is an inline function in the header; see
- <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54113>.
- _GL_INLINE_HEADER_END contains useful stuff to put
- in the same include file, after uses of _GL_INLINE.
+[/* Please see the Gnulib manual for how to use these macros.
Suppress extern inline with HP-UX cc, as it appears to be broken; see
<http://lists.gnu.org/archive/html/bug-texinfo/2013-02/msg00030.html>.
@@ -39,7 +31,8 @@ AC_DEFUN([gl_EXTERN_INLINE],
&& !defined __APPLE__)
# define _GL_INLINE inline
# define _GL_EXTERN_INLINE extern inline
-#elif 2 < __GNUC__ + (7 <= __GNUC_MINOR__) && !defined __APPLE__
+#elif (2 < __GNUC__ + (7 <= __GNUC_MINOR__) && !defined __STRICT_ANSI__ \
+ && !defined __APPLE__)
# if __GNUC_GNU_INLINE__
/* __gnu_inline__ suppresses a GCC 4.2 diagnostic. */
# define _GL_INLINE extern inline __attribute__ ((__gnu_inline__))
@@ -59,6 +52,10 @@ AC_DEFUN([gl_EXTERN_INLINE],
# define _GL_INLINE_HEADER_CONST_PRAGMA \
_Pragma ("GCC diagnostic ignored \"-Wsuggest-attribute=const\"")
# endif
+ /* Suppress GCC's bogus "no previous prototype for 'FOO'"
+ and "no previous declaration for 'FOO'" diagnostics,
+ when FOO is an inline function in the header; see
+ <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54113>. */
# define _GL_INLINE_HEADER_BEGIN \
_Pragma ("GCC diagnostic push") \
_Pragma ("GCC diagnostic ignored \"-Wmissing-prototypes\"") \
diff --git a/gl/m4/fseeko.m4 b/gl/m4/fseeko.m4
index e0f2dfbe1f..ca9da2835d 100644
--- a/gl/m4/fseeko.m4
+++ b/gl/m4/fseeko.m4
@@ -1,4 +1,4 @@
-# fseeko.m4 serial 16
+# fseeko.m4 serial 17
dnl Copyright (C) 2007-2013 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -37,7 +37,7 @@ AC_DEFUN([gl_FUNC_FSEEKO],
fi
m4_ifdef([gl_FUNC_FFLUSH_STDIN], [
gl_FUNC_FFLUSH_STDIN
- if test $gl_cv_func_fflush_stdin = no; then
+ if test $gl_cv_func_fflush_stdin != yes; then
REPLACE_FSEEKO=1
fi
])
diff --git a/gl/m4/gnulib-comp.m4 b/gl/m4/gnulib-comp.m4
index 24ed4b30d1..a1ec16c9f2 100644
--- a/gl/m4/gnulib-comp.m4
+++ b/gl/m4/gnulib-comp.m4
@@ -989,6 +989,7 @@ changequote([, ])dnl
gl_LOCALENAME
AC_CHECK_FUNCS_ONCE([newlocale])
gl_LOCK
+ gl_MODULE_INDICATOR([lock])
gl_FUNC_LSTAT
if test $REPLACE_LSTAT = 1; then
AC_LIBOBJ([lstat])
diff --git a/gl/m4/lock.m4 b/gl/m4/lock.m4
index d3fc1eff01..aae1701a0a 100644
--- a/gl/m4/lock.m4
+++ b/gl/m4/lock.m4
@@ -24,6 +24,9 @@ AC_DEFUN([gl_LOCK],
[[
#if __FreeBSD__ == 4
error "No, in FreeBSD 4.0 recursive mutexes actually don't work."
+#elif (defined __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ \
+ && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1070)
+error "No, in Mac OS X < 10.7 recursive mutexes actually don't work."
#else
int x = (int)PTHREAD_MUTEX_RECURSIVE;
return !x;
diff --git a/gl/m4/manywarnings.m4 b/gl/m4/manywarnings.m4
index 45a30afda7..be6d4c91c5 100644
--- a/gl/m4/manywarnings.m4
+++ b/gl/m4/manywarnings.m4
@@ -98,6 +98,7 @@ AC_DEFUN([gl_MANYWARN_ALL_GCC],
-W \
-Wabi \
-Waddress \
+ -Waggressive-loop-optimizations \
-Wall \
-Warray-bounds \
-Wattributes \
@@ -125,7 +126,6 @@ AC_DEFUN([gl_MANYWARN_ALL_GCC],
-Wformat-security \
-Wformat-y2k \
-Wformat-zero-length \
- -Wformat=2 \
-Wfree-nonheap-object \
-Wignored-qualifiers \
-Wimplicit \
@@ -143,9 +143,7 @@ AC_DEFUN([gl_MANYWARN_ALL_GCC],
-Wmissing-braces \
-Wmissing-declarations \
-Wmissing-field-initializers \
- -Wmissing-format-attribute \
-Wmissing-include-dirs \
- -Wmissing-noreturn \
-Wmissing-parameter-type \
-Wmissing-prototypes \
-Wmudflap \
@@ -166,6 +164,7 @@ AC_DEFUN([gl_MANYWARN_ALL_GCC],
-Wpointer-sign \
-Wpointer-to-int-cast \
-Wpragmas \
+ -Wreturn-local-addr \
-Wreturn-type \
-Wsequence-point \
-Wshadow \
@@ -187,7 +186,6 @@ AC_DEFUN([gl_MANYWARN_ALL_GCC],
-Wtype-limits \
-Wuninitialized \
-Wunknown-pragmas \
- -Wunreachable-code \
-Wunsafe-loop-optimizations \
-Wunused \
-Wunused-but-set-parameter \
diff --git a/gl/m4/stdalign.m4 b/gl/m4/stdalign.m4
index a866ff670b..20be01aaf2 100644
--- a/gl/m4/stdalign.m4
+++ b/gl/m4/stdalign.m4
@@ -31,7 +31,8 @@ AC_DEFUN([gl_STDALIGN_H],
/* Test _Alignas only on platforms where gnulib can help. */
#if \
- (__GNUC__ || __IBMC__ || __IBMCPP__ \
+ ((defined __cplusplus && 201103 <= __cplusplus) \
+ || __GNUC__ || __IBMC__ || __IBMCPP__ || __ICC \
|| 0x5110 <= __SUNPRO_C || 1300 <= _MSC_VER)
struct alignas_test { char c; char alignas (8) alignas_8; };
char test_alignas[offsetof (struct alignas_test, alignas_8) == 8
diff --git a/gl/m4/warnings.m4 b/gl/m4/warnings.m4
index 4b2ac38501..184873283b 100644
--- a/gl/m4/warnings.m4
+++ b/gl/m4/warnings.m4
@@ -1,4 +1,4 @@
-# warnings.m4 serial 7
+# warnings.m4 serial 8
dnl Copyright (C) 2008-2013 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -27,7 +27,7 @@ AC_DEFUN([gl_COMPILER_OPTION_IF],
AS_VAR_PUSHDEF([gl_Flags], [_AC_LANG_PREFIX[]FLAGS])dnl
AC_CACHE_CHECK([whether _AC_LANG compiler handles $1], m4_defn([gl_Warn]), [
gl_save_compiler_FLAGS="$gl_Flags"
- gl_AS_VAR_APPEND(m4_defn([gl_Flags]), [" $1"])
+ gl_AS_VAR_APPEND(m4_defn([gl_Flags]), [" $gl_unknown_warnings_are_errors $1"])
AC_COMPILE_IFELSE([m4_default([$4], [AC_LANG_PROGRAM([])])],
[AS_VAR_SET(gl_Warn, [yes])],
[AS_VAR_SET(gl_Warn, [no])])
@@ -38,6 +38,14 @@ AS_VAR_POPDEF([gl_Flags])dnl
AS_VAR_POPDEF([gl_Warn])dnl
])
+# gl_UNKNOWN_WARNINGS_ARE_ERRORS
+# ------------------------------
+# Clang doesn't complain about unknown warning options unless one also
+# specifies -Wunknown-warning-option -Werror. Detect this.
+AC_DEFUN([gl_UNKNOWN_WARNINGS_ARE_ERRORS],
+[gl_COMPILER_OPTION_IF([-Werror -Wunknown-warning-option],
+ [gl_unknown_warnings_are_errors='-Wunknown-warning-option -Werror'],
+ [gl_unknown_warnings_are_errors=])])
# gl_WARN_ADD(OPTION, [VARIABLE = WARN_CFLAGS],
# [PROGRAM = AC_LANG_PROGRAM()])
@@ -47,7 +55,8 @@ AS_VAR_POPDEF([gl_Warn])dnl
#
# If VARIABLE is a variable name, AC_SUBST it.
AC_DEFUN([gl_WARN_ADD],
-[gl_COMPILER_OPTION_IF([$1],
+[AC_REQUIRE([gl_UNKNOWN_WARNINGS_ARE_ERRORS])
+gl_COMPILER_OPTION_IF([$1],
[gl_AS_VAR_APPEND(m4_if([$2], [], [[WARN_CFLAGS]], [[$2]]), [" $1"])],
[],
[$3])
diff --git a/gl/msvc-inval.c b/gl/msvc-inval.c
index 72a6b6ee89..396031e4c2 100644
--- a/gl/msvc-inval.c
+++ b/gl/msvc-inval.c
@@ -28,7 +28,7 @@
# if MSVC_INVALID_PARAMETER_HANDLING == DEFAULT_HANDLING
-static void cdecl
+static void __cdecl
gl_msvc_invalid_parameter_handler (const wchar_t *expression,
const wchar_t *function,
const wchar_t *file,
@@ -45,7 +45,7 @@ gl_msvc_invalid_parameter_handler (const wchar_t *expression,
# if defined _MSC_VER
-static void cdecl
+static void __cdecl
gl_msvc_invalid_parameter_handler (const wchar_t *expression,
const wchar_t *function,
const wchar_t *file,
@@ -94,7 +94,7 @@ gl_msvc_inval_current (void)
}
}
-static void cdecl
+static void __cdecl
gl_msvc_invalid_parameter_handler (const wchar_t *expression,
const wchar_t *function,
const wchar_t *file,
diff --git a/gl/stdalign.in.h b/gl/stdalign.in.h
index c3a67321b0..7254a3dec1 100644
--- a/gl/stdalign.in.h
+++ b/gl/stdalign.in.h
@@ -41,13 +41,28 @@
are 4 unless the option '-malign-double' is used.
The result cannot be used as a value for an 'enum' constant, if you
- want to be portable to HP-UX 10.20 cc and AIX 3.2.5 xlc. */
+ want to be portable to HP-UX 10.20 cc and AIX 3.2.5 xlc.
+
+ Include <stddef.h> for offsetof. */
#include <stddef.h>
-#if defined __cplusplus
+
+/* FreeBSD 9.1 <sys/cdefs.h>, included by <stddef.h> and lots of other
+ standard headers, defines conflicting implementations of _Alignas
+ and _Alignof that are no better than ours; override them. */
+#undef _Alignas
+#undef _Alignof
+
+#if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112
+# ifdef __cplusplus
+# if 201103 <= __cplusplus
+# define _Alignof(type) alignof (type)
+# else
template <class __t> struct __alignof_helper { char __a; __t __b; };
-# define _Alignof(type) offsetof (__alignof_helper<type>, __b)
-#else
-# define _Alignof(type) offsetof (struct { char __a; type __b; }, __b)
+# define _Alignof(type) offsetof (__alignof_helper<type>, __b)
+# endif
+# else
+# define _Alignof(type) offsetof (struct { char __a; type __b; }, __b)
+# endif
#endif
#define alignof _Alignof
#define __alignof_is_defined 1
@@ -77,12 +92,16 @@
*/
-#if __GNUC__ || __IBMC__ || __IBMCPP__ || 0x5110 <= __SUNPRO_C
-# define _Alignas(a) __attribute__ ((__aligned__ (a)))
-#elif 1300 <= _MSC_VER
-# define _Alignas(a) __declspec (align (a))
+#if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112
+# if defined __cplusplus && 201103 <= __cplusplus
+# define _Alignas(a) alignas (a)
+# elif __GNUC__ || __IBMC__ || __IBMCPP__ || __ICC || 0x5110 <= __SUNPRO_C
+# define _Alignas(a) __attribute__ ((__aligned__ (a)))
+# elif 1300 <= _MSC_VER
+# define _Alignas(a) __declspec (align (a))
+# endif
#endif
-#ifdef _Alignas
+#if defined _Alignas || (defined __STDC_VERSION && 201112 <= __STDC_VERSION__)
# define alignas _Alignas
# define __alignas_is_defined 1
#endif
diff --git a/gl/stdio.in.h b/gl/stdio.in.h
index d6af99ca77..06cbad00d3 100644
--- a/gl/stdio.in.h
+++ b/gl/stdio.in.h
@@ -579,13 +579,23 @@ _GL_CXXALIAS_SYS (fwrite, size_t,
<http://sources.redhat.com/bugzilla/show_bug.cgi?id=11959>,
which sometimes causes an unwanted diagnostic for fwrite calls.
This affects only function declaration attributes under certain
- versions of gcc, and is not needed for C++. */
+ versions of gcc and clang, and is not needed for C++. */
# if (0 < __USE_FORTIFY_LEVEL \
&& __GLIBC__ == 2 && 4 <= __GLIBC_MINOR__ && __GLIBC_MINOR__ <= 15 \
&& 3 < __GNUC__ + (4 <= __GNUC_MINOR__) \
&& !defined __cplusplus)
# undef fwrite
-# define fwrite(a, b, c, d) ({size_t __r = fwrite (a, b, c, d); __r; })
+# undef fwrite_unlocked
+extern size_t __REDIRECT (rpl_fwrite,
+ (const void *__restrict, size_t, size_t,
+ FILE *__restrict),
+ fwrite);
+extern size_t __REDIRECT (rpl_fwrite_unlocked,
+ (const void *__restrict, size_t, size_t,
+ FILE *__restrict),
+ fwrite_unlocked);
+# define fwrite rpl_fwrite
+# define fwrite_unlocked rpl_fwrite_unlocked
# endif
# endif
_GL_CXXALIASWARN (fwrite);
diff --git a/gl/tests/Makefile.am b/gl/tests/Makefile.am
index 0b3462cbb8..5eeffe6c67 100644
--- a/gl/tests/Makefile.am
+++ b/gl/tests/Makefile.am
@@ -22,7 +22,7 @@
#
# Generated by gnulib-tool.
-AUTOMAKE_OPTIONS = 1.5 foreign subdir-objects
+AUTOMAKE_OPTIONS = 1.9.6 foreign subdir-objects
SUBDIRS = .
TESTS =
diff --git a/gl/tests/getcwd-lgpl.c b/gl/tests/getcwd-lgpl.c
index d550f35c4e..cebe8f7b3d 100644
--- a/gl/tests/getcwd-lgpl.c
+++ b/gl/tests/getcwd-lgpl.c
@@ -20,6 +20,7 @@
#include <unistd.h>
#include <errno.h>
+#include <stdlib.h>
#include <string.h>
#if GNULIB_GETCWD
diff --git a/gl/tests/ignore-value.h b/gl/tests/ignore-value.h
index 63ecde8513..ebd6bf42f5 100644
--- a/gl/tests/ignore-value.h
+++ b/gl/tests/ignore-value.h
@@ -33,15 +33,16 @@
declared with attribute warn_unused_result". */
#ifndef _GL_IGNORE_VALUE_H
-# define _GL_IGNORE_VALUE_H
+#define _GL_IGNORE_VALUE_H
/* The __attribute__((__warn_unused_result__)) feature
is available in gcc versions 3.4 and newer,
while the typeof feature has been available since 2.7 at least. */
-# if __GNUC__ < 3 || (__GNUC__ == 3 && __GNUC_MINOR__ < 4)
-# define ignore_value(x) ((void) (x))
-# else
-# define ignore_value(x) (({ __typeof__ (x) __x = (x); (void) __x; }))
-# endif
+#if 3 < __GNUC__ + (4 <= __GNUC_MINOR__)
+# define ignore_value(x) \
+ (__extension__ ({ __typeof__ (x) __x = (x); (void) __x; }))
+#else
+# define ignore_value(x) ((void) (x))
+#endif
#endif
diff --git a/gl/tests/malloca.c b/gl/tests/malloca.c
index 3cd2f6d99e..311be569bc 100644
--- a/gl/tests/malloca.c
+++ b/gl/tests/malloca.c
@@ -49,12 +49,18 @@
#define MAGIC_SIZE sizeof (int)
/* This is how the header info would look like without any alignment
considerations. */
-struct preliminary_header { void *next; char room[MAGIC_SIZE]; };
+struct preliminary_header { void *next; int magic; };
/* But the header's size must be a multiple of sa_alignment_max. */
#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 (HEADER_SIZE == sizeof (struct header));
+union header {
+ void *next;
+ struct {
+ char room[HEADER_SIZE - MAGIC_SIZE];
+ int word;
+ } magic;
+};
+verify (HEADER_SIZE == sizeof (union 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
@@ -74,20 +80,21 @@ mmalloca (size_t n)
if (nplus >= n)
{
- char *p = (char *) malloc (nplus);
+ void *p = malloc (nplus);
if (p != NULL)
{
size_t slot;
+ union header *h = p;
- p += HEADER_SIZE;
+ p = h + 1;
/* Put a magic number into the indicator word. */
- ((int *) p)[-1] = MAGIC_NUMBER;
+ h->magic.word = MAGIC_NUMBER;
/* Enter p into the hash table. */
slot = (uintptr_t) p % HASH_TABLE_SIZE;
- ((struct header *) (p - HEADER_SIZE))->next = mmalloca_results[slot];
+ h->next = mmalloca_results[slot];
mmalloca_results[slot] = p;
return p;
@@ -123,15 +130,17 @@ freea (void *p)
void **chain = &mmalloca_results[slot];
for (; *chain != NULL;)
{
+ union header *h = p;
if (*chain == p)
{
/* Found it. Remove it from the hash table and free it. */
- char *p_begin = (char *) p - HEADER_SIZE;
- *chain = ((struct header *) p_begin)->next;
+ union header *p_begin = h - 1;
+ *chain = p_begin->next;
free (p_begin);
return;
}
- chain = &((struct header *) ((char *) *chain - HEADER_SIZE))->next;
+ h = *chain;
+ chain = &h[-1].next;
}
}
/* At this point, we know it was not a mmalloca() result. */
diff --git a/gl/tests/test-getaddrinfo.c b/gl/tests/test-getaddrinfo.c
index 1b9892f410..5c27d3bef8 100644
--- a/gl/tests/test-getaddrinfo.c
+++ b/gl/tests/test-getaddrinfo.c
@@ -114,6 +114,8 @@ simple (char const *host, char const *service)
for (ai = ai0; ai; ai = ai->ai_next)
{
+ void *ai_addr = ai->ai_addr;
+ struct sockaddr_in *sock_addr = ai_addr;
dbgprintf ("\tflags %x\n", ai->ai_flags);
dbgprintf ("\tfamily %x\n", ai->ai_family);
dbgprintf ("\tsocktype %x\n", ai->ai_socktype);
@@ -121,8 +123,7 @@ simple (char const *host, char const *service)
dbgprintf ("\taddrlen %ld: ", (unsigned long) ai->ai_addrlen);
dbgprintf ("\tFound %s\n",
inet_ntop (ai->ai_family,
- &((struct sockaddr_in *)
- ai->ai_addr)->sin_addr,
+ &sock_addr->sin_addr,
buf, sizeof (buf) - 1));
if (ai->ai_canonname)
dbgprintf ("\tFound %s...\n", ai->ai_canonname);
diff --git a/gl/tests/test-snprintf.c b/gl/tests/test-snprintf.c
index 805735769e..108346e129 100644
--- a/gl/tests/test-snprintf.c
+++ b/gl/tests/test-snprintf.c
@@ -52,7 +52,7 @@ main (int argc, char *argv[])
#if !CHECK_SNPRINTF_POSIX
if (size > 0)
#endif
- ASSERT (memcmp (buf + size, "DEADBEEF" + size, 8 - size) == 0);
+ ASSERT (memcmp (buf + size, &"DEADBEEF"[size], 8 - size) == 0);
}
else
{
diff --git a/gl/tests/test-sys_socket.c b/gl/tests/test-sys_socket.c
index 0ac8a33264..9084b18b6d 100644
--- a/gl/tests/test-sys_socket.c
+++ b/gl/tests/test-sys_socket.c
@@ -47,7 +47,7 @@ main (void)
sa_family_t i;
/* Check some errno values. */
- switch (0)
+ switch (ENOTSOCK)
{
case ENOTSOCK:
case EADDRINUSE:
diff --git a/gl/tests/test-vasnprintf.c b/gl/tests/test-vasnprintf.c
index f29b05aeb5..4cce0a947a 100644
--- a/gl/tests/test-vasnprintf.c
+++ b/gl/tests/test-vasnprintf.c
@@ -55,7 +55,7 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...))
ASSERT (length == 5);
if (size < 6)
ASSERT (result != buf);
- ASSERT (memcmp (buf + size, "DEADBEEF" + size, 8 - size) == 0);
+ ASSERT (memcmp (buf + size, &"DEADBEEF"[size], 8 - size) == 0);
if (result != buf)
free (result);
}
diff --git a/gl/tests/test-vsnprintf.c b/gl/tests/test-vsnprintf.c
index 3353b2eb47..84b5d89676 100644
--- a/gl/tests/test-vsnprintf.c
+++ b/gl/tests/test-vsnprintf.c
@@ -65,7 +65,7 @@ main (int argc, char *argv[])
#if !CHECK_VSNPRINTF_POSIX
if (size > 0)
#endif
- ASSERT (memcmp (buf + size, "DEADBEEF" + size, 8 - size) == 0);
+ ASSERT (memcmp (buf + size, &"DEADBEEF"[size], 8 - size) == 0);
}
else
{
diff --git a/gl/vasnprintf.c b/gl/vasnprintf.c
index 8fdab32ea5..5267b1bb5e 100644
--- a/gl/vasnprintf.c
+++ b/gl/vasnprintf.c
@@ -5153,7 +5153,8 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
size_t tmp_length =
MAX_ROOM_NEEDED (&a, dp->arg_index,
dp->conversion, type, flags,
- width, has_precision,
+ has_width ? width : 0,
+ has_precision,
precision, pad_ourselves);
if (maxlen < tmp_length)
diff --git a/gl/verify.h b/gl/verify.h
index cb8e90b542..d42d0750ee 100644
--- a/gl/verify.h
+++ b/gl/verify.h
@@ -18,7 +18,7 @@
/* Written by Paul Eggert, Bruno Haible, and Jim Meyering. */
#ifndef _GL_VERIFY_H
-# define _GL_VERIFY_H
+#define _GL_VERIFY_H
/* Define _GL_HAVE__STATIC_ASSERT to 1 if _Static_assert works as per C11.
@@ -31,14 +31,24 @@
Use this only with GCC. If we were willing to slow 'configure'
down we could also use it with other compilers, but since this
affects only the quality of diagnostics, why bother? */
-# if (4 < __GNUC__ || (__GNUC__ == 4 && 6 <= __GNUC_MINOR__)) && !defined __cplusplus
-# define _GL_HAVE__STATIC_ASSERT 1
-# endif
+#if (4 < __GNUC__ + (6 <= __GNUC_MINOR__) \
+ && (201112L <= __STDC_VERSION__ || !defined __STRICT_ANSI__) \
+ && !defined __cplusplus)
+# define _GL_HAVE__STATIC_ASSERT 1
+#endif
/* The condition (99 < __GNUC__) is temporary, until we know about the
first G++ release that supports static_assert. */
-# if (99 < __GNUC__) && defined __cplusplus
-# define _GL_HAVE_STATIC_ASSERT 1
-# endif
+#if (99 < __GNUC__) && defined __cplusplus
+# define _GL_HAVE_STATIC_ASSERT 1
+#endif
+
+/* FreeBSD 9.1 <sys/cdefs.h>, included by <stddef.h> and lots of other
+ system headers, defines a conflicting _Static_assert that is no
+ better than ours; override it. */
+#ifndef _GL_HAVE_STATIC_ASSERT
+# include <stddef.h>
+# undef _Static_assert
+#endif
/* Each of these macros verifies that its argument R is nonzero. To
be portable, R should be an integer constant expression. Unlike
@@ -141,50 +151,50 @@
Use a template type to work around the problem. */
/* Concatenate two preprocessor tokens. */
-# define _GL_CONCAT(x, y) _GL_CONCAT0 (x, y)
-# define _GL_CONCAT0(x, y) x##y
+#define _GL_CONCAT(x, y) _GL_CONCAT0 (x, y)
+#define _GL_CONCAT0(x, y) x##y
/* _GL_COUNTER is an integer, preferably one that changes each time we
use it. Use __COUNTER__ if it works, falling back on __LINE__
otherwise. __LINE__ isn't perfect, but it's better than a
constant. */
-# if defined __COUNTER__ && __COUNTER__ != __COUNTER__
-# define _GL_COUNTER __COUNTER__
-# else
-# define _GL_COUNTER __LINE__
-# endif
+#if defined __COUNTER__ && __COUNTER__ != __COUNTER__
+# define _GL_COUNTER __COUNTER__
+#else
+# define _GL_COUNTER __LINE__
+#endif
/* Generate a symbol with the given prefix, making it unique if
possible. */
-# define _GL_GENSYM(prefix) _GL_CONCAT (prefix, _GL_COUNTER)
+#define _GL_GENSYM(prefix) _GL_CONCAT (prefix, _GL_COUNTER)
/* Verify requirement R at compile-time, as an integer constant expression
that returns 1. If R is false, fail at compile-time, preferably
with a diagnostic that includes the string-literal DIAGNOSTIC. */
-# define _GL_VERIFY_TRUE(R, DIAGNOSTIC) \
- (!!sizeof (_GL_VERIFY_TYPE (R, DIAGNOSTIC)))
+#define _GL_VERIFY_TRUE(R, DIAGNOSTIC) \
+ (!!sizeof (_GL_VERIFY_TYPE (R, DIAGNOSTIC)))
-# ifdef __cplusplus
-# if !GNULIB_defined_struct__gl_verify_type
+#ifdef __cplusplus
+# if !GNULIB_defined_struct__gl_verify_type
template <int w>
struct _gl_verify_type {
unsigned int _gl_verify_error_if_negative: w;
};
-# define GNULIB_defined_struct__gl_verify_type 1
-# endif
-# define _GL_VERIFY_TYPE(R, DIAGNOSTIC) \
- _gl_verify_type<(R) ? 1 : -1>
-# elif defined _GL_HAVE__STATIC_ASSERT
-# define _GL_VERIFY_TYPE(R, DIAGNOSTIC) \
- struct { \
- _Static_assert (R, DIAGNOSTIC); \
- int _gl_dummy; \
- }
-# else
-# define _GL_VERIFY_TYPE(R, DIAGNOSTIC) \
- struct { unsigned int _gl_verify_error_if_negative: (R) ? 1 : -1; }
+# define GNULIB_defined_struct__gl_verify_type 1
# endif
+# define _GL_VERIFY_TYPE(R, DIAGNOSTIC) \
+ _gl_verify_type<(R) ? 1 : -1>
+#elif defined _GL_HAVE__STATIC_ASSERT
+# define _GL_VERIFY_TYPE(R, DIAGNOSTIC) \
+ struct { \
+ _Static_assert (R, DIAGNOSTIC); \
+ int _gl_dummy; \
+ }
+#else
+# define _GL_VERIFY_TYPE(R, DIAGNOSTIC) \
+ struct { unsigned int _gl_verify_error_if_negative: (R) ? 1 : -1; }
+#endif
/* Verify requirement R at compile-time, as a declaration without a
trailing ';'. If R is false, fail at compile-time, preferably
@@ -193,23 +203,23 @@ template <int w>
Unfortunately, unlike C11, this implementation must appear as an
ordinary declaration, and cannot appear inside struct { ... }. */
-# ifdef _GL_HAVE__STATIC_ASSERT
-# define _GL_VERIFY _Static_assert
-# else
-# define _GL_VERIFY(R, DIAGNOSTIC) \
- extern int (*_GL_GENSYM (_gl_verify_function) (void)) \
- [_GL_VERIFY_TRUE (R, DIAGNOSTIC)]
-# endif
+#ifdef _GL_HAVE__STATIC_ASSERT
+# define _GL_VERIFY _Static_assert
+#else
+# define _GL_VERIFY(R, DIAGNOSTIC) \
+ extern int (*_GL_GENSYM (_gl_verify_function) (void)) \
+ [_GL_VERIFY_TRUE (R, DIAGNOSTIC)]
+#endif
/* _GL_STATIC_ASSERT_H is defined if this code is copied into assert.h. */
-# ifdef _GL_STATIC_ASSERT_H
-# if !defined _GL_HAVE__STATIC_ASSERT && !defined _Static_assert
-# define _Static_assert(R, DIAGNOSTIC) _GL_VERIFY (R, DIAGNOSTIC)
-# endif
-# if !defined _GL_HAVE_STATIC_ASSERT && !defined static_assert
-# define static_assert _Static_assert /* C11 requires this #define. */
-# endif
+#ifdef _GL_STATIC_ASSERT_H
+# if !defined _GL_HAVE__STATIC_ASSERT && !defined _Static_assert
+# define _Static_assert(R, DIAGNOSTIC) _GL_VERIFY (R, DIAGNOSTIC)
+# endif
+# if !defined _GL_HAVE_STATIC_ASSERT && !defined static_assert
+# define static_assert _Static_assert /* C11 requires this #define. */
# endif
+#endif
/* @assert.h omit start@ */
@@ -227,18 +237,18 @@ template <int w>
verify_true is obsolescent; please use verify_expr instead. */
-# define verify_true(R) _GL_VERIFY_TRUE (R, "verify_true (" #R ")")
+#define verify_true(R) _GL_VERIFY_TRUE (R, "verify_true (" #R ")")
/* Verify requirement R at compile-time. Return the value of the
expression E. */
-# define verify_expr(R, E) \
- (_GL_VERIFY_TRUE (R, "verify_expr (" #R ", " #E ")") ? (E) : (E))
+#define verify_expr(R, E) \
+ (_GL_VERIFY_TRUE (R, "verify_expr (" #R ", " #E ")") ? (E) : (E))
/* Verify requirement R at compile-time, as a declaration without a
trailing ';'. */
-# define verify(R) _GL_VERIFY (R, "verify (" #R ")")
+#define verify(R) _GL_VERIFY (R, "verify (" #R ")")
/* @assert.h omit end@ */