]> git.eshelyaron.com Git - emacs.git/commitdiff
Limit <config.h>’s includes
authorPaul Eggert <eggert@cs.ucla.edu>
Fri, 30 Sep 2016 19:14:04 +0000 (12:14 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Fri, 30 Sep 2016 19:38:52 +0000 (12:38 -0700)
This follows up on recent problems with the fact that config.h
includes stdlib.h etc.; some files need to include stdlib.h later.
config.h generally should limit itself to includes that are
universally safe; outside of MS-Windows, only stdbool.h makes
the cut among the files currently included.  So, move the
other includes to just the files that need them (Bug#24506).
* configure.ac (config_opsysfile): Remove, as this generic hook
is no longer needed.
* lib-src/etags.c, src/unexmacosx.c, src/w32.c, src/w32notify.c:
* src/w32proc.c (_GNU_SOURCE):
Remove, as it’s OK for config.h to do this now.
* src/conf_post.h: Include <ms-w32.h>, instead of the generic
config_opsysfile, for simplicity as this old way of configuring is
now done only for the MS-Windows port.  Do not include <ms-w32.h>
if DEFER_MS_W32_H, for the benefit of the few files that want its
effects later.  Do not include <alloca.h>, <string.h>, or
<stdlib.h>.  Other files modified to include these headers as
needed, or to not include headers that are no longer needed.
* src/lisp.h: Include <alloca.h> and <string.h> here, since
some of the inline functions need them.
* src/regex.c: Include <alloca.h> if not emacs.  (If emacs,
we can rely on SAFE_ALLOCA.)  There is no longer any need to
worry about HAVE_ALLOCA_H.
* src/unexmacosx.c: Rely on config.h not including stdlib.h.
* src/w32.c, src/w32notify.c, src/w32proc.c (DEFER_MS_W32_H):
Define before including <config.h> first, and include <ms-w32.h>
after the troublesome headers.

49 files changed:
configure.ac
lib-src/emacsclient.c
lib-src/etags.c
lib-src/hexl.c
lib-src/make-docfile.c
lib-src/movemail.c
lib-src/pop.c
lib-src/profile.c
lib-src/update-game-score.c
lib/openat-die.c
lwlib/lwlib-Xm.c
lwlib/lwlib.c
src/alloc.c
src/buffer.c
src/callproc.c
src/charset.c
src/conf_post.h
src/dbusbind.c
src/dispnew.c
src/doprnt.c
src/editfns.c
src/emacs-module.c
src/emacs.c
src/eval.c
src/filelock.c
src/fns.c
src/font.c
src/fontset.c
src/frame.c
src/keymap.c
src/lisp.h
src/lread.c
src/process.c
src/regex.c
src/sysdep.c
src/systty.h
src/term.c
src/unexcw.c
src/unexmacosx.c
src/w32.c
src/w32notify.c
src/w32proc.c
src/widget.c
src/xdisp.c
src/xfaces.c
src/xfns.c
src/xfont.c
src/xgselect.c
src/xterm.c

index 8479b0708f85ea8a20207af33db2cb22dbd4b458..da577a3773fe8170a35fd98ff0185168a5232f7c 100644 (file)
@@ -4882,14 +4882,6 @@ AC_DEFINE_UNQUOTED(EMACS_CONFIGURATION,  "${canonical}",
                   [Define to the canonical Emacs configuration name.])
 AC_DEFINE_UNQUOTED(EMACS_CONFIG_OPTIONS, "${emacs_config_options}",
                   [Define to the options passed to configure.])
-AH_TEMPLATE(config_opsysfile, [Some platforms that do not use configure
-  define this to include extra configuration information.])
-
-case $opsys in
-  mingw32)
-    AC_DEFINE(config_opsysfile, <ms-w32.h>, [])
-    ;;
-esac
 
 XMENU_OBJ=
 XOBJ=
index 458519d25fd53585e4b3a70a16b38b6db60da71a..59b6ac97a058e24fc90e3a301d9442335ebc42b1 100644 (file)
@@ -74,6 +74,7 @@ char *w32_getenv (const char *);
 #include <stdarg.h>
 #include <ctype.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <getopt.h>
 #include <unistd.h>
 
index a81b46d2e079a67155c922bc4e91289b939696ed..0479f8e4ebdd4c0b40ac8c0c0bd4a4470efafdcc 100644 (file)
@@ -90,10 +90,6 @@ char pot_etags_version[] = "@(#) pot revision number is 17.38.1.4";
 
 #include <config.h>
 
-#ifndef _GNU_SOURCE
-# define _GNU_SOURCE 1         /* enables some compiler checks on GNU */
-#endif
-
 /* WIN32_NATIVE is for XEmacs.
    MSDOS, WINDOWSNT, DOS_NT are for Emacs. */
 #ifdef WIN32_NATIVE
index 9a5ca7e1543d2560f8312d0bd0d9677dfd18efed..5bd8579d25835ea9918aad5457fecee1e6f127d8 100644 (file)
@@ -22,6 +22,8 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 #include <config.h>
 
 #include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
 #include <ctype.h>
 
 #include <binary-io.h>
index f463f13699bfb1960e3f1439df927582a6ff3837..9ba9b6e9af868822c95a0d521ab14af900b082b9 100644 (file)
@@ -37,11 +37,11 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 #include <config.h>
 
 #include <stdarg.h>
-#include <stdbool.h>
 #include <stddef.h>
 #include <stdint.h>
 #include <stdio.h>
-#include <stdlib.h>   /* config.h unconditionally includes this anyway */
+#include <stdlib.h>
+#include <string.h>
 
 #ifdef WINDOWSNT
 /* Defined to be sys_fopen in ms-w32.h, but only #ifdef emacs, so this
index 45779dae5c2cccf04a5a45f10f0c4388decf1a5c..8111c8721bbd0b03e4f827dc1cfdad1bb812469f 100644 (file)
@@ -59,8 +59,8 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <sys/file.h>
-#include <stdbool.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <errno.h>
 #include <time.h>
 
index 99ec1cf824aace256c29d70e5eca7c866acacbfe..99424c584c2a0a73b4af38aa95d4e6b5546045e5 100644 (file)
@@ -63,10 +63,12 @@ void sys_freeaddrinfo (struct addrinfo * ai);
 extern struct servent *hes_getservbyname (/* char *, char * */);
 #endif
 
+#include <alloca.h>
 #include <pwd.h>
 #include <netdb.h>
 #include <errno.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
 
index 0e6037760496bbe0cf7691748e756665fd365a85..edd36cafd3780279c22d6df30f9f0b85c614734f 100644 (file)
@@ -35,6 +35,7 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include <inttypes.h>
 #include <stdio.h>
+#include <stdlib.h>
 
 #include <intprops.h>
 #include <systime.h>
index 7675e9bdd4c5963df96e98d903f6d10f386c2b65..7e1b332bdcd24853646712f6cc75226fbb8bd420 100644 (file)
@@ -37,7 +37,6 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 #include <errno.h>
 #include <inttypes.h>
 #include <limits.h>
-#include <stdbool.h>
 #include <string.h>
 #include <stdlib.h>
 #include <stdio.h>
index f09123ea785d4254212a3c7d5c6f96724d6f64d8..8dab8b97429b91048ec4bb62f073034c6e5ff10c 100644 (file)
@@ -2,5 +2,6 @@
    This should never happen with Emacs.  */
 #include <config.h>
 #include "openat.h"
+#include <stdlib.h>
 void openat_save_fail (int errnum) { abort (); }
 void openat_restore_fail (int errnum) { abort (); }
index c92edd2f9e3c69a824d6fdc837a6517d84eb294d..45faff8673a70764f8554485ff6116abb2ec3d0f 100644 (file)
@@ -22,6 +22,7 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include <unistd.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <setjmp.h>
 
 #include <X11/StringDefs.h>
index d1c5195dbf989144bf79f9f8d54b912a3dc877b3..e66147f1fe37cb72c8b8514d2152a8c49be6a8e1 100644 (file)
@@ -26,6 +26,7 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include <sys/types.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include "lwlib-int.h"
 #include "lwlib-utils.h"
 #include <X11/StringDefs.h>
index 8dae6bffbd9abc031e4f05e9e8a2edb2627f6d69..72987dd3190f8dfe1cda55aa517914c5102fc843 100644 (file)
@@ -22,6 +22,7 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include <errno.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <limits.h>            /* For CHAR_BIT.  */
 #include <signal.h>            /* For SIGABRT, SIGDANGER.  */
 
index 24c997fcdbd5a37afee27fd40d4005c8782d1208..3d205bb71ba326841dae937bb44ae53ccf5c5ef0 100644 (file)
@@ -25,6 +25,7 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 #include <sys/param.h>
 #include <errno.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <unistd.h>
 
 #include <verify.h>
index 454ed6d633cd66368537cab8f76072f48169803e..8ed28556e0d25185cfe4d74472cb3c460fa17c3d 100644 (file)
@@ -22,6 +22,7 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 #include <config.h>
 #include <errno.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <sys/types.h>
 #include <unistd.h>
 
index cdbfe119515424a22b2c4d0c698a6b0bc5151c94..ff937bc5a1395385df4358a863fbf5a779fa2012 100644 (file)
@@ -30,6 +30,7 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include <errno.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <unistd.h>
 #include <limits.h>
 #include <sys/types.h>
index 6d54524b970cf4b7075c20463c9a42aedd7a18a3..9c544e89e9420d853700b489fc0083af274a8ec0 100644 (file)
@@ -18,22 +18,23 @@ 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 <http://www.gnu.org/licenses/>.  */
 
-/* Commentary:
+/* 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.
 
-   Rather than writing this code directly in AH_BOTTOM, we include it
-   via this file.  This is so that it does not get processed by
-   autoheader.  Eg, any undefs here would otherwise be commented out.
-*/
+   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
+   only) because it historically was included here and changing that
+   would take some work.  */
 
-/* Code: */
+#include <stdbool.h>
 
-/* Include any platform specific configuration file.  */
-#ifdef config_opsysfile
-# include config_opsysfile
+#if defined DOS_NT && !defined DEFER_MS_W32_H
+# include <ms-w32.h>
 #endif
 
-#include <stdbool.h>
-
 /* GNUC_PREREQ (V, W, X) is true if this is GNU C version V.W.X or later.
    It can be used in a preprocessor expression.  */
 #ifndef __GNUC_MINOR__
@@ -55,14 +56,6 @@ typedef unsigned int bool_bf;
 typedef bool bool_bf;
 #endif
 
-#ifndef WINDOWSNT
-/* On AIX 3 this must be included before any other include file.  */
-#include <alloca.h>
-#if ! HAVE_ALLOCA
-# error "alloca not available on this machine"
-#endif
-#endif
-
 /* Simulate __has_attribute on compilers that lack it.  It is used only
    on arguments like alloc_size that are handled in this simulation.  */
 #ifndef __has_attribute
@@ -239,9 +232,6 @@ extern void _DebPrint (const char *fmt, ...);
 extern char *emacs_getenv_TZ (void);
 extern int emacs_setenv_TZ (char const *);
 
-#include <string.h>
-#include <stdlib.h>
-
 #if __GNUC__ >= 3  /* On GCC 3.0 we might get a warning.  */
 #define NO_INLINE __attribute__((noinline))
 #else
@@ -365,5 +355,3 @@ extern int emacs_setenv_TZ (char const *);
 #else
 # define UNINIT /* empty */
 #endif
-
-/* conf_post.h ends here */
index 7a94c81eeab531f19f1144ee5e31cc0b1f1f3ad9..a0146a3bf532e98340d47d8f9b187ecf47069d16 100644 (file)
@@ -20,6 +20,7 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #ifdef HAVE_DBUS
 #include <stdio.h>
+#include <stdlib.h>
 #include <dbus/dbus.h>
 
 #include "lisp.h"
index 82d0b76a95f0a0b39f6516dc9546550346fdc4d9..70d4de07aacadd45a916948b362196c0fe23a76c 100644 (file)
@@ -21,6 +21,7 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 #include <config.h>
 
 #include "sysstdio.h"
+#include <stdlib.h>
 #include <unistd.h>
 
 #include "lisp.h"
index de2b89e1225a3c7629db235f611b64f12f0207f8..733800500590de320262b1f7de28d718f59df5f0 100644 (file)
@@ -103,6 +103,7 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include <config.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <float.h>
 #include <unistd.h>
 #include <limits.h>
index c5b177e41f26720d791fd873caa8cfbab972bb6b..0bcc439e50ec34df1c847331557891dae0aaeafd 100644 (file)
@@ -49,6 +49,7 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 #include <limits.h>
 
 #include <intprops.h>
+#include <stdlib.h>
 #include <strftime.h>
 #include <verify.h>
 
index 0e755ef956be64125764dcabbc87abbbd83cdfa0..5075263edffcdfc06742aafd639c0a4ca67c92ab 100644 (file)
@@ -21,11 +21,9 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "emacs-module.h"
 
-#include <stdbool.h>
 #include <stddef.h>
 #include <stdint.h>
 #include <stdio.h>
-#include <string.h>
 
 #include "lisp.h"
 #include "dynlib.h"
index 9b2300989fac227b5bce77e7c9c0d1182a94697f..13378c4c3b04d8f590c41088a258aecae32bc61d 100644 (file)
@@ -24,6 +24,7 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 #include <errno.h>
 #include <fcntl.h>
 #include <stdio.h>
+#include <stdlib.h>
 
 #include <sys/types.h>
 #include <sys/file.h>
index 407561082d12d598c91ef8d16ed91448245390c2..2fedbf377cf8bcfe892733b2d4b701b83712134c 100644 (file)
@@ -22,6 +22,7 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 #include <config.h>
 #include <limits.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include "lisp.h"
 #include "blockinput.h"
 #include "commands.h"
index bde34e2c6c2bdeb3bb954cfc8be79e209936e502..a2e1df99f07c7fd88b0768bf0099f2b58ec95931 100644 (file)
@@ -27,6 +27,7 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 #include <sys/stat.h>
 #include <signal.h>
 #include <stdio.h>
+#include <stdlib.h>
 
 #ifdef HAVE_PWD_H
 #include <pwd.h>
index 31f0fd274187ff4710e692aaab4cd22f0f4d3851..4f12dd522490e4b93dec0e56471b677ede91948f 100644 (file)
--- a/src/fns.c
+++ b/src/fns.c
@@ -20,6 +20,7 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include <config.h>
 
+#include <stdlib.h>
 #include <unistd.h>
 #include <filevercmp.h>
 #include <intprops.h>
index f2800633b629bbf3f3c230fa15b1f2bc94074cb6..cfbc5c7e26620ee689e21e72c2aa5b3904eb3db3 100644 (file)
@@ -23,6 +23,7 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 #include <config.h>
 #include <float.h>
 #include <stdio.h>
+#include <stdlib.h>
 
 #include <c-ctype.h>
 
index 67696d0fead2daf8b4d665920e9024fd0d0a78c5..fe595d81a3e95b6be7326cb0bc003ceec3d84784 100644 (file)
@@ -26,6 +26,7 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include <config.h>
 #include <stdio.h>
+#include <stdlib.h>
 
 #include "lisp.h"
 #include "blockinput.h"
index 42a01f57724f3ff3ee56e691721bf1da6ccaad6e..45559b0be9822b191c846ea903c3b9140e0e305e 100644 (file)
@@ -20,6 +20,7 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 #include <config.h>
 
 #include <stdio.h>
+#include <stdlib.h>
 #include <errno.h>
 #include <limits.h>
 
index b27df1d0452817f103aa22f90e5ababd81d9c17f..c4a59adff5b9c5fe757cbd0331448cc95da2cab6 100644 (file)
@@ -41,6 +41,7 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include <config.h>
 #include <stdio.h>
+#include <stdlib.h>
 
 #include "lisp.h"
 #include "commands.h"
index f653d855dad892af9e1b88fc4b5a4aa802da67c6..74308985f18ecd87f512073b958afcf5a6250b31 100644 (file)
@@ -21,10 +21,12 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 #ifndef EMACS_LISP_H
 #define EMACS_LISP_H
 
+#include <alloca.h>
 #include <setjmp.h>
 #include <stdalign.h>
 #include <stdarg.h>
 #include <stddef.h>
+#include <string.h>
 #include <float.h>
 #include <inttypes.h>
 #include <limits.h>
index d3413d16ceac7128068f334c57f20ff63deb003a..10eec3b1be04aaf62d0ca681752e68f347c8396d 100644 (file)
@@ -23,6 +23,7 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include <config.h>
 #include "sysstdio.h"
+#include <stdlib.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <sys/file.h>
index 9a0ab00c505c93f1368a2df6bc81fe5e75cba9f2..8cf045ca9c2549a7dde430676b032e1b383af32d 100644 (file)
@@ -22,6 +22,7 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 #include <config.h>
 
 #include <stdio.h>
+#include <stdlib.h>
 #include <errno.h>
 #include <sys/types.h>         /* Some typedefs are used in sys/file.h.  */
 #include <sys/file.h>
index 41c1d3f61065170af5b223e9cb10995bae1f99b0..1917a8480ae4ee263251c8bc3e8eb5068f2fbf95 100644 (file)
@@ -50,6 +50,7 @@
 #include <config.h>
 
 #include <stddef.h>
+#include <stdlib.h>
 
 #ifdef emacs
 /* We need this for `regex.h', and perhaps for the Emacs include files.  */
@@ -443,25 +444,12 @@ init_syntax_once (void)
 
 #else /* not REGEX_MALLOC  */
 
-/* Emacs already defines alloca, sometimes.  */
-# ifndef alloca
-
-/* Make alloca work the best possible way.  */
-#  ifdef __GNUC__
-#   define alloca __builtin_alloca
-#  else /* not __GNUC__ */
-#   ifdef HAVE_ALLOCA_H
-#    include <alloca.h>
-#   endif /* HAVE_ALLOCA_H */
-#  endif /* not __GNUC__ */
-
-# endif /* not alloca */
-
 # ifdef emacs
 #  define REGEX_USE_SAFE_ALLOCA USE_SAFE_ALLOCA
 #  define REGEX_SAFE_FREE() SAFE_FREE ()
 #  define REGEX_ALLOCATE SAFE_ALLOCA
 # else
+#  include <alloca.h>
 #  define REGEX_ALLOCATE alloca
 # endif
 
index 190d6fbe920957e57dec41a483cf6653e3bede75..0121f01631c63e623b668af9bc88fd0db32812fd 100644 (file)
@@ -26,6 +26,7 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 #include <grp.h>
 #endif /* HAVE_PWD_H */
 #include <limits.h>
+#include <stdlib.h>
 #include <unistd.h>
 
 #include <c-ctype.h>
index fbdc6b18373092a4eba73e9526709dd2520eb389..a53c874699f5ed9df9a8dc3398d7b73d7d4fa809 100644 (file)
@@ -26,7 +26,6 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 #include <fcntl.h>
 #endif /* not DOS_NT */
 
-#include <stdbool.h>
 #include <sys/ioctl.h>
 
 #ifdef HPUX
index c22d07ac579f4c5a553933d2a45d90e78aba205f..d691a7aa101bc569f003782f64566416f1583b25 100644 (file)
@@ -23,6 +23,7 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 #include <errno.h>
 #include <fcntl.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <sys/file.h>
 #include <sys/time.h>
 #include <unistd.h>
index 6343b38bcff6e14924209f39318ce4e37df76d4a..c0d1bc176a54bd781dd241e07c14cd303977cf97 100644 (file)
@@ -21,7 +21,6 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 #include <config.h>
 #include "unexec.h"
 #include "lisp.h"
-#include <string.h>
 #include <stdio.h>
 #include <fcntl.h>
 #include <a.out.h>
index 185a9d1f62b16f6a4157a845dcd45660ffc7bdea..ea8e884f177f55b4dbef5fa0f0d15cd71a2d29be 100644 (file)
@@ -85,20 +85,16 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
    be changed accordingly.
 */
 
-/* Enable GNU extensions in gnulib replacement headers.  */
-#define _GNU_SOURCE 1
-
-/* config.h #define:s malloc/realloc/free and then includes stdlib.h.
-   We want the undefined versions, but if config.h includes stdlib.h
-   with the #define:s in place, the prototypes will be wrong and we get
-   warnings.  To prevent that, include stdlib.h before config.h.  */
-
-#include <stdlib.h>
 #include <config.h>
+
+/* Although <config.h> redefines malloc to unexec_malloc, etc., this
+   file wants stdlib.h to declare the originals.  */
 #undef malloc
 #undef realloc
 #undef free
 
+#include <stdlib.h>
+
 #include "unexec.h"
 #include "lisp.h"
 
index 6cb8e748bd52af21d1e8d34a827e70329885d25a..e0a34060f0aa9fa0688bce843766f7e06d9d61e3 100644 (file)
--- a/src/w32.c
+++ b/src/w32.c
@@ -21,8 +21,8 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
    Geoff Voelker (voelker@cs.washington.edu)                         7-29-94
 */
 
-/* Enable GNU extensions in gnulib replacement headers.  */
-#define _GNU_SOURCE 1
+#define DEFER_MS_W32_H
+#include <config.h>
 
 #include <mingw_time.h>
 #include <stddef.h> /* for offsetof */
@@ -40,9 +40,9 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 #include <sys/utime.h>
 #include <math.h>
 
-/* must include CRT headers *before* config.h */
+/* Include CRT headers *before* ms-w32.h.  */
+#include <ms-w32.h>
 
-#include <config.h>
 #include <mbstring.h>  /* for _mbspbrk, _mbslwr, _mbsrchr, ... */
 
 #undef access
index 15e8a86cf175f3b015f07bb21a2a535f026a3d6b..32a03f70a661c5e86db69335c8abdcff52bef584 100644 (file)
@@ -81,14 +81,14 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
    thread to exit.  The main thread waits for some time for the worker
    thread to exit, and if it doesn't, terminates it forcibly.  */
 
-/* Enable GNU extensions in gnulib replacement headers.  */
-#define _GNU_SOURCE 1
+#define DEFER_MS_W32_H
+#include <config.h>
 
 #include <stddef.h>
 #include <errno.h>
 
-/* must include CRT headers *before* config.h */
-#include <config.h>
+/* Include CRT headers *before* ms-w32.h.  */
+#include <ms-w32.h>
 
 #include <windows.h>
 
index e23b1b3563c5d3966b216061fbcb6165243ed67e..aef4e44d73a3568cfeb2b34164fa9e7ed3b9ba8f 100644 (file)
@@ -22,8 +22,8 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
      Adapted from alarm.c by Tim Fleehart
 */
 
-/* Enable GNU extensions in gnulib replacement headers.  */
-#define _GNU_SOURCE 1
+#define DEFER_MS_W32_H
+#include <config.h>
 
 #include <mingw_time.h>
 #include <stdio.h>
@@ -38,8 +38,8 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 #include <mbstring.h>
 #include <locale.h>
 
-/* must include CRT headers *before* config.h */
-#include <config.h>
+/* Include CRT headers *before* ms-w32.h.  */
+#include <ms-w32.h>
 
 #undef signal
 #undef wait
index 28bb475ddfa769dc300f4e0a8fc598f7bbcc395f..59ed431e23bf047351743b1982a65ea8730cabef 100644 (file)
@@ -32,6 +32,7 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 #include "widget.h"
 
 #include <stdio.h>
+#include <stdlib.h>
 
 #include "lisp.h"
 #include "xterm.h"
index 13af87f953c6cad2fbb83b99f95fc4c733726825..e8061663f866dde8e19fab4e2f70ef8a89f06f79 100644 (file)
@@ -288,6 +288,7 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include <config.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <limits.h>
 
 #include "lisp.h"
index 056f90cb7ac7684350b433d9a4181f488d80ee5f..5837f35d7b6af708fea3303cbea0e7d30c24acaf 100644 (file)
@@ -200,6 +200,7 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
    used to fill in unspecified attributes of the default face.  */
 
 #include <config.h>
+#include <stdlib.h>
 #include "sysstdio.h"
 #include <sys/types.h>
 #include <sys/stat.h>
index dd39e782face807dbdcf5288e9b6df512dad7378..8571d0e20abb8a70c06edd2efba88b101d336279 100644 (file)
@@ -19,6 +19,7 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include <config.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <math.h>
 #include <unistd.h>
 
index 8fbe94c01abecac425b6fa3f76a01c1c5eeaebc3..45b0e0a5f5329e5f1a74c4e8f4e4c1e69c5469d9 100644 (file)
@@ -21,6 +21,7 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include <config.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <X11/Xlib.h>
 
 #include "lisp.h"
index ac88afdd54bd448dd58affca291d33aa99c9ae26..7850a16e9c024b08777281b1236369d0c2f931a5 100644 (file)
@@ -25,7 +25,6 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include <glib.h>
 #include <errno.h>
-#include <stdbool.h>
 #include "blockinput.h"
 #include "systime.h"
 
index 4c14e62058f57b00601fa638d68587c8ccfcea5f..747669446f57bb51dcd1642f94106cee33a6b0bc 100644 (file)
@@ -22,6 +22,7 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include <config.h>
 #include <stdio.h>
+#include <stdlib.h>
 #ifdef USE_CAIRO
 #include <math.h>
 #endif