From 12a7e0f88eaa68aabe7e32589e2d5c8f776f6346 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Wed, 7 Sep 2016 17:04:49 -0700 Subject: Update from gnulib MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This incorporates: 2016-09-07 flexmember: new macro FLEXALIGNOF 2016-09-07 flexmember: port better to GCC + valgrind 2016-08-18 Port modules to use getprogname explicitly 2016-09-02 manywarnings: add -fno-common * admin/merge-gnulib (GNULIB_TOOL_FLAGS): Don’t avoid flexmember, since time_rz now uses part of it. Instead, remove m4/flexmember.m4. * configure.ac (AC_C_FLEXIBLE_ARRAY_MEMBER): Define away, since Emacs assumes C99 and therefore removes m4/flexmember.m4. * lib/euidaccess.c, lib/group-member.c, lib/time_rz.c: * m4/manywarnings.m4: Copy from gnulib. * lib/flexmember.h: New file, from gnulib. * lib/gnulib.mk, m4/gnulib-comp.m4: Regenerate. --- admin/merge-gnulib | 5 +++-- configure.ac | 2 ++ lib/euidaccess.c | 3 --- lib/flexmember.h | 42 ++++++++++++++++++++++++++++++++++++++++++ lib/gnulib.mk | 11 ++++++++++- lib/group-member.c | 4 ---- lib/time_rz.c | 3 ++- m4/gnulib-comp.m4 | 15 +++++++++++++++ m4/manywarnings.m4 | 1 + 9 files changed, 75 insertions(+), 11 deletions(-) create mode 100644 lib/flexmember.h diff --git a/admin/merge-gnulib b/admin/merge-gnulib index 5d6512760d..1e3b759962 100755 --- a/admin/merge-gnulib +++ b/admin/merge-gnulib @@ -44,7 +44,7 @@ GNULIB_MODULES=' GNULIB_TOOL_FLAGS=' --avoid=close --avoid=dup - --avoid=fchdir --avoid=flexmember --avoid=fstat + --avoid=fchdir --avoid=fstat --avoid=malloc-posix --avoid=msvc-inval --avoid=msvc-nothrow --avoid=open --avoid=openat-die --avoid=opendir --avoid=raise @@ -93,7 +93,8 @@ test -x "$gnulib_srcdir"/gnulib-tool || { } "$gnulib_srcdir"/gnulib-tool --dir="$src" $GNULIB_TOOL_FLAGS $GNULIB_MODULES && -rm -- "$src"lib/gl_openssl.h "$src"m4/fcntl-o.m4 "$src"m4/gl-openssl.m4 \ +rm -- "$src"lib/gl_openssl.h "$src"m4/fcntl-o.m4 "$src"m4/flexmember.m4 \ + "$src"m4/gl-openssl.m4 \ "$src"m4/gnulib-cache.m4"$src" m4/warn-on-use.m4 && cp -- "$gnulib_srcdir"/build-aux/texinfo.tex "$src"doc/misc && cp -- "$gnulib_srcdir"/build-aux/move-if-change "$src"build-aux && diff --git a/configure.ac b/configure.ac index e8aeae266f..9856228d51 100644 --- a/configure.ac +++ b/configure.ac @@ -775,6 +775,8 @@ dnl alternative to lib/gnulib.mk, so as to avoid generating header files dnl that clash with MinGW. AM_CONDITIONAL([BUILDING_FOR_WINDOWSNT], [test "x$opsys" = "xmingw32"]) +# Skip gnulib's tests for flexible array members, as Emacs assumes C99. +AC_DEFUN([AC_C_FLEXIBLE_ARRAY_MEMBER]) # Avoid gnulib's tests for -lcrypto, so that there's no static dependency on it. AC_DEFUN([gl_CRYPTO_CHECK]) # Avoid gnulib's tests for HAVE_WORKING_O_NOATIME and HAVE_WORKING_O_NOFOLLOW, diff --git a/lib/euidaccess.c b/lib/euidaccess.c index 82af9417ac..e9eb0e948a 100644 --- a/lib/euidaccess.c +++ b/lib/euidaccess.c @@ -197,8 +197,6 @@ weak_alias (__euidaccess, euidaccess) # include # include -char *program_name; - int main (int argc, char **argv) { @@ -206,7 +204,6 @@ main (int argc, char **argv) int mode; int err; - program_name = argv[0]; if (argc < 3) abort (); file = argv[1]; diff --git a/lib/flexmember.h b/lib/flexmember.h new file mode 100644 index 0000000000..62c556bae2 --- /dev/null +++ b/lib/flexmember.h @@ -0,0 +1,42 @@ +/* Sizes of structs with flexible array members. + + Copyright 2016 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + + Written by Paul Eggert. */ + +#include + +/* Nonzero multiple of alignment of TYPE, suitable for FLEXSIZEOF below. + On older platforms without _Alignof, use a pessimistic bound that is + safe in practice even if FLEXIBLE_ARRAY_MEMBER is 1. + On newer platforms, use _Alignof to get a tighter bound. */ + +#if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112 +# define FLEXALIGNOF(type) (sizeof (type) & ~ (sizeof (type) - 1)) +#else +# define FLEXALIGNOF(type) _Alignof (type) +#endif + +/* Upper bound on the size of a struct of type TYPE with a flexible + array member named MEMBER that is followed by N bytes of other data. + This is not simply sizeof (TYPE) + N, since it may require + alignment on unusually picky C11 platforms, and + FLEXIBLE_ARRAY_MEMBER may be 1 on pre-C11 platforms. + Yield a value less than N if and only if arithmetic overflow occurs. */ + +#define FLEXSIZEOF(type, member, n) \ + ((offsetof (type, member) + FLEXALIGNOF (type) - 1 + (n)) \ + & ~ (FLEXALIGNOF (type) - 1)) diff --git a/lib/gnulib.mk b/lib/gnulib.mk index cc8429658e..c431de6811 100644 --- a/lib/gnulib.mk +++ b/lib/gnulib.mk @@ -21,7 +21,7 @@ # the same distribution terms as the rest of that program. # # Generated by gnulib-tool. -# Reproduce by: gnulib-tool --import --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --avoid=close --avoid=dup --avoid=fchdir --avoid=flexmember --avoid=fstat --avoid=malloc-posix --avoid=msvc-inval --avoid=msvc-nothrow --avoid=open --avoid=openat-die --avoid=opendir --avoid=raise --avoid=save-cwd --avoid=select --avoid=setenv --avoid=sigprocmask --avoid=stdarg --avoid=stdbool --avoid=threadlib --avoid=unsetenv --makefile-name=gnulib.mk --conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca-opt binary-io byteswap c-ctype c-strcase careadlinkat close-stream count-one-bits count-trailing-zeros crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 dtoastr dtotimespec dup2 environ execinfo faccessat fcntl fcntl-h fdatasync fdopendir filemode filevercmp fstatat fsync getloadavg getopt-gnu gettime gettimeofday gitlog-to-changelog ignore-value intprops largefile lstat manywarnings memrchr mkostemp mktime pipe2 pselect pthread_sigmask putenv qcopy-acl readlink readlinkat sig2str socklen stat-time std-gnu11 stdalign stddef stdio stpcpy strftime strtoimax strtoumax symlink sys_stat sys_time time time_r time_rz timegm timer-time timespec-add timespec-sub unsetenv update-copyright utimens vla warnings +# Reproduce by: gnulib-tool --import --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --avoid=close --avoid=dup --avoid=fchdir --avoid=fstat --avoid=malloc-posix --avoid=msvc-inval --avoid=msvc-nothrow --avoid=open --avoid=openat-die --avoid=opendir --avoid=raise --avoid=save-cwd --avoid=select --avoid=setenv --avoid=sigprocmask --avoid=stdarg --avoid=stdbool --avoid=threadlib --avoid=unsetenv --makefile-name=gnulib.mk --conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca-opt binary-io byteswap c-ctype c-strcase careadlinkat close-stream count-one-bits count-trailing-zeros crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 dtoastr dtotimespec dup2 environ execinfo faccessat fcntl fcntl-h fdatasync fdopendir filemode filevercmp fstatat fsync getloadavg getopt-gnu gettime gettimeofday gitlog-to-changelog ignore-value intprops largefile lstat manywarnings memrchr mkostemp mktime pipe2 pselect pthread_sigmask putenv qcopy-acl readlink readlinkat sig2str socklen stat-time std-gnu11 stdalign stddef stdio stpcpy strftime strtoimax strtoumax symlink sys_stat sys_time time time_r time_rz timegm timer-time timespec-add timespec-sub unsetenv update-copyright utimens vla warnings MOSTLYCLEANFILES += core *.stackdump @@ -449,6 +449,15 @@ EXTRA_DIST += filevercmp.h ## end gnulib module filevercmp +## begin gnulib module flexmember + +if gl_GNULIB_ENABLED_flexmember + +endif +EXTRA_DIST += flexmember.h + +## end gnulib module flexmember + ## begin gnulib module fpending diff --git a/lib/group-member.c b/lib/group-member.c index 365e166921..6bbab893c7 100644 --- a/lib/group-member.c +++ b/lib/group-member.c @@ -97,15 +97,11 @@ group_member (gid_t gid) #ifdef TEST -char *program_name; - int main (int argc, char **argv) { int i; - program_name = argv[0]; - for (i = 1; i < argc; i++) { gid_t gid; diff --git a/lib/time_rz.c b/lib/time_rz.c index 55b764ea8b..38afb5fc3c 100644 --- a/lib/time_rz.c +++ b/lib/time_rz.c @@ -32,6 +32,7 @@ #include #include +#include "flexmember.h" #include "time-internal.h" #if !HAVE_TZSET @@ -94,7 +95,7 @@ tzalloc (char const *name) { size_t name_size = name ? strlen (name) + 1 : 0; size_t abbr_size = name_size < ABBR_SIZE_MIN ? ABBR_SIZE_MIN : name_size + 1; - timezone_t tz = malloc (offsetof (struct tm_zone, abbrs) + abbr_size); + timezone_t tz = malloc (FLEXSIZEOF (struct tm_zone, abbrs, abbr_size)); if (tz) { tz->next = NULL; diff --git a/m4/gnulib-comp.m4 b/m4/gnulib-comp.m4 index 5a3fc98597..5fc667c352 100644 --- a/m4/gnulib-comp.m4 +++ b/m4/gnulib-comp.m4 @@ -79,6 +79,7 @@ AC_DEFUN([gl_EARLY], # Code from module fdopendir: # Code from module filemode: # Code from module filevercmp: + # Code from module flexmember: # Code from module fpending: # Code from module fstatat: # Code from module fsync: @@ -413,6 +414,7 @@ AC_DEFUN([gl_INIT], gl_gnulib_enabled_dirfd=false gl_gnulib_enabled_dosname=false gl_gnulib_enabled_euidaccess=false + gl_gnulib_enabled_flexmember=false gl_gnulib_enabled_getdtablesize=false gl_gnulib_enabled_getgroups=false gl_gnulib_enabled_be453cec5eecf5731a274f2de7f2db36=false @@ -472,6 +474,13 @@ AC_DEFUN([gl_INIT], fi fi } + func_gl_gnulib_m4code_flexmember () + { + if ! $gl_gnulib_enabled_flexmember; then + AC_C_FLEXIBLE_ARRAY_MEMBER + gl_gnulib_enabled_flexmember=true + fi + } func_gl_gnulib_m4code_getdtablesize () { if ! $gl_gnulib_enabled_getdtablesize; then @@ -679,6 +688,9 @@ AC_DEFUN([gl_INIT], if { test $HAVE_DECL_STRTOUMAX = 0 || test $REPLACE_STRTOUMAX = 1; } && test $ac_cv_type_unsigned_long_long_int = yes; then func_gl_gnulib_m4code_strtoull fi + if test "$HAVE_TIMEZONE_T" = 0; then + func_gl_gnulib_m4code_flexmember + fi if test $HAVE_TIMEGM = 0 || test $REPLACE_TIMEGM = 1; then func_gl_gnulib_m4code_5264294aa0a5557541b53c8c741f7f31 fi @@ -687,6 +699,7 @@ AC_DEFUN([gl_INIT], AM_CONDITIONAL([gl_GNULIB_ENABLED_dirfd], [$gl_gnulib_enabled_dirfd]) AM_CONDITIONAL([gl_GNULIB_ENABLED_dosname], [$gl_gnulib_enabled_dosname]) AM_CONDITIONAL([gl_GNULIB_ENABLED_euidaccess], [$gl_gnulib_enabled_euidaccess]) + AM_CONDITIONAL([gl_GNULIB_ENABLED_flexmember], [$gl_gnulib_enabled_flexmember]) AM_CONDITIONAL([gl_GNULIB_ENABLED_getdtablesize], [$gl_gnulib_enabled_getdtablesize]) AM_CONDITIONAL([gl_GNULIB_ENABLED_getgroups], [$gl_gnulib_enabled_getgroups]) AM_CONDITIONAL([gl_GNULIB_ENABLED_be453cec5eecf5731a274f2de7f2db36], [$gl_gnulib_enabled_be453cec5eecf5731a274f2de7f2db36]) @@ -892,6 +905,7 @@ AC_DEFUN([gl_FILE_LIST], [ lib/filemode.h lib/filevercmp.c lib/filevercmp.h + lib/flexmember.h lib/fpending.c lib/fpending.h lib/fstatat.c @@ -1013,6 +1027,7 @@ AC_DEFUN([gl_FILE_LIST], [ m4/fdatasync.m4 m4/fdopendir.m4 m4/filemode.m4 + m4/flexmember.m4 m4/fpending.m4 m4/fstatat.m4 m4/fsync.m4 diff --git a/m4/manywarnings.m4 b/m4/manywarnings.m4 index 90823b0acf..89fd0ae38e 100644 --- a/m4/manywarnings.m4 +++ b/m4/manywarnings.m4 @@ -103,6 +103,7 @@ AC_DEFUN([gl_MANYWARN_ALL_GCC], gl_manywarn_set= for gl_manywarn_item in \ + -fno-common \ -W \ -Wabi \ -Waddress \ -- cgit v1.2.3