changeset 109168:fb5779a6cf4b

Simplify start_of_data, start_of_text and related code. * src/mem-limits.h: Remove !emacs and _LIBC conditional code. (start_of_data): Merge into start_of_data function. * src/sysdep.c (start_of_text): Remove. Move simplified versions of it in the only users: src/unexaix.c and unexec.c. (read_input_waiting): Remove local declaration of quit_char. (start, etext): Remove declarations. (start_of_data): Merge with the version in mem-limits.h and move to vm-limits.c. * src/vm-limit.c (start_of_data): Merged and simplified version of the code formerly in mem-limits.h and sysdep.c. * src/unexec.c (start): New declaration, moved from sysdep.c. (start_of_text): Simplified version of the code formerly in sysdep.c. * unexaix.c (start_of_text): Simplified version of the code formerly in sysdep.c. * src/m/alpha.h (HAVE_TEXT_START): Remove. (TEXT_START): Move ... * src/unexalpha.c (TEXT_START): ... here. * src/s/hpux10-20.h (TEXT_START): Remove. * src/s/darwin.h (TEXT_START): * src/m/mips.h (TEXT_START): * src/m/macppc.h (HAVE_TEXT_START): * src/m/m68k.h (TEXT_START): * src/m/iris4d.h (TEXT_START): * src/m/intel386.h (TEXT_START): * src/m/ibmrs6000.h (TEXT_START): * src/m/ia64.h (HAVE_TEXT_START): * src/s/msdos.h (TEXT_START): Likewise.
author Dan Nicolaescu <dann@ics.uci.edu>
date Wed, 07 Jul 2010 20:03:52 -0700
parents ec5aba8edfaa
children 5df3f77a9df9
files admin/CPP-DEFINES src/ChangeLog src/m/alpha.h src/m/ia64.h src/m/ibmrs6000.h src/m/intel386.h src/m/iris4d.h src/m/m68k.h src/m/macppc.h src/m/mips.h src/mem-limits.h src/s/darwin.h src/s/hpux10-20.h src/s/msdos.h src/sysdep.c src/unexaix.c src/unexalpha.c src/unexec.c src/vm-limit.c
diffstat 19 files changed, 102 insertions(+), 144 deletions(-) [+]
line wrap: on
line diff
--- a/admin/CPP-DEFINES	Wed Jul 07 19:37:32 2010 -0700
+++ b/admin/CPP-DEFINES	Wed Jul 07 20:03:52 2010 -0700
@@ -186,7 +186,6 @@
 HAVE_SYS_TIME_H
 HAVE_TCATTR
 HAVE_TERMIOS_H
-HAVE_TEXT_START
 HAVE_TIMEVAL
 HAVE_TM_ZONE
 HAVE_TZSET
@@ -262,7 +261,6 @@
 TAB3
 TABDLY
 TERM
-TEXT_START
 THIS_IS_CONFIGURE
 TIME_WITH_SYS_TIME
 TIOCSIGSEND
--- a/src/ChangeLog	Wed Jul 07 19:37:32 2010 -0700
+++ b/src/ChangeLog	Wed Jul 07 20:03:52 2010 -0700
@@ -1,3 +1,34 @@
+2010-07-08  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	Simplify cstart_of_data, start_of_code and related code.
+	* mem-limits.h: Remove !emacs and _LIBC conditional code.
+	(start_of_data): Merge into start_of_data function.
+	* sysdep.c (start_of_text): Remove.  Move simplified versions of
+	it in the only users: unexaix.c and unexec.c.
+	(read_input_waiting): Remove local declaration of quit_char.
+	(start, etext): Remove declarations.
+	(start_of_data): Merge with the version in mem-limits.h and move
+	to vm-limits.c.
+	* vm-limit.c (start_of_data): Merged and simplified version of the
+	code formerly in mem-limits.h and sysdep.c.
+	* unexec.c (start): New declaration, moved from sysdep.c.
+	(start_of_text): Simplified version of the code formerly in sysdep.c.
+	* unexaix.c (start_of_text): Simplified version of the code
+	formerly in sysdep.c.
+	* m/alpha.h (HAVE_TEXT_START): Remove.
+	(TEXT_START): Move ...
+	* unexalpha.c (TEXT_START): ... here.
+	* s/hpux10-20.h (TEXT_START): Remove.
+	* s/darwin.h (TEXT_START):
+	* m/mips.h (TEXT_START):
+	* m/macppc.h (HAVE_TEXT_START):
+	* m/m68k.h (TEXT_START):
+	* m/iris4d.h (TEXT_START):
+	* m/intel386.h (TEXT_START):
+	* m/ibmrs6000.h (TEXT_START):
+	* m/ia64.h (HAVE_TEXT_START):
+	* s/msdos.h (TEXT_START): Likewise.
+
 2010-07-07  Andreas Schwab  <schwab@linux-m68k.org>
 
 	* alloc.c (overrun_check_malloc, overrun_check_realloc)
--- a/src/m/alpha.h	Wed Jul 07 19:37:32 2010 -0700
+++ b/src/m/alpha.h	Wed Jul 07 20:03:52 2010 -0700
@@ -53,14 +53,9 @@
 #define DATA_START    0x140000000
 #endif
 
-#if (defined (__NetBSD__) || defined (__OpenBSD__))
-#define HAVE_TEXT_START
-#endif
-
 #else  /* not __ELF__ */
 
 /* Describe layout of the address space in an executing process.  */
-#define TEXT_START    0x120000000
 #define DATA_START    0x140000000
 
 #endif /* __ELF__ */
--- a/src/m/ia64.h	Wed Jul 07 19:37:32 2010 -0700
+++ b/src/m/ia64.h	Wed Jul 07 20:03:52 2010 -0700
@@ -58,7 +58,5 @@
 #endif /* not _MALLOC_INTERNAL */
 #endif /* REL_ALLOC */
 
-#define HAVE_TEXT_START
-
 /* arch-tag: 9b8e9fb2-2e49-4c22-b68f-11a488e77c66
    (do not change this comment) */
--- a/src/m/ibmrs6000.h	Wed Jul 07 19:37:32 2010 -0700
+++ b/src/m/ibmrs6000.h	Wed Jul 07 20:03:52 2010 -0700
@@ -22,7 +22,6 @@
 /* The data segment in this machine always starts at address 0x20000000.
    An address of data cannot be stored correctly in a Lisp object;
    we always lose the high bits.  We must tell XPNTR to add them back.  */
-#define TEXT_START 0x10000000
 #define DATA_START 0x20000000
 #define WORDS_BIG_ENDIAN
 #define DATA_SEG_BITS 0x20000000
--- a/src/m/intel386.h	Wed Jul 07 19:37:32 2010 -0700
+++ b/src/m/intel386.h	Wed Jul 07 20:03:52 2010 -0700
@@ -23,10 +23,6 @@
    is the most significant byte.  */
 #undef WORDS_BIG_ENDIAN
 
-#ifdef USG
-#define TEXT_START 0
-#endif /* USG */
-
 #ifdef WINDOWSNT
 #define VIRT_ADDR_VARIES
 #define DATA_START 	get_data_start ()
--- a/src/m/iris4d.h	Wed Jul 07 19:37:32 2010 -0700
+++ b/src/m/iris4d.h	Wed Jul 07 20:03:52 2010 -0700
@@ -30,8 +30,6 @@
    This flag only matters if you use USE_LISP_UNION_TYPE.  */
 #define EXPLICIT_SIGN_EXTEND
 
-#define TEXT_START 0x400000
-
 /* DATA_SEG_BITS forces extra bits to be or'd in with any pointers which
    were stored in a Lisp_Object (as Emacs uses fewer than 32 bits for
    the value field of a LISP_OBJECT).  */
--- a/src/m/m68k.h	Wed Jul 07 19:37:32 2010 -0700
+++ b/src/m/m68k.h	Wed Jul 07 20:03:52 2010 -0700
@@ -41,7 +41,6 @@
 #endif
 
 #define NO_REMAP
-#define TEXT_START 0
 #endif
 
 /* arch-tag: 4eadd161-b4e8-4b82-82a1-e4ce7f42969d
--- a/src/m/macppc.h	Wed Jul 07 19:37:32 2010 -0700
+++ b/src/m/macppc.h	Wed Jul 07 20:03:52 2010 -0700
@@ -28,10 +28,6 @@
 /* Convert that into an integer that is 100 for a load average of 1.0  */
 #define LOAD_AVE_CVT(x) (int) (((double) (x)) * 100.0 / FSCALE)
 
-#if (defined (__NetBSD__) || defined (__OpenBSD__)) && defined (__ELF__)
-#define HAVE_TEXT_START
-#endif
-
 #ifdef _ARCH_PPC64
 #ifndef _LP64
 #define _LP64
--- a/src/m/mips.h	Wed Jul 07 19:37:32 2010 -0700
+++ b/src/m/mips.h	Wed Jul 07 20:03:52 2010 -0700
@@ -31,8 +31,5 @@
    This flag only matters if you use USE_LISP_UNION_TYPE.  */
 #define EXPLICIT_SIGN_EXTEND
 
-/* Describe layout of the address space in an executing process.  */
-#define TEXT_START      0x00400000
-
 /* arch-tag: 8fd020ee-78a7-4d87-96ce-6129f52f7bee
    (do not change this comment) */
--- a/src/mem-limits.h	Wed Jul 07 19:37:32 2010 -0700
+++ b/src/mem-limits.h	Wed Jul 07 20:03:52 2010 -0700
@@ -25,17 +25,6 @@
 /* Some systems need this before <sys/resource.h>.  */
 #include <sys/types.h>
 
-#ifdef _LIBC
-
-#include <sys/resource.h>
-#define BSD4_2			/* Tell code below to use getrlimit.  */
-
-/* Old Linux startup code won't define __data_start.  */
-extern int etext, __data_start; weak_extern (__data_start)
-#define start_of_data()	(&__data_start ?: &etext)
-
-#else /* not _LIBC */
-
 #ifdef HAVE_SYS_RESOURCE_H
 # include <sys/time.h>
 # include <sys/resource.h>
@@ -54,7 +43,6 @@
 #include <sys/resource.h>
 #endif /* BSD4_2 */
 
-#ifdef emacs
 /* The important properties of this type are that 1) it's a pointer, and
    2) arithmetic on it should work as if the size of the object pointed
    to has a size of 1.  */
@@ -77,26 +65,5 @@
 #define EXCEEDS_LISP_PTR(ptr) ((EMACS_UINT) (ptr) >> VALBITS)
 #endif
 
-#ifdef DATA_START
-#define start_of_data() ((char *)DATA_START)
-#endif
-
-#ifdef BSD_SYSTEM
-#ifndef DATA_SEG_BITS
-#ifndef DATA_START
-extern char etext;
-#define start_of_data() &etext
-#endif
-#endif
-#endif
-
-#else  /* not emacs */
-extern char etext;
-#define start_of_data() &etext
-#endif /* not emacs */
-
-#endif /* not _LIBC */
-
-
 /* arch-tag: fe39244e-e54f-4208-b7aa-02556f7841c5
    (do not change this comment) */
--- a/src/s/darwin.h	Wed Jul 07 19:37:32 2010 -0700
+++ b/src/s/darwin.h	Wed Jul 07 20:03:52 2010 -0700
@@ -117,9 +117,6 @@
 /* Define HAVE_SOCKETS if system supports 4.2-compatible sockets.  */
 #define HAVE_SOCKETS
 
-/* start_of_text isn't actually used, so make it compile without error.  */
-#define TEXT_START (0)
-
 /* Definitions for how to compile & link.  */
 #ifdef HAVE_NS
 #define SYSTEM_PURESIZE_EXTRA 200000
--- a/src/s/hpux10-20.h	Wed Jul 07 19:37:32 2010 -0700
+++ b/src/s/hpux10-20.h	Wed Jul 07 20:03:52 2010 -0700
@@ -131,7 +131,6 @@
 #define DATA_SEG_BITS 0x40000000
 
 #define DATA_START    0x40000000
-#define TEXT_START    0x00000000
 
 /* Data type of load average, as read out of kmem.  */
 #define LOAD_AVE_TYPE double
--- a/src/s/msdos.h	Wed Jul 07 19:37:32 2010 -0700
+++ b/src/s/msdos.h	Wed Jul 07 20:03:52 2010 -0700
@@ -75,7 +75,6 @@
 #define _longjmp longjmp
 
 #define DATA_START  (&etext + 1)
-#define TEXT_START  &start
 
 #define _NAIVE_DOS_REGS
 
--- a/src/sysdep.c	Wed Jul 07 19:37:32 2010 -0700
+++ b/src/sysdep.c	Wed Jul 07 20:03:52 2010 -0700
@@ -79,9 +79,6 @@
 #include "dosfns.h"
 #include "msdos.h"
 #include <sys/param.h>
-
-extern int etext;
-extern unsigned start __asm__ ("start");
 #endif
 
 #include <sys/file.h>
@@ -1511,83 +1508,6 @@
 }
 #endif /* HAVE_PTYS */
 
-#if !defined(CANNOT_DUMP) || !defined(SYSTEM_MALLOC)
-/* Some systems that cannot dump also cannot implement these.  */
-
-/*
- *	Return the address of the start of the text segment prior to
- *	doing an unexec.  After unexec the return value is undefined.
- *	See crt0.c for further explanation and _start.
- *
- */
-
-#if !(defined (__NetBSD__) && defined (__ELF__))
-#ifndef HAVE_TEXT_START
-char *
-start_of_text (void)
-{
-#ifdef TEXT_START
-  return ((char *) TEXT_START);
-#else
-  extern int _start ();
-  return ((char *) _start);
-#endif /* TEXT_START */
-}
-#endif /* not HAVE_TEXT_START */
-#endif
-
-/*
- *	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.
- *
- *	On Uniplus+ systems with shared text, data starts at a
- *	fixed address.  Each port (from a given oem) is generally
- *	different, and the specific value of the start of data can
- *	be obtained via the UniPlus+ specific "uvar" system call,
- *	however the method outlined in crt0.c seems to be more portable.
- *
- *	Probably what will have to happen when a USG unexec is available,
- *	at least on UniPlus, is temacs will have to be made unshared so
- *	that text and data are contiguous.  Then once loadup is complete,
- *	unexec will produce a shared executable where the data can be
- *	at the normal shared text boundary and the startofdata variable
- *	will be patched by unexec to the correct value.
- *
- */
-
-#ifndef start_of_data
-char *
-start_of_data (void)
-{
-#ifdef DATA_START
-  return ((char *) DATA_START);
-#else
-#ifdef 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.
-   */
-  extern char **environ;
-
-  return ((char *) &environ);
-#else
-  extern int data_start;
-  return ((char *) &data_start);
-#endif /* ORDINARY_LINK */
-#endif /* DATA_START */
-}
-#endif /* start_of_data */
-#endif /* NEED_STARTS (not CANNOT_DUMP or not SYSTEM_MALLOC) */
-
 /* init_system_name sets up the string for the Lisp function
    system-name to return. */
 
@@ -1912,7 +1832,6 @@
   /* XXX This needs to be updated for multi-tty support.  Is there
      anybody who needs to emulate select these days?  */
   int nread, i;
-  extern int quit_char;
 
   if (read_socket_hook)
     {
--- a/src/unexaix.c	Wed Jul 07 19:37:32 2010 -0700
+++ b/src/unexaix.c	Wed Jul 07 20:03:52 2010 -0700
@@ -71,7 +71,7 @@
 #include <unistd.h>
 #include <fcntl.h>
 
-extern char *start_of_text (void);		/* Start of text */
+char *start_of_text (void);		        /* Start of text */
 extern char *start_of_data (void);		/* Start of initialized data */
 
 extern int _data;
@@ -669,5 +669,18 @@
   return 0;
 }
 
+/*
+ *	Return the address of the start of the text segment prior to
+ *	doing an unexec.  After unexec the return value is undefined.
+ *	See crt0.c for further explanation and _start.
+ *
+ */
+
+char *
+start_of_text (void)
+{
+  return ((char *) 0x10000000);
+}
+
 /* arch-tag: 0783857a-7c2d-456f-a426-58b722d69fd0
    (do not change this comment) */
--- a/src/unexalpha.c	Wed Jul 07 19:37:32 2010 -0700
+++ b/src/unexalpha.c	Wed Jul 07 20:03:52 2010 -0700
@@ -79,8 +79,10 @@
 #define	_RDATA		".rdata"
 #define	_SDATA		".sdata"
 #define	_SBSS		".sbss"
+#define TEXT_START     0x120000000
 #endif /* __NetBSD__ || __OpenBSD__ */
 
+
 static void fatal_unexec (char *, char *);
 static void mark_x (char *);
 
--- a/src/unexec.c	Wed Jul 07 19:37:32 2010 -0700
+++ b/src/unexec.c	Wed Jul 07 20:03:52 2010 -0700
@@ -687,6 +687,21 @@
   return 0;
 }
 
+extern unsigned start __asm__ ("start");
+
+/*
+ *	Return the address of the start of the text segment prior to
+ *	doing an unexec.  After unexec the return value is undefined.
+ *	See crt0.c for further explanation and _start.
+ *
+ */
+
+char *
+start_of_text (void)
+{
+  return ((char *) &start);
+}
+
 /* ****************************************************************
  * unexec
  *
--- a/src/vm-limit.c	Wed Jul 07 19:37:32 2010 -0700
+++ b/src/vm-limit.c	Wed Jul 07 20:03:52 2010 -0700
@@ -244,6 +244,46 @@
     (*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.
+ *
+ */
+
+POINTER
+start_of_data (void)
+{
+#ifdef BSD_SYSTEM
+  extern char etext;
+  return (POINTER)(&etext);
+#elif defined DATA_START
+  return ((POINTER) 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.
+   */
+  extern char **environ;
+  return ((POINTER) &environ);
+#else
+  extern int data_start;
+  return ((POINTER) &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.  */