From 8208d2bf95f924ed810dc06e84fc4c7d5ac004a5 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sat, 17 May 2014 01:11:31 -0700 Subject: [PATCH] Assume C99 or later. * lib/stdarg.in.h, lib/stdbool.in.h, m4/stdarg.m4, m4/stdbool.m4: Remove. * configure.ac (_AC_PROG_CC_C89): Define a dummy, to keep 'configure' smaller. (gl_PROG_CC_C99): Use this to get C99 or later. * lib/gnulib.mk, m4/gnulib-comp.m4: Regenerate. * admin/merge-gnulib (GNULIB_MODULES): Remove stdarg, stdbool. (GNULIB_TOOL_FLAGS): Avoid stdarg, stdbool. * doc/lispref/internals.texi (C Dialect): Document this. * etc/NEWS: Document this. * nt/gnulib.mk: Remove stdarg and stdbool modules. * src/bytecode.c (B__dummy__): Remove. * src/conf_post.h (bool_bf) [!NS_IMPL_GNUSTEP]: Use bool. (FLEXIBLE_ARRAY_MEMBER): Now always empty. * src/dbusbind.c (XD_DEBUG_MESSAGE) [!DBUS_DEBUG]: * src/regex.c (DEBUG_PRINT): Assume varargs macros. * src/lisp.h (DEFUN_FUNCTION_INIT): Remove. All uses now assume C99. Fixes: debbugs:17487 --- ChangeLog | 10 ++++ admin/ChangeLog | 6 +++ admin/merge-gnulib | 3 +- configure.ac | 8 ++- doc/lispref/ChangeLog | 5 ++ doc/lispref/internals.texi | 13 +++-- etc/ChangeLog | 4 ++ etc/NEWS | 2 + lib/gnulib.mk | 53 +----------------- lib/stdarg.in.h | 35 ------------ lib/stdbool.in.h | 132 --------------------------------------------- m4/gnulib-comp.m4 | 13 ----- m4/stdarg.m4 | 78 --------------------------- m4/stdbool.m4 | 100 ---------------------------------- nt/ChangeLog | 5 ++ nt/gnulib.mk | 51 ------------------ src/ChangeLog | 10 ++++ src/bytecode.c | 2 - src/conf_post.h | 20 ++++--- src/dbusbind.c | 6 +-- src/emacs.c | 2 +- src/lisp.h | 7 +-- src/regex.c | 7 +-- 23 files changed, 71 insertions(+), 501 deletions(-) delete mode 100644 lib/stdarg.in.h delete mode 100644 lib/stdbool.in.h delete mode 100644 m4/stdarg.m4 delete mode 100644 m4/stdbool.m4 diff --git a/ChangeLog b/ChangeLog index 70e7de030d2..39dee67f7ec 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2014-05-17 Paul Eggert + + Assume C99 or later (Bug#17487). + * lib/stdarg.in.h, lib/stdbool.in.h, m4/stdarg.m4, m4/stdbool.m4: + Remove. + * configure.ac (_AC_PROG_CC_C89): Define a dummy, to keep 'configure' + smaller. + (gl_PROG_CC_C99): Use this to get C99 or later. + * lib/gnulib.mk, m4/gnulib-comp.m4: Regenerate. + 2014-05-16 Paul Eggert Don't require pkg-config when building from repository. diff --git a/admin/ChangeLog b/admin/ChangeLog index 0981e0eaf10..3d8b21ff144 100644 --- a/admin/ChangeLog +++ b/admin/ChangeLog @@ -1,3 +1,9 @@ +2014-05-17 Paul Eggert + + Assume C99 or later (Bug#17487). + * merge-gnulib (GNULIB_MODULES): Remove stdarg, stdbool. + (GNULIB_TOOL_FLAGS): Avoid stdarg, stdbool. + 2014-05-16 Paul Eggert Don't require pkg-config when building from repository. diff --git a/admin/merge-gnulib b/admin/merge-gnulib index b93d12fbd20..5df2020f3aa 100755 --- a/admin/merge-gnulib +++ b/admin/merge-gnulib @@ -35,7 +35,7 @@ GNULIB_MODULES=' intprops largefile lstat manywarnings memrchr mkostemp mktime pipe2 pselect pthread_sigmask putenv qacl readlink readlinkat - sig2str socklen stat-time stdalign stdarg stdbool stdio + sig2str socklen stat-time stdalign stdio strftime strtoimax strtoumax symlink sys_stat sys_time time timer-time timespec-add timespec-sub unsetenv update-copyright utimens @@ -49,6 +49,7 @@ GNULIB_TOOL_FLAGS=' --avoid=open --avoid=openat-die --avoid=opendir --avoid=raise --avoid=save-cwd --avoid=select --avoid=sigprocmask + --avoid=stdarg --avoid=stdbool --avoid=threadlib --conditional-dependencies --import --no-changelog --no-vc-files --makefile-name=gnulib.mk diff --git a/configure.ac b/configure.ac index 55e5b8c0b5f..0119685394b 100644 --- a/configure.ac +++ b/configure.ac @@ -670,6 +670,9 @@ fi #### Choose a compiler. +dnl Don't bother to test for C89. +AC_DEFUN([_AC_PROG_CC_C89], [$2]) + dnl Sets GCC=yes if using gcc. AC_PROG_CC([gcc cc cl clang "$XCRUN gcc" "$XCRUN clang"]) if test -n "$XCRUN"; then @@ -677,6 +680,9 @@ if test -n "$XCRUN"; then test -n "$AR" && export AR fi +dnl Emacs needs C99 or later. +gl_PROG_CC_C99 + AM_PROG_CC_C_O if test x$GCC = xyes; then @@ -1303,7 +1309,7 @@ else CPPFLAGS="$C_SWITCH_SYSTEM $C_SWITCH_MACHINE $CPPFLAGS" fi -# Suppress obsolescent Autoconf test for size_t; Emacs assumes C89 or better. +# Suppress obsolescent Autoconf test for size_t; Emacs assumes C99 or better. AC_DEFUN([AC_TYPE_SIZE_T]) # Likewise for obsolescent test for uid_t, gid_t; Emacs assumes them. AC_DEFUN([AC_TYPE_UID_T]) diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog index 7d85e4059c9..d892e1307a0 100644 --- a/doc/lispref/ChangeLog +++ b/doc/lispref/ChangeLog @@ -1,3 +1,8 @@ +2014-05-17 Paul Eggert + + Assume C99 or later (Bug#17487). + * internals.texi (C Dialect): Document this. + 2014-05-15 Dmitry Antipov * lists.texi (Building Cons Cells and Lists): Remove diff --git a/doc/lispref/internals.texi b/doc/lispref/internals.texi index bfc9d491c5e..3a5bd4aea7e 100644 --- a/doc/lispref/internals.texi +++ b/doc/lispref/internals.texi @@ -580,15 +580,14 @@ Emacs session. @section C Dialect @cindex C programming language -The C part of Emacs is portable to C89: C99-specific features such as -@samp{} and @samp{inline} are not used without a check, +The C part of Emacs is portable to C99 or later: C11-specific features such +as @samp{} and @samp{_Noreturn} are not used without a check, typically at configuration time, and the Emacs build procedure -provides a substitute implementation if necessary. Some C99 features, -such as declarations after statements, are too difficult to provide -substitutes for, so they are avoided entirely. +provides a substitute implementation if necessary. Some C11 features, +such as anonymous structures and unions, are too difficult to emulate, +so they are avoided entirely. -At some point in the not-too-distant future the base C dialect will -change from C89 to C99, and eventually it will no doubt change to C11. +At some point in the future the base C dialect will no doubt change to C11. @node Writing Emacs Primitives @section Writing Emacs Primitives diff --git a/etc/ChangeLog b/etc/ChangeLog index 80f3bf54a11..5a359e02863 100644 --- a/etc/ChangeLog +++ b/etc/ChangeLog @@ -1,3 +1,7 @@ +2014-05-17 Paul Eggert + + * NEWS: Assume C99 or later (Bug#17487). + 2014-05-16 Paul Eggert Don't require pkg-config when building from repository. diff --git a/etc/NEWS b/etc/NEWS index cfee11e5917..f14fab3faea 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -25,6 +25,8 @@ otherwise leave it unmarked. * Installation Changes in Emacs 24.5 +++ +** Building Emacs now requires C99 or later. + ** Building Emacs now requires GNU make. ** By default, Emacs no longer works on IRIX. We expect that Emacs diff --git a/lib/gnulib.mk b/lib/gnulib.mk index e219292aa34..231b38dbf03 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 --dir=. --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=sigprocmask --avoid=threadlib --makefile-name=gnulib.mk --conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca-opt 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 fstatat fsync getloadavg getopt-gnu gettime gettimeofday intprops largefile lstat manywarnings memrchr mkostemp mktime pipe2 pselect pthread_sigmask putenv qacl readlink readlinkat sig2str socklen stat-time stdalign stdarg stdbool stdio strftime strtoimax strtoumax symlink sys_stat sys_time time timer-time timespec-add timespec-sub unsetenv update-copyright utimens warnings +# Reproduce by: gnulib-tool --import --dir=. --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=sigprocmask --avoid=stdarg --avoid=stdbool --avoid=threadlib --makefile-name=gnulib.mk --conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca-opt 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 fstatat fsync getloadavg getopt-gnu gettime gettimeofday intprops largefile lstat manywarnings memrchr mkostemp mktime pipe2 pselect pthread_sigmask putenv qacl readlink readlinkat sig2str socklen stat-time stdalign stdio strftime strtoimax strtoumax symlink sys_stat sys_time time timer-time timespec-add timespec-sub unsetenv update-copyright utimens warnings MOSTLYCLEANFILES += core *.stackdump @@ -900,57 +900,6 @@ EXTRA_DIST += stdalign.in.h ## end gnulib module stdalign -## begin gnulib module stdarg - -BUILT_SOURCES += $(STDARG_H) - -# We need the following in order to create when the system -# doesn't have one that works with the given compiler. -if GL_GENERATE_STDARG_H -stdarg.h: stdarg.in.h $(top_builddir)/config.status - $(AM_V_GEN)rm -f $@-t $@ && \ - { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ - sed -e 's|@''GUARD_PREFIX''@|GL|g' \ - -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ - -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ - -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ - -e 's|@''NEXT_STDARG_H''@|$(NEXT_STDARG_H)|g' \ - < $(srcdir)/stdarg.in.h; \ - } > $@-t && \ - mv $@-t $@ -else -stdarg.h: $(top_builddir)/config.status - rm -f $@ -endif -MOSTLYCLEANFILES += stdarg.h stdarg.h-t - -EXTRA_DIST += stdarg.in.h - -## end gnulib module stdarg - -## begin gnulib module stdbool - -BUILT_SOURCES += $(STDBOOL_H) - -# We need the following in order to create when the system -# doesn't have one that works. -if GL_GENERATE_STDBOOL_H -stdbool.h: stdbool.in.h $(top_builddir)/config.status - $(AM_V_GEN)rm -f $@-t $@ && \ - { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ - sed -e 's/@''HAVE__BOOL''@/$(HAVE__BOOL)/g' < $(srcdir)/stdbool.in.h; \ - } > $@-t && \ - mv $@-t $@ -else -stdbool.h: $(top_builddir)/config.status - rm -f $@ -endif -MOSTLYCLEANFILES += stdbool.h stdbool.h-t - -EXTRA_DIST += stdbool.in.h - -## end gnulib module stdbool - ## begin gnulib module stddef BUILT_SOURCES += $(STDDEF_H) diff --git a/lib/stdarg.in.h b/lib/stdarg.in.h deleted file mode 100644 index 5b37dd3601a..00000000000 --- a/lib/stdarg.in.h +++ /dev/null @@ -1,35 +0,0 @@ -/* Substitute for and wrapper around . - Copyright (C) 2008-2014 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, 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 _@GUARD_PREFIX@_STDARG_H - -#if __GNUC__ >= 3 -@PRAGMA_SYSTEM_HEADER@ -#endif -@PRAGMA_COLUMNS@ - -/* The include_next requires a split double-inclusion guard. */ -#@INCLUDE_NEXT@ @NEXT_STDARG_H@ - -#ifndef _@GUARD_PREFIX@_STDARG_H -#define _@GUARD_PREFIX@_STDARG_H - -#ifndef va_copy -# define va_copy(a,b) ((a) = (b)) -#endif - -#endif /* _@GUARD_PREFIX@_STDARG_H */ -#endif /* _@GUARD_PREFIX@_STDARG_H */ diff --git a/lib/stdbool.in.h b/lib/stdbool.in.h deleted file mode 100644 index 651e8dffdb3..00000000000 --- a/lib/stdbool.in.h +++ /dev/null @@ -1,132 +0,0 @@ -/* Copyright (C) 2001-2003, 2006-2014 Free Software Foundation, Inc. - Written by Bruno Haible , 2001. - - 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 _GL_STDBOOL_H -#define _GL_STDBOOL_H - -/* ISO C 99 for platforms that lack it. */ - -/* Usage suggestions: - - Programs that use should be aware of some limitations - and standards compliance issues. - - Standards compliance: - - - must be #included before 'bool', 'false', 'true' - can be used. - - - You cannot assume that sizeof (bool) == 1. - - - Programs should not undefine the macros bool, true, and false, - as C99 lists that as an "obsolescent feature". - - Limitations of this substitute, when used in a C89 environment: - - - must be #included before the '_Bool' type can be used. - - - You cannot assume that _Bool is a typedef; it might be a macro. - - - Bit-fields of type 'bool' are not supported. Portable code - should use 'unsigned int foo : 1;' rather than 'bool foo : 1;'. - - - In C99, casts and automatic conversions to '_Bool' or 'bool' are - performed in such a way that every nonzero value gets converted - to 'true', and zero gets converted to 'false'. This doesn't work - with this substitute. With this substitute, only the values 0 and 1 - give the expected result when converted to _Bool' or 'bool'. - - - C99 allows the use of (_Bool)0.0 in constant expressions, but - this substitute cannot always provide this property. - - Also, it is suggested that programs use 'bool' rather than '_Bool'; - this isn't required, but 'bool' is more common. */ - - -/* 7.16. Boolean type and values */ - -/* BeOS already #defines false 0, true 1. We use the same - definitions below, but temporarily we have to #undef them. */ -#if defined __BEOS__ && !defined __HAIKU__ -# include /* defines bool but not _Bool */ -# undef false -# undef true -#endif - -#ifdef __cplusplus -# define _Bool bool -# define bool bool -#else -# if defined __BEOS__ && !defined __HAIKU__ - /* A compiler known to have 'bool'. */ - /* If the compiler already has both 'bool' and '_Bool', we can assume they - are the same types. */ -# if !@HAVE__BOOL@ -typedef bool _Bool; -# endif -# else -# if !defined __GNUC__ - /* If @HAVE__BOOL@: - Some HP-UX cc and AIX IBM C compiler versions have compiler bugs when - the built-in _Bool type is used. See - http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html - http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html - http://lists.gnu.org/archive/html/bug-coreutils/2005-10/msg00086.html - Similar bugs are likely with other compilers as well; this file - wouldn't be used if was working. - So we override the _Bool type. - If !@HAVE__BOOL@: - Need to define _Bool ourselves. As 'signed char' or as an enum type? - Use of a typedef, with SunPRO C, leads to a stupid - "warning: _Bool is a keyword in ISO C99". - Use of an enum type, with IRIX cc, leads to a stupid - "warning(1185): enumerated type mixed with another type". - Even the existence of an enum type, without a typedef, - "Invalid enumerator. (badenum)" with HP-UX cc on Tru64. - The only benefit of the enum, debuggability, is not important - with these compilers. So use 'signed char' and no enum. */ -# define _Bool signed char -# else - /* With this compiler, trust the _Bool type if the compiler has it. */ -# if !@HAVE__BOOL@ - /* For the sake of symbolic names in gdb, define true and false as - enum constants, not only as macros. - It is tempting to write - typedef enum { false = 0, true = 1 } _Bool; - so that gdb prints values of type 'bool' symbolically. But then - values of type '_Bool' might promote to 'int' or 'unsigned int' - (see ISO C 99 6.7.2.2.(4)); however, '_Bool' must promote to 'int' - (see ISO C 99 6.3.1.1.(2)). So add a negative value to the - enum; this ensures that '_Bool' promotes to 'int'. */ -typedef enum { _Bool_must_promote_to_int = -1, false = 0, true = 1 } _Bool; -# endif -# endif -# endif -# define bool _Bool -#endif - -/* The other macros must be usable in preprocessor directives. */ -#ifdef __cplusplus -# define false false -# define true true -#else -# define false 0 -# define true 1 -#endif - -#define __bool_true_false_are_defined 1 - -#endif /* _GL_STDBOOL_H */ diff --git a/m4/gnulib-comp.m4 b/m4/gnulib-comp.m4 index 0ba2d7950af..98acc069c92 100644 --- a/m4/gnulib-comp.m4 +++ b/m4/gnulib-comp.m4 @@ -119,13 +119,6 @@ AC_DEFUN([gl_EARLY], # Code from module stat: # Code from module stat-time: # Code from module stdalign: - # Code from module stdarg: - dnl Some compilers (e.g., AIX 5.3 cc) need to be in c99 mode - dnl for the builtin va_copy to work. With Autoconf 2.60 or later, - dnl gl_PROG_CC_C99 arranges for this. With older Autoconf gl_PROG_CC_C99 - dnl shouldn't hurt, though installers are on their own to set c99 mode. - gl_PROG_CC_C99 - # Code from module stdbool: # Code from module stddef: # Code from module stdint: # Code from module stdio: @@ -342,8 +335,6 @@ AC_DEFUN([gl_INIT], gl_STAT_TIME gl_STAT_BIRTHTIME gl_STDALIGN_H - gl_STDARG_H - AM_STDBOOL_H gl_STDDEF_H gl_STDINT_H gl_STDIO_H @@ -891,8 +882,6 @@ AC_DEFUN([gl_FILE_LIST], [ lib/stat-time.h lib/stat.c lib/stdalign.in.h - lib/stdarg.in.h - lib/stdbool.in.h lib/stddef.in.h lib/stdint.in.h lib/stdio.in.h @@ -998,8 +987,6 @@ AC_DEFUN([gl_FILE_LIST], [ m4/stat-time.m4 m4/stat.m4 m4/stdalign.m4 - m4/stdarg.m4 - m4/stdbool.m4 m4/stddef_h.m4 m4/stdint.m4 m4/stdio_h.m4 diff --git a/m4/stdarg.m4 b/m4/stdarg.m4 deleted file mode 100644 index 732aa313b6a..00000000000 --- a/m4/stdarg.m4 +++ /dev/null @@ -1,78 +0,0 @@ -# stdarg.m4 serial 6 -dnl Copyright (C) 2006, 2008-2014 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 From Bruno Haible. -dnl Provide a working va_copy in combination with . - -AC_DEFUN([gl_STDARG_H], -[ - STDARG_H='' - NEXT_STDARG_H='' - AC_MSG_CHECKING([for va_copy]) - AC_CACHE_VAL([gl_cv_func_va_copy], [ - AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM( - [[#include ]], - [[ -#ifndef va_copy -void (*func) (va_list, va_list) = va_copy; -#endif - ]])], - [gl_cv_func_va_copy=yes], - [gl_cv_func_va_copy=no])]) - AC_MSG_RESULT([$gl_cv_func_va_copy]) - if test $gl_cv_func_va_copy = no; then - dnl Provide a substitute. - dnl Usually a simple definition in is enough. Not so on AIX 5 - dnl with some versions of the /usr/vac/bin/cc compiler. It has an - dnl which does '#undef va_copy', leading to a missing va_copy symbol. For - dnl this platform, we use an substitute. But we cannot use this - dnl approach on other platforms, because often defines only - dnl preprocessor macros and gl_ABSOLUTE_HEADER, gl_CHECK_NEXT_HEADERS do - dnl not work in this situation. - AC_EGREP_CPP([vaccine], - [#if defined _AIX && !defined __GNUC__ - AIX vaccine - #endif - ], [gl_aixcc=yes], [gl_aixcc=no]) - if test $gl_aixcc = yes; then - dnl Provide a substitute file. - STDARG_H=stdarg.h - gl_NEXT_HEADERS([stdarg.h]) - dnl Fallback for the case when contains only macro definitions. - if test "$gl_cv_next_stdarg_h" = '""'; then - gl_cv_next_stdarg_h='"///usr/include/stdarg.h"' - NEXT_STDARG_H="$gl_cv_next_stdarg_h" - fi - else - dnl Provide a substitute in , either __va_copy or as a simple - dnl assignment. - gl_CACHE_VAL_SILENT([gl_cv_func___va_copy], [ - AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM( - [[#include ]], - [[ -#ifndef __va_copy -error, bail out -#endif - ]])], - [gl_cv_func___va_copy=yes], - [gl_cv_func___va_copy=no])]) - if test $gl_cv_func___va_copy = yes; then - AC_DEFINE([va_copy], [__va_copy], - [Define as a macro for copying va_list variables.]) - else - AH_VERBATIM([gl_VA_COPY], [/* A replacement for va_copy, if needed. */ -#define gl_va_copy(a,b) ((a) = (b))]) - AC_DEFINE([va_copy], [gl_va_copy], - [Define as a macro for copying va_list variables.]) - fi - fi - fi - AC_SUBST([STDARG_H]) - AM_CONDITIONAL([GL_GENERATE_STDARG_H], [test -n "$STDARG_H"]) - AC_SUBST([NEXT_STDARG_H]) -]) diff --git a/m4/stdbool.m4 b/m4/stdbool.m4 deleted file mode 100644 index 006ed52de5d..00000000000 --- a/m4/stdbool.m4 +++ /dev/null @@ -1,100 +0,0 @@ -# Check for stdbool.h that conforms to C99. - -dnl Copyright (C) 2002-2006, 2009-2014 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. - -#serial 5 - -# Prepare for substituting if it is not supported. - -AC_DEFUN([AM_STDBOOL_H], -[ - AC_REQUIRE([AC_CHECK_HEADER_STDBOOL]) - - # Define two additional variables used in the Makefile substitution. - - if test "$ac_cv_header_stdbool_h" = yes; then - STDBOOL_H='' - else - STDBOOL_H='stdbool.h' - fi - AC_SUBST([STDBOOL_H]) - AM_CONDITIONAL([GL_GENERATE_STDBOOL_H], [test -n "$STDBOOL_H"]) - - if test "$ac_cv_type__Bool" = yes; then - HAVE__BOOL=1 - else - HAVE__BOOL=0 - fi - AC_SUBST([HAVE__BOOL]) -]) - -# AM_STDBOOL_H will be renamed to gl_STDBOOL_H in the future. -AC_DEFUN([gl_STDBOOL_H], [AM_STDBOOL_H]) - -# This version of the macro is needed in autoconf <= 2.68. - -AC_DEFUN([AC_CHECK_HEADER_STDBOOL], - [AC_CACHE_CHECK([for stdbool.h that conforms to C99], - [ac_cv_header_stdbool_h], - [AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM( - [[ - #include - #ifndef bool - "error: bool is not defined" - #endif - #ifndef false - "error: false is not defined" - #endif - #if false - "error: false is not 0" - #endif - #ifndef true - "error: true is not defined" - #endif - #if true != 1 - "error: true is not 1" - #endif - #ifndef __bool_true_false_are_defined - "error: __bool_true_false_are_defined is not defined" - #endif - - struct s { _Bool s: 1; _Bool t; } s; - - char a[true == 1 ? 1 : -1]; - char b[false == 0 ? 1 : -1]; - char c[__bool_true_false_are_defined == 1 ? 1 : -1]; - char d[(bool) 0.5 == true ? 1 : -1]; - /* See body of main program for 'e'. */ - char f[(_Bool) 0.0 == false ? 1 : -1]; - char g[true]; - char h[sizeof (_Bool)]; - char i[sizeof s.t]; - enum { j = false, k = true, l = false * true, m = true * 256 }; - /* The following fails for - HP aC++/ANSI C B3910B A.05.55 [Dec 04 2003]. */ - _Bool n[m]; - char o[sizeof n == m * sizeof n[0] ? 1 : -1]; - char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1]; - /* Catch a bug in an HP-UX C compiler. See - http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html - http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html - */ - _Bool q = true; - _Bool *pq = &q; - ]], - [[ - bool e = &s; - *pq |= q; - *pq |= ! q; - /* Refer to every declared value, to avoid compiler optimizations. */ - return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l - + !m + !n + !o + !p + !q + !pq); - ]])], - [ac_cv_header_stdbool_h=yes], - [ac_cv_header_stdbool_h=no])]) - AC_CHECK_TYPES([_Bool]) -]) diff --git a/nt/ChangeLog b/nt/ChangeLog index fc1b0a09102..a3cb5e62dac 100644 --- a/nt/ChangeLog +++ b/nt/ChangeLog @@ -1,3 +1,8 @@ +2014-05-17 Paul Eggert + + Assume C99 or later (Bug#17487). + * gnulib.mk: Remove stdarg and stdbool modules. + 2014-05-16 Paul Eggert Don't require pkg-config when building from repository. diff --git a/nt/gnulib.mk b/nt/gnulib.mk index 7877c154b96..7c2cceb959f 100644 --- a/nt/gnulib.mk +++ b/nt/gnulib.mk @@ -671,57 +671,6 @@ EXTRA_DIST += stdalign.in.h ## end gnulib module stdalign -## begin gnulib module stdarg - -BUILT_SOURCES += $(STDARG_H) - -# We need the following in order to create when the system -# doesn't have one that works with the given compiler. -if GL_GENERATE_STDARG_H -stdarg.h: stdarg.in.h $(top_builddir)/config.status - $(AM_V_GEN)rm -f $@-t $@ && \ - { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ - sed -e 's|@''GUARD_PREFIX''@|GL|g' \ - -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ - -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ - -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ - -e 's|@''NEXT_STDARG_H''@|$(NEXT_STDARG_H)|g' \ - < $(srcdir)/stdarg.in.h; \ - } > $@-t && \ - mv $@-t $@ -else -stdarg.h: $(top_builddir)/config.status - rm -f $@ -endif -MOSTLYCLEANFILES += stdarg.h stdarg.h-t - -EXTRA_DIST += stdarg.in.h - -## end gnulib module stdarg - -## begin gnulib module stdbool - -BUILT_SOURCES += $(STDBOOL_H) - -# We need the following in order to create when the system -# doesn't have one that works. -if GL_GENERATE_STDBOOL_H -stdbool.h: stdbool.in.h $(top_builddir)/config.status - $(AM_V_GEN)rm -f $@-t $@ && \ - { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ - sed -e 's/@''HAVE__BOOL''@/$(HAVE__BOOL)/g' < $(srcdir)/stdbool.in.h; \ - } > $@-t && \ - mv $@-t $@ -else -stdbool.h: $(top_builddir)/config.status - rm -f $@ -endif -MOSTLYCLEANFILES += stdbool.h stdbool.h-t - -EXTRA_DIST += stdbool.in.h - -## end gnulib module stdbool - ## begin gnulib module stddef BUILT_SOURCES += $(STDDEF_H) diff --git a/src/ChangeLog b/src/ChangeLog index a89d14bbe23..31fe13e074c 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,13 @@ +2014-05-17 Paul Eggert + + Assume C99 or later (Bug#17487). + * bytecode.c (B__dummy__): Remove. + * conf_post.h (bool_bf) [!NS_IMPL_GNUSTEP]: Use bool. + (FLEXIBLE_ARRAY_MEMBER): Now always empty. + * dbusbind.c (XD_DEBUG_MESSAGE) [!DBUS_DEBUG]: + * regex.c (DEBUG_PRINT): Assume varargs macros. + * lisp.h (DEFUN_FUNCTION_INIT): Remove. All uses now assume C99. + 2014-05-17 Fabrice Popineau * buffer.c (init_buffer) [USE_MMAP_FOR_BUFFERS]: Always map new diff --git a/src/bytecode.c b/src/bytecode.c index f1bdfd9d9c5..f489c74a144 100644 --- a/src/bytecode.c +++ b/src/bytecode.c @@ -292,8 +292,6 @@ enum byte_code_op Bscan_buffer = 0153, /* No longer generated as of v18. */ Bset_mark = 0163, /* this loser is no longer generated as of v18 */ #endif - - B__dummy__ = 0 /* Pacify C89. */ }; /* Whether to maintain a `top' and `bottom' field in the stack frame. */ diff --git a/src/conf_post.h b/src/conf_post.h index 95b028a66ee..123f4803da5 100644 --- a/src/conf_post.h +++ b/src/conf_post.h @@ -34,9 +34,10 @@ along with GNU Emacs. If not, see . */ #include -/* The pre-C99 emulation doesn't work for bool bitfields. - Nor does compiling Objective-C with standard GCC. */ -#if __STDC_VERSION__ < 199901 || NS_IMPL_GNUSTEP +/* The type of bool bitfields. Needed to compile Objective-C with + standard GCC. It was also needed to port to pre-C99 compilers, + although we don't care about that any more. */ +#if NS_IMPL_GNUSTEP typedef unsigned int bool_bf; #else typedef bool bool_bf; @@ -293,14 +294,11 @@ extern void _DebPrint (const char *fmt, ...); /* To use the struct hack with N elements, declare the struct like this: struct s { ...; t name[FLEXIBLE_ARRAY_MEMBER]; }; - and allocate (offsetof (struct s, name) + N * sizeof (t)) bytes. */ -#if 199901 <= __STDC_VERSION__ -# define FLEXIBLE_ARRAY_MEMBER -#elif __GNUC__ && !defined __STRICT_ANSI__ -# define FLEXIBLE_ARRAY_MEMBER 0 -#else -# define FLEXIBLE_ARRAY_MEMBER 1 -#endif + and allocate (offsetof (struct s, name) + N * sizeof (t)) bytes. + + This macro used to expand to something different on pre-C99 compilers. + FIXME: Remove it, and remove all uses. */ +#define FLEXIBLE_ARRAY_MEMBER /* Use this to suppress gcc's `...may be used before initialized' warnings. */ #ifdef lint diff --git a/src/dbusbind.c b/src/dbusbind.c index 8ebc56c72c4..8997e01b068 100644 --- a/src/dbusbind.c +++ b/src/dbusbind.c @@ -142,10 +142,7 @@ static bool xd_in_read_queued_messages = 0; } while (0) #else /* !DBUS_DEBUG */ -# if __STDC_VERSION__ < 199901 -# define XD_DEBUG_MESSAGE (void) /* Pre-C99 compilers cannot debug. */ -# else -# define XD_DEBUG_MESSAGE(...) \ +# define XD_DEBUG_MESSAGE(...) \ do { \ if (!NILP (Vdbus_debug)) \ { \ @@ -154,7 +151,6 @@ static bool xd_in_read_queued_messages = 0; message ("%s: %s", __func__, s); \ } \ } while (0) -# endif # define XD_DEBUG_VALID_LISP_OBJECT_P(object) #endif diff --git a/src/emacs.c b/src/emacs.c index deebb2280c7..16d91de84a4 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -214,7 +214,7 @@ int initial_argc; static void sort_args (int argc, char **argv); static void syms_of_emacs (void); -/* C89 needs each string be at most 509 characters, so the usage +/* C99 needs each string to be at most 4095 characters, and the usage strings below are split to not overflow this limit. */ static char const *const usage_message[] = { "\ diff --git a/src/lisp.h b/src/lisp.h index f47fb0c2a24..67b26ef91c7 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -2654,16 +2654,11 @@ CHECK_NUMBER_CDR (Lisp_Object x) minargs, maxargs, lname, intspec, 0}; \ Lisp_Object fnname #else /* not _MSC_VER */ -# if __STDC_VERSION__ < 199901 -# define DEFUN_FUNCTION_INIT(fnname, maxargs) (Lisp_Object (*) (void)) fnname -# else -# define DEFUN_FUNCTION_INIT(fnname, maxargs) .a ## maxargs = fnname -# endif #define DEFUN(lname, fnname, sname, minargs, maxargs, intspec, doc) \ Lisp_Object fnname DEFUN_ARGS_ ## maxargs ; \ static struct Lisp_Subr alignas (GCALIGNMENT) sname = \ { { PVEC_SUBR << PSEUDOVECTOR_AREA_BITS }, \ - { DEFUN_FUNCTION_INIT (fnname, maxargs) }, \ + { .a ## maxargs = fnname }, \ minargs, maxargs, lname, intspec, 0}; \ Lisp_Object fnname #endif diff --git a/src/regex.c b/src/regex.c index 622db708b98..ac71b797fbd 100644 --- a/src/regex.c +++ b/src/regex.c @@ -1190,12 +1190,7 @@ print_double_string (re_char *where, re_char *string1, ssize_t size1, # define assert(e) # define DEBUG_STATEMENT(e) -# if __STDC_VERSION__ < 199901L -# define DEBUG_COMPILES_ARGUMENTS -# define DEBUG_PRINT /* 'DEBUG_PRINT (x, y)' discards X and Y. */ (void) -# else -# define DEBUG_PRINT(...) -# endif +# define DEBUG_PRINT(...) # define DEBUG_PRINT_COMPILED_PATTERN(p, s, e) # define DEBUG_PRINT_DOUBLE_STRING(w, s1, sz1, s2, sz2) -- 2.11.4.GIT