summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2012-05-30 12:23:37 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2012-05-30 12:23:37 -0700
commit9e4bf381b7f2ffa95c64cac0cd8015152a33289c (patch)
tree81ec2f9d47a0fb963ab83083c5ca849c3f85b9ba
parent6e8a178669e918fb40a0cffce00757b2caae973d (diff)
downloademacs-9e4bf381b7f2ffa95c64cac0cd8015152a33289c.tar.gz
Clean up __executable_start, monstartup when --enable-profiling.
The following changes affect the code only when profiling. * dispnew.c (__executable_start): Rename from safe_bcopy. Define only on platforms that need it. * emacs.c: Include <sys/gmon.h> when profiling. (_mcleanup): Remove decl, since <sys/gmon.h> does it now. (__executable_start): Remove decl, since lisp.h does it now. (safe_bcopy): Remove decl; no longer has that name. (main): Coalesce #if into single bit of code, for simplicity. Cast pointers to uintptr_t, since standard libraries want integers and not pointers. * lisp.h (__executable_start): New decl.
-rw-r--r--src/ChangeLog15
-rw-r--r--src/dispnew.c10
-rw-r--r--src/emacs.c30
-rw-r--r--src/lisp.h4
4 files changed, 34 insertions, 25 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index c21c21deb9a..767dfa47036 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,18 @@
+2012-05-30 Paul Eggert <eggert@cs.ucla.edu>
+
+ Clean up __executable_start, monstartup when --enable-profiling.
+ The following changes affect the code only when profiling.
+ * dispnew.c (__executable_start): Rename from safe_bcopy.
+ Define only on platforms that need it.
+ * emacs.c: Include <sys/gmon.h> when profiling.
+ (_mcleanup): Remove decl, since <sys/gmon.h> does it now.
+ (__executable_start): Remove decl, since lisp.h does it now.
+ (safe_bcopy): Remove decl; no longer has that name.
+ (main): Coalesce #if into single bit of code, for simplicity.
+ Cast pointers to uintptr_t, since standard libraries want integers
+ and not pointers.
+ * lisp.h (__executable_start): New decl.
+
2012-05-30 Jim Meyering <meyering@redhat.com>
* callproc.c (Fcall_process_region): Include directory component
diff --git a/src/dispnew.c b/src/dispnew.c
index d8808de3caa..a23f2b9a959 100644
--- a/src/dispnew.c
+++ b/src/dispnew.c
@@ -332,11 +332,13 @@ DEFUN ("dump-redisplay-history", Fdump_redisplay_history,
#endif /* GLYPH_DEBUG == 0 */
-#if defined PROFILING && !HAVE___EXECUTABLE_START
-/* FIXME: only used to find text start for profiling. */
-
+#if (defined PROFILING \
+ && (defined __FreeBSD__ || defined GNU_LINUX || defined __MINGW32__) \
+ && !HAVE___EXECUTABLE_START)
+/* This function comes first in the Emacs executable and is used only
+ to estimate the text start for profiling. */
void
-safe_bcopy (const char *from, char *to, int size)
+__executable_start (void)
{
abort ();
}
diff --git a/src/emacs.c b/src/emacs.c
index d3e8e4466e3..8ffacdab1c6 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -65,6 +65,12 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include "nsterm.h"
#endif
+#if (defined PROFILING \
+ && (defined __FreeBSD__ || defined GNU_LINUX || defined __MINGW32__))
+# include <sys/gmon.h>
+extern void moncontrol (int mode);
+#endif
+
#ifdef HAVE_X_WINDOWS
#include "xterm.h"
#endif
@@ -320,9 +326,9 @@ pthread_t main_thread;
#ifdef HAVE_NS
/* NS autrelease pool, for memory management. */
static void *ns_pool;
-#endif
+#endif
+
-
/* Handle bus errors, invalid instruction, etc. */
#ifndef FLOAT_CATCH_SIGILL
@@ -1664,32 +1670,14 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
#ifdef PROFILING
if (initialized)
{
- extern void _mcleanup ();
#ifdef __MINGW32__
extern unsigned char etext asm ("etext");
#else
extern char etext;
#endif
-#ifdef HAVE___EXECUTABLE_START
- /* This symbol is defined by GNU ld to the start of the text
- segment. */
- extern char __executable_start[];
-#else
- extern void safe_bcopy ();
-#endif
atexit (_mcleanup);
-#ifdef HAVE___EXECUTABLE_START
- monstartup (__executable_start, &etext);
-#else
- /* This uses safe_bcopy because that function comes first in the
- Emacs executable. It might be better to use something that
- gives the start of the text segment, but start_of_text is not
- defined on all systems now. */
- /* FIXME: Does not work on architectures with function
- descriptors. */
- monstartup (safe_bcopy, &etext);
-#endif
+ monstartup ((uintptr_t) __executable_start, (uintptr_t) &etext);
}
else
moncontrol (0);
diff --git a/src/lisp.h b/src/lisp.h
index a05e3075ec7..de627b9f4ad 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -2758,6 +2758,10 @@ extern void replace_range_2 (ptrdiff_t, ptrdiff_t, ptrdiff_t, ptrdiff_t,
extern void syms_of_insdel (void);
/* Defined in dispnew.c */
+#if (defined PROFILING \
+ && (defined __FreeBSD__ || defined GNU_LINUX || defined __MINGW32__))
+void __executable_start (void) NO_RETURN;
+#endif
extern Lisp_Object selected_frame;
extern Lisp_Object Vwindow_system;
EXFUN (Fding, 1);