[Message Prev][Message Next][Thread Prev][Thread Next][Message Index][Thread Index]
[MD:2819]Portable dumper
- X-ml-count: 2819
- Subject: [MD:2819]Portable dumper
- From: Yoshiki Hayashi <yoshiki@xxxxxxxxxx>
- Date: 17 Jan 2002 14:02:28 +0900
- User-agent: T-gnus/6.15.3 (based on Oort Gnus v0.03) (revision 06)
Yoshiki Hayashi <yoshiki@xxxxxxxxxx> writes:
> 今の local と前の patch の差分は次の mail で送ります。
というわけで、patch です。前の pach をあてた後、top
directory に移動して patch -p0 < 65.diff としてあててくださ
い。autoconf; ./configure --with-pdump; make で
pdump 版の Emacs ができるようになっています。ただし、
emacs.dmp を発見する code はまだ書いていないので、cd src;
./emacs としないと起動しません。
# Solaris では動かなかった。ただいま debug 中。(;_;)
# 結局 Solaris の man をみると stdio.h は include しなければ
# いけないもよう。
Index: ./configure.in
===================================================================
--- ./configure.in
+++ ./configure.in Wed Jan 16 23:18:05 2002
@@ -66,6 +66,13 @@
esac
with_x_toolkit=$val
])
+AC_ARG_WITH(pdump,
+[ --with-pdump use portable dumper],
+[ case "${withval}" in
+ n | no ) ;;
+ *) AC_DEFINE(PDUMP) ;;
+ esac
+])
#### Make srcdir absolute, if it isn't already. It's important to
#### avoid running the path through pwd unnecessary, since pwd can
Index: ./src/dispnew.c
===================================================================
--- ./src/dispnew.c
+++ ./src/dispnew.c Wed Jan 16 23:54:41 2002
@@ -1955,7 +1955,7 @@
session's frames, frame names, buffers, buffer-read-only flags, and
buffer-modified-flags, and a trailing sentinel (so we don't need to
add length checks). */
-Lisp_Object frame_and_buffer_state;
+static Lisp_Object frame_and_buffer_state;
DEFUN ("frame-or-buffer-changed-p", Fframe_or_buffer_changed_p,
Sframe_or_buffer_changed_p, 0, 0, 0,
@@ -2639,6 +2639,12 @@
}
void
+reinit_syms_of_display ()
+{
+ frame_and_buffer_state = Fmake_vector (make_number (20), Qlambda);
+}
+
+void
syms_of_display ()
{
defsubr (&Sredraw_frame);
@@ -2650,8 +2656,8 @@
defsubr (&Ssleep_for);
defsubr (&Ssend_string_to_terminal);
- frame_and_buffer_state = Fmake_vector (make_number (20), Qlambda);
- staticpro (&frame_and_buffer_state);
+ reinit_syms_of_display ();
+ staticpro_nopdump (&frame_and_buffer_state);
Qdisplay_table = intern ("display-table");
staticpro (&Qdisplay_table);
Index: ./src/lisp.h
===================================================================
--- ./src/lisp.h
+++ ./src/lisp.h Wed Jan 16 23:16:57 2002
@@ -19,7 +19,6 @@
Boston, MA 02111-1307, USA. */
-#define PDUMP
/* These are default choices for the types to use. */
#ifndef EMACS_INT
#define EMACS_INT int
Index: ./src/buffer.c
===================================================================
--- ./src/buffer.c
+++ ./src/buffer.c Thu Jan 17 00:50:02 2002
@@ -68,7 +68,7 @@
/* A Lisp_Object pointer to the above, used for staticpro */
-Lisp_Object Vbuffer_defaults;
+static Lisp_Object Vbuffer_defaults;
/* This structure marks which slots in a buffer have corresponding
default values in buffer_defaults.
@@ -100,7 +100,7 @@
struct buffer buffer_local_symbols;
/* A Lisp_Object pointer to the above, used for staticpro */
-Lisp_Object Vbuffer_local_symbols;
+static Lisp_Object Vbuffer_local_symbols;
/* This structure holds the required types for the values in the
buffer-local slots. If a slot contains Qnil, then the
@@ -3843,8 +3843,6 @@
void
reinit_buffer_once_2 ()
{
- buffer_defaults.major_mode = Qfundamental_mode;
-
Vprin1_to_string_buffer = Fget_buffer_create (build_string (" prin1"));
/* super-magic invisible buffer */
@@ -3973,6 +3971,7 @@
QSFundamental = build_string ("Fundamental");
Qfundamental_mode = intern ("fundamental-mode");
+ buffer_defaults.major_mode = Qfundamental_mode;
Qmode_class = intern ("mode-class");
@@ -4055,12 +4054,12 @@
last_overlay_modification_hooks
= Fmake_vector (make_number (10), Qnil);
- staticpro (&Vbuffer_defaults);
- staticpro (&Vbuffer_local_symbols);
+ staticpro_nopdump (&Vbuffer_defaults);
+ staticpro_nopdump (&Vbuffer_local_symbols);
staticpro (&Qfundamental_mode);
staticpro (&Qmode_class);
staticpro (&QSFundamental);
- staticpro (&Vbuffer_alist);
+ staticpro_nopdump (&Vbuffer_alist);
staticpro (&Qprotected_field);
staticpro (&Qpermanent_local);
staticpro (&Qkill_buffer_hook);
Index: ./src/print.c
===================================================================
--- ./src/print.c
+++ ./src/print.c Thu Jan 17 00:21:56 2002
@@ -1934,7 +1934,7 @@
Vprint_gensym_alist = Qnil;
/* prin1_to_string_buffer initialized in init_buffer_once in buffer.c */
- staticpro (&Vprin1_to_string_buffer);
+ staticpro_nopdump (&Vprin1_to_string_buffer);
defsubr (&Sprin1);
defsubr (&Sprin1_to_string);
Index: ./src/Makefile.in
===================================================================
--- ./src/Makefile.in
+++ ./src/Makefile.in Thu Jan 17 11:04:26 2002
@@ -807,6 +807,9 @@
all: emacs OTHER_FILES
emacs: temacs ${etc}DOC ${lisp}
+#ifdef PDUMP
+ ./temacs -nd -batch -l loadup dump
+#else
#ifdef CANNOT_DUMP
rm -f emacs
ln temacs emacs
@@ -817,6 +820,7 @@
./temacs -batch -l loadup dump
#endif /* ! defined (HAVE_SHM) */
#endif /* ! defined (CANNOT_DUMP) */
+#endif /* ! defined (PDUMP) */
-./emacs -q -batch -f list-load-path-shadows
/* We run make-docfile twice because the command line may get too long
Index: ./src/emacs.c
===================================================================
--- ./src/emacs.c
+++ ./src/emacs.c Thu Jan 17 11:13:58 2002
@@ -592,6 +592,29 @@
#endif /* DOUG_LEA_MALLOC */
+static void
+print_version_and_exit ()
+{
+ Lisp_Object tem;
+ tem = Fsymbol_value (intern ("emacs-version"));
+ if (!STRINGP (tem))
+ {
+ fprintf (stderr, "Invalid value of `emacs-version'\n");
+ exit (1);
+ }
+ else
+ {
+ printf ("GNU Emacs %s\n", XSTRING (tem)->data);
+ printf ("Copyright (C) 1999 Free Software Foundation, Inc.\n");
+ printf ("GNU Emacs comes with ABSOLUTELY NO WARRANTY.\n");
+ printf ("You may redistribute copies of Emacs\n");
+ printf ("under the terms of the GNU General Public License.\n");
+ printf ("For more information about these matters, ");
+ printf ("see the file named COPYING.\n");
+ exit (0);
+ }
+}
+
/* ARGSUSED */
int
main (argc, argv, envp)
@@ -607,6 +630,10 @@
struct rlimit rlim;
#endif
int no_loadup = 0;
+#ifdef PDUMP
+ int print_version = 0;
+ int no_dump = 0;
+#endif
#ifdef LINUX_SBRK_BUG
__sbrk (1);
@@ -621,43 +648,29 @@
argc = 0;
while (argv[argc]) argc++;
-#ifdef PDUMP
- {
- /* Looks like this has to be after sort_args.
- It uses xmalloc and malloc_initialize_hook depends on the value
- of initislized. */
- struct stat stat_ignored;
- if (stat ("emacs.dmp", &stat_ignored) == 0)
- initialized = 1;
- }
-#endif
-
- /* #### FIXME. Pdump should handle this option later. */
if (argmatch (argv, argc, "-version", "--version", 3, NULL, &skip_args)
/* We don't know the version number unless this is a dumped Emacs.
So ignore --version otherwise. */
- && initialized)
+#ifndef PDUMP
+ && initialized
+#endif
+ )
{
- Lisp_Object tem;
- tem = Fsymbol_value (intern ("emacs-version"));
- if (!STRINGP (tem))
- {
- fprintf (stderr, "Invalid value of `emacs-version'\n");
- exit (1);
- }
- else
- {
- printf ("GNU Emacs %s\n", XSTRING (tem)->data);
- printf ("Copyright (C) 1999 Free Software Foundation, Inc.\n");
- printf ("GNU Emacs comes with ABSOLUTELY NO WARRANTY.\n");
- printf ("You may redistribute copies of Emacs\n");
- printf ("under the terms of the GNU General Public License.\n");
- printf ("For more information about these matters, ");
- printf ("see the file named COPYING.\n");
- exit (0);
- }
+#ifdef PDUMP
+ print_version = 1;
+#else
+ print_version_and_exit ();
+#endif
}
+#ifdef PDUMP
+ if (argmatch (argv, argc, "-nd", "--no-dump-file", 6, NULL, &skip_args))
+ {
+ no_dump = 1;
+ fprintf (stderr, "found\n");
+ }
+#endif
+
/* Map in shared memory, if we are using that. */
#ifdef HAVE_SHM
if (argmatch (argv, argc, "-nl", "--no-shared-memory", 6, NULL, &skip_args))
@@ -678,11 +691,7 @@
{
extern int malloc_cookie;
/* This helps out unexnext.c. */
-#ifdef PDUMP
- if (0)
-#else
if (initialized)
-#endif /* PDUMP */
if (malloc_jumpstart (malloc_cookie) != 0)
printf ("malloc jumpstart failed!\n");
}
@@ -717,7 +726,11 @@
might define a smaller stack limit at that time. */
if (1
#ifndef CANNOT_DUMP
- && (!noninteractive || initialized)
+ && (!noninteractive
+#ifndef PDUMP
+ || initialized
+#endif
+ )
#endif
&& !getrlimit (RLIMIT_STACK, &rlim))
{
@@ -804,6 +817,9 @@
#endif
inhibit_window_system = 0;
+#ifdef PDUMP
+ initialized = ! no_dump;
+#endif
/* Handle the -t switch, which specifies filename to use as terminal */
while (1)
@@ -862,9 +878,7 @@
if (! noninteractive)
{
#ifdef BSD_PGRPS
-#ifndef PDUMP
if (initialized)
-#endif
{
inherited_pgroup = EMACS_GETPGRP (0);
setpgrp (0, getpid ());
@@ -883,10 +897,8 @@
/* Don't catch SIGHUP if dumping. */
if (1
#ifndef CANNOT_DUMP
-#ifndef PDUMP
&& initialized
#endif
-#endif
)
{
sigblock (sigmask (SIGHUP));
@@ -900,7 +912,8 @@
if (
#ifndef CANNOT_DUMP
- ! noninteractive || initialized
+ ! noninteractive
+ || initialized
#else
1
#endif
@@ -1004,7 +1017,7 @@
#ifdef PDUMP
else
{
- if (pdump_load ("emacs.dmp"))
+ if (pdump_load ())
{
fprintf (stderr, "emacs: failed to load dumped file\n");
exit (1);
@@ -1319,6 +1332,7 @@
/* Reinitialize cache from Vcoding_category_list */
Fupdate_coding_systems_internal ();
Fset_coding_priority_internal ();
+ reinit_syms_of_display ();
reinit_syms_of_editfns_1 ();
reinit_syms_of_editfns_2 ();
reinit_syms_of_insdel ();
@@ -1337,6 +1351,8 @@
#ifdef HAVE_NTGUI
reinit_syms_of_w32fns ();
#endif
+ if (print_version)
+ print_version_and_exit ();
}
#endif
@@ -1459,6 +1475,9 @@
#ifdef VMS
{ "-map", "--map-data", 130, 0 },
#endif
+#ifdef PDUMP
+ { "-nd", "--no-dump-file", 125, 0},
+#endif
{ "-t", "--terminal", 120, 1 },
{ "-nw", "--no-windows", 110, 0 },
{ "-batch", "--batch", 100, 0 },
@@ -1904,6 +1923,7 @@
#endif
#ifdef PDUMP
pdump ();
+ Fadd_name_to_file (build_string ("temacs"), build_string ("emacs"), Qt);
#else
#ifdef DOUG_LEA_MALLOC
malloc_state_ptr = malloc_get_state ();
Index: ./src/config.in
===================================================================
--- ./src/config.in
+++ ./src/config.in Wed Jan 16 23:16:53 2002
@@ -355,6 +355,9 @@
#define SIGTYPE RETSIGTYPE
#endif
+/* Define this if you are building with portable dumper. */
+#undef PDUMP
+
#ifdef emacs /* Don't do this for lib-src. */
/* Tell regex.c to use a type compatible with Emacs. */
#define RE_TRANSLATE_TYPE Lisp_Object
Index: ./src/minibuf.c
===================================================================
--- ./src/minibuf.c
+++ ./src/minibuf.c Thu Jan 17 00:00:11 2002
@@ -2123,7 +2123,7 @@
init_minibuf_once ()
{
reinit_minibuf_once ();
- staticpro (&Vminibuffer_list);
+ staticpro_nopdump (&Vminibuffer_list);
}
void
Index: ./src/puresize.h
===================================================================
--- ./src/puresize.h
+++ ./src/puresize.h Thu Jan 17 00:59:03 2002
@@ -60,7 +60,7 @@
#endif
/* Signal an error if OBJ is pure. */
-#if 1
+#ifdef PDUMP
#define CHECK_IMPURE(obj)
#else
#define CHECK_IMPURE(obj) \
@@ -72,19 +72,18 @@
/* Define PURE_P. */
+#ifdef PDUMP
+#define PURE_P(obj) 0
+#else
#ifdef VIRT_ADDR_VARIES
/* For machines like APOLLO where text and data can go anywhere
in virtual memory. */
extern EMACS_INT pure[];
-#if 1
-#define PURE_P(obj) 0
-#else
#define PURE_P(obj) \
((PNTR_COMPARISON_TYPE) XPNTR (obj) < (PNTR_COMPARISON_TYPE) ((char *) pure + PURESIZE) \
&& (PNTR_COMPARISON_TYPE) XPNTR (obj) >= (PNTR_COMPARISON_TYPE) pure)
-#endif /* 1 */
#else /* not VIRT_ADDR_VARIES */
#ifdef PNTR_COMPARISON_TYPE
@@ -104,3 +103,4 @@
#endif /* PNTR_COMPARISON_TYPE */
#endif /* VIRT_ADDRESS_VARIES */
+#endif /* PDUMP */
Index: ./src/frame.c
===================================================================
--- ./src/frame.c
+++ ./src/frame.c Thu Jan 17 00:29:28 2002
@@ -2271,7 +2271,7 @@
{
syms_of_frame_1 ();
- staticpro (&Vframe_list);
+ staticpro_nopdump (&Vframe_list);
DEFVAR_LISP ("terminal-frame", &Vterminal_frame,
"The initial frame-object, which represents Emacs's stdout.");
Index: ./src/alloc.c
===================================================================
--- ./src/alloc.c
+++ ./src/alloc.c Thu Jan 17 11:58:36 2002
@@ -1690,6 +1690,10 @@
int staticidx = 0;
+#define NSTATICSP 20
+Lisp_Object *staticpvec[NSTATICSP] = {0};
+int staticpidx = 0;
+
/* Put an entry in staticvec, pointing at the variable whose address is given */
void
@@ -1701,6 +1705,15 @@
abort ();
}
+void
+staticpro_nopdump (varaddress)
+ Lisp_Object *varaddress;
+{
+ staticpvec[staticpidx++] = varaddress;
+ if (staticpidx >= NSTATICSP)
+ abort ();
+}
+
struct catchtag
{
Lisp_Object tag;
@@ -1834,6 +1847,8 @@
for (i = 0; i < staticidx; i++)
mark_object (staticvec[i]);
+ for (i = 0; i < staticpidx; i++)
+ mark_object (staticpvec[i]);
for (tail = gcprolist; tail; tail = tail->next)
for (i = 0; i < tail->nvars; i++)
if (!XMARKBIT (tail->var[i]))
@@ -3191,22 +3206,7 @@
case Lisp_Vectorlike:
if (BUFFERP (obj) || WINDOWP (obj) || WINDOW_CONFIGURATIONP (obj)
|| FRAMEP (obj))
- {
- const char *msg;
- if (BUFFERP (obj))
- msg = "buffer";
- else if (WINDOWP (obj))
- msg = "obj";
- else if (WINDOW_CONFIGURATIONP (obj))
- msg = "window configuration";
- else if (FRAMEP (obj))
- msg = "frame";
- else
- msg = "";
- fprintf (stderr, "Trying to dump undumpable object %s %d\n",
- msg, obj);
- break;
- }
+ abort ();
else if (SUBRP (obj))
{
/* #### Relies on sizeof (char *) == sizeof (int)
@@ -3244,7 +3244,7 @@
}
else
{
- fprintf (stderr, "unsupported object %d\n", obj);
+ abort ();
break;
}
case Lisp_Symbol:
@@ -3568,10 +3568,9 @@
pdump_add_special_buffers ()
{
int i, offset;
- struct buffer *buffers[3];
- buffers[0] = &buffer_defaults;
- buffers[1] = &buffer_local_symbols;
- buffers[2] = NULL;
+ struct buffer *buffers[] = {&buffer_defaults,
+ &buffer_local_symbols,
+ NULL};
for (i = 0; buffers[i]; i++)
{
for (offset = (char *)&buffers[i]->undo_list - (char *)buffers[i];
@@ -3585,7 +3584,10 @@
pdump_write_special_buffers (FILE *pdump_stream)
{
int i, offset;
- struct buffer *buffers[4];
+ struct buffer *buffers[] = {&buffer_defaults,
+ &buffer_local_symbols,
+ &buffer_local_types,
+ NULL};
/* This one is special because all the fields are int, which are
immediate values. */
@@ -3594,10 +3596,6 @@
- (char *)&buffer_local_flags.undo_list),
1, pdump_stream);
- buffers[0] = &buffer_defaults;
- buffers[1] = &buffer_local_symbols;
- buffers[2] = &buffer_local_types;
- buffers[3] = NULL;
for (i = 0; buffers[i]; i++)
for (offset = (char *)&buffers[i]->undo_list - (char *)buffers[i];
offset < sizeof (struct buffer);
@@ -3611,12 +3609,9 @@
}
static char *pdump_objects_start;
-extern Lisp_Object Vminibuffer_list;
-extern Lisp_Object Vprin1_to_string_buffer;
-extern Lisp_Object Vbuffer_defaults, Vbuffer_local_symbols, Vbuffer_alist;
-extern Lisp_Object Vframe_list, Vterminal_frame;
+/* These two are DEFVAR'ed. */
+extern Lisp_Object Vterminal_frame;
extern Lisp_Object point_marker;
-extern Lisp_Object frame_and_buffer_state;
#include "coding.h" /* for emacs_code_class */
void
pdump ()
@@ -3625,24 +3620,11 @@
pdump_header_t header;
int pdump_fd; /* File descriptor of dumped data. */
FILE *pdump_stream; /* Stream of dumped data. */
- Lisp_Object saved_minibuf_list = Vminibuffer_list;
- Lisp_Object saved_prin1_to_string_buffer = Vprin1_to_string_buffer;
- Lisp_Object saved_buffer_defaults = Vbuffer_defaults;
- Lisp_Object saved_buffer_local_symbols = Vbuffer_local_symbols;
- Lisp_Object saved_buffer_alist = Vbuffer_alist;
- Lisp_Object saved_frame_list = Vframe_list;
- Lisp_Object saved_terminal_frame = Vterminal_frame;
+ Lisp_Object saved_terminal_frame;
Lisp_Object saved_point_marker = point_marker;
- Lisp_Object saved_frame_and_buffer_state = frame_and_buffer_state;
- Vminibuffer_list = Qnil;
- Vprin1_to_string_buffer = Qnil;
- Vbuffer_defaults = Qnil;
- Vbuffer_local_symbols = Qnil;
- Vbuffer_alist = Qnil;
- Vframe_list = Qnil;
+ saved_terminal_frame = Vterminal_frame;
Vterminal_frame = Qnil;
point_marker = Qnil;
- frame_and_buffer_state = Fmake_vector (make_number (20), Qlambda);
#undef open
pdump_fd = open ("emacs.dmp", O_WRONLY | O_CREAT | O_TRUNC, 0666);
@@ -3675,6 +3657,9 @@
root.val = pdump_forward_object (*staticvec[i]);
fwrite (&root, sizeof (root), 1, pdump_stream);
}
+
+ fwrite (&staticpidx, sizeof (staticpidx), 1, pdump_stream);
+ fwrite (staticpvec, sizeof (staticpvec[0]), staticpidx, pdump_stream);
fwrite (pdump_pointers, sizeof (pdump_pointers[0]),
pdump_pointers_index, pdump_stream);
pdump_write_special_buffers (pdump_stream);
@@ -3693,15 +3678,8 @@
}
fclose (pdump_stream);
close (pdump_fd);
- Vminibuffer_list = saved_minibuf_list;
- Vprin1_to_string_buffer = saved_prin1_to_string_buffer;
- Vbuffer_defaults = saved_buffer_defaults;
- Vbuffer_local_symbols = saved_prin1_to_string_buffer;
- Vbuffer_alist = saved_buffer_alist;
- Vframe_list = saved_frame_list;
Vterminal_frame = saved_terminal_frame;
point_marker = saved_point_marker;
- frame_and_buffer_state = saved_frame_and_buffer_state;
}
#define PDUMP_RELOCATE(obj, offset) \
@@ -3717,10 +3695,10 @@
static void pdump_relocate_objects (long offset);
int
-pdump_load (const char *filename)
+pdump_load ()
{
int i;
- int fd = open (filename, O_RDONLY);
+ int fd = open ("emacs.dmp", O_RDONLY);
char *ret;
long offset;
@@ -3746,6 +3724,8 @@
}
if (offset != 0)
pdump_relocate_objects (ret - pdump_header.offset);
+ read (fd, &staticpidx, sizeof (staticpidx));
+ read (fd, &staticpvec, sizeof (staticpvec[0]) * staticpidx);
for (i = 0; i < pdump_header.pointers_length; i++)
{
pdump_forward_pointer_t fp;
@@ -3768,11 +3748,10 @@
if (offset != 0)
{
int i, buff_offset;
- struct buffer *buffers[4];
- buffers[0] = &buffer_defaults;
- buffers[1] = &buffer_local_symbols;
- buffers[2] = &buffer_local_types;
- buffers[3] = NULL;
+ struct buffer *buffers[] = {&buffer_defaults,
+ &buffer_local_symbols,
+ &buffer_local_types,
+ NULL};
for (i = 0; buffers[i]; i++)
for (buff_offset = (char *)&buffers[i]->undo_list - (char *)buffers[i];
buff_offset < sizeof (struct buffer);
--
Yoshiki Hayashi