summaryrefslogtreecommitdiff
path: root/src/pdumper.c
Commit message (Collapse)AuthorAgeFilesLines
* Fix duplicated words in commentsRobert Pluim2019-10-151-2/+2
| | | | | | | | * src/coding.c (encode_string_utf_8): * src/keyboard.c (syms_of_keyboard): * src/mini-gmp.c (gmp_lucas_mod, mpz_export): * src/pdumper.c (dump_set_referrer, dump_queue_compute_score): * src/timefns.c (Ftime_convert): Remove duplicated words.
* * src/pdumper.c (dump_buffer): Update structure hash.Philipp Stephani2019-10-051-1/+1
|
* Fix compilation with CHECK_STRUCTSAndreas Schwab2019-09-221-1/+1
| | | | * src/pdumper.c (dump_buffer): Update hash of struct buffer.
* Improve checking of pdump load failuresPaul Eggert2019-09-111-3/+8
| | | | | | | | | | | | | | | | | | | | | | | * src/alloc.c (memory_full): Just report "memory exhausted" if failure occurs during initialization, since fancier recovery schemes are not likely to work when not initialized. * src/emacs.c (dump_error_to_string): Accept int, not enum pdumper_load_result, since the result might not fit in the enum. Use strerror if it was derived from errno. This is for better diagnostics of pdump load failures. (load_pdump_find_executable): Return char *, not enum. 2nd arg is now pointer to buffer size, rather than pointer to pointer to buffer. All callers changed. Use Emacs allocator since they should now be OK even during early startup. Use check_executable instead access, to use effective rather than real permissions. (load_pdump): Return void since callers ignore result. Use int where enum could be too narrow. Use heap rather than stack for possibly-long string. Prefer ptrdiff_t to size_t. * src/fileio.c (check_executable): Now extern. * src/pdumper.c (pdumper_load): Return int that may have errno added to it, for better diagnostics when loads fail.
* Port pdumper mmap to AIXPaul Eggert2019-09-041-1/+1
| | | | | * src/pdumper.c (needs_mmap_retry_p) [_AIX]: Return true. Problem observed on AIX 7.1 and 7.2 in GCC compile farm.
* Avoid macros in pdumper.c when it’s easyPaul Eggert2019-09-031-98/+98
| | | | | | | | | | | | | | | | | | | | | | | | | | Problem with DUMP_SET_REFERRER mentioned by Pip Cet at end of: https://lists.gnu.org/archive/html/emacs-devel/2019-07/msg00548.html * src/pdumper.c (DANGEROUS, EMACS_RELOC_TYPE_BITS) (EMACS_RELOC_LENGTH_BITS, DUMP_RELOC_TYPE_BITS) (DUMP_RELOC_ALIGNMENT_BITS, DUMP_RELOC_OFFSET_BITS) (DUMP_RELOCATION_ALIGNMENT, DUMP_ALIGNMENT) (WEIGHT_NONE, WEIGHT_NORMAL, WEIGHT_STRONG) (PDUMPER_MAX_OBJECT_SIZE): Now a constant, not a macro. (divide_round_up): Now a function, not a macro DIVIDE_ROUND_UP. All uses changed. (enum link_weight_enum, WEIGHT_NONE_VALUE) (WEIGHT_NORMAL_VALUE, WEIGHT_STRONG_VALUE): Remove. (struct link_weight): Just use an int. (dump_set_referrer): New function, replacing DUMP_SET_REFERRER macro with a different API. All uses changed. (dump_clear_referrer): Rename from DUMP_CLEAR_REFERRER. All uses changed. (DEFINE_FROMLISP_FUNC, DEFINE_TOLISP_FUNC): Remove. (intmax_t_from_lisp, intmax_t_to_lisp, dump_off_from_lisp) (dump_off_to_lisp): Define without using macros, (dump_off_from_lisp): Add an eassert range check. (DUMP_FIELD_COPY): Simplify.
* Avoid casting -1 to possibly-unsigned enumPaul Eggert2019-09-031-2/+2
| | | | | | | | | | | | | * src/alloc.c (mark_maybe_pointer): * src/pdumper.h (pdumper_object_p_precise): Use pdumper_valid_object_type_p. * src/pdumper.c (pdumper_find_object_type_impl): * src/pdumper.h (pdumper_find_object_type): Return int, not enum Lisp_Type. All callers changed. * src/pdumper.h (PDUMPER_NO_OBJECT): Do not cast -1 to enum Lisp_Type; in theory, C18 says this could yield 7, which would mean PDUMPER_NO_OBJECT == Lisp_Float (!). (pdumper_valid_object_type_p): New function.
* Fix compilation with CHECK_STRUCTSAndreas Schwab2019-08-311-1/+1
| | | | * src/pdumper.c (dump_hash_table): Update hash of Lisp_Hash_Table.
* Be more careful about pointers to bignum valsPaul Eggert2019-08-211-8/+7
| | | | | | | | | | | | | | | This uses ‘const’ to be better at catching bugs that mistakenly attempt to modify a bignum value. Lisp bignums are supposed to be immutable. * src/alloc.c (make_pure_bignum): * src/fns.c (sxhash_bignum): Accept Lisp_Object instead of struct Lisp_Bignum *, as that’s simpler now. Caller changed. * src/bignum.h (bignum_val, xbignum_val): New inline functions. Prefer them to &i->value and XBIGNUM (i)->value, since they apply ‘const’ to the result. * src/timefns.c (lisp_to_timespec): Use mpz_t const * to point to a bignum value.
* Re-port dump_bitset_clear to -fsanitize=undefinedPaul Eggert2019-08-061-1/+4
| | | | | | | * src/pdumper.c (dump_bitset_clear): Skip the memset if the size is zero, because in that case the destination might be NULL. This fixes a bug introduced in 2019-07-26T06:17:52Zeggert@cs.ucla.edu. Add a comment to make the bug less likely to reoccur.
* Fix compilation with CHECK_STRUCTSEli Zaretskii2019-08-051-1/+1
| | | | | * src/pdumper.c (dump_hash_table): Update hash of HASH_Lisp_Hash_Table. (Bug#36929)
* Adjust remaining uses of `NILP (HASH_HASH)`.Stefan Monnier2019-07-261-14/+19
| | | | | | | | * src/json.c (lisp_to_json_toplevel_1): * src/pdumper.c (dump_hash_table_stable_p, hash_table_contents): * src/print.c (print, print_vectorlike): * src/minibuf.c (Ftry_completion, Fall_completions, Ftest_completion): Use `EQ (HASH_KEY, Qunbound)` instead of `NILP (HASH_HASH)`.
* Don't dump the `hash` vector if it will need to be recomputed anywayStefan Monnier2019-07-261-2/+8
| | | | | | | | | | | * src/fns.c (hash_table_rehash): Only set `hash` field at the end. (sweep_weak_table): Only set slot of `hash` vector when that vector exists. (Fhash_table_count): No need to hash_rehash_if_needed any more. * src/lisp.h (hash_rehash_needed_p): Test the presence of `hash` instead. * src/pdumper.c (check_hash_table_rehash, dump_hash_table): Set `hash` to nil to indicate that the table needs to be rehashed.
* * src/fns.c (hash_index_size): New function, extracted from make_hash_tableStefan Monnier2019-07-261-3/+4
| | | | | | (make_hash_table, maybe_resize_hash_table): Use it. * src/pdumper.c (check_hash_table_rehash): Use hash_rehash_needed_p.
* Minor pdumper tweaksPaul Eggert2019-07-251-15/+12
| | | | | | | * src/pdumper.c (dump_hash_table_stable_p): Bool vectors and bignums are also stable keys. (decode_emacs_reloc, drain_reloc_list, Fdump_emacs_portable): (dump_bitset_clear): Simplify use of memset.
* Merge pdumper.c and alloc.c builtin symbol testsPaul Eggert2019-07-231-6/+1
| | | | | | | * src/alloc.c (c_symbol_p): Move from here ... * src/lisp.h (c_symbol_p): ... to here, and make it more portable to hypothetical platforms where pointers are wider than ptrdiff_t. * src/pdumper.c (dump_builtin_symbol_p): Use c_symbol_p.
* Improve pdumper doc; say unexec is deprecatedPaul Eggert2019-07-231-5/+5
| | | | | | | | | | | Say that pdumping cannot redump unless -batch is used. Say that the traditional unexec dumping method is by default not available, and is deprecated. Don't call dump files "portable", as dump files are not any more portable than the Emacs executables themselves. Just call them "dump files". Similar, prefer "portable dumper" (since the dumper code is portable) to "portable dumping" (since the dump file is not). Be more systematic about calling them "dump files" instead of "dumped images" or whatnot.
* Do not pdump user-defined hashtabsPaul Eggert2019-07-221-0/+2
| | | | | | * src/pdumper.c (dump_hash_table_stable_p): Signal an error if a hash table has user-defined tests (Bug#36769). * src/fns.c (hashfn_user_defined): Now extern.
* Fix crash if user test munges hash tablePaul Eggert2019-07-201-0/+1
| | | | | | | | | | | | | | | | | * src/fns.c (restore_mutability) (hash_table_user_defined_call): New functions. (cmpfn_user_defined, hashfn_user_defined): Use them. (make_hash_table, copy_hash_table): Mark new hash table as mutable. (check_mutable_hash_table): New function. (Fclrhash, Fputhash, Fremhash): Use it instead of CHECK_IMPURE. * src/lisp.h (struct hash_table_test): User-defined functions now take pointers to struct Lisp_Hash_Table, not to struct hash_table_test. All uses changed. (struct Lisp_Hash_Table): New member ‘mutable’. * src/pdumper.c (dump_hash_table): Copy it. * test/src/fns-tests.el (test-hash-function-that-mutates-hash-table): New test, which tests for the bug.
* Rename ‘pure’ to ‘purecopy’Paul Eggert2019-07-201-1/+1
| | | | | | * src/lisp.h (struct Lisp_Hash_Table): Rename ‘pure’ member to ‘purecopy’, as the old name was quite confusing (it did not mean the hash table was pure). All uses changed.
* Avoid interleaving stderr in dump_fingerprintPaul Eggert2019-07-131-6/+7
| | | | | | | | * src/fns.c (hexbuf_digest): New function, containing most of the old make_digest_string. (make_digest_string): Use it. * src/pdumper.c (dump_fingerprint): Rewrite to use a single fprintf call, to avoid interleaving on GNU/Linux.
* Replace Vdead with tagged pointerPaul Eggert2019-07-121-4/+1
| | | | | | | | | | | | | | This speeds up ‘make compile-always’ by 0.1% on my platform. Suggested by Pip Cet in: https://lists.gnu.org/r/emacs-devel/2019-07/msg00257.html * src/.gdbinit (pwinx, pgx, xbuffer, xprintstr): Output dead_object () as "DEAD". * src/alloc.c (Vdead, DEADP): Remove. All uses replaced by dead_object () / deadp. (deadp): New function. (init_alloc_once_for_pdumper): Remove no-longer-needed initialization. * src/lisp.h (dead_object): New function.
* Defend fingerprint against even-smarter LTOPaul Eggert2019-07-091-5/+7
| | | | | | | * src/pdumper.c (Fdump_emacs_portable, pdumper_load): Don’t cast volatile to non-volatile pointer, as that does not in general suffice to prevent a compiler from optimizing away memcmp and/or memcpy calls. Instead, copy the fingerprint by hand.
* Make fingerprint handling compatible with LTOAndreas Schwab2019-07-091-3/+5
| | | | | | | | | | Tell the compiler that the fingerprint variable is modified unpredictably. * lib/fingerprint.h (fingerprint): Remove const. * lib/fingerprint.c (fingerprint): Likewise. * src/pdumper.c (Fdump_emacs_portable): Cast fingerprint variable. (pdumper_load): Likewise. * lib-src/make-fingerprint.c (main): Likewise.
* Use fewer locks when accessing stdioPaul Eggert2019-07-081-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * src/alloc.c, src/bidi.c, src/emacs-module.c, src/pdumper.c: * src/regex-emacs.c, src/unexhp9k800.c, src/unexmacosx.c: * src/widget.c, src/xdisp.c, src/xselect.c, src/xterm.c: Include sysstdio.h instead of stdio.h, to avoid locking stdio streams in many cases. * src/alloc.c (test_setjmp): * src/bidi.c (bidi_dump_cached_states): * src/cm.c (calccost): * src/dispnew.c (init_display_interactive): * src/emacs.c (main): * src/image.c (convert_mono_to_color_image): * src/minibuf.c (read_minibuf_noninteractive): * src/nsfont.m (ns_descriptor_to_entity) (ns_dump_glyphstring): * src/nsterm.h (NSTRACE_MSG_NO_DASHES): * src/nsterm.m (ns_mouse_position) (sendEvent:, keyDown:, performDragOperation:): * src/pdumper.c (dump_fingerprint, print_paths_to_root_1): * src/print.c (debug_print): * src/regex-emacs.c (debug_putchar, print_fastmap) (print_partial_compiled_pattern, print_compiled_pattern) (print_double_string, regex_compile): * src/term.c (vfatal): * src/unexhp9k800.c (read_header): * src/unexmacosx.c (unexec_error): * src/widget.c (EmacsFrameInitialize): * src/xdisp.c (message_to_stderr, vmessage, dump_glyph_row) (Fdump_glyph_matrix, Fdump_frame_glyph_matrix, dump_glyph_string): * src/xfaces.c (Fdump_colors, Fdump_face): * src/xselect.c (x_clipboard_manager_error_2): * src/xterm.c (x_initialize): * src/xwidget.c (WEBKIT_FN_INIT): Prefer unlocked calls like fputs to locked calls like fprintf. * src/charset.c (read_hex): * src/cm.c (cmputc, cmcheckmagic): * src/dispnew.c (update_frame, update_frame_with_menu) (update_frame_1, Fsend_string_to_terminal, Fding) (bitch_at_user): * src/emacs.c (main, Fdump_emacs): * src/emacs-module.c (module_abort): * src/fileio.c (Fdo_auto_save): * src/image.c (slurp_file) (png_read_from_file, png_load_body, our_stdio_fill_input_buffer): * src/keyboard.c (record_char, kbd_buffer_get_event) (handle_interrupt): * src/lread.c (readbyte_from_stdio, read1): * src/minibuf.c (read_minibuf_noninteractive): * src/print.c (printchar_to_stream, strout) (Fredirect_debugging_output): * src/sysdep.c (reset_sys_modes, close_output_streams) (procfs_ttyname, procfs_get_total_memory): * src/term.c (tty_ring_bell, tty_send_additional_strings) (tty_set_terminal_modes, tty_reset_terminal_modes) (tty_update_end, tty_clear_end_of_line, tty_write_glyphs) (tty_write_glyphs_with_face, tty_insert_glyphs) (tty_menu_activate): * src/xfaces.c (Fx_load_color_file): Simplify by using ordinary calls like putc to explicitly-unlocked calls like putc_unlocked, since the ordinary calls are now unlocked anyway. * src/emacs.c (main, Fdump_emacs): * src/pdumper.c (Fdump_emacs_portable): Coalesce adjacent printfs. * src/nsterm.h: Include sysstdio.h as this file’s macros rely on it. * src/regex-emacs.c (print_compiled_pattern): Omit redundant fflush. * src/sysstdio.h: Include unlocked-io.h. (clearerr_unlocked, feof_unlocked, ferror_unlocked) (fflush_unlocked, fgets_unlocked, fputc_unlocked) (fputs_unlocked, fread_unlocked, fwrite_unlocked) (getc_unlocked, getchar_unlocked, putc_unlocked) (putchar_unlocked): Remove these macros; now done by unlocked-io.h. * src/xwidget.c: Include sysstdio.h.
* Fix arbitrary INT_MAX limit on referrer reprPaul Eggert2019-06-201-1/+2
| | | | | * src/pdumper.c (print_paths_to_root_1): Don’t assume strlen (repr) < INT_MAX.
* Update hash value in pdumper.cEli Zaretskii2019-06-151-1/+1
| | | | | * src/pdumper.c (dump_fwd_buffer_obj) [CHECK_STRUCTS]: Update the hash in HASH_Lisp_Buffer_Objfwd. (Bug#36225)
* Improve error message when dmpstruct.h needs to be updatedEli Zaretskii2019-06-151-25/+25
| | | | | | | | | | | | * src/pdumper.c (dump_cons, dump_interval_tree, dump_string) (dump_marker, dump_overlay, dump_finalizer) (dump_bignum, dump_float, dump_fwd_int, dump_fwd_bool) (dump_fwd_obj, dump_fwd_buffer_obj, dump_fwd_kboard_obj) (dump_fwd, dump_blv, dump_symbol, dump_vectorlike_generic) (dump_hash_table, dump_buffer, dump_bool_vector, dump_subr) (dump_vectorlike, dump_object, dump_charset) [CHECK_STRUCTS]: Make the error message more specific where to find the comment to CHECK_STRUCTS.
* Port to Oracle Developer Studio 12.6Paul Eggert2019-04-251-34/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This compiler is a bit pickier about checking conformance to the C standard, ranging from syntax trivia (no extra ";" at the top level) to portability trivia (warnings re conversion between function and data pointers) to more-important stuff like lack of support for some __attribute__ usages. * src/dynlib.c (dynlib_addr): First argument is a function pointer, not a data pointer. All callers changed. * src/emacs-module.c (module_function_address): Return module_funcptr, not void *. All uses changed. * src/lisp.h (module_funcptr) [HAVE_MODULES]: New type. * src/lread.c (union ieee754_double): Don’t assume the usual semantics for converting signed to unsigned int when initializing a bitfield, as the Oracle compiler complains and the C standard is unclear. * src/pdumper.c (ALLOW_IMPLICIT_CONVERSION): Make it clearer that -Wsign-conversion is disabled everywhere in this file. (dump_trace, dump_tailq_prepend, dump_tailq_append): Don’t assume __attribute__. (dump_object_self_representing_p): Don’t disable conversion warnings; it’s not needed here. (DEFINE_FROMLISP_FUNC): Avoid possible signal in integer conversion from unsigned to signed. (DEFINE_FROMLISP_FUNC, finish_dump_pvec): Avoid warning about unreachable statements on platforms not supporting the __attribute__. (intmax_t_from_lisp, intmax_t_to_lisp, dump_off_from_lisp) (dump_off_to_lisp, dump_emacs_reloc_immediate_lv) (dump_emacs_reloc_immediate_ptrdiff_t) (dump_emacs_reloc_immediate_intmax_t) (dump_emacs_reloc_immediate_int, dump_emacs_reloc_immediate_bool): Omit stray semicolon that violates C standard. (dump_metadata_for_pdumper): Add cast to pacify compiler complaining about conversion from function pointer to data pointer. (Fdump_emacs_portable): Do not use CALLN to call a function with zero arguments, as C99 prohibits empty initializers. * src/xdisp.c (syms_of_xdisp): Do not nest calls to pure_list, to work around a bug in Oracle Developer Studio 12.6.
* Fix drain_reloc_list alignment bugPaul Eggert2019-04-211-2/+3
| | | | | | | | | | | * src/pdumper.c (dump_charset): Use alignof (struct charset), not alignof (int), since struct charset might be more strictly aligned than int. I think this is just a minor performance issue, but we might as well use the correct alignment. (drain_reloc_list): Use an alignment instead of a size for the output alignment. This prevents undefined behavior when alignof (struct emacs_reloc) == 8 and sizeof (dump_off) == 4 when building on x86-64 with gcc -fsanitize=undefined.
* Port dump_bitset_clear to -fsanitize=undefinedPaul Eggert2019-04-211-1/+2
| | | | | | | * src/pdumper.c (dump_bitset_clear): Pacify -fsanitize=undefined by avoiding memset (NULL, x, 0), which strictly speaking has undefined behavior although it works on all production platforms I know.
* Fix double-free in pdumperPaul Eggert2019-04-211-3/+9
| | | | | | | | | Revert the double-free bug that I introduced in 2019-03-11T15:20:54Z!eggert@cs.ucla.edu. * src/pdumper.c (dump_mmap_reset): Do not free the private member; that’s the release function’s job. (dump_mm_heap_cb_release): Free cb if its refcount goes to zero. (dump_mmap_contiguous_heap): Mention memory leak in comment.
* Fix another hash false alarmPaul Eggert2019-04-191-1/+1
| | | | * src/pdumper.c (dump_vectorlike): Fix hash.
* Remove some #ifdefs for user pointers.Philipp Stephani2019-04-191-2/+0
| | | | | | | | | | | | | | | | | Even if Emacs is compiled without module support, we don't have to comment out every bit of user pointer support. Defining the basic structures and functions and detecting user pointers in switch statements is harmless, and we're already doing the same for module functions. Removing these #ifdefs makes the code a bit easier to read. * src/lisp.h (PVEC_USER_PTR, struct Lisp_User_Ptr, USER_PTRP) (XUSER_PTR): Define unconditionally. * src/data.c (Ftype_of): * src/alloc.c (cleanup_vector): * src/print.c (print_vectorlike): * src/pdumper.c (dump_vectorlike): Remove #ifdef for user pointers.
* Fix dump_map_file on unusual platformsPaul Eggert2019-04-191-1/+1
| | | | | * src/pdumper.c (dump_map_file): Fix recently-introduced typo on platforms that support neither POSIX nor MS-Windows VM.
* Mark _Noreturn error functions as coldPaul Eggert2019-04-181-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On my platform this made ‘make compile-always’ 1.3% faster. Suggested by Alex Gramiak in: https://lists.gnu.org/r/emacs-devel/2019-04/msg00684.html * configure.ac (nw): Don’t use -Wsuggest-attribute=cold. * lib-src/make-docfile.c (write_globals): Mark noreturn functions as cold. * src/callproc.c (exec_failed): * src/data.c (wrong_length_argument, wrong_type_argument): * src/emacs-module.c (module_abort): * src/emacs.c (terminate_due_to_signal): * src/eval.c (unwind_to_catch): * src/image.c (my_png_error, my_error_exit): * src/json.c (json_out_of_memory, json_parse_error): * src/keyboard.c (quit_throw_to_read_char, user_error): * src/lisp.h (die, wrong_type_argument, wrong_choice) (args_out_of_range, args_out_of_range_3, circular_list) (buffer_overflow, memory_full, buffer_memory_full) (string_overflow, xsignal, xsignal0, xsignal1, xsignal2) (xsignal3, signal_error, overflow_error, error, verror) (nsberror, report_file_errno, report_file_error) (report_file_notify_error, terminate_due_to_signal) (emacs_abort, fatal): * src/lread.c (load_error_old_style_backquotes) (end_of_file_error, invalid_syntax): * src/pdumper.c (error_unsupported_dump_object): * src/puresize.h (pure_write_error): * src/search.c (matcher_overflow): * src/sound.c (sound_perror, alsa_sound_perror): * src/sysdep.c (handle_arith_signal): * src/systime.h (time_overflow): * src/term.c (maybe_fatal, vfatal): * src/textprop.c (text_read_only): * src/timefns.c (invalid_time_zone_specification) (time_error, invalid_hz): * src/xterm.c (x_connection_closed): Use AVOID instead of _Noreturn void, so that it’s marked cold. * src/conf_post.h (__has_attribute_cold) [!__has_attribute]: New macro. (ATTRIBUTE_COLD): New macro. * src/frame.h (WINDOW_SYSTEM_RETURN): Add ATTRIBUTE_COLD. * src/lisp.h (AVOID): New macro. * src/xterm.c: Omit unnecessary static decls, so that we needn’t worry about which functions should be marked cold. (x_io_error_quitter): Mark as cold.
* Bring back dmpstruct.hPaul Eggert2019-04-101-0/+81
| | | | | | | | | | | | | | | | | | Bring back the dmpstruct.h checking, and use it when --enable-checking=structs is specified. The checking can be helpful to some developers, although it gets in the way of others and is not needed for ordinary tarball builds. * src/dmpstruct.awk: Restore this file, with mode 644 not 755. * configure.ac: New option-arg --enable-checking=structs, implied by --enable-checking. (CHECK_STRUCTS): New macro and var. * src/Makefile.in (CHECK_STRUCTS): New macro. (dmpstruct_headers, dmpstruct.h, dmpstruct.h): Restore these macros and rules. (pdumper.o): Restore this dependency if $(CHECK_STRUCTS) is true. (mostlyclean): Remove dmpstruct.h. * src/pdumper.c [CHECK_STRUCTS]: Include dmpstruct.h, and restore checks against hashes.
* Remove assumption of uint64_t etc. in portable codePaul Eggert2019-04-091-59/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | C11 doesn’t guarantee the existence of types like uint64_t, so avoid these types in portable code, as it’s easy to do so. There’s no need to avoid the types in w32-specific code, since w32 is guaranteed to have them. * lib-src/make-fingerprint.c (main): * src/fingerprint-dummy.c: * src/fingerprint.h: * src/pdumper.c (dump_fingerprint, struct dump_header): Prefer unsigned char to uint8_t in portable code, as either will do. Put an "#include <config.h>" in fingerprint.c files, so that the corresponding .o file is rebuilt after ./configure is run. * lib-src/make-fingerprint.c (main): Simplify loop. * src/Makefile.in (fingerprint.c): Update atomically. * src/pdumper.c: Omit unnecessary check that off_t is the same size as int32_t or int64_t, as the code does not rely on this assumption. (dump_off): Use int_least32_t, not int32_t. (struct dump_reloc): Use unsigned int, not uint32_t. (dump_anonymous_allocate_w32, dump_anonymous_allocate_posix) (dump_anonymous_allocate, dump_map_file_w32, dump_map_file_posix) (dump_map_file: Do the sanity checks at compile time, not at run-time, to avoid usage of uint64_t etc. on non-w32 platforms.
* Remove dmpstruct.hPaul Eggert2019-04-091-89/+0
| | | | | | | | | | | | | | | | The hassles of updating the dmpstruct.h-using code bit me again. These updates are more trouble than they’re worth. See: https://lists.gnu.org/r/emacs-devel/2019-03/msg00122.html As I’m the main person who’s made changes in this area since dmpstruct.h was introduced, I’m the most motivated to clean up the situation. * make-dist (possibly_non_vc_files): Remove src/dmpstruct.h. * src/Makefile.in (dmpstruct_headers, dmpstruct.h): Remove. (pdumper.o): Do not depend on dmpstruct.h. (mostlyclean): Do not remove dmpstruct.h. * src/dmpstruct.awk: Remove. * src/pdumper.c: Do not include dmpstruct.h. (CHECK_STRUCTS): Remove. All uses removed.
* Allow gap before first non-Lisp pseudovec memberPaul Eggert2019-04-081-2/+2
| | | | | | | | | | | | | Problem reported by Keith David Bershatsky in: https://lists.gnu.org/r/emacs-devel/2019-04/msg00259.html Solution suggested by Stefan Monnier in: https://lists.gnu.org/r/emacs-devel/2019-04/msg00282.html * src/buffer.h (BUFFER_LISP_SIZE): Simplify by using PSEUDOVECSIZE. (BUFFER_REST_SIZE): Simplify by using VECSIZE and BUFFER_LISP_SIZE. * src/lisp.h (PSEUDOVECSIZE): Base it on the last Lisp field, not the first non-Lisp field. All callers changed. Callers without Lisp fields changed to use ALLOCATE_PLAIN_PSEUDOVECTOR. (ALLOCATE_PLAIN_PSEUDOVECTOR): New macro.
* Improve commentary in 'field_relpos'Eli Zaretskii2019-04-031-1/+11
| | | | | | * src/pdumper.c (PDUMPER_MAX_OBJECT_SIZE): New macro. (field_relpos): Use PDUMPER_MAX_OBJECT_SIZE, and comment on why we require that relpos be not too large.
* Restore process-environment after portable dumpingEli Zaretskii2019-04-031-6/+9
| | | | | | | | | * src/pdumper.c (struct dump_context): New member old_process_environment. (Fdump_emacs_portable): Record the original value of process-environment. (dump_unwind_cleanup): Restore the original values of process-environment and post-gc-hook.
* Fix union Lisp_Fwd * alignment bugPaul Eggert2019-04-011-14/+12
| | | | | | | | | | | | | | It's not portable to cast (e.g.) struct Lisp_Objfwd * to union Lisp_Fwd * and then back again, because the compiler can then assume that the pointer is aligned for union Lisp_Fwd * when accessing the struct Lisp_Objfwd * components, and this assumption might be incorrect becase we don't force that alignment. * src/lisp.h (lispfwd): New type, replacing ... (union Lisp_Fwd): ... this type, which was removed. All uses changed. (SET_SYMBOL_FWD): 2nd arg is now void *, not lispfwd. All uses changed (casts no longer needed; they were not portable anyway).
* Don't run buffer-related hooks in " *code conversion work*" buffersEli Zaretskii2019-03-301-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | Note: portions of this change were mistakenly pushed as part of an unrelated commit a35a1f6a9. * src/buffer.c (Fget_buffer_create): Set inhibit_buffer_hooks non-zero for temporary buffers created by coding.c. Don't run buffer-list-update-hook for such buffers. (Frename_buffer, Fkill_buffer, record_buffer) (Fbury_buffer_internal): Don't run hooks for buffers whose inhibit_buffer_hooks flag is set. * src/buffer.h (struct buffer): New member inhibit_buffer_hooks. * src/pdumper.c (dump_buffer): Dump the new field. Update the hash value in HASH_buffer_XXX. * src/coding.c (make_conversion_work_buffer): Function deleted; code moved to code_conversion_save. (code_conversion_save): Insert code from make_conversion_work_buffer, but arrange for unwind-protecting the current buffer before switching to the work buffer. This avoids leaving reused_workbuf_in_use set if user presses C-g during encoding/decoding. (Vcode_conversion_workbuf_name): Now external variable. * src/coding.h (Vcode_conversion_reused_workbuf): Declare.
* Attempt to fix crashes under GDB on Windows 10Eli Zaretskii2019-03-271-1/+2
| | | | | | | * src/pdumper.c (dump_discard_mem) [VM_SUPPORTED == VM_MS_WINDOWS]: Don't pass NULL pointer as last argument to VirtualProtect. Reported by Martin Rudalics <rudalics@gmx.at>.
* Avoid duplicate entries in process-environment after re-dumpingEli Zaretskii2019-03-211-0/+6
| | | | | * src/pdumper.c (Fdump_emacs_portable): Reset process-environment to nil. (Bug#34936)
* Use ‘const’ to clarify GC markingPaul Eggert2019-03-191-4/+5
| | | | | | | | | | | | | | | | | | | Add ‘const’ to make the GC marking code a bit clearer. This can also help the compiler in some cases, I think because GCC can now determine more often that the value of a static C variable can be cached when its address is now converted to ‘Lisp Object const *’ before escaping. * src/alloc.c (staticvec, mark_maybe_objects, mark_memory) (mark_stack, staticpro, mark_object_root_visitor) (garbage_collect_1): * src/pdumper.c (dump_ptr_referrer, dump_emacs_reloc_to_lv) (dump_emacs_reloc_to_emacs_ptr_raw, dump_root_visitor): * src/lisp.h (vcopy, struct gc_root_visitor): * src/sysdep.c (stack_overflow): * src/thread.c (mark_one_thread): * src/thread.h (struct thread_state): Use pointer-to-const instead of plain pointer in some GC-related places where either will do.
* Fix 'define-charset' after dumping with pdumperEli Zaretskii2019-03-171-1/+5
| | | | | | | | * src/charset.h: * src/charset.c (charset_table_used): Now static. (charset_table_size): Now extern. * src/pdumper.c (dump_charset_table): Dump the entire charset_table, not just its used slots. (Bug#34826)
* Reindent pdumper per usual Emacs stylePaul Eggert2019-03-111-407/+326
| | | | * src/pdumper.c, src/pdumper.h: Reindent.
* Fix a small pdumper memory leakPaul Eggert2019-03-111-12/+8
| | | | | | | * src/pdumper.c (dump_mmap_reset): Free the private area here ... (dump_mm_heap_cb_release): ... instead of here. (dump_mmap_release_heap): Simplify by avoiding a local. (dump_mmap_contiguous): Reindent GNU style.