diff options
| author | Paul Eggert | 2019-02-27 01:14:27 -0800 |
|---|---|---|
| committer | Paul Eggert | 2019-02-27 01:23:30 -0800 |
| commit | e828765d01313acddcf17279b6b43ae9f777f2a4 (patch) | |
| tree | 8dd465c5899c62ad5613fe97172fad1ddf419097 /src/lisp.h | |
| parent | 2f7885a4b3609dec19e4595c6c24f3a21f33c5d6 (diff) | |
| download | emacs-e828765d01313acddcf17279b6b43ae9f777f2a4.tar.gz emacs-e828765d01313acddcf17279b6b43ae9f777f2a4.zip | |
DEFVAR_INT variables are now intmax_t
Formerly they were fixnums, which led to problems when dealing
with values that might not fit on 32-bit platforms, such as
string-chars-consed or floats_consed. 64-bit counters should
be good enough for these (for a while, anyway...).
While we’re at it, fix some unlikely integer overflow bugs
that have been in the code for a while.
* lib-src/make-docfile.c (write_globals):
* src/data.c (do_symval_forwarding, store_symval_forwarding):
* src/eval.c (restore_stack_limits, call_debugger):
* src/frame.h (struct frame.cost_calculation_baud_rate):
* src/keyboard.c (last_auto_save, bind_polling_period, read_char):
* src/lisp.h (struct Lisp_Intfwd.intvar):
* src/lread.c (defvar_int):
* src/pdumper.c (dump_fwd_int):
* src/thread.h (struct thread_state.m_lisp_eval_depth):
* src/undo.c (truncate_undo_list):
* src/xselect.c (wait_for_property_change)
(x_get_foreign_selection):
* src/xterm.c (x_emacs_to_x_modifiers):
DEFVAR_INT variables now have the C type intmax_t, not EMACS_INT.
* src/data.c (store_symval_forwarding):
* src/gnutls.c (Fgnutls_boot):
* src/keyboard.c (bind_polling_period):
* src/macros.c (pop_kbd_macro, Fexecute_kbd_macro):
* src/undo.c (truncate_undo_list):
Allow any integer that fits into intmax_t, instead of
requiring it to be a Lisp fixnum.
* src/dispnew.c (update_window):
* src/frame.c (x_figure_window_size):
* src/gnutls.c (init_gnutls_functions)
(emacs_gnutls_handle_error):
* src/keyboard.c (make_lisp_event):
* src/nsterm.m (ns_dumpglyphs_image):
* src/profiler.c (make_log):
* src/scroll.c (calculate_scrolling)
(calculate_direct_scrolling):
* src/termcap.c (tputs):
* src/xterm.c (x_draw_image_relief):
Avoid implementation-defined behavior on conversion of
out-of-range integers.
* src/eval.c (when_entered_debugger): Now intmax_t.
(max_ensure_room): New function, that avoids signed integer overflow.
(call_debugger, signal_or_quit): Use it.
* src/fileio.c (Fdo_auto_save):
* src/keyboard.c (make_lisp_event):
* src/term.c (calculate_costs):
* src/xdisp.c (build_desired_tool_bar_string)
(hscroll_window_tree, try_scrolling, decode_mode_spec)
(x_produce_glyphs):
Avoid signed integer overflow.
* src/lisp.h (clip_to_bounds): Generalize to intmax_t.
* src/pdumper.c (dump_emacs_reloc_immediate_emacs_int): Remove, ...
(dump_emacs_reloc_immediate_intmax_t): ... replacing with this
function. All uses changed.
* src/profiler.c (make_log): Omit args. All callers changed.
* src/termcap.c: Include stdlib.h, for atoi.
Include intprops.h.
* src/window.c (sanitize_next_screen_context_lines): New function.
(window_scroll_pixel_based, window_scroll_line_based):
Use it to avoid signed integer overflow.
Diffstat (limited to 'src/lisp.h')
| -rw-r--r-- | src/lisp.h | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/lisp.h b/src/lisp.h index 3b481089cfd..388cd04163a 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -1260,8 +1260,8 @@ INLINE bool | |||
| 1260 | #define FIXNUM_OVERFLOW_P(i) \ | 1260 | #define FIXNUM_OVERFLOW_P(i) \ |
| 1261 | (! ((0 <= (i) || MOST_NEGATIVE_FIXNUM <= (i)) && (i) <= MOST_POSITIVE_FIXNUM)) | 1261 | (! ((0 <= (i) || MOST_NEGATIVE_FIXNUM <= (i)) && (i) <= MOST_POSITIVE_FIXNUM)) |
| 1262 | 1262 | ||
| 1263 | INLINE ptrdiff_t | 1263 | INLINE intmax_t |
| 1264 | clip_to_bounds (ptrdiff_t lower, EMACS_INT num, ptrdiff_t upper) | 1264 | clip_to_bounds (intmax_t lower, intmax_t num, intmax_t upper) |
| 1265 | { | 1265 | { |
| 1266 | return num < lower ? lower : num <= upper ? num : upper; | 1266 | return num < lower ? lower : num <= upper ? num : upper; |
| 1267 | } | 1267 | } |
| @@ -2664,7 +2664,7 @@ make_uint (uintmax_t n) | |||
| 2664 | struct Lisp_Intfwd | 2664 | struct Lisp_Intfwd |
| 2665 | { | 2665 | { |
| 2666 | enum Lisp_Fwd_Type type; /* = Lisp_Fwd_Int */ | 2666 | enum Lisp_Fwd_Type type; /* = Lisp_Fwd_Int */ |
| 2667 | EMACS_INT *intvar; | 2667 | intmax_t *intvar; |
| 2668 | }; | 2668 | }; |
| 2669 | 2669 | ||
| 2670 | /* Boolean forwarding pointer to an int variable. | 2670 | /* Boolean forwarding pointer to an int variable. |
| @@ -3099,7 +3099,7 @@ enum maxargs | |||
| 3099 | extern void defvar_lisp (struct Lisp_Objfwd *, const char *, Lisp_Object *); | 3099 | extern void defvar_lisp (struct Lisp_Objfwd *, const char *, Lisp_Object *); |
| 3100 | extern void defvar_lisp_nopro (struct Lisp_Objfwd *, const char *, Lisp_Object *); | 3100 | extern void defvar_lisp_nopro (struct Lisp_Objfwd *, const char *, Lisp_Object *); |
| 3101 | extern void defvar_bool (struct Lisp_Boolfwd *, const char *, bool *); | 3101 | extern void defvar_bool (struct Lisp_Boolfwd *, const char *, bool *); |
| 3102 | extern void defvar_int (struct Lisp_Intfwd *, const char *, EMACS_INT *); | 3102 | extern void defvar_int (struct Lisp_Intfwd *, const char *, intmax_t *); |
| 3103 | extern void defvar_kboard (struct Lisp_Kboard_Objfwd *, const char *, int); | 3103 | extern void defvar_kboard (struct Lisp_Kboard_Objfwd *, const char *, int); |
| 3104 | 3104 | ||
| 3105 | /* Macros we use to define forwarded Lisp variables. | 3105 | /* Macros we use to define forwarded Lisp variables. |