emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 12a7e0f 1/2: Update from gnulib


From: Paul Eggert
Subject: [Emacs-diffs] master 12a7e0f 1/2: Update from gnulib
Date: Thu, 8 Sep 2016 01:10:15 +0000 (UTC)

branch: master
commit 12a7e0f88eaa68aabe7e32589e2d5c8f776f6346
Author: Paul Eggert <address@hidden>
Commit: Paul Eggert <address@hidden>

    Update from gnulib
    
    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(-)

diff --git a/admin/merge-gnulib b/admin/merge-gnulib
index 5d65127..1e3b759 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 e8aeae2..9856228 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 82af941..e9eb0e9 100644
--- a/lib/euidaccess.c
+++ b/lib/euidaccess.c
@@ -197,8 +197,6 @@ weak_alias (__euidaccess, euidaccess)
 # include <stdio.h>
 # include <stdlib.h>
 
-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 0000000..62c556b
--- /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 <http://www.gnu.org/licenses/>.
+
+   Written by Paul Eggert.  */
+
+#include <stddef.h>
+
+/* 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 cc84296..c431de6 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 - 
[...]
+# 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-depend [...]
 
 
 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 365e166..6bbab89 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 55b764e..38afb5f 100644
--- a/lib/time_rz.c
+++ b/lib/time_rz.c
@@ -32,6 +32,7 @@
 #include <stdlib.h>
 #include <string.h>
 
+#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 5a3fc98..5fc667c 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 90823b0..89fd0ae 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 \



reply via email to

[Prev in Thread] Current Thread [Next in Thread]