From: Paul Eggert Date: Sun, 12 Aug 2018 18:10:11 +0000 (-0700) Subject: Make mini-gmp safe for --enable-gcc-warnings X-Git-Tag: emacs-27.0.90~4582 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=d966f8d29110f74d84187e013ca8c7e7411951aa;p=emacs.git Make mini-gmp safe for --enable-gcc-warnings * configure.ac (GMP_OBJ): When building mini-gmp, compile mini-gmp-emacs.c, not mini-gmp.c. * lib-src/etags.c (NDEBUG): Don't attempt to redefine, in case the builder compiles with -DNDEBUG. * src/conf_post.h (NDEBUG) [!ENABLE_CHECKING && !NDEBUG]: Define. This avoids bloat in mini-gmp-emacs.o. * src/mini-gmp-emacs.c: New file, which pacifies --enable-gcc-warnings. --- diff --git a/configure.ac b/configure.ac index 58bdefab6d6..c40b3bd2903 100644 --- a/configure.ac +++ b/configure.ac @@ -4308,7 +4308,7 @@ AC_ARG_WITH([mini-gmp], GNU Multiple Precision (GMP) library; this is the default on systems with recent-enough GMP.])]) GMP_LIB= -GMP_OBJ=mini-gmp.o +GMP_OBJ=mini-gmp-emacs.o HAVE_GMP=no case $with_mini_gmp in yes) ;; diff --git a/lib-src/etags.c b/lib-src/etags.c index ee506703436..102d867b387 100644 --- a/lib-src/etags.c +++ b/lib-src/etags.c @@ -85,7 +85,9 @@ char pot_etags_version[] = "@(#) pot revision number is 17.38.1.4"; # define DEBUG true #else # define DEBUG false -# define NDEBUG /* disable assert */ +# ifndef NDEBUG +# define NDEBUG /* disable assert */ +# endif #endif #include diff --git a/src/conf_post.h b/src/conf_post.h index 0927fca7ca3..f9838bc662a 100644 --- a/src/conf_post.h +++ b/src/conf_post.h @@ -20,9 +20,16 @@ along with GNU Emacs. If not, see . */ /* Put the code here rather than in configure.ac using AH_BOTTOM. This way, the code does not get processed by autoheader. For - example, undefs here are not commented out. + example, undefs here are not commented out. */ - To help make dependencies clearer elsewhere, this file typically +/* Disable 'assert' unless enabling checking. Do this early, in + case some misguided implementation depends on NDEBUG in some + include file other than assert.h. */ +#if !defined ENABLE_CHECKING && !defined NDEBUG +# define NDEBUG +#endif + +/* To help make dependencies clearer elsewhere, this file typically does not #include other files. The exceptions are first stdbool.h because it is unlikely to interfere with configuration and bool is such a core part of the C language, and second ms-w32.h (DOS_NT diff --git a/src/mini-gmp-emacs.c b/src/mini-gmp-emacs.c new file mode 100644 index 00000000000..7a1b7ab5de5 --- /dev/null +++ b/src/mini-gmp-emacs.c @@ -0,0 +1,32 @@ +/* Tailor mini-gmp.c for GNU Emacs + +Copyright 2018 Free Software Foundation, Inc. + +This file is part of GNU Emacs. + +GNU Emacs 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. + +GNU Emacs 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 GNU Emacs. If not, see . */ + +#include + +#include + +/* Pacify GCC -Wsuggest-attribute=malloc. */ +static void *gmp_default_alloc (size_t) ATTRIBUTE_MALLOC; + +/* Pacify GCC -Wunused-variable for variables used only in 'assert' calls. */ +#if defined NDEBUG && GNUC_PREREQ (4, 6, 0) +# pragma GCC diagnostic ignored "-Wunused-variable" +#endif + +#include "mini-gmp.c"