1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-02-04 06:31:13 -08:00
Commit graph

49190 commits

Author SHA1 Message Date
Paul Eggert
ad2c81082a Prefer C23 ckd_* to Gnulib *_WRAPV and *_OK macros
* src/alloc.c (android_make_lisp_symbol) [HAVE_ANDROID && !__clang__]:
* src/android.c (android_blit_copy, android_blit_xor)
(android_get_image):
* src/androidmenu.c (android_menu_show):
* src/androidselect.c (Fandroid_get_clipboard_data)
(android_notifications_notify_1):
* src/androidterm.c (android_decode_utf16)
(android_text_to_string):
* src/haiku_select.cc (be_display_notification):
* src/sfnt.c (sfnt_read_cmap_format_8, sfnt_read_cmap_format_12)
(sfnt_read_cmap_format_14, sfnt_read_cmap_table_1)
(sfnt_expand_compound_glyph_context, sfnt_poly_edges_exact)
(sfnt_read_meta_table, sfnt_read_ttc_header)
(sfnt_read_cvt_table, sfnt_read_fpgm_table)
(sfnt_read_prep_table, sfnt_make_interpreter)
(sfnt_interpret_simple_glyph, sfnt_interpret_compound_glyph_2)
(sfnt_interpret_compound_glyph, sfnt_read_default_uvs_table)
(sfnt_read_nondefault_uvs_table, sfnt_create_uvs_context)
(sfnt_read_fvar_table, sfnt_read_gvar_table)
(sfnt_read_avar_table, sfnt_read_cvar_table):
* src/sfntfont-android.c (GET_SCANLINE_BUFFER):
* src/textconv.c (really_commit_text, really_set_composing_text)
(really_replace_text, get_surrounding_text):
Prefer C2x stdckdint.h macros to intprops.h macros.
2024-01-28 00:26:44 -08:00
Paul Eggert
a3d7092114 Rename TAG_PTR to TAG_PTR_INITIALLY
* src/lisp.h (TAG_PTR_INITIALLY): Rename from TAG_PTR, since calls
can be used only as initializers, and the convention elsewhere in
lisp.c is to give these macros names ending in ‘_INITIALLY’.
This should help avoid confusion such as we recently experienced
in make_lisp_symbol_internal.  All uses changed.
2024-01-28 00:26:44 -08:00
Paul Eggert
fcf69960e8 * src/lisp.h: Improve TAG_PTR comments. 2024-01-28 00:26:44 -08:00
Paul Eggert
99a122b5b8 Fix C conformance issue in LISPSYM_INITIALLY
* src/lisp.h (LISPSYM_INITIALLY): Remove unnecessary cast to char *.
The C standard allows but does not require support for casts to
pointers in constant expressions in static initializers.
2024-01-28 00:26:44 -08:00
Eli Zaretskii
e1970c99f0 Fix "emacs -nw" on MS-Windows
* src/w32term.c (w32_flip_buffers_if_dirty): Do nothing if F is
not a GUI frame.  This avoids rare crashes in "emacs -nw".
* src/w32console.c (initialize_w32_display): Set the
ENABLE_EXTENDED_FLAGS bit in 'prev_console_mode'.
2024-01-28 10:19:48 +02:00
Eli Zaretskii
aa386cd92f ; * src/pdumper.c: Fix comments. 2024-01-27 22:21:11 +02:00
Eli Zaretskii
58f0603d40 Allow users to opt out of following Windows Dark mode
* src/w32fns.c (globals_of_w32fns) <w32-follow-system-dark-mode>:
New variable.
(w32_applytheme): Disable application of Dark mode if
'w32-follow-system-dark-mode' is nil.

* etc/NEWS:
* doc/emacs/msdos.texi (Windows Misc): Document
'w32-follow-system-dark-mode'.
2024-01-27 19:11:22 +02:00
Stefan Monnier
3c4b6823c3 * src/pdumper.c (Fdump_emacs_portable): Simplify commit 16a16645f5 2024-01-27 11:15:54 -05:00
Mattias Engdegård
da726c6de2 Add DOHASH_SAFE, make DOHASH faster (bug#68690)
Revert DOHASH to the fast (field-caching) implementation but with
an assertion to detect misuses.  Add DOHASH_SAFE for use in
code that must tolerate arbitrary mutation of the table being
iterated through.

* src/lisp.h (DOHASH): Go back to fast design that only allows
restricted mutation, but with a checking assertion.
(DOHASH_SAFE): New macro that tolerates arbitrary mutation while being
much simpler (and acceptably fast).
* src/fns.c (Fmaphash):
* src/comp.c (compile_function, Fcomp__compile_ctxt_to_file):
Use DOHASH_SAFE.
2024-01-27 12:37:53 +01:00
Stefan Monnier
08007a030e pdumper.c: Minor improvements found while debugging
* src/pdumper.c (dump_hash_table_list): Remove unused return value;
and simplify with `vconcat`.
(dump_charset): Don't copy uninitialized fields.
2024-01-26 23:15:57 -05:00
Stefan Monnier
89734c4f1d pdumder.c: Fix bug#68690
The problem was that the offset computed for the `charset_table` array
was a multiple of 4 but the `struct charset` needed an alignment on
a multiple of 8, so `dump_charset` inserted 4 bytes of padding,
whereas you can't have padding at the beginning of an array.

* src/pdumper.c (dump_charset): Don't set alignment here.
(dump_charset_table): Set it here instead.
2024-01-26 23:08:13 -05:00
Eli Zaretskii
de020255a5 Fix crash backtraces on MS-Windows, broken by ASLR
* src/w32fns.c (DEFAULT_IMAGE_BASE): Define for 64-bit and 32-bit
MinGW builds.
(emacs_abort): Correct the callstack addresses for potential
relocation of the image base due to ASLR.  This makes 'addr2line'
be able to interpret emacs_backtrace.txt when ASLR is in effect,
which it is on every modern version of MS-Windows.  (Bug#63365)

* configure.ac (LD_SWITCH_SYSTEM_TEMACS) [mingw32]: Add comment
about keeping the image-base values in sync with w32fns.c.

* etc/DEBUG (How to disable ASLR): New section.
2024-01-26 15:01:51 +02:00
Po Lu
16831e290e Avert race condition between window attachment and buffer swap
* java/org/gnu/emacs/EmacsView.java (swapBuffers): Synchronize
such that code cannot execute between the bitmap's being loaded
and being transferred to surfaceView.
(onDetachedFromWindow): Recycle bitmap after the surface view is
reset.

* java/org/gnu/emacs/EmacsWindow.java (recreateActivity):

* src/android.c (android_init_emacs_window)
(android_recreate_activity):

* src/androidfns.c (Fandroid_recreate_activity)
(syms_of_androidfns): New functions for debugging window
attachment.

* src/androidgui.h: Update prototypes.
2024-01-26 11:24:51 +08:00
Basil L. Contovounesios
a8cfe3bda8 ; Update 'struct charset' hash for CHECK_STRUCTS
This follows commit 33b8d5b6c5 of 2024-01-23
"(struct charset): Remove dependency on hash-table internals".
2024-01-25 15:57:54 +01:00
Po Lu
caea0c1649 Prevent matrices from remaining invalid post mini-window resize
* src/androidfns.c (android_create_tip_frame): Enable building
with GLYPH_DEBUG.

* src/window.c (resize_mini_window_apply): Garbage the frame if
F->redisplay is already set to indicate that redisplay_internal
should nevertheless return to it.
2024-01-25 12:18:40 +08:00
Stefan Monnier
ad004f10f3 * src/lisp.h (DOHASH): Handle rehashing (bug#68690)
I gave too much credit to the comment, and didn't realize that macro
was used in places that didn't obey the comment.
This macro is getting pretty hideous!
2024-01-24 14:52:31 -05:00
Stefan Monnier
c9705037e9 Fix build when CHECK_LISP_OBJECT_TYPE is set
* src/lisp.h (make_lisp_symbol_internal): Fix last commit.
2024-01-24 10:21:44 -05:00
Stefan Monnier
cc861fc528 (struct composition): Remove dependency on hash-table internals
`struct composition` kept an index into the internal `key_and_value` array
of hash tables, which only worked because of details of how
hash-tables are handled.  Replace it with a reference to the
key stored at that location in the hash-table, which saves us an
indirection while at it.

* src/composite.h (struct composition): Replace `hash_index` with
the actual `key`.
(COMPOSITION_KEY): Simplify accordingly.
(mark_composite): Declare.
* src/composite.c (get_composition_id): Adjust accordingly.
(mark_composite): New function.

* src/charset.c (mark_charset): Uncomment.
* src/lisp.h (mark_charset): Declare.
* src/alloc.c (garbage_collect): Call `mark_charset` and `mark_composite`.
* src/pdumper.c (hash_table_contents): Remove invalid comment, since
compositions aren't dumped.
2024-01-24 08:16:41 -05:00
Stefan Monnier
3018c6e7ba (DOHASH): Change calling convention
This leads to simpler code in the users, and more efficient machine
code because we don't repeatedly need to fetch the `table_size`
and `key_and_value` fields of the hash table object.

* src/lisp.h (DOHASH): Rewrite.
* src/composite.c (composition_gstring_lookup_cache): Simplify.
(composition_gstring_cache_clear_font):
* src/print.c (print):
* src/pdumper.c (hash_table_contents):
* src/minibuf.c (Ftest_completion):
* src/json.c (lisp_to_json_nonscalar_1):
* src/emacs-module.c (module_global_reference_p):
* src/comp.c (compile_function, Fcomp__compile_ctxt_to_file):
* src/fns.c (Fmaphash): Adjust to new calling convention.
2024-01-24 08:07:54 -05:00
Stefan Monnier
802821b81a Remove too-tricky make_lisp_symbol optimization
Simplify optimization for make_lisp_symbol, so that
it’s less tricky and works well enough for gcc -Og or -O2.
* src/lisp.h (lisp_h_builtin_lisp_symbol): Remove.
(builtin_lisp_symbol) [DEFINE_KEY_OPS_AS_MACROS]: Remove.
(make_lisp_symbol_nodebug): New internal static function,
which is like the old make_lisp_symbol but without the eassert.
(make_lisp_symbol, builtin_lisp_symbol): Use it, so that
make_lisp_symbol has the eassert but builtin_lisp_symbol doesn’t.
Co-authored-by: Paul Eggert <eggert@cs.ucla.edu>
2024-01-23 23:36:45 -08:00
Stefan Monnier
33b8d5b6c5 (struct charset): Remove dependency on hash-table internals
`struct charset` kept an index into the internal `key_and_value` array
of hash tables, which only worked because of details of how
hash-tables are handled.  Replace it with a reference to the
value stored at that location in the hash-table, which saves us an
indirection while at it.

* src/charset.h (struct charset): Replace `hash_index` field with
`attributes` field.
(CHARSET_ATTRIBUTES): Simplify accordingly.
(CHARSET_HASH_INDEX): Delete unused macro.
* src/charset.c (Fdefine_charset_internal):
* src/pdumper.c (dump_charset): Adjust accordingly.
(dump_charset_table): Set the referrer since that's needed while
dumping Lisp_Object fields.
2024-01-23 22:30:13 -05:00
Gerd Möllmann
21e272fe4f ; Fix DOHASH 2024-01-23 06:47:40 +01:00
Po Lu
54abf10dfe Correct crash when executing IP within twilight zone
* src/sfnt.c (sfnt_address_zp2, sfnt_address_zp1)
(sfnt_address_zp0): Don't save into X or Y if the zone is set to
the twilight zone and they are NULL.
2024-01-23 10:30:51 +08:00
Po Lu
a3d10046d9 * src/sfnt.c (sfnt_mul_f26dot6_fixed): Correct typo in last change. 2024-01-23 09:41:41 +08:00
Stefan Monnier
f821ac29e0 * src/regex-emacs.c (forall_firstchar_1): Improve corner case
Fixes a "FORALL_FIRSTCHAR: Broken assumption2!!" warning with:

    "^\\(# *\\)\\([^ ]+?\\) *: *\\(.*?\\(?:\n\\1[ \t]+.*?\\)*\\)[[:space:]]*$"
2024-01-22 15:06:24 -05:00
Stefan Monnier
797c688f4a * src/pdumper.c (dump_object_needs_dumping_p): Simplify
(hash_table_contents): Use DOHASH.
2024-01-22 09:48:48 -05:00
Po Lu
b2366900d4 Do not overwrite flags of succeeding points during generic move
* src/sfnt.c (sfnt_move): Save FLAGS and restore it after X
axis movement loop.
2024-01-22 16:02:05 +08:00
Po Lu
05495bfa6c Correct values of INSTCTRL flags tested
* src/sfnt.c (sfnt_mul_f26dot6_round): New function.
(sfnt_mul_f26dot6_fixed): Replace by call to
sfnt_mul_fixed_round.
(MUL): Round result, as the Apple and MS scalers do.
(sfnt_interpret_control_value_program): The instruction control
flag which reverts CVT modifications is 2, not 4.
2024-01-22 16:02:05 +08:00
Paul Eggert
088afa7e2f Add an eassert back to XSYMBOL
Problem reported by Alan Mackenzie in:
https://lists.gnu.org/r/emacs-devel/2024-01/msg00755.html
* src/lisp.h (XSYMBOL): If the arg is not a bare symbol, then
eassert (symbols_with_pos_enabled).  This shouldn’t affect code
generated for regular builds, and could catch caller errors in
debug builds.  For debug builds although this slows things down
XSYMBOL should still be faster than it was the day before
yesterday, as there’s still no need to eassert (SYMBOLP	(a)).
2024-01-21 21:13:39 -08:00
Paul Eggert
df7c6211cb Speed up builtin_lisp_symbol when not optimizing
This should help when building with --enable-checking and
compiling with gcc -O0.  Problem reorted by Stefan Monnier in:
https://lists.gnu.org/r/emacs-devel/2024-01/msg00770.html
* src/lisp.h (lisp_h_builtin_lisp_symbol): New macro,
with a body equivalent in effect to the old ‘builtin_lisp_symbol’
but faster when not optimizing.
(builtin_lisp_symbol): Use it.
If DEFINE_KEY_OPS_AS_MACROS, also define as macro.
2024-01-21 20:02:18 -08:00
Mattias Engdegård
1d754c7960 Change HASH_UNUSED_ENTRY_KEY from Qunbound to NULL float
This removes hacks from code that had to be careful not to use
Qunbound as a hash table key, at the cost of a minor hack in
the GC marker.

* src/lisp.h (INVALID_LISP_VALUE, HASH_UNUSED_ENTRY_KEY):
Define as a null-pointer float.
* src/alloc.c (process_mark_stack): Add hack to ignore that value.
* src/pdumper.c (dump_object_needs_dumping_p)
(pdumper_init_symbol_unbound, pdumper_load):
* src/print.c (PRINT_CIRCLE_CANDIDATE_P): Remove hacks for Qunbound.
2024-01-21 11:21:51 +01:00
Mattias Engdegård
50201e03b9 Make better use of fixnum range in sxhash etc
Recent hash table changes reduced the range of sxhash, sxhash-eq etc
to [0,2**32) on platforms with 62-bit fixnums.  This change makes them
use the full fixnum range again.  Hash table hashing is unaffected.

* src/fns.c (sxhash_eq, sxhash_eql): New.
(hash_hash_to_fixnum): Replace with...
(reduce_emacs_uint_to_fixnum): ...this.
(hashfn_eq, hashfn_eql, Fsxhash_eq, Fsxhash_eql, Fsxhash_equal)
(Fsxhash_equal_including_properties): Use the new functions.
2024-01-21 11:21:51 +01:00
Mattias Engdegård
7a87ca09a7 Clarify permitted mutation in maphash documentation
* doc/lispref/hash.texi (Hash Access):
* src/fns.c (Fmaphash):
Make it clear what the function passed as argument can do.  Until now
these rules were unwritten, and are still unenforced.
2024-01-21 11:21:51 +01:00
Mattias Engdegård
fec87a4b36 Add C macro for hash table iteration
This removes some boilerplate code and further reduces dependencies on
hash table implementation internals.

* src/lisp.h (DOHASH): New.
* src/comp.c (compile_function, Fcomp__compile_ctxt_to_file):
* src/composite.c (composition_gstring_cache_clear_font):
* src/emacs-module.c (module_global_reference_p):
* src/fns.c (Fmaphash):
* src/json.c (lisp_to_json_nonscalar_1):
* src/minibuf.c (Ftest_completion):
* src/print.c (print):
Use it instead of a hand-written loop.
2024-01-21 11:21:51 +01:00
Paul Eggert
bdcd662a21 Speed up make_lisp_symbol when debugging
* src/lisp.h (make_lisp_symbol): In eassert use XBARE_SYMBOL
rather than XSYMBOL.  This is safe because the symbol must be
bare.  The change speeds up make_lisp_symbol when debugging.
2024-01-20 17:28:53 -08:00
Paul Eggert
cf26f57316 Simplify and tune XSYMBOL
* src/lisp.h (XSYMBOL): Simplify and tune.  There is no need to
examine symbols_with_pos_enabled here, since the arg must be a symbol
so if it's not a bare symbol then it must be a symbol_with_pos;
and checking whether a symbol is bare is cheap.

With Ubuntu 23.10 on a Xeon W-1350, this shrank Emacs’s executable
text size by 0.1% and sped up a default build of all *.elc files by
0.4%.

Remove unnecessary eassert, since XBARE_SYMBOL and XSYMBOL_WITH_POS
have easserts that suffice.
2024-01-20 17:28:53 -08:00
Paul Eggert
b6ed79b71c Be more systematic about parens in C source code
Be more systematic about putting space before paren in calls,
and in avoiding unnecessary parentheses in macros.
This was partly inspired by my wading through gcc -E output
while debugging something else, and seeing too many parens.

This patch does not change the generated .o files on my platform.
2024-01-20 17:28:53 -08:00
Paul Eggert
0a47a5a4be Omit some parens
* src/lisp.h (XBARE_SYMBOL, XSYMBOL): Omit parentheses that are no
longer needed now that we have symbols with positions and these
symbols are never macros.
2024-01-20 17:28:53 -08:00
Paul Eggert
973c1b8a18 Pacify gcc -Wsuggest-attribute=malloc
* src/lisp.h (hash_table_alloc_bytes):
Declare with ATTRIBUTE_MALLOC_SIZE ((1)).
2024-01-20 17:28:52 -08:00
Eli Zaretskii
1b31a784bf Merge from origin/emacs-29
5bb5590dec Fix blunder in labeled_narrow_to_region
78ddb32fad Fix documentation of icon-elements
725a3f32f8 ; Fix typos in symbol names
6653ee66ca Improve two docstrings in ox-latex
7d869a0402 Doc fix in auth-source-read-char-choice
f149de223b Merge branch 'emacs-29' of git.savannah.gnu.org:/srv/git/...
1f97a87879 Fix info-xref-tests
51f391998b Add @kindex in manuals for existing keybindings on 'C-x x...
2024-01-20 06:25:59 -05:00
Po Lu
b3e4fbe867 Round projs computed executing IP/ISECT instructions and improve IUP
* src/sfnt.c (sfnt_multiply_divide_rounded): New function.
(sfnt_multiply_divide_signed): Always round values, as fonts
which rely on IP to move points in concert with prior motion and
subsequently round such points with MDAP are sensitive to minor
deviations in the behavior of the former instruction.
(load_unscaled): New macro.
(IUP_SINGLE_PAIR, sfnt_interpret_iup_1): Compute ratio w/
unscaled points if possible.
2024-01-20 09:30:04 +08:00
Po Lu
bd5bfc2913 Fix another cause of superfluous inotify signals on Android
* src/android.c (android_select): If the event queue isn't
empty upon the initial check, clear all fdsets.
2024-01-19 20:51:24 +08:00
Mattias Engdegård
e7a6ce847f Don't use Qunbound as hash table key when printing (bug#68244)
This flaw could cause an assertion failure.

* src/print.c (PRINT_CIRCLE_CANDIDATE_P): Don't consider Qunbound a
print-circle candidate; it should never be seen by Lisp anyway.
2024-01-18 18:57:03 +01:00
Mattias Engdegård
ef01250ef9 Only use a hash index size of 1 for tables with size 0 (bug#68244)
This invariant was intended but insufficiently enforced which could
lead to an assertion failure.

* src/fns.c (hash_index_size): Assume size>0, and return a value >1.
(make_hash_table): Only use hash_index_size for size>0.
2024-01-18 18:56:26 +01:00
Po Lu
d4d5830f8a ; * src/androidterm.c (handle_one_android_event): Fix typo. 2024-01-18 10:32:50 +08:00
Po Lu
daec3e7b41 Increase accuracy of IP instruction
* src/sfnt.c (sfnt_interpret_ip): Avoid precision loss by
retrieving original positions from the unscaled outline,
whenever possible.
2024-01-17 09:30:47 +08:00
Mattias Engdegård
f19f5604de Update pdumper hashes for buffer and Lisp_Hash_Table
* src/pdumper.c (dump_hash_table): Update for changes in recent
hash-table patch suites (bug#68244).
(dump_buffer): Update for case-fold-search changes (bug#66117).
2024-01-16 20:34:43 +01:00
Mattias Engdegård
dc404c5d0c More efficient hash table thawing
* src/fns.c (hash_table_thaw): Don't allocate anything for empty
tables.  Don't initialise the next vector twice.
(maybe_resize_hash_table): Factor out min_size constant.
2024-01-16 20:34:43 +01:00
Po Lu
c11cdf1858 ; * src/xterm.c (x_focus_frame): Insert missing unblock_input. 2024-01-15 14:32:26 +08:00
Gregory Heytings
5bb5590dec Fix blunder in labeled_narrow_to_region
* src/editfns.c (labeled_narrow_to_region): Record point before,
instead of after, calling narrow-to-region; otherwise point may
already have been changed.  Fixes bug#66764.
2024-01-14 21:59:21 +00:00