aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggert2011-06-21 09:15:07 -0700
committerPaul Eggert2011-06-21 09:15:07 -0700
commitfa23e171f4d9390c1c4151355ec72f9ff6fc90ab (patch)
tree3545fbfe6da37d20d6cc37a4d2f1be884a868a6a
parent9e9de01439b2c57e79505ba0668894c9addc3bf1 (diff)
downloademacs-fa23e171f4d9390c1c4151355ec72f9ff6fc90ab.tar.gz
emacs-fa23e171f4d9390c1c4151355ec72f9ff6fc90ab.zip
Use gnulib's alloca-opt module.
* .bzrignore: Add lib/alloca.h. * Makefile.in (GNULIB_MODULES): Add alloca-opt. * configure.in (AC_FUNC_ALLOCA): Remove almost all the alloca stuff, as gnulib now does that for us. Put alloca check after gl_INIT. * lib/gnulib.mk, m4/gl-comp.m4: Regenerate. * lib/alloca.in.h, m4/alloca.m4: New files, from gnulib.
-rw-r--r--ChangeLog10
-rw-r--r--Makefile.in1
-rw-r--r--configure.in34
-rw-r--r--lib/alloca.in.h56
-rw-r--r--lib/gnulib.mk25
-rw-r--r--m4/alloca.m4121
-rw-r--r--m4/gl-comp.m44
7 files changed, 226 insertions, 25 deletions
diff --git a/ChangeLog b/ChangeLog
index e523175936e..c73d6bf85f6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
12011-06-21 Paul Eggert <eggert@cs.ucla.edu>
2
3 Use gnulib's alloca-opt module.
4 * .bzrignore: Add lib/alloca.h.
5 * Makefile.in (GNULIB_MODULES): Add alloca-opt.
6 * configure.in (AC_FUNC_ALLOCA): Remove almost all the alloca stuff,
7 as gnulib now does that for us. Put alloca check after gl_INIT.
8 * lib/gnulib.mk, m4/gl-comp.m4: Regenerate.
9 * lib/alloca.in.h, m4/alloca.m4: New files, from gnulib.
10
12011-06-21 Leo Liu <sdl.web@gmail.com> 112011-06-21 Leo Liu <sdl.web@gmail.com>
2 12
3 * m4/sha256.m4: 13 * m4/sha256.m4:
diff --git a/Makefile.in b/Makefile.in
index 4fe51076aea..40d76104397 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -332,6 +332,7 @@ DOS_gnulib_comp.m4 = gl-comp.m4
332# $(gnulib_srcdir) (relative to $(srcdir) and should have build tools 332# $(gnulib_srcdir) (relative to $(srcdir) and should have build tools
333# as per $(gnulib_srcdir)/DEPENDENCIES. 333# as per $(gnulib_srcdir)/DEPENDENCIES.
334GNULIB_MODULES = \ 334GNULIB_MODULES = \
335 alloca-opt \
335 careadlinkat crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 dtoastr \ 336 careadlinkat crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 dtoastr \
336 filemode getloadavg getopt-gnu ignore-value intprops lstat mktime readlink \ 337 filemode getloadavg getopt-gnu ignore-value intprops lstat mktime readlink \
337 socklen stdarg stdio strftime strtoumax symlink sys_stat 338 socklen stdarg stdio strftime strtoumax symlink sys_stat
diff --git a/configure.in b/configure.in
index 0135b9f1bf1..e4d2e2e96c8 100644
--- a/configure.in
+++ b/configure.in
@@ -990,7 +990,7 @@ AC_SYS_LARGEFILE
990 990
991## If user specified a crt-dir, use that unconditionally. 991## If user specified a crt-dir, use that unconditionally.
992if test "X$CRT_DIR" = "X"; then 992if test "X$CRT_DIR" = "X"; then
993 993
994 case "$canonical" in 994 case "$canonical" in
995 x86_64-*-linux-gnu* | s390x-*-linux-gnu*) 995 x86_64-*-linux-gnu* | s390x-*-linux-gnu*)
996 ## On x86-64 and s390x GNU/Linux distributions, the standard library 996 ## On x86-64 and s390x GNU/Linux distributions, the standard library
@@ -2565,15 +2565,6 @@ if test $emacs_cv_netdb_declares_h_errno = yes; then
2565 AC_DEFINE(HAVE_H_ERRNO, 1, [Define to 1 if netdb.h declares h_errno.]) 2565 AC_DEFINE(HAVE_H_ERRNO, 1, [Define to 1 if netdb.h declares h_errno.])
2566fi 2566fi
2567 2567
2568AC_FUNC_ALLOCA
2569
2570dnl src/alloca.c has been removed. Could also check if $ALLOCA is set?
2571dnl FIXME is there an autoconf test that does the right thing, without
2572dnl needing to call A_M_E afterwards?
2573if test x"$ac_cv_func_alloca_works" != xyes; then
2574 AC_MSG_ERROR( [a system implementation of alloca is required] )
2575fi
2576
2577# fmod, logb, and frexp are found in -lm on most systems. 2568# fmod, logb, and frexp are found in -lm on most systems.
2578# On HPUX 9.01, -lm does not contain logb, so check for sqrt. 2569# On HPUX 9.01, -lm does not contain logb, so check for sqrt.
2579AC_CHECK_LIB(m, sqrt) 2570AC_CHECK_LIB(m, sqrt)
@@ -2687,6 +2678,14 @@ gl_ASSERT_NO_GNULIB_POSIXCHECK
2687gl_ASSERT_NO_GNULIB_TESTS 2678gl_ASSERT_NO_GNULIB_TESTS
2688gl_INIT 2679gl_INIT
2689 2680
2681# Check for alloca.
2682dnl src/alloca.c has been removed. Could also check if $ALLOCA is set?
2683dnl FIXME is there an autoconf test that does the right thing, without
2684dnl needing to call A_M_E afterwards?
2685if test x"$ac_cv_func_alloca_works" != xyes; then
2686 AC_MSG_ERROR( [a system implementation of alloca is required] )
2687fi
2688
2690# UNIX98 PTYs. 2689# UNIX98 PTYs.
2691AC_CHECK_FUNCS(grantpt) 2690AC_CHECK_FUNCS(grantpt)
2692 2691
@@ -3534,20 +3533,7 @@ AH_BOTTOM([
3534 3533
3535#include <string.h> 3534#include <string.h>
3536#include <stdlib.h> 3535#include <stdlib.h>
3537 3536#include <alloca.h>
3538#ifdef HAVE_ALLOCA_H
3539# include <alloca.h>
3540#elif defined __GNUC__
3541# define alloca __builtin_alloca
3542#elif defined _AIX
3543# define alloca __alloca
3544#else
3545# include <stddef.h>
3546# ifdef __cplusplus
3547extern "C"
3548# endif
3549void *alloca (size_t);
3550#endif
3551 3537
3552#ifndef HAVE_STRCHR 3538#ifndef HAVE_STRCHR
3553#define strchr(a, b) index (a, b) 3539#define strchr(a, b) index (a, b)
diff --git a/lib/alloca.in.h b/lib/alloca.in.h
new file mode 100644
index 00000000000..5b69c6c81a8
--- /dev/null
+++ b/lib/alloca.in.h
@@ -0,0 +1,56 @@
1/* Memory allocation on the stack.
2
3 Copyright (C) 1995, 1999, 2001-2004, 2006-2011 Free Software Foundation,
4 Inc.
5
6 This program is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published
8 by the Free Software Foundation; either version 3, or (at your option)
9 any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
15
16 You should have received a copy of the GNU General Public
17 License along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
19 USA. */
20
21/* Avoid using the symbol _ALLOCA_H here, as Bison assumes _ALLOCA_H
22 means there is a real alloca function. */
23#ifndef _GL_ALLOCA_H
24#define _GL_ALLOCA_H
25
26/* alloca (N) returns a pointer to N bytes of memory
27 allocated on the stack, which will last until the function returns.
28 Use of alloca should be avoided:
29 - inside arguments of function calls - undefined behaviour,
30 - in inline functions - the allocation may actually last until the
31 calling function returns,
32 - for huge N (say, N >= 65536) - you never know how large (or small)
33 the stack is, and when the stack cannot fulfill the memory allocation
34 request, the program just crashes.
35 */
36
37#ifndef alloca
38# ifdef __GNUC__
39# define alloca __builtin_alloca
40# elif defined _AIX
41# define alloca __alloca
42# elif defined _MSC_VER
43# include <malloc.h>
44# define alloca _alloca
45# elif defined __DECC && defined __VMS
46# define alloca __ALLOCA
47# else
48# include <stddef.h>
49# ifdef __cplusplus
50extern "C"
51# endif
52void *alloca (size_t);
53# endif
54#endif
55
56#endif /* _GL_ALLOCA_H */
diff --git a/lib/gnulib.mk b/lib/gnulib.mk
index 5987138fafb..0fd7f520acb 100644
--- a/lib/gnulib.mk
+++ b/lib/gnulib.mk
@@ -9,7 +9,7 @@
9# the same distribution terms as the rest of that program. 9# the same distribution terms as the rest of that program.
10# 10#
11# Generated by gnulib-tool. 11# Generated by gnulib-tool.
12# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=. --makefile-name=gnulib.mk --conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files careadlinkat crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 dtoastr filemode getloadavg getopt-gnu ignore-value intprops lstat mktime readlink socklen stdarg stdio strftime strtoumax symlink sys_stat 12# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=. --makefile-name=gnulib.mk --conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca-opt careadlinkat crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 dtoastr filemode getloadavg getopt-gnu ignore-value intprops lstat mktime readlink socklen stdarg stdio strftime strtoumax symlink sys_stat
13 13
14 14
15MOSTLYCLEANFILES += core *.stackdump 15MOSTLYCLEANFILES += core *.stackdump
@@ -21,6 +21,29 @@ libgnu_a_LIBADD = $(gl_LIBOBJS)
21libgnu_a_DEPENDENCIES = $(gl_LIBOBJS) 21libgnu_a_DEPENDENCIES = $(gl_LIBOBJS)
22EXTRA_libgnu_a_SOURCES = 22EXTRA_libgnu_a_SOURCES =
23 23
24## begin gnulib module alloca-opt
25
26BUILT_SOURCES += $(ALLOCA_H)
27
28# We need the following in order to create <alloca.h> when the system
29# doesn't have one that works with the given compiler.
30if GL_GENERATE_ALLOCA_H
31alloca.h: alloca.in.h $(top_builddir)/config.status
32 $(AM_V_GEN)rm -f $@-t $@ && \
33 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
34 cat $(srcdir)/alloca.in.h; \
35 } > $@-t && \
36 mv -f $@-t $@
37else
38alloca.h: $(top_builddir)/config.status
39 rm -f $@
40endif
41MOSTLYCLEANFILES += alloca.h alloca.h-t
42
43EXTRA_DIST += alloca.in.h
44
45## end gnulib module alloca-opt
46
24## begin gnulib module allocator 47## begin gnulib module allocator
25 48
26libgnu_a_SOURCES += allocator.c 49libgnu_a_SOURCES += allocator.c
diff --git a/m4/alloca.m4 b/m4/alloca.m4
new file mode 100644
index 00000000000..891fc8bc36f
--- /dev/null
+++ b/m4/alloca.m4
@@ -0,0 +1,121 @@
1# alloca.m4 serial 12
2dnl Copyright (C) 2002-2004, 2006-2007, 2009-2011 Free Software Foundation,
3dnl Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7
8AC_DEFUN([gl_FUNC_ALLOCA],
9[
10 AC_REQUIRE([AC_FUNC_ALLOCA])
11 if test $ac_cv_func_alloca_works = no; then
12 gl_PREREQ_ALLOCA
13 fi
14
15 # Define an additional variable used in the Makefile substitution.
16 if test $ac_cv_working_alloca_h = yes; then
17 AC_CACHE_CHECK([for alloca as a compiler built-in], [gl_cv_rpl_alloca], [
18 AC_EGREP_CPP([Need own alloca], [
19#if defined __GNUC__ || defined _AIX || defined _MSC_VER
20 Need own alloca
21#endif
22 ], [gl_cv_rpl_alloca=yes], [gl_cv_rpl_alloca=no])
23 ])
24 if test $gl_cv_rpl_alloca = yes; then
25 dnl OK, alloca can be implemented through a compiler built-in.
26 AC_DEFINE([HAVE_ALLOCA], [1],
27 [Define to 1 if you have 'alloca' after including <alloca.h>,
28 a header that may be supplied by this distribution.])
29 ALLOCA_H=alloca.h
30 else
31 dnl alloca exists as a library function, i.e. it is slow and probably
32 dnl a memory leak. Don't define HAVE_ALLOCA in this case.
33 ALLOCA_H=
34 fi
35 else
36 ALLOCA_H=alloca.h
37 fi
38 AC_SUBST([ALLOCA_H])
39 AM_CONDITIONAL([GL_GENERATE_ALLOCA_H], [test -n "$ALLOCA_H"])
40])
41
42# Prerequisites of lib/alloca.c.
43# STACK_DIRECTION is already handled by AC_FUNC_ALLOCA.
44AC_DEFUN([gl_PREREQ_ALLOCA], [:])
45
46# This works around a bug in autoconf <= 2.68.
47# See <http://lists.gnu.org/archive/html/bug-gnulib/2011-06/msg00277.html>.
48
49m4_version_prereq([2.69], [] ,[
50
51# This is taken from the following Autoconf patch:
52# http://git.savannah.gnu.org/cgit/autoconf.git/commit/?id=6cd9f12520b0d6f76d3230d7565feba1ecf29497
53
54# _AC_LIBOBJ_ALLOCA
55# -----------------
56# Set up the LIBOBJ replacement of `alloca'. Well, not exactly
57# AC_LIBOBJ since we actually set the output variable `ALLOCA'.
58# Nevertheless, for Automake, AC_LIBSOURCES it.
59m4_define([_AC_LIBOBJ_ALLOCA],
60[# The SVR3 libPW and SVR4 libucb both contain incompatible functions
61# that cause trouble. Some versions do not even contain alloca or
62# contain a buggy version. If you still want to use their alloca,
63# use ar to extract alloca.o from them instead of compiling alloca.c.
64AC_LIBSOURCES(alloca.c)
65AC_SUBST([ALLOCA], [\${LIBOBJDIR}alloca.$ac_objext])dnl
66AC_DEFINE(C_ALLOCA, 1, [Define to 1 if using `alloca.c'.])
67
68AC_CACHE_CHECK(whether `alloca.c' needs Cray hooks, ac_cv_os_cray,
69[AC_EGREP_CPP(webecray,
70[#if defined CRAY && ! defined CRAY2
71webecray
72#else
73wenotbecray
74#endif
75], ac_cv_os_cray=yes, ac_cv_os_cray=no)])
76if test $ac_cv_os_cray = yes; then
77 for ac_func in _getb67 GETB67 getb67; do
78 AC_CHECK_FUNC($ac_func,
79 [AC_DEFINE_UNQUOTED(CRAY_STACKSEG_END, $ac_func,
80 [Define to one of `_getb67', `GETB67',
81 `getb67' for Cray-2 and Cray-YMP
82 systems. This function is required for
83 `alloca.c' support on those systems.])
84 break])
85 done
86fi
87
88AC_CACHE_CHECK([stack direction for C alloca],
89 [ac_cv_c_stack_direction],
90[AC_RUN_IFELSE([AC_LANG_SOURCE(
91[AC_INCLUDES_DEFAULT
92int
93find_stack_direction (int *addr, int depth)
94{
95 int dir, dummy = 0;
96 if (! addr)
97 addr = &dummy;
98 *addr = addr < &dummy ? 1 : addr == &dummy ? 0 : -1;
99 dir = depth ? find_stack_direction (addr, depth - 1) : 0;
100 return dir + dummy;
101}
102
103int
104main (int argc, char **argv)
105{
106 return find_stack_direction (0, argc + !argv + 20) < 0;
107}])],
108 [ac_cv_c_stack_direction=1],
109 [ac_cv_c_stack_direction=-1],
110 [ac_cv_c_stack_direction=0])])
111AH_VERBATIM([STACK_DIRECTION],
112[/* If using the C implementation of alloca, define if you know the
113 direction of stack growth for your system; otherwise it will be
114 automatically deduced at runtime.
115 STACK_DIRECTION > 0 => grows toward higher addresses
116 STACK_DIRECTION < 0 => grows toward lower addresses
117 STACK_DIRECTION = 0 => direction of growth unknown */
118@%:@undef STACK_DIRECTION])dnl
119AC_DEFINE_UNQUOTED(STACK_DIRECTION, $ac_cv_c_stack_direction)
120])# _AC_LIBOBJ_ALLOCA
121])
diff --git a/m4/gl-comp.m4 b/m4/gl-comp.m4
index 64a7874c4c8..24141a2639b 100644
--- a/m4/gl-comp.m4
+++ b/m4/gl-comp.m4
@@ -26,6 +26,7 @@ AC_DEFUN([gl_EARLY],
26 m4_pattern_allow([^gl_LIBOBJS$])dnl a variable 26 m4_pattern_allow([^gl_LIBOBJS$])dnl a variable
27 m4_pattern_allow([^gl_LTLIBOBJS$])dnl a variable 27 m4_pattern_allow([^gl_LTLIBOBJS$])dnl a variable
28 AC_REQUIRE([AC_PROG_RANLIB]) 28 AC_REQUIRE([AC_PROG_RANLIB])
29 # Code from module alloca-opt:
29 # Code from module allocator: 30 # Code from module allocator:
30 # Code from module arg-nonnull: 31 # Code from module arg-nonnull:
31 # Code from module c++defs: 32 # Code from module c++defs:
@@ -94,6 +95,7 @@ AC_DEFUN([gl_INIT],
94 m4_pushdef([gl_LIBSOURCES_DIR], []) 95 m4_pushdef([gl_LIBSOURCES_DIR], [])
95 gl_COMMON 96 gl_COMMON
96 gl_source_base='lib' 97 gl_source_base='lib'
98gl_FUNC_ALLOCA
97AC_CHECK_FUNCS_ONCE([readlinkat]) 99AC_CHECK_FUNCS_ONCE([readlinkat])
98gl_MD5 100gl_MD5
99gl_SHA1 101gl_SHA1
@@ -392,6 +394,7 @@ AC_DEFUN([gl_FILE_LIST], [
392 build-aux/arg-nonnull.h 394 build-aux/arg-nonnull.h
393 build-aux/c++defs.h 395 build-aux/c++defs.h
394 build-aux/warn-on-use.h 396 build-aux/warn-on-use.h
397 lib/alloca.in.h
395 lib/allocator.c 398 lib/allocator.c
396 lib/allocator.h 399 lib/allocator.h
397 lib/careadlinkat.c 400 lib/careadlinkat.c
@@ -445,6 +448,7 @@ AC_DEFUN([gl_FILE_LIST], [
445 lib/unistd.in.h 448 lib/unistd.in.h
446 lib/verify.h 449 lib/verify.h
447 m4/00gnulib.m4 450 m4/00gnulib.m4
451 m4/alloca.m4
448 m4/c-strtod.m4 452 m4/c-strtod.m4
449 m4/extensions.m4 453 m4/extensions.m4
450 m4/filemode.m4 454 m4/filemode.m4