From 8d390e2511eed485d3194c3959570191563baabd Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Fri, 23 Jul 2021 18:49:16 -0500 Subject: [PATCH 2/3] By-hand fixes for update from Gnulib * .gitignore: Add lib/malloc/*.gl.h. * admin/merge-gnulib: Copy lib/af_alg.h and lib/save-cwd.h directly from Gnulib, without worrying about Gnulib modules, as these files are special cases. * lib/af_alg.h, lib/save-cwd.h: Copy from Gnulib. * lib/malloca.c, lib/malloca.h: * m4/close-stream.m4, m4/glibc21.m4, m4/malloca.m4: Remove. These are either no longer present in Gnulib, or are no longer needed by modules that Emacs uses. --- .gitignore | 1 + INSTALL | 7 ++- admin/merge-gnulib | 3 ++ etc/NEWS | 6 +++ lib/af_alg.h | 18 +++---- lib/malloca.c | 106 -------------------------------------- lib/malloca.h | 123 --------------------------------------------- lib/save-cwd.h | 4 +- m4/close-stream.m4 | 11 ---- m4/glibc21.m4 | 34 ------------- m4/malloca.m4 | 14 ------ 11 files changed, 26 insertions(+), 301 deletions(-) delete mode 100644 lib/malloca.c delete mode 100644 lib/malloca.h delete mode 100644 m4/close-stream.m4 delete mode 100644 m4/glibc21.m4 delete mode 100644 m4/malloca.m4 diff --git a/.gitignore b/.gitignore index fcbc9cd7f4..00d0599b63 100644 --- a/.gitignore +++ b/.gitignore @@ -65,6 +65,7 @@ lib/ieee754.h lib/inttypes.h lib/libgnu.a lib/limits.h +lib/malloc/*.gl.h lib/signal.h lib/std*.h !lib/std*.in.h diff --git a/INSTALL b/INSTALL index b6f681a153..8c036f2e60 100644 --- a/INSTALL +++ b/INSTALL @@ -322,8 +322,11 @@ Use --without-toolkit-scroll-bars to disable Motif or Xaw3d scroll bars. Use --without-xim to inhibit the default use of X Input Methods. In this case, the X resource useXIM can be used to turn on use of XIM. -Use --disable-largefile to omit support for files larger than 2GB on -systems which support that. +Use --disable-largefile to omit support for files larger than 2GB, and +--disable-year2038 to omit support for timestamps past the year 2038, +on systems which allow omitting such support. This may help when +linking Emacs to a library with an ABI that requires a particular +width for off_t or for time_t. Use --without-sound to disable sound support. diff --git a/admin/merge-gnulib b/admin/merge-gnulib index 1c8b442700..76349034fd 100755 --- a/admin/merge-gnulib +++ b/admin/merge-gnulib @@ -118,5 +118,8 @@ avoided_flags= "$gnulib_srcdir"/build-aux/install-sh \ "$gnulib_srcdir"/build-aux/move-if-change \ "$src"build-aux && +cp -- "$gnulib_srcdir"/lib/af_alg.h \ + "$gnulib_srcdir"/lib/save-cwd.h \ + "$src"lib && { test -z "$src" || cd "$src"; } && ./autogen.sh diff --git a/etc/NEWS b/etc/NEWS index 95218faa1b..7c23a1eff3 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -78,6 +78,12 @@ It was declared obsolete in Emacs 27.1. This was only ever relevant when building from a repository checkout. This now requires makeinfo, which is part of the texinfo package. +--- +** There is a new configure option '--disable-year2038' to omit +support for 64-bit timestamps on platforms like GNU/Linux ARM where +time_t is traditionally 32-bit. This may be helpful when linking +Emacs to a library with ABI requiring 32-bit time_t. + --- ** Support for building with '-fcheck-pointer-bounds' has been removed. GCC has withdrawn the '-fcheck-pointer-bounds' option and support for diff --git a/lib/af_alg.h b/lib/af_alg.h index 4c5854cc99..f0fe7fc055 100644 --- a/lib/af_alg.h +++ b/lib/af_alg.h @@ -1,18 +1,18 @@ /* af_alg.h - Compute message digests from file streams and buffers. - Copyright (C) 2018-2020 Free Software Foundation, Inc. + Copyright (C) 2018-2021 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 2, or (at your option) any - later version. + This file 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.1 of the + License, or (at your option) any later version. - This program is distributed in the hope that it will be useful, + This file 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. + GNU Lesser 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 . */ + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ /* Written by Matteo Croce , 2018. Documentation by Bruno Haible , 2018. */ diff --git a/lib/malloca.c b/lib/malloca.c deleted file mode 100644 index d68d233dcb..0000000000 --- a/lib/malloca.c +++ /dev/null @@ -1,106 +0,0 @@ -/* Safe automatic memory allocation. - Copyright (C) 2003, 2006-2007, 2009-2021 Free Software Foundation, - Inc. - Written by Bruno Haible , 2003, 2018. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . */ - -#define _GL_USE_STDLIB_ALLOC 1 -#include - -/* Specification. */ -#include "malloca.h" - -#include "verify.h" - -/* The speed critical point in this file is freea() applied to an alloca() - result: it must be fast, to match the speed of alloca(). The speed of - mmalloca() and freea() in the other case are not critical, because they - are only invoked for big memory sizes. - Here we use a bit in the address as an indicator, an idea by Ondřej Bílka. - malloca() can return three types of pointers: - - Pointers ≡ 0 mod 2*sa_alignment_max come from stack allocation. - - Pointers ≡ sa_alignment_max mod 2*sa_alignment_max come from heap - allocation. - - NULL comes from a failed heap allocation. */ - -/* Type for holding very small pointer differences. */ -typedef unsigned char small_t; -/* Verify that it is wide enough. */ -verify (2 * sa_alignment_max - 1 <= (small_t) -1); - -void * -mmalloca (size_t n) -{ -#if HAVE_ALLOCA - /* Allocate one more word, used to determine the address to pass to freea(), - and room for the alignment ≡ sa_alignment_max mod 2*sa_alignment_max. */ - size_t nplus = n + sizeof (small_t) + 2 * sa_alignment_max - 1; - - if (nplus >= n) - { - char *mem = (char *) malloc (nplus); - - if (mem != NULL) - { - char *p = - (char *)((((uintptr_t)mem + sizeof (small_t) + sa_alignment_max - 1) - & ~(uintptr_t)(2 * sa_alignment_max - 1)) - + sa_alignment_max); - /* Here p >= mem + sizeof (small_t), - and p <= mem + sizeof (small_t) + 2 * sa_alignment_max - 1 - hence p + n <= mem + nplus. - So, the memory range [p, p+n) lies in the allocated memory range - [mem, mem + nplus). */ - ((small_t *) p)[-1] = p - mem; - /* p ≡ sa_alignment_max mod 2*sa_alignment_max. */ - return p; - } - } - /* Out of memory. */ - return NULL; -#else -# if !MALLOC_0_IS_NONNULL - if (n == 0) - n = 1; -# endif - return malloc (n); -#endif -} - -#if HAVE_ALLOCA -void -freea (void *p) -{ - /* Check argument. */ - if ((uintptr_t) p & (sa_alignment_max - 1)) - { - /* p was not the result of a malloca() call. Invalid argument. */ - abort (); - } - /* Determine whether p was a non-NULL pointer returned by mmalloca(). */ - if ((uintptr_t) p & sa_alignment_max) - { - void *mem = (char *) p - ((small_t *) p)[-1]; - free (mem); - } -} -#endif - -/* - * Hey Emacs! - * Local Variables: - * coding: utf-8 - * End: - */ diff --git a/lib/malloca.h b/lib/malloca.h deleted file mode 100644 index a04e54593f..0000000000 --- a/lib/malloca.h +++ /dev/null @@ -1,123 +0,0 @@ -/* Safe automatic memory allocation. - Copyright (C) 2003-2007, 2009-2021 Free Software Foundation, Inc. - Written by Bruno Haible , 2003. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . */ - -#ifndef _MALLOCA_H -#define _MALLOCA_H - -#include -#include -#include -#include - -#include "xalloc-oversized.h" - - -#ifdef __cplusplus -extern "C" { -#endif - - -/* safe_alloca(N) is equivalent to alloca(N) when it is safe to call - alloca(N); otherwise it returns NULL. It either returns N bytes of - memory allocated on the stack, that lasts until the function returns, - or NULL. - Use of safe_alloca should be avoided: - - inside arguments of function calls - undefined behaviour, - - in inline functions - the allocation may actually last until the - calling function returns. -*/ -#if HAVE_ALLOCA -/* The OS usually guarantees only one guard page at the bottom of the stack, - and a page size can be as small as 4096 bytes. So we cannot safely - allocate anything larger than 4096 bytes. Also care for the possibility - of a few compiler-allocated temporary stack slots. - This must be a macro, not a function. */ -# define safe_alloca(N) ((N) < 4032 ? alloca (N) : NULL) -#else -# define safe_alloca(N) ((void) (N), NULL) -#endif - -/* malloca(N) is a safe variant of alloca(N). It allocates N bytes of - memory allocated on the stack, that must be freed using freea() before - the function returns. Upon failure, it returns NULL. */ -#if HAVE_ALLOCA -# define malloca(N) \ - ((N) < 4032 - (2 * sa_alignment_max - 1) \ - ? (void *) (((uintptr_t) (char *) alloca ((N) + 2 * sa_alignment_max - 1) \ - + (2 * sa_alignment_max - 1)) \ - & ~(uintptr_t)(2 * sa_alignment_max - 1)) \ - : mmalloca (N)) -#else -# define malloca(N) \ - mmalloca (N) -#endif -extern void * mmalloca (size_t n); - -/* Free a block of memory allocated through malloca(). */ -#if HAVE_ALLOCA -extern void freea (void *p); -#else -# define freea free -#endif - -/* nmalloca(N,S) is an overflow-safe variant of malloca (N * S). - It allocates an array of N objects, each with S bytes of memory, - on the stack. S must be positive and N must be nonnegative. - The array must be freed using freea() before the function returns. */ -#define nmalloca(n, s) (xalloc_oversized (n, s) ? NULL : malloca ((n) * (s))) - - -#ifdef __cplusplus -} -#endif - - -/* ------------------- Auxiliary, non-public definitions ------------------- */ - -/* Determine the alignment of a type at compile time. */ -#if defined __GNUC__ || defined __clang__ || defined __IBM__ALIGNOF__ -# define sa_alignof __alignof__ -#elif defined __cplusplus - template struct sa_alignof_helper { char __slot1; type __slot2; }; -# define sa_alignof(type) offsetof (sa_alignof_helper, __slot2) -#elif defined __hpux - /* Work around a HP-UX 10.20 cc bug with enums constants defined as offsetof - values. */ -# define sa_alignof(type) (sizeof (type) <= 4 ? 4 : 8) -#elif defined _AIX - /* Work around an AIX 3.2.5 xlc bug with enums constants defined as offsetof - values. */ -# define sa_alignof(type) (sizeof (type) <= 4 ? 4 : 8) -#else -# define sa_alignof(type) offsetof (struct { char __slot1; type __slot2; }, __slot2) -#endif - -enum -{ -/* The desired alignment of memory allocations is the maximum alignment - among all elementary types. */ - sa_alignment_long = sa_alignof (long), - sa_alignment_double = sa_alignof (double), - sa_alignment_longlong = sa_alignof (long long), - sa_alignment_longdouble = sa_alignof (long double), - sa_alignment_max = ((sa_alignment_long - 1) | (sa_alignment_double - 1) - | (sa_alignment_longlong - 1) - | (sa_alignment_longdouble - 1) - ) + 1 -}; - -#endif /* _MALLOCA_H */ diff --git a/lib/save-cwd.h b/lib/save-cwd.h index e1e69eceaf..3cefba58c0 100644 --- a/lib/save-cwd.h +++ b/lib/save-cwd.h @@ -1,7 +1,7 @@ /* Save and restore current working directory. - Copyright (C) 1995, 1997-1998, 2003, 2009-2021 Free Software - Foundation, Inc. + Copyright (C) 1995, 1997-1998, 2003, 2009-2021 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 diff --git a/m4/close-stream.m4 b/m4/close-stream.m4 deleted file mode 100644 index feeb4eae5d..0000000000 --- a/m4/close-stream.m4 +++ /dev/null @@ -1,11 +0,0 @@ -#serial 4 -dnl Copyright (C) 2006-2007, 2009-2021 Free Software Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -dnl Prerequisites of lib/close-stream.c. -AC_DEFUN([gl_CLOSE_STREAM], -[ - : -]) diff --git a/m4/glibc21.m4 b/m4/glibc21.m4 deleted file mode 100644 index 74a781aa1c..0000000000 --- a/m4/glibc21.m4 +++ /dev/null @@ -1,34 +0,0 @@ -# glibc21.m4 serial 5 -dnl Copyright (C) 2000-2002, 2004, 2008, 2010-2021 Free Software -dnl Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -# Test for the GNU C Library, version 2.1 or newer, or uClibc. -# From Bruno Haible. - -AC_DEFUN([gl_GLIBC21], - [ - AC_CACHE_CHECK([whether we are using the GNU C Library >= 2.1 or uClibc], - [ac_cv_gnu_library_2_1], - [AC_EGREP_CPP([Lucky], - [ -#include -#ifdef __GNU_LIBRARY__ - #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2) - Lucky GNU user - #endif -#endif -#ifdef __UCLIBC__ - Lucky user -#endif - ], - [ac_cv_gnu_library_2_1=yes], - [ac_cv_gnu_library_2_1=no]) - ] - ) - AC_SUBST([GLIBC21]) - GLIBC21="$ac_cv_gnu_library_2_1" - ] -) diff --git a/m4/malloca.m4 b/m4/malloca.m4 deleted file mode 100644 index 7ee33773d2..0000000000 --- a/m4/malloca.m4 +++ /dev/null @@ -1,14 +0,0 @@ -# malloca.m4 serial 2 -dnl Copyright (C) 2003-2004, 2006-2007, 2009-2021 Free Software -dnl Foundation, Inc. -dnl This file is free software; the Free Software Foundation -dnl gives unlimited permission to copy and/or distribute it, -dnl with or without modifications, as long as this notice is preserved. - -AC_DEFUN([gl_MALLOCA], -[ - dnl Use the autoconf tests for alloca(), but not the AC_SUBSTed variables - dnl @ALLOCA@ and @LTALLOCA@. - dnl gl_FUNC_ALLOCA dnl Already brought in by the module dependencies. - AC_REQUIRE([gl_EEMALLOC]) -]) -- 2.31.1