summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2013-02-24 21:55:37 -0800
committerPaul Eggert <eggert@cs.ucla.edu>2013-02-24 21:55:37 -0800
commit1ddc2bd6ff0b5071454d2591f835927ea5b85a06 (patch)
treedff377164bcc7d9e8a84e0279cee6f9c28e3fcc5 /src
parent82fcf982c39d5ff821bb7d3353ca973e277e1810 (diff)
downloademacs-1ddc2bd6ff0b5071454d2591f835927ea5b85a06.tar.gz
Simplify data_start configuration.
This is a followon simplification to the fix for Bug#13650. * admin/CPP-DEFINES (DATA_START, ORDINARY_LINK): Remove. * configure.ac (CRT_DIR, LIB_STANDARD, START_FILES, DATA_START) (LD_FIRSTFLAG, ORDINARY_LINK, LIB_GCC): Remove. (AC_CHECK_HEADERS_ONCE): Remove sys/resource.h, as it's not always needed. (HAVE_DATA_START): New macro. * etc/PROBLEMS (LIBS_SYSTEM, LIBS_MACHINE, LIBS_STANDARD): Remove. Remove legacy-systems section, as this stuff is no longer applicable with current linking strategies. * src/Makefile.in (LD_FIRSTFLAG, LIB_GCC, CRT_DIR, LIB_STANDARD) (START_FILES): Remove. All uses removed. (otherobj): Remove $(VMLIMIT_OBJ), as it's now first. (ALLOBJS): Move here from autodeps.mk, and with VMLIMITS_OBJ first. (buildobj.h): Use it. ($(ALLOBJS)): Depend on globals.h. (temacs$(EXEEXT)): Use $(ALLOBJS). * src/autodeps.mk (ALLOBJS): Move to Makefile.in. * src/deps.mk (vm-limit.o): * src/makefile.w32-in ($(BLD)/vm-limit.$(O)): Do not depend on mem-limits.h. * src/emacs.c (__do_global_ctors, __do_global_ctors_aux) (__do_global_dtors, __CTOR_LIST__, __DTOR_LIST__) [__GNUC__ && !ORDINARY_LINK]: Remove. * src/mem-limits.h, src/pre-crt0.c: Remove. * src/unexaix.c, src/unexcoff.c: Don't include mem-limits.h. * src/unexcoff.c (etext): New decl. (make_hdr): Use it instead of start_of_data. * src/vm-limit.c: Move most of mem-limits.h's contents here. (data_start): New decl. It's OK if this is approximate, so simplify-away some unnecessary exactness. (POINTER): Remove; all uses removed. (data_space_start): Now char *, to avoid casts. (exceeds_lisp_ptr): New function, replacing the old EXCEEDS_LISP_PTR macro. All uses changed. (check_memory_limits): Simplify and remove casts. (start_of_data) [!CANNOT_DUMP || !SYSTEM_MALLOC]: Remove. (memory_warnings): Use data_start instead of start_of_data. Fixes: debbugs:13783
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog33
-rw-r--r--src/Makefile.in34
-rw-r--r--src/autodeps.mk1
-rw-r--r--src/deps.mk2
-rw-r--r--src/emacs.c26
-rw-r--r--src/makefile.w32-in1
-rw-r--r--src/mem-limits.h43
-rw-r--r--src/pre-crt0.c10
-rw-r--r--src/unexaix.c2
-rw-r--r--src/unexcoff.c4
-rw-r--r--src/vm-limit.c103
11 files changed, 95 insertions, 164 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 8d3fc1e56fb..00d1f30dd46 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,36 @@
+2013-02-25 Paul Eggert <eggert@cs.ucla.edu>
+
+ Simplify data_start configuration (Bug#13783).
+ This is a followon simplification to the fix for Bug#13650.
+ * Makefile.in (LD_FIRSTFLAG, LIB_GCC, CRT_DIR, LIB_STANDARD)
+ (START_FILES): Remove. All uses removed.
+ (otherobj): Remove $(VMLIMIT_OBJ), as it's now first.
+ (ALLOBJS): Move here from autodeps.mk, and with VMLIMITS_OBJ first.
+ (buildobj.h): Use it.
+ ($(ALLOBJS)): Depend on globals.h.
+ (temacs$(EXEEXT)): Use $(ALLOBJS).
+ * autodeps.mk (ALLOBJS): Move to Makefile.in.
+ * deps.mk (vm-limit.o):
+ * makefile.w32-in ($(BLD)/vm-limit.$(O)):
+ Do not depend on mem-limits.h.
+ * emacs.c (__do_global_ctors, __do_global_ctors_aux)
+ (__do_global_dtors, __CTOR_LIST__, __DTOR_LIST__)
+ [__GNUC__ && !ORDINARY_LINK]: Remove.
+ * mem-limits.h, pre-crt0.c: Remove.
+ * unexaix.c, unexcoff.c: Don't include mem-limits.h.
+ * unexcoff.c (etext): New decl.
+ (make_hdr): Use DATA_START instead of start_of_data.
+ * vm-limit.c: Move most of mem-limits.h's contents here.
+ (data_start): New decl. It's OK if this is approximate,
+ so simplify-away some unnecessary exactness.
+ (POINTER): Remove; all uses removed.
+ (data_space_start): Now char *, to avoid casts.
+ (exceeds_lisp_ptr): New function, replacing the old
+ EXCEEDS_LISP_PTR macro. All uses changed.
+ (check_memory_limits): Simplify and remove casts.
+ (start_of_data) [!CANNOT_DUMP || !SYSTEM_MALLOC]: Remove.
+ (memory_warnings): Use data_start instead of start_of_data.
+
2013-02-24 Andreas Schwab <schwab@linux-m68k.org>
* xdisp.c (set_message): Only check for debug-on-message if STRING
diff --git a/src/Makefile.in b/src/Makefile.in
index 6ee03177861..b2034a3379d 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -36,7 +36,6 @@ WINDRES = @WINDRES@
CFLAGS = @CFLAGS@
CPPFLAGS = @CPPFLAGS@
LDFLAGS = @LDFLAGS@
-LD_FIRSTFLAG=@LD_FIRSTFLAG@
EXEEXT = @EXEEXT@
version = @version@
# Substitute an assignment for the MAKE variable, because
@@ -102,10 +101,8 @@ LD_SWITCH_X_SITE_RPATH=@LD_SWITCH_X_SITE_RPATH@
## System-specific LDFLAGS.
LD_SWITCH_SYSTEM=@LD_SWITCH_SYSTEM@
-## This holds any special options for linking temacs only (ie, not
-## used by configure). Not used elsewhere because it sometimes
-## contains options that have to do with using Emacs's crt0,
-## which are only good with temacs.
+## This holds any special options for linking temacs only (i.e., not
+## used by configure).
LD_SWITCH_SYSTEM_TEMACS=@LD_SWITCH_SYSTEM_TEMACS@
## Flags to pass to ld only for temacs.
@@ -120,14 +117,6 @@ PAXCTL = @PAXCTL@
## Some systems define this to request special libraries.
LIBS_SYSTEM=@LIBS_SYSTEM@
-## Where to find libgcc.a, if using gcc and necessary.
-LIB_GCC=@LIB_GCC@
-
-CRT_DIR=@CRT_DIR@
-## May use $CRT_DIR.
-LIB_STANDARD=@LIB_STANDARD@
-START_FILES = @START_FILES@
-
## -lm, or empty.
LIB_MATH=@LIB_MATH@
@@ -389,17 +378,16 @@ POST_ALLOC_OBJ=@POST_ALLOC_OBJ@
## List of object files that make-docfile should not be told about.
otherobj= $(TERMCAP_OBJ) $(PRE_ALLOC_OBJ) $(GMALLOC_OBJ) $(RALLOC_OBJ) \
- $(POST_ALLOC_OBJ) $(VMLIMIT_OBJ) $(WIDGET_OBJ) $(LIBOBJS)
+ $(POST_ALLOC_OBJ) $(WIDGET_OBJ) $(LIBOBJS)
+## All object files linked into temacs. $(VMLIMIT_OBJ) should be first.
+ALLOBJS = $(VMLIMIT_OBJ) $(obj) $(otherobj)
## Configure inserts the file lisp.mk at this point, defining $lisp.
@lisp_frag@
## Construct full set of libraries to be linked.
-## Note that SunOS needs -lm to come before -lc; otherwise, you get
-## duplicated symbols. If the standard libraries were compiled
-## with GCC, we might need LIB_GCC again after them.
LIBES = $(LIBS) $(W32_LIBS) $(LIBS_GNUSTEP) $(LIBX_BASE) $(LIBIMAGE) \
$(LIBX_OTHER) $(LIBSOUND) \
$(RSVG_LIBS) $(IMAGEMAGICK_LIBS) $(LIB_CLOCK_GETTIME) \
@@ -409,7 +397,7 @@ LIBES = $(LIBS) $(W32_LIBS) $(LIBS_GNUSTEP) $(LIBX_BASE) $(LIBIMAGE) \
$(LIBS_TERMCAP) $(GETLOADAVG_LIBS) $(SETTINGS_LIBS) $(LIBSELINUX_LIBS) \
$(FREETYPE_LIBS) $(FONTCONFIG_LIBS) $(LIBOTF_LIBS) $(M17N_FLT_LIBS) \
$(LIBACL_LIBS) $(LIBGNUTLS_LIBS) $(LIB_PTHREAD) $(LIB_PTHREAD_SIGMASK) \
- $(LIB_GCC) $(LIB_MATH) $(LIB_STANDARD) $(LIB_GCC)
+ $(LIB_MATH)
all: emacs$(EXEEXT) $(OTHER_FILES)
.PHONY: all
@@ -456,7 +444,7 @@ $(libsrc)/make-docfile$(EXEEXT):
cd $(libsrc); $(MAKE) $(MFLAGS) make-docfile$(EXEEXT)
buildobj.h: Makefile
- echo "#define BUILDOBJ \"$(obj) $(otherobj) " "\"" > buildobj.h
+ echo "#define BUILDOBJ \"$(ALLOBJS) " "\"" >$@
globals.h: gl-stamp; @true
@@ -468,15 +456,15 @@ gl-stamp: $(libsrc)/make-docfile$(EXEEXT) $(GLOBAL_SOURCES)
$(srcdir)/../build-aux/move-if-change gl-tmp globals.h
echo timestamp > $@
-$(obj) $(otherobj): globals.h
+$(ALLOBJS): globals.h
$(lib)/libgnu.a: $(config_h)
cd $(lib) && $(MAKE) libgnu.a
-temacs$(EXEEXT): $(START_FILES) stamp-oldxmenu $(obj) $(otherobj) \
+temacs$(EXEEXT): stamp-oldxmenu $(ALLOBJS) \
$(lib)/libgnu.a $(W32_RES)
- $(CC) $(LD_FIRSTFLAG) $(ALL_CFLAGS) $(TEMACS_LDFLAGS) $(LDFLAGS) \
- -o temacs $(START_FILES) $(obj) $(otherobj) $(lib)/libgnu.a $(LIBES) \
+ $(CC) $(ALL_CFLAGS) $(TEMACS_LDFLAGS) $(LDFLAGS) \
+ -o temacs $(ALLOBJS) $(lib)/libgnu.a $(LIBES) \
$(W32_RES_LINK)
test "$(CANNOT_DUMP)" = "yes" || \
test "X$(PAXCTL)" = X || $(PAXCTL) -r temacs$(EXEEXT)
diff --git a/src/autodeps.mk b/src/autodeps.mk
index fb0e21366c7..8b014a7508c 100644
--- a/src/autodeps.mk
+++ b/src/autodeps.mk
@@ -2,5 +2,4 @@
## This is inserted in src/Makefile if AUTO_DEPEND=yes.
-ALLOBJS=$(START_FILES) ${obj} ${otherobj}
-include $(ALLOBJS:%.o=${DEPDIR}/%.d)
diff --git a/src/deps.mk b/src/deps.mk
index 47185c9262c..83444474c59 100644
--- a/src/deps.mk
+++ b/src/deps.mk
@@ -144,7 +144,7 @@ macros.o: macros.c window.h buffer.h commands.h macros.h keyboard.h msdos.h \
dispextern.h lisp.h globals.h $(config_h) systime.h coding.h composite.h
gmalloc.o: gmalloc.c $(config_h)
ralloc.o: ralloc.c lisp.h $(config_h)
-vm-limit.o: vm-limit.c mem-limits.h lisp.h globals.h $(config_h)
+vm-limit.o: vm-limit.c lisp.h globals.h $(config_h)
marker.o: marker.c buffer.h character.h lisp.h globals.h $(config_h)
minibuf.o: minibuf.c syntax.h frame.h window.h keyboard.h systime.h \
buffer.h commands.h character.h msdos.h $(INTERVALS_H) keymap.h \
diff --git a/src/emacs.c b/src/emacs.c
index c494dff8cac..b96076b1340 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -521,32 +521,6 @@ DEFUN ("invocation-directory", Finvocation_directory, Sinvocation_directory,
static char const dump_tz[] = "UtC0";
#endif
-#ifndef ORDINARY_LINK
-/* We don't include crtbegin.o and crtend.o in the link,
- so these functions and variables might be missed.
- Provide dummy definitions to avoid error.
- (We don't have any real constructors or destructors.) */
-#ifdef __GNUC__
-
-/* Define a dummy function F. Declare F too, to pacify gcc
- -Wmissing-prototypes. */
-#define DEFINE_DUMMY_FUNCTION(f) \
- void f (void) ATTRIBUTE_CONST EXTERNALLY_VISIBLE; void f (void) {}
-
-#ifndef GCC_CTORS_IN_LIBC
-DEFINE_DUMMY_FUNCTION (__do_global_ctors)
-DEFINE_DUMMY_FUNCTION (__do_global_ctors_aux)
-DEFINE_DUMMY_FUNCTION (__do_global_dtors)
-/* GNU/Linux has a bug in its library; avoid an error. */
-#ifndef GNU_LINUX
-char * __CTOR_LIST__[2] EXTERNALLY_VISIBLE = { (char *) (-1), 0 };
-#endif
-char * __DTOR_LIST__[2] EXTERNALLY_VISIBLE = { (char *) (-1), 0 };
-#endif /* GCC_CTORS_IN_LIBC */
-DEFINE_DUMMY_FUNCTION (__main)
-#endif /* __GNUC__ */
-#endif /* ORDINARY_LINK */
-
/* Test whether the next argument in ARGV matches SSTR or a prefix of
LSTR (at least MINLEN characters). If so, then if VALPTR is non-null
(the argument is supposed to have a value) store in *VALPTR either
diff --git a/src/makefile.w32-in b/src/makefile.w32-in
index 6e1873f8e49..d60331198db 100644
--- a/src/makefile.w32-in
+++ b/src/makefile.w32-in
@@ -1492,7 +1492,6 @@ $(BLD)/unexw32.$(O) : \
$(BLD)/vm-limit.$(O) : \
$(SRC)/vm-limit.c \
- $(SRC)/mem-limits.h \
$(SRC)/w32heap.h \
$(NT_INC)/unistd.h \
$(CONFIG_H) \
diff --git a/src/mem-limits.h b/src/mem-limits.h
deleted file mode 100644
index 941ccf5f121..00000000000
--- a/src/mem-limits.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/* Includes for memory limit warnings.
- Copyright (C) 1990, 1993-1996, 2001-2013 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 <http://www.gnu.org/licenses/>. */
-
-#ifdef MSDOS
-#include <dpmi.h>
-extern int etext;
-#endif
-
-/* Some systems need this before <sys/resource.h>. */
-#include <sys/types.h>
-
-#ifdef HAVE_SYS_RESOURCE_H
-# include <sys/time.h>
-# include <sys/resource.h>
-#else
-# if HAVE_SYS_VLIMIT_H
-# include <sys/vlimit.h> /* Obsolete, says glibc */
-# endif
-#endif
-
-extern char *start_of_data (void) ATTRIBUTE_CONST;
-#if USE_LSB_TAG || UINTPTR_MAX <= VAL_MAX
-#define EXCEEDS_LISP_PTR(ptr) 0
-#else
-#define EXCEEDS_LISP_PTR(ptr) \
- (((uintptr_t) (ptr) & ~DATA_SEG_BITS) >> VALBITS)
-#endif
diff --git a/src/pre-crt0.c b/src/pre-crt0.c
deleted file mode 100644
index 6b9618c8dc3..00000000000
--- a/src/pre-crt0.c
+++ /dev/null
@@ -1,10 +0,0 @@
-/* This file is loaded before crt0.o on machines where we do not
- remap part of the data space into text space in unexec.
- On these machines, there is no problem with standard crt0.o's
- that make environ an initialized variable. However, we do
- need to make sure the label data_start exists anyway. */
-
-/* Create a label to appear at the beginning of data space.
- Its value is nonzero so that it cannot be put into bss. */
-
-int data_start = 1;
diff --git a/src/unexaix.c b/src/unexaix.c
index da44480fdca..44a824b8c12 100644
--- a/src/unexaix.c
+++ b/src/unexaix.c
@@ -59,8 +59,6 @@ what you give them. Help stamp out software-hoarding! */
#include <unistd.h>
#include <fcntl.h>
-#include "mem-limits.h"
-
extern char _data[];
extern char _text[];
diff --git a/src/unexcoff.c b/src/unexcoff.c
index 466a5c0e491..2e662a34145 100644
--- a/src/unexcoff.c
+++ b/src/unexcoff.c
@@ -99,7 +99,7 @@ struct aouthdr
#include <sys/file.h>
-#include "mem-limits.h"
+extern int etext;
static long block_copy_start; /* Old executable start point */
static struct filehdr f_hdr; /* File header */
@@ -168,7 +168,7 @@ make_hdr (int new, int a_out,
pagemask = getpagesize () - 1;
/* Adjust text/data boundary. */
- data_start = (int) start_of_data ();
+ data_start = (int) DATA_START;
data_start = ADDR_CORRECT (data_start);
data_start = data_start & ~pagemask; /* (Down) to page boundary. */
diff --git a/src/vm-limit.c b/src/vm-limit.c
index fc7a253325a..3fca8bd26c1 100644
--- a/src/vm-limit.c
+++ b/src/vm-limit.c
@@ -19,7 +19,37 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include <config.h>
#include <unistd.h> /* for 'environ', on AIX */
#include "lisp.h"
-#include "mem-limits.h"
+
+#ifdef MSDOS
+#include <dpmi.h>
+extern int etext;
+#endif
+
+/* Some systems need this before <sys/resource.h>. */
+#include <sys/types.h>
+
+#ifdef HAVE_SYS_RESOURCE_H
+# include <sys/time.h>
+# include <sys/resource.h>
+#else
+# if HAVE_SYS_VLIMIT_H
+# include <sys/vlimit.h> /* Obsolete, says glibc */
+# endif
+#endif
+
+/* Start of data. It is OK if this is approximate; it's used only as
+ a heuristic. */
+#ifdef DATA_START
+# define data_start ((char *) DATA_START)
+#else
+extern char data_start[];
+# ifndef HAVE_DATA_START
+/* Initialize to nonzero, so that it's put into data and not bss.
+ Link this file's object code first, so that this symbol is near the
+ start of data. */
+char data_start[1] = { 1 };
+# endif
+#endif
/*
Level number of warnings already issued.
@@ -35,12 +65,20 @@ static enum warnlevel warnlevel;
0 means don't issue them. */
static void (*warn_function) (const char *);
-/* Start of data space; can be changed by calling malloc_init. */
-static void *data_space_start;
+/* Start of data space; can be changed by calling memory_warnings. */
+static char *data_space_start;
/* Number of bytes of writable memory we can expect to be able to get. */
static size_t lim_data;
+/* Return true if PTR cannot be represented as an Emacs Lisp object. */
+static bool
+exceeds_lisp_ptr (void *ptr)
+{
+ return (! USE_LSB_TAG
+ && VAL_MAX < UINTPTR_MAX
+ && ((uintptr_t) ptr & ~DATA_SEG_BITS) >> VALBITS != 0);
+}
#ifdef HAVE_GETRLIMIT
@@ -122,10 +160,12 @@ check_memory_limits (void)
{
#ifdef REL_ALLOC
extern void *(*real_morecore) (ptrdiff_t);
+#else
+ void *(*real_morecore) (ptrdiff_t) = 0;
#endif
extern void *(*__morecore) (ptrdiff_t);
- void *cp;
+ char *cp;
size_t five_percent;
size_t data_size;
enum warnlevel new_warnlevel;
@@ -135,13 +175,8 @@ check_memory_limits (void)
five_percent = lim_data / 20;
/* Find current end of memory and issue warning if getting near max */
-#ifdef REL_ALLOC
- if (real_morecore)
- cp = (char *) (*real_morecore) (0);
- else
-#endif
- cp = (char *) (*__morecore) (0);
- data_size = (char *) cp - (char *) data_space_start;
+ cp = (real_morecore ? real_morecore : __morecore) (0);
+ data_size = cp - data_space_start;
if (!warn_function)
return;
@@ -188,49 +223,10 @@ check_memory_limits (void)
warnlevel = warned_85;
}
- if (EXCEEDS_LISP_PTR (cp))
+ if (exceeds_lisp_ptr (cp))
(*warn_function) ("Warning: memory in use exceeds lisp pointer size");
}
-#if !defined (CANNOT_DUMP) || !defined (SYSTEM_MALLOC)
-/* Some systems that cannot dump also cannot implement these. */
-
-/*
- * Return the address of the start of the data segment prior to
- * doing an unexec. After unexec the return value is undefined.
- * See crt0.c for further information and definition of data_start.
- *
- * Apparently, on BSD systems this is etext at startup. On
- * USG systems (swapping) this is highly mmu dependent and
- * is also dependent on whether or not the program is running
- * with shared text. Generally there is a (possibly large)
- * gap between end of text and start of data with shared text.
- *
- */
-
-char *
-start_of_data (void)
-{
-#ifdef BSD_SYSTEM
- extern char etext;
- return (void *) &etext;
-#elif defined DATA_START
- return (void *) DATA_START;
-#elif defined ORDINARY_LINK
- /*
- * This is a hack. Since we're not linking crt0.c or pre_crt0.c,
- * data_start isn't defined. We take the address of environ, which
- * is known to live at or near the start of the system crt0.c, and
- * we don't sweat the handful of bytes that might lose.
- */
- return (void *) &environ;
-#else
- extern int data_start;
- return (void *) &data_start;
-#endif
-}
-#endif /* (not CANNOT_DUMP or not SYSTEM_MALLOC) */
-
/* Enable memory usage warnings.
START says where the end of pure storage is.
WARNFUN specifies the function to call to issue a warning. */
@@ -240,10 +236,7 @@ memory_warnings (void *start, void (*warnfun) (const char *))
{
extern void (* __after_morecore_hook) (void); /* From gmalloc.c */
- if (start)
- data_space_start = start;
- else
- data_space_start = start_of_data ();
+ data_space_start = start ? start : data_start;
warn_function = warnfun;
__after_morecore_hook = check_memory_limits;