summaryrefslogtreecommitdiff
path: root/src/gmalloc.c
Commit message (Collapse)AuthorAgeFilesLines
* Add portable dumperDaniel Colascione2019-01-151-6/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a new portable dumper as an alternative to unexec. Use it by default. * src/dmpstruct.awk: New file. * src/doc.c (get_doc_string): use will_dump_p(). * src/editfns.c (styled_format): silence compiler warning with UNINIT. * src/emacs-module.c (syms_of_module): staticpro ltv_mark. * src/emacs.c (gflags): new variable. (init_cmdargs): unwrap (string_starts_with_p, find_argument, dump_error_to_string) (load_pdump): new functions. (main): detect pdumper and --temacs invocation; actually load portable dump when detected; set gflags as appropriate; changes to init functions throughout to avoid passing explicit 'initialized' argument. * src/eval.c (inhibit_lisp_code): remove unused variable. (init_eval_once_for_pdumper): new function. (init_eval_once): call it. * src/filelock.c: CANNOT_DUMP -> will_dump_p() * src/fingerprint-dummy.c: new file * src/fingerprint.h: new file * src/fns.c: CANNOT_DUMP -> will_dump_p(), etc. (weak_hash_tables): remove (hashfn_equal, hashfn_eql): un-staticify (make_hash_table): set new 'next_weak' hash table field; drop global weak_hash_tables logic. (copy_hash_table): drop global weak_hash_tables logic. (hash_table_rehash): new function. (hash_lookup, hash_put, hash_remove_from_table, hash_clear): rehash if needed. (sweep_weak_table): un-staticify; explain logic; bool-ify. (sweep_weak_hash_tables): remove function. * src/font.c (syms_of_font): remember pdumper stuff. * src/fontset.c (syms_of_fontset): remember pdumper stuff. * src/frame.c (make_initial_frame): don't reset Vframe_list. (init_frame_once_for_pdumper, init_frame_once): new functions. (syms_of_frame): remove redundant staticpro. * src/fringe.c (init_fringe_once_for_pdumper): new functin. (init_fringe_once): call it. * src/ftcrfont.c (syms_of_ftcrfont_for_pdumper): new function. (syms_of_ftcrfont): call it. * src/ftfont.c (syms_of_ftfont_for_pdumper): new function. (syms_of_ftfont): call it. * src/ftxont.c (syms_of_ftxfont_for_pdumper): new function. (syms_of_ftxfont): call it. * src/gmalloc.c: adjust for pdumper througout (DUMPED): remove weird custom dumped indicator. * src/gnutls.c (syms_of_gnutls): pdumper note for gnutls_global_initialized. * src/image.c (syms_of_image): add pdumper comment, initializer note. * src/insdel.c (prepare_to_modify_buffer_1): account for buffer contents possibly being in dump image. * src/keyboard.c (syms_of_keyboard_for_pdumper): new function. (syms_of_keyboard): staticpro more; call pdumper syms function. * src/lisp.h: add comments throughout (gflags): declare. (will_dump_p, will_bootstrap_p, will_dump_with_pdumper_p) (dumped_with_pdumper_p, will_dump_with_unexec_p) (dumped_with_unexec_p, definitely_will_not_unexec_p): new functions. (POWER_OF_2, ROUNDUP): move macros. (PSEUDOVECTOR_TYPE, PSEUDOVECTOR_TYPEP): take vectorlike header pointer instead of vector; constify. (Lisp_Hash_Table): add comment about need to rehash on access; add comment for next_weak. (HASH_KEY, HASH_VALUE, HASH_HASH, HASH_TABLE_SIZE): const-ify. (hash_table_rehash): declare. (hash_rehash_needed_p, hash_rehash_if_needed): new functions. (finalizers, doomed_finalizers): declare extern. (SUBR_SECTION_ATTRIBUTE): new macro. (staticvec, staticidx): un-static-ify. (sweep_weak_hash_tables): remove declaration. (sweep_weak_table): declare. (hashfn_eql, hashfn_equal): declare. (number_finalizers_run): new variable. (Vdead): externify when ENABLE_CHECKING. (gc_root_type): new enumeration. (gc_root_visitor): new struct. (visit_static_gc_roots): declare. (vectorlike_nbytes): declare. (vector_nbytes): define as trivial inline function wrapper for vectorlike_nbytes. (init_obarray_once): change signature. (primary_thread): extern-ify. (init_buffer): change signature. (init_frame_once): declare. * src/lread.c (readevalloop): adjust for new dumped predicates. (init_obarray_once): new function. (ndefsubr): new variable. (defsubr): increment it. (load_path_check): adjust for pdumper. (load_path_default): use pdumper functions; adjust for dump search. * src/macfont.m (macfont_init_font_change_handler): avoid shadowing global. (syms_of_macfont_for_pdumper): new function. (syms_of_macfont): call it. * src/menu.c (syms_of_menu): staticpro more stuff. * src/minibuf.c (Ftry_completion): rehash if needed. (init_minibuf_once_for_pdumper): new function. (init_minibuf_once): call it. * src/nsfont.m (syms_of_nsfns): staticpro more. * src/nsfont.m (syms_of_nsfont_for_pdumper): new function. (syms_of_nsfont): call it. * src/nsterm.m (syms_of_nsfont): remember pdumper stuff. * src/pdumper.c: new file. * src/pdumper.h: new file. * src/process.c (init_process_emacs): use new pdumper functions instead of CANNOT_DUMP. * src/profiler.c (syms_of_profiler_for_pdumper): new function. (syms_of_profiler_for_pdumper): call it. * src/search.c (syms_of_search_for_pdumper): new function. (syms_of_search_for_pdumper): call it. * src/sheap.c (bss_sbrk_did_unexec): remove. * src/sheap.h (bss_sbrk_did_unexec): remove. * src/syntax.c (syms_of_syntax): don't redundantly staticpro re_match_object. * src/sysdep.c: use will_dump_with_unexec_p() instead of bss hack thing. * src/syssignals.h (init_sigsegv): declare. * src/systime.h (init_timefns): remove bool from signature. * src/textprop.c (syms_of_textprop): move staticpro. * src/thread.c (main_thread_p): constify. * src/thread.h (main_thread_p): constify. * src/timefns.c (init_timefns): remove bool from signature. (syms_of_timefns_for_pdumper): new function. (syms_of_timefns): call it. * src/w32.c: rearrange code. * src/w32.h (w32_relocate): declare. * src/w32fns.c (syms_of_w32fns): add pdumper note. * src/w32font.c (syms_of_w32font_for_pdumper): new function. (syms_of_w32font): call it. * src/w32heap.c (using_dynamic_heap): new variable. (init_heap): use it. * src/w32menu.c (syms_of_w32menu): add pdumper note. * src/w32proc.c (ctrl_c_handler, mainCRTStartup, _start, open_input_file) (rva_to_section, close_file_data): move here. * src/w32uniscribe.c (syms_of_w32uniscribe_for_pdumper): new function. (syms_of_w32uniscribe): call it. * src/window.c (init_window_once_for_pdumper): new function. (init_window_once): call it; staticpro more stuff. * src/xfont.c (syms_of_xfont_for_pdumper): new function. (syms_of_xfont): call it. * src/xftfont.c (syms_of_xftfont_for_pdumper): new function. (syms_of_xftfont): call it. * src/xmenu.c (syms_of_xmenu_for_pdumper): new function. (syms_of_xmenu): call it. * src/xselect.c (syms_of_xselect_for_pdumper): new function. (syms_of_xselect): call it. * src/xsettings.c (syms_of_xsettings): add more pdumper notes. * src/term.c (syms_of_xterm): add pdumper note. * src/dispnew.c (init_faces_initial): new function. (init_display_interactive): rename from init_display; use will_dump_p instead of !initialized. Initialize faces early for pdumper if needed. (init_display): new function. (syms_of_display_for_pdumper): new function. (syms_of_display): call it. * src/dbusbind.c (syms_of_dbusbind): Add TODO for bus reset on pdumper load. * src/data.c (Fdefalias): Use will_dump_p instead of Vpurify_flag. (Fmake_variable_buffer_local): silence compiler warning with -Og by making valcontents UNINIT. (arith_driver): silence compiler warning with UNINIT. * src/conf_post.h (ATTRIBUTE_SECTION): new macro. * src/composite.c (composition_gstring_put_cache): rehash hash table if needed. * src/coding.c (init_coding_once, syms_of_coding): remember pdumper stuff. * src/charset.h (charset_table_size, charset_table_user): declare. * src/charset.c (charset_table_used, charset_table_size): un-static. (init_charset_oncem, syms_of_charset): remember pdumper stuff. * src/category.c (category_table_version): remove obsolete variable. * src/callint.c (syms_of_callint): staticpro 'preserved_fns' (init_callproc): use will_dump_p instead of !CANNOT_DUMP. * src/bytecode.c (exec_byte_code): rehash table tables if needed * src/buffer.c (alloc_buffer_text, free_buffer_text): account for pdumper (init_buffer_once): add TODO; remember stuff for pdumper. (init_buffer): don't take initialized argument; adjust for pdumper. * src/atimer.c (init_atimer): initialize subr only if !initialized. * src/alloc.c: (vector_marked_p, set_vector_marked) (vectorlike_marked_p, set_vectorlike_marked, cons_marked_p) (set_cons_marked, string_marked_p, set_string_marked) (symbol_marked_p, set_symbol_marked, interval_marked_p) (set_interval_marked): new accessor routines. Use them instead of raw GC access throughout. (Vdead): make non-static when ENABLE_CHECKING. (vectorlike_nbytes): rename of 'vector_nbytes'; take a vectorlike header as input instead of a vector. (number_finalizers_run): new internal C variable. (mark_maybe_object): check for pdumper objects. (valid_pointer_p): don't be gratuitously inefficient under rr(1). (make_pure_c_string): add support for size_byte = -2 mode indicating that string data points into Emacs image rodata. (visit_vectorlike_root): visits GC roots embedded in vectorlike objects. (visit_buffer_root): visits GC roots embedded in our totally-not-a-buffer buffer global objects. (visit_static_gc_roots): visit GC roots in the Emacs data section. (mark_object_root_visitor): root callback used for conventional GC marking (weak_hash_tables): new internal variable for tracking found weak hash tables during GC. (mark_and_sweep_weak_table_contents): new weak hash table marking. (garbage_collect_1): use new GC root visitor machinery. (mark_vectorlike): accept a vectorlike_header instead of a Lisp_Vector. (mark_frame, mark_window, mark_hash_table): new functions. (mark_object): initialize 'm'; check for pdumper objects and use new mark-bit accessors throughout. Remove some object-specific marking code and move to helper functions above. (survives_gc_p): check for pdumper objects. (gc-sweep): clear pdumper mark bits. (init_alloc_once_for_pdumper): new helper function for early init called both during normal init and pdumper load. (init_alloc_once): pdumper integration. * src/Makefile.in: Rewrite dumping for pdumper; add pdumper.o; invoke temacs with --temacs command line option; build dmpstruct.h from dmpstruct.awk; stop relying on CANNOT_DUMP; clean up pdumper intermediate files during build. * nextstep/Makefile.in: build emacs.pdmp into NS packages * lisp/startup.el: account for new '--temacs' and '--dump-file' command line option. * lisp/loadup.el: rewrite early init to account for pdumper; use injected 'dump-mode' variable (set via the new '--temacs' option) instead of parsing command line. * lisp/cus-start.el: Check 'dump-mode' instead of 'purify-flag', since the new 'dump-mode' * lib-src/make-fingerprint.c: new program * lib-src/Makefile.in: built make-fingerprint utility program * configure.ac: Add --with-pdumper toggle to control pdumper support; add --with-unexec toggle to control unexec support. Add --with-dumping option to control which dumping strategy we use by default. Adjust for pdumper throughout. Check for posix_madvise. * Makefile.in: Add @DUMPING@ substitution; add pdumper mode. * .gitignore: Add make-fingerprint, temacs.in, fingerprint.c, dmpstruct.h, and pdumper dump files.
* Merge from origin/emacs-26Paul Eggert2018-12-311-1/+1
|\ | | | | | | | | | | 2fcf2df Fix copyright years by hand 26bed8b Update copyright year to 2019 2814292 Fix value of default frame height. (Bug#33921)
| * Update copyright year to 2019Paul Eggert2019-01-011-1/+1
| | | | | | | | Run 'TZ=UTC0 admin/update-copyright $(git ls-files)'.
* | Assume ‘emacs’ is defined in Emacs-only codePaul Eggert2018-12-171-7/+1
| | | | | | | | | | | | | | * src/charset.c, src/coding.c, src/coding.h, src/gmalloc.c: * src/ralloc.c, src/regex-emacs.c: Simplify slightly by assuming that ‘emacs’ is defined. These modules have long been specific to Emacs, and are not used elsewhere.
* | Merge from origin/emacs-26Paul Eggert2018-01-011-1/+1
|\ \ | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 63b04c11d5 Fix copyright years by hand 5c7dd8a783 Update copyright year to 2018 220a9ecba1 Merge from Gnulib 312c565566 Don't add empty keyboard macro to macro ring (Bug#24992) 39ca289a7a Allow customization of decoding of "man" command f8240815ea * etc/NEWS: Add security consideration note on passphrase ... 0c78822c70 Fix subtle problem with scroll-down when scroll-margin is ... acd289c5a4 Fix problems with indexing in User manual b240c7846b * lisp/help.el (describe-key): Only (copy-sequence elt) wh... e879a5444a * src/buffer.c (Frestore_buffer_modified_p): Fix bug#29846 81b1028b63 Improve documentation of 'inhibit-modification-hooks' and ... 7175496d7a Fix doc string of 'enable-recursive-minibuffers' 5b38406491 Fix documentation of delsel and of killing text # Conflicts: # etc/NEWS # etc/refcards/ru-refcard.tex
| * Update copyright year to 2018Paul Eggert2018-01-011-1/+1
| | | | | | | | Run admin/update-copyright.
* | Narrow pointer bounds when appropriatePaul Eggert2017-12-121-3/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This typically occurs in a storage manager, where the caller is expected to access only the newly-allocated object, instead of using the returned value to access unrelated parts of the heap. * src/alloc.c (allocate_string, allocate_string_data) (compact_small_strings, find_string_data_in_pure) (sweep_strings, setup_on_free_list, allocate_vectorlike (pure_alloc): * src/bytecode.c (exec_byte_code): * src/callint.c (Fcall_interactively): * src/dispnew.c (scrolling): * src/editfns.c (styled_format): * src/frame.c (xrdb_get_resource, x_get_resource_string): * src/fringe.c (Fdefine_fringe_bitmap): * src/gmalloc.c (malloc, realloc, aligned_alloc): Narrow pointer bounds when appropriate. * src/alloc.c (SDATA_OF_STRING): * src/lisp.h (make_lisp_symbol) [__CHKP__]: Widen bounds here, though. * src/bytecode.c, src/callint.c, src/dispnew.c, src/editfns.c: * src/emacs.c, src/frame.c, src/fringe.c: Include ptr-bounds.h. * src/ptr-bounds.h (ptr_bounds_clip): New function.
* | Port to gcc -fcheck-pointer-boundsPaul Eggert2017-12-121-1/+5
|/ | | | | | | | | | | | | | | | | | | | | | This is a minimal port, just to get Emacs running; it does not attempt to make the pointer bounds at all tight. * src/ptr-bounds.h: New file. * src/alloc.c, src/gmalloc.c: Include it. * src/alloc.c (live_string_holding, live_cons_holding) (live_symbol_holding, live_misc_holding, garbage_collect_1) (sweep_conses, sweep_floats): * src/gmalloc.c (malloc_initialize_1, _free_internal_nolock) (_realloc_internal_nolock): Widen pointer bounds as necessary. We're in a memory allocator so this is OK. * src/lisp.h (lisp_h_XSYMBOL, make_lisp_symbol) [__CHKP__]: Do not convert from pointer to integer and back again, so that GCC does not lose track of pointer bounds. (XSYMBOL) [__CHKP__ && !USE_LSB_TAG]: Now a compile-time error. Although it's possible to support both -fcheck-pointer-bounds and --with-wide-int, it's more work; keep things simple for now. (DEFINE_LISP_SYMBOL) [__CHKP__]: Now a no-op, to avoid trouble with unbounded pointers.
* Use hybrid malloc for FreeBSD (Bug#28308)Noam Postavsky2017-11-041-5/+6
| | | | | | | | FreeBSD aarch64 does not provide sbrk, so gmalloc cannot be used; when using system malloc dumping does not work correctly (allocated data is invalid after dumping). * configure.ac: Set hybrid_malloc for freebsd. * src/gmalloc.c (gdefault_morecore) [!HAVE_SBRK]: Don't call sbrk.
* Prefer HTTPS to FTP and HTTP in documentationPaul Eggert2017-09-131-9/+9
| | | | | | | | | | | | | Most of this change is to boilerplate commentary such as license URLs. This change was prompted by ftp://ftp.gnu.org's going-away party, planned for November. Change these FTP URLs to https://ftp.gnu.org instead. Make similar changes for URLs to other organizations moving away from FTP. Also, change HTTP to HTTPS for URLs to gnu.org and fsf.org when this works, as this will further help defend against man-in-the-middle attacks (for this part I omitted the MS-DOS and MS-Windows sources and the test tarballs to keep the workload down). HTTPS is not fully working to lists.gnu.org so I left those URLs alone for now.
* Remove malloc_find_address relicPaul Eggert2017-06-211-11/+1
| | | | | * src/gmalloc.c (register_heapinfo, _malloc_internal_nolock): Omit unnecessary initialization.
* Fix temacs hybrid_malloc core dumpPaul Eggert2017-06-211-30/+41
| | | | | | | | | | | | | | | | | | | | | | | Without this patch, ./temacs would dump core sometimes on Fedora 25 x86-64. The problem was that the hybrid allocator assumed that all pointers into bss_sbrk_buffer are allocated via gmalloc. This assumption is not true on Fedora, because the standard memory allocator calls gdefault_morecore, which means its blocks are interleaved with our blocks. Usually the code happened to work, because our data structures agreed with the glibc data structures, but this was merely luck due to a shared pedigree, and as glibc mutates our luck has run out. * src/gmalloc.c (ALLOCATED_BEFORE_DUMPING) [HYBRID_MALLOC]: Remove; no longer needed. (BLOCK): Use unsigned division, as that does the right thing near zero. (register_heapinfo, __malloc_internal_nolock, __free_internal_nolock) (_realloc_internal_nolock): Big blocks now have type -1, not 0, as 0 now means the block is not ours. (morecore_nolock): Omit now-unnecessary casts to size_t. (allocated_via_gmalloc) [HYBRID_MALLOC]: New function. (hybrid_free, hybrid_realloc) [HYBRID_MALLOC]: Use it, to avoid calling the wrong free or realloc function in some cases.
* Merge from origin/emacs-25Paul Eggert2017-01-011-1/+1
|\ | | | | | | | | 2e2a806 Fix copyright years by hand 5badc81 Update copyright year to 2017
| * Update copyright year to 2017Paul Eggert2016-12-311-1/+1
| | | | | | | | Run admin/update-copyright.
| * Port --enable-gcc-warnings to bleeding-edge glibcPaul Eggert2016-10-231-7/+6
| | | | | | | | | | | | | | | | | | | | | | Bleeding-edge glibc sets emacs_cv_var_doug_lea_malloc to 'no'. Do not merge to master. * configure.ac: Check for valloc decl when compiling gmalloc.c. * src/gmalloc.c (emacs_abort) [emacs]: Adjust decl to match what is in lisp.h. Remove duplicate decl. (aligned_alloc): #undef before defining. (aligned_alloc, memalign) [!MSDOS]: Declare. (valloc) [HAVE_DECL_VALLOC]: Remove duplicate decl.
* | Port --enable-gcc-warnings to Ubuntu 16.10Paul Eggert2016-11-131-0/+1
| | | | | | | | | | | | | | * src/gmalloc.c: Include <stdlib.h>, so it declares hybrid_aligned_alloc (the definiens of the aligned_alloc macro), so that GCC doesn't complain that hybrid_aligned_alloc is defined without being declared.
* | Merge from origin/emacs-25Paul Eggert2016-10-251-4/+0
|\ \ | |/ | | | | | | | | | | ee04aed Fix handling of buffer relocation in regex.c functions 71ca4f6 Avoid relocating buffers while libxml2 reads its text 1b3fc8a ; Remove redundant code in gmalloc.c 9afea93 Attempt to catch reads from a buffer that is relocated
| * ; Remove redundant code in gmalloc.cEli Zaretskii2016-10-231-4/+0
| | | | | | | | | | * src/gmalloc.c [WINDOWSNT]: Remove MS-Windows only inclusion of w32heap.h, as the MS-Windows build no longer uses gmalloc.c.
* | Prefer now-standard int width macrosPaul Eggert2016-09-151-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * src/data.c (ULL_WIDTH): * src/lisp.h (EMACS_INT_WIDTH, BITS_PER_BITS_WORD): * src/lread.c (read_integer): * src/term.c (produce_glyphless_glyph): * src/xterm.c (x_send_scroll_bar_event): Use *_WIDTH macros instead of CHAR_BIT * sizeof. * src/data.c (ULL_WIDTH): Rename from BITS_PER_ULL for consistency with the *_WIDTH standard macros. All uses changed. * src/gmalloc.c (INT_BIT): Remove. All uses replaced with INT_WIDTH. * src/lisp.h (EMACS_INT_WIDTH): Rename from BITS_PER_EMACS_INT for consistency with the *_WIDTH standard macros. All uses changed. (BITS_PER_CHAR): Remove; all uses replaced by CHAR_BIT. This must be the same as CHAR_WIDTH and avoids confusion with Elisp char-width, which counts columns not bits. (BITS_PER_SHORT): Remove; all uses replaced by SHRT_WIDTH. (BITS_PER_LONG): Remove; all uses replaced by LONG_WIDTH. * src/lread.c: Do not include limits.h since CHAR_BIT is no longer used directly.
* | New macro GNUC_PREREQ for GCC versionPaul Eggert2016-06-121-1/+1
| | | | | | | | | | | | | | | | | | | | * src/conf_post.h (GNUC_PREREQ): New macro. Change uses of __GNUC_MINOR__ and __GNUC_PATCHLEVEL__ to use this macro instead, for clarity and consistency. (PRINTF_ARCHETYPE): New macro. Define it to __gnu_printf__ only if glibc, since non-GNU platforms don’t necessarily support GNU printf formats. (ATTRIBUTE_FORMAT_PRINTF): Use it.
* | Omit valloc decl if redundantPaul Eggert2016-02-091-4/+7
| | | | | | | | | | * src/gmalloc.c (valloc): Omit decl if malloc.h is included, to pacify --enable-gcc-warnings.
* | Restore the calloc family.Wolfgang Jenkner2016-02-091-3/+12
| | | | | | | | | | | | | | | | | | * src/gmalloc.c (calloc, gcalloc, hybrid_calloc): Restore definitions. They were lost in a4817d8 but calloc is still (marginally) used in code statically liked with emacs, so hybrid_calloc is needed. Also, in the non-hybrid case, we can't get rid of calloc anyway as other libraries liked with emacs may need it. * src/conf_post.h: Restore redefinition of calloc to hybrid_calloc.
* | Port new hybrid malloc to FreeBSDPaul Eggert2016-01-311-4/+7
| | | | | | | | | | | | Problem reported by Wolfgang Jenkner in: http://bugs.gnu.org/22086#118 * src/gmalloc.c (__malloc_initialize_hook, __after_morecore_hook) (__morecore) [HYBRID_MALLOC]: Define in this case too.
* | Fix extern symbols defined and not usedPaul Eggert2016-01-301-4/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | * src/alloc.c: Always include <signal.h>. (malloc_warning) [!SIGDANGER && (SYSTEM_MALLOC || HYBRID_MALLOC)]: Do not define; unused. * src/emacs.c, src/lisp.h (might_dump) [!DOUG_LEA_MALLOC]: Now static. * src/gmalloc.c (gdefault_morecore): Rename from __default_morecore, to avoid collision with glibc. Now static. All uses changed. * src/lastfile.c (my_edata): Define only if ((!defined SYSTEM_MALLOC && !defined HYBRID_MALLOC && !defined WINDOWSNT) \ || defined CYGWIN || defined DARWIN_OS). (Bug#22086)
* | Build lib/e-*.o only on platforms that need itPaul Eggert2016-01-301-7/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * configure.ac (hybrid malloc): Simplify configuration. (SHEAP_OBJ): Remove; no longer needed. (HYBRID_MALLOC): New var. Subst it. (HYBRID_MALLOC_LIB): New Automake conditional. * lib/Makefile.am (noinst_LIBRARIES): Add libegnu.a only if HYBRID_MALLOC_LIB. (libegnu_a_CPPFLAGS): Omit AM_CPPFLAGS; not needed. (MOSTLYCLEANFILES): Add libegnu.a. * src/Makefile.in (SHEAP_OBJ): Remove. (HYBRID_MALLOC): New macro. (base_obj): Use it to conditionally add sheap.o. (LIBEGNU_ARCHIVE): New macro. ($(LIBEGNU_ARCHIVE)): New rule, replacing $(lib)/libegnu.a. All uses of the latter replaced by the former. * src/alloc.c (USE_ALIGNED_ALLOC): Simplify configuration. Correct misspelling ALIGNED_ALLOC to HAVE_ALIGNED_ALLOC. * src/gmalloc.c: Update comment. * src/lisp.h (aligned_alloc) [!DOUG_LEA_MALLOC && !HYBRID_MALLOC && !SYSTEM_MALLOC]: New decl. (Bug#22086)
* | Include <malloc.h> when advisablePaul Eggert2016-01-301-89/+67
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This should help insulate us better from future glibc changes. It is good hygiene to include .h files for APIs that Emacs uses. Fix type clashes between Emacs and GNU <malloc.h> (Bug#22086). * configure.ac: Check for malloc.h. * src/alloc.c: Include <malloc.h> depending on HAVE_MALLOC_H, not on DOUG_LEA_MALLOC. * src/emacs.c, src/gmalloc.c (malloc_enable_thread): Remove decl (now in lisp.h). * src/gmalloc.c: Include stddef.h earlier, for ptrdiff_t. [emacs]: Include lisp.h. [HAVE_MALLOC_H]: Include <malloc.h>. (__MALLOC_HOOK_VOLATILE): New macro, if not already defined. (__after_morecore_hook, __malloc_initialize_hook, __morecore) (__default_morecore): [!HAVE_MALLOC_H]: New decls near non-inclusion of <malloc.h>. (calloc): Make it clear that the macro should not be used. Remove unused decl. (malloc_info): New macro, to avoid clash with glibc <malloc.h>. (__morecore, __default_morecore, __after_morecore_hook) (__malloc_extra_blocks, __malloc_initialize_hook, __free_hook) (__malloc_hook, __realloc_hook, __memalign_hook, memory_warnings): Remove later decls. (gmalloc_hook, gfree_hook, grealloc_hook): Rename from __malloc_hook, __free_hook, __realloc_hook to avoid type collision with glibc <malloc.h>. All uses changed. (gmalloc_hook): (__malloc_extra_blocks) [DOUG_LEA_MALLOC||HYBRID_MALLOC||SYSTEM_MALLOC]: Now static. (gmalloc_hook, __malloc_extra_blocks): Define even if [!HYBRID_MALLOC]. (__malloc_initialize_hook, __after_morecore_hook): Declare with types compatible with glibc. (__memalign_hook, hybrid_calloc) [HYBRID_MALLOC]: Remove. All uses removed. * src/lisp.h (__malloc_extra_blocks, malloc_enable_thread): New decls. * src/ralloc.c, src/vm-limit.c: Simplify includes and include <malloc.h> if available.
* | Pacify --enable-gcc-warnings when HYBRID_MALLOCPaul Eggert2016-01-301-38/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * src/buffer.c (init_buffer): * src/emacs.c (main): * src/xsmfns.c (smc_save_yourself_CB, x_session_initialize): Use emacs_get_current_dir_name, not get_current_dir_name. * src/conf_post.h (aligned_alloc) [HYBRID_MALLOC && emacs]: New macro. (HYBRID_GET_CURRENT_DIR_NAME, get_current_dir_name): Remove. * src/emacs.c: Include "sheap.h". (report_sheap_usage): Remove decl. (Fdump_emacs) [HYBRID_MALLOC]: Report usage directly. Don't assume ptrdiff_t can be printed as int. * src/gmalloc.c [HYBRID_MALLOC]: Include "sheap.h" rather than declaring its contents by hand. (get_current_dir_name, gget_current_dir_name) (hybrid_get_current_dir_name): Remove. (emacs_abort): Remove duplicate decl. (aligned_alloc): Undef, like malloc etc. (ALLOCATED_BEFORE_DUMPING): Now a static function, not a macro. Make it a bit more efficient. (malloc_find_object_address): Remove unused decl. (enum mcheck_status, mcheck, mprobe, mtrace, muntrace, struct mstats) (mstats, memory_warnings): Declare only if GC_MCHECK. * src/lisp.h (emacs_get_current_dir_name): New decl, replacing get_current_dir_name. * src/sheap.c: Include sheap.h first. (STATIC_HEAP_SIZE): Remove; now in sheap.h. (debug_sheap): Now static. (bss_sbrk_buffer_end): Remove; no longer used. (bss_sbrk_ptr): Now static and private. (bss_sbrk_did_unexec): Now bool. (BLOCKSIZE): Remove, to avoid GCC warning about its not being used. (bss_sbrk): Don't treat request_size 0 as special, since the code works without this being a special case. Avoid overflow if request size exceeds INT_MAX. (report_sheap_usage): Remove; now done in emacs.c. * src/sheap.h: New file. * src/sysdep.c (get_current_dir_name): Remove macro. Include "sheap.h". (emacs_get_current_dir_name): Rename function from get_current_dir_name. Handle HYBRID_MALLOC here; this is simpler. (Bug#22086)
* | Add musl patch to support HYBRID_MALLOC on elf systemsWolfgang Jenkner2016-01-301-2/+2
| | | | | | | | | | | | | | | | | | * src/gmalloc.c: Adjust for HYBRID_MALLOC in the non CYGWIN case. (__default_morecore): Here, in particular. * configure.ac: Define HYBRID_MALLOC when unexelf.o is used. New variable SHEAP_OBJ. * src/Makefile.in: Use it. (Bug#22086)
* | Internal linkage for gmalloc etc. if HYBRID_MALLOCWolfgang Jenkner2016-01-301-17/+41
|/ | | | | | | | | | | | | | | | | This avoids clashes with symbols if the after-dump malloc is derived from Doug Lea's implementation (Bug#22086). * src/gmalloc.c (emacs_abort, __morecore, __default_morecore): Move declarations up. For HYBRID_MALLOC, turn all `extern' declarations below to `static' ones. (aligned_alloc): Declare for !MSDOS as well. (heapsize, _fraghead): Move resp. copy declaration downwards. For HYBRID_MALLOC, conditionalize out the other definitions, since the previous `static' declarations double as tentative definitions, anyway. (_malloc, _free, _realloc, __free_hook, _aligned_blocks) (__realloc_hook, __memalign_hook): Conditionalize out. (cfree, memalign, valloc): Ditto.
* Update copyright year to 2016Paul Eggert2016-01-011-1/+1
| | | | Run admin/update-copyright.
* Always define gmalloc etc. in src/gmalloc.cWolfgang Jenkner2015-12-261-3/+33
| | | | | | | | | | This is a work-around to prevent the compiler from using semantic knowledge about malloc for optimization purposes. E.g., gcc 5.2 with -O2 replaces most of calloc's definition by a call to calloc; see Bug#22085. * src/gmalloc.c [!HYBRID_MALLOC] (malloc, realloc, calloc) (aligned_alloc, free): Do not undef. Instead, define these as functions (perhaps renamed to gmalloc etc.) in terms of gmalloc etc.
* Update copyright year to 2015Paul Eggert2015-01-011-1/+1
| | | | Run admin/update-copyright.
* Consistently use min and max macros from lisp.h.Dmitry Antipov2014-10-031-1/+1
| | | | | | | | | | * coding.c (min, max): * font.c (MAX): * unexhp9k800.c (min): * unexw32.c (min, max): Use definitions from lisp.h. * regex.c (MAX, MIN) [!emacs]: Define own max and min as such. Adjust users. * gmalloc.c (min): Tiny style change.
* * src/sheap.c (bss_sbrk_buffer_beg): Remove redundant variable.Ken Brown2014-09-281-2/+2
| | | | * src/gmalloc.c [CYGWIN]: Adapt to change in sheap.c.
* Fix implementation of HYBRID_MALLOC on Cygwin.Ken Brown2014-09-271-3/+3
| | | | | | | * src/sheap.c (bss_sbrk_buffer_end): Cast to void *. (bss_sbrk_buffer_beg): New variable. Use it... * src/gmalloc.c (ALLOCATED_BEFORE_DUMPING) [CYGWIN]: ...here, to fix incorrect definition.
* Fix bug#18368 with broken build on AIX due to HYBRID_MALLOC changes.Ken Brown2014-08-301-7/+11
| | | | | | * src/gmalloc.c: Don't include <stdlib.h>. Declare system malloc and friends before defining hybrid_malloc and friends if HYBRID_MALLOC is defined. (Bug#18368)
* Add support for HYBRID_MALLOC, allowing the use of gmalloc beforeKen Brown2014-08-281-82/+149
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | dumping and the system malloc after dumping. (Bug#18222) * configure.ac (HYBRID_MALLOC): New macro; define to use gmalloc before dumping and the system malloc after dumping. Define on Cygwin. * src/conf_post.h (malloc, realloc, calloc, free) [HYBRID_MALLOC]: Define as macros, expanding to hybrid_malloc, etc. (HYBRID_GET_CURRENT_DIR_NAME): New macro. (get_current_dir_name) [HYBRID_GET_CURRENT_DIR_NAME]: Define as macro. * src/gmalloc.c: Set up the infrastructure for HYBRID_MALLOC, with a full implementation on Cygwin. Remove Cygwin-specific code that is no longer needed. (malloc, realloc, calloc, free, aligned_alloc) [HYBRID_MALLOC]: Redefine as macros expanding to gmalloc, grealloc, etc. (DUMPED, ALLOCATED_BEFORE_DUMPING) [CYGWIN]: New macros. (get_current_dir_name) [HYBRID_GET_CURRENT_DIR_NAME]: Undefine. (USE_PTHREAD, posix_memalign) [HYBRID_MALLOC]: Don't define. (hybrid_malloc, hybrid_calloc, hybrid_free, hybrid_realloc) [HYBRID_MALLOC]: (hybrid_get_current_dir_name) [HYBRID_GET_CURRENT_DIR_NAME]: (hybrid_aligned_alloc) [HYBRID_MALLOC && (HAVE_ALIGNED_ALLOC || HAVE_POSIX_MEMALIGN)]: New functions. * src/alloc.c (aligned_alloc) [HYBRID_MALLOC && (ALIGNED_ALLOC || HAVE_POSIX_MEMALIGN)]: Define as macro expanding to hybrid_aligned_alloc; declare. (USE_ALIGNED_ALLOC) [HYBRID_MALLOC && (ALIGNED_ALLOC || HAVE_POSIX_MEMALIGN)]: Define. (refill_memory_reserve) [HYBRID_MALLOC]: Do nothing. * src/sysdep.c (get_current_dir_name) [HYBRID_GET_CURRENT_DIR_NAME]: Define as macro, expanding to gget_current_dir_name, and define the latter. * src/emacs.c (main) [HYBRID_MALLOC]: Don't call memory_warnings() or malloc_enable_thread(). Don't initialize malloc. * src/lisp.h (NONPOINTER_BITS) [CYGWIN]: Define (because GNU_MALLOC is no longer defined on Cygwin). (refill_memory_reserve) [HYBRID_MALLOC]: Don't declare. * src/sheap.c (bss_sbrk_buffer_end): New variable. * src/unexcw.c (__malloc_initialized): Remove variable. * src/ralloc.c: Throughout, treat HYBRID_MALLOC the same as SYSTEM_MALLOC. * src/xdisp.c (decode_mode_spec) [HYBRID_MALLOC]: Don't check Vmemory_full.
* Merge from emacs-24; up to 2014-06-29T18:32:35Z!michael.albinus@gmx.deGlenn Morris2014-08-141-1/+20
|\
| * * src/gmalloc.c (_malloc_mutex, _aligned_blocks_mutex) [CYGWIN]: Use ↵Ken Brown2014-08-111-1/+20
| | | | | | | | ERRORCHECK mutexes. (Bug#18222)
* | Supply malloc and alloc_size attributes for extern allocators.Paul Eggert2014-05-221-3/+3
|/ | | | | | | | | | | This documents the C API, and helps GCC generate a bit better code. * conf_post.h (ATTRIBUTE_MALLOC, ATTRIBUTE_ALLOC_SIZE) (ATTRIBUTE_MALLOC_SIZE): New macros. * gmalloc.c (malloc, realloc, calloc): * gtkutil.h (malloc_widget_value): * lisp.h (ralloc, r_re_alloc, xmalloc, xzalloc, xrealloc, xnmalloc) (xnrealloc, xstrdup, xlispstrdup, record_xmalloc): Use them.
* Further follow-up to last change in gmalloc.c.Ken Brown2014-03-041-11/+11
| | | | | * src/gmalloc.c (aligned_alloc): Clarify the code by making `adj' represent the actual adjustment needed for alignment.
* Follow-up improvements for last change in gmalloc.c.Eli Zaretskii2014-03-041-15/+28
| | | | | | | | src/gmalloc.c (aligned_alloc): Don't allocate more memory than needed, and don't reallocate if the initial allocation already fits the bill. Suggested by Ken Brown <kbrown@cornell.edu>. Fixes: debbugs:16901
* Fix crashes in lisp_align_free in a build with GC_MCHECK.Eli Zaretskii2014-03-031-2/+26
| | | | | | | | | | | src/gmalloc.c (aligned_alloc): Fix adjustment of size of the allocated buffer due to alignment. (freehook): If the block to be freed was allocated by 'aligned_alloc', find its real pointer before calling 'free'. (mabort) [emacs]: Call 'emacs_abort', not 'abort', to provide a backtrace. Fixes: debbugs:16901
* Update copyright year to 2014 by running admin/update-copyright.Paul Eggert2014-01-011-1/+1
|
* Merge from gnulib.Paul Eggert2013-11-081-5/+4
| | | | | | | | This incorporates: 2013-11-08 extern-inline: port better to OS X 10.9 2013-11-08 fpending: fix regression on DragonFly BSD * lib/fpending.h, m4/extern-inline.m4, m4/fpending.m4: Update from gnulib.
* Port to C11 aligned_alloc, and fix some integer overflows.Paul Eggert2013-11-061-10/+32
| | | | | | | | | | | | | | | | | | * configure.ac (GMALLOC_OBJ): Initialize to empty if !system_malloc and doug_lea_malloc. (aligned_alloc): Test for existence if !GMALLOC_OBJ and not darwin. (posix_memalign): Test for existence only if !GMALLOC_OBJ and not darwin and !aligned_alloc. * src/alloc.c (USE_ALIGNED_ALLOC): New symbol. (USE_POSIX_MEMALIGN): Remove. All uses replaced with USE_ALIGNED_ALLOC, and use of posix_memalign replaced with aligned_alloc. (aligned_alloc): New function, defined or declared as needed. * src/conf_post.h (HAVE_POSIX_MEMALIGN) [DARWIN_OS]: Don't undef; configure.ac now does this. * src/gmalloc.c (aligned_alloc) [MSDOS]: New decl. (calloc, aligned_alloc): Check for integer overflow. (aligned_alloc): Rename from memalign. All uses changed. (memalign): New function, an alias for aligned_alloc.
* Merge from emacs-24; up to 2012-12-06T01:39:03Z!monnier@iro.umontreal.caPaul Eggert2013-01-021-29/+11
|\
| * Update copyright notices for 2013.Paul Eggert2013-01-011-2/+2
| |
| * Use URLs, not Boston addresses, in copyright notices.Paul Eggert2012-12-311-27/+9
| |
* | Assume POSIX 1003.1-1988 or later for errno.h.Paul Eggert2012-11-261-8/+0
|/ | | | | | | | | | | | | | | * lib-src/movemail.c (main): Assume EAGAIN and EBUSY. * src/dired.c (directory_files_internal, file_name_completion): Assume EAGAIN and EINTR are defined. * src/fileio.c (Fcopy_file): Assume EISDIR is defined. * src/gmalloc.c (ENOMEM, EINVAL): Assume they're defined. * src/gnutls.c (emacs_gnutls_write): Assume EAGAIN is defined. * src/lread.c (readbyte_from_file): Assume EINTR is defined. * src/process.c (wait_reading_process_output, send_process) [subprocesses]: Assume EIO and EAGAIN are defined. * src/unexcoff.c (write_segment): Assume EFAULT is defined. Fixes: debbugs:12968