static pdumper_hook dump_hooks[24];
static int nr_dump_hooks = 0;
+static pdumper_hook dump_late_hooks[24];
+static int nr_dump_late_hooks = 0;
+
static struct
{
void *mem;
(void const *) dump_hooks[i]);
dump_emacs_reloc_immediate_int (ctx, &nr_dump_hooks, nr_dump_hooks);
+ for (int i = 0; i < nr_dump_late_hooks; ++i)
+ dump_emacs_reloc_to_emacs_ptr_raw (ctx, &dump_late_hooks[i],
+ (void const *) dump_late_hooks[i]);
+ dump_emacs_reloc_immediate_int (ctx, &nr_dump_late_hooks,
+ nr_dump_late_hooks);
+
for (int i = 0; i < nr_remembered_data; ++i)
{
dump_emacs_reloc_to_emacs_ptr_raw (ctx, &remembered_data[i].mem,
hook ();
}
+void
+pdumper_do_now_and_after_late_load_impl (pdumper_hook hook)
+{
+ if (nr_dump_late_hooks == ARRAYELTS (dump_late_hooks))
+ fatal ("out of dump hooks: make dump_late_hooks[] bigger");
+ dump_late_hooks[nr_dump_late_hooks++] = hook;
+ hook ();
+}
+
static void
pdumper_remember_user_data_1 (void *mem, int nbytes)
{
dump_do_all_dump_reloc_for_phase (header, dump_base, LATE_RELOCS);
dump_do_all_dump_reloc_for_phase (header, dump_base, VERY_LATE_RELOCS);
+
+ /* Run the functions Emacs registered for doing post-dump-load
+ initialization. */
+ for (int i = 0; i < nr_dump_late_hooks; ++i)
+ dump_late_hooks[i] ();
+
initialized = true;
struct timespec load_timespec =
typedef void (*pdumper_hook)(void);
extern void pdumper_do_now_and_after_load_impl (pdumper_hook hook);
+extern void pdumper_do_now_and_after_late_load_impl (pdumper_hook hook);
INLINE void
pdumper_do_now_and_after_load (pdumper_hook hook)
#endif
}
+/* Same as 'pdumper_do_now_and_after_load' but for hooks running code
+ that can call into Lisp. */
+INLINE void
+pdumper_do_now_and_after_late_load (pdumper_hook hook)
+{
+#ifdef HAVE_PDUMPER
+ pdumper_do_now_and_after_late_load_impl (hook);
+#else
+ hook ();
+#endif
+}
+
/* Macros useful in pdumper callback functions. Assign a value if
we're loading a dump and the value needs to be reset to its
original value, and if we're initializing for the first time,
minibuf_selected_window = Qnil;
staticpro (&minibuf_selected_window);
- pdumper_do_now_and_after_load (init_window_once_for_pdumper);
+ pdumper_do_now_and_after_late_load (init_window_once_for_pdumper);
}
static void init_window_once_for_pdumper (void)