diff options
| author | Paul Eggert | 2015-11-19 14:03:29 -0800 |
|---|---|---|
| committer | Paul Eggert | 2015-11-19 14:04:00 -0800 |
| commit | 68d58e69738db41061812b10f2f3f50b6a1b9aa0 (patch) | |
| tree | 8045f9ded98f40daf1901862d729d1336adf2f06 /src | |
| parent | f2c002592196297a3517b3ed1f05c8ac7b096044 (diff) | |
| download | emacs-68d58e69738db41061812b10f2f3f50b6a1b9aa0.tar.gz emacs-68d58e69738db41061812b10f2f3f50b6a1b9aa0.zip | |
Prefer intmax_t to int64_t in module code
* modules/mod-test/mod-test.c (sum, Fmod_test_sum):
* src/emacs-module.c (module_extract_integer)
(module_make_integer):
* src/emacs-module.h (struct emacs_env_25):
Prefer intmax_t to int64_t. This doesn’t change the generated
code on any of the machines Emacs currently ports to, but it’s
at least in theory more future-proof as C99 doesn’t guarantee
that int64_t exists.
Diffstat (limited to 'src')
| -rw-r--r-- | src/emacs-module.c | 13 | ||||
| -rw-r--r-- | src/emacs-module.h | 5 |
2 files changed, 5 insertions, 13 deletions
diff --git a/src/emacs-module.c b/src/emacs-module.c index 4fa01bf5bed..b39ac7df057 100644 --- a/src/emacs-module.c +++ b/src/emacs-module.c | |||
| @@ -451,11 +451,9 @@ module_eq (emacs_env *env, emacs_value a, emacs_value b) | |||
| 451 | return EQ (value_to_lisp (a), value_to_lisp (b)); | 451 | return EQ (value_to_lisp (a), value_to_lisp (b)); |
| 452 | } | 452 | } |
| 453 | 453 | ||
| 454 | static int64_t | 454 | static intmax_t |
| 455 | module_extract_integer (emacs_env *env, emacs_value n) | 455 | module_extract_integer (emacs_env *env, emacs_value n) |
| 456 | { | 456 | { |
| 457 | verify (INT64_MIN <= MOST_NEGATIVE_FIXNUM); | ||
| 458 | verify (INT64_MAX >= MOST_POSITIVE_FIXNUM); | ||
| 459 | check_main_thread (); | 457 | check_main_thread (); |
| 460 | eassert (module_non_local_exit_check (env) == emacs_funcall_exit_return); | 458 | eassert (module_non_local_exit_check (env) == emacs_funcall_exit_return); |
| 461 | const Lisp_Object l = value_to_lisp (n); | 459 | const Lisp_Object l = value_to_lisp (n); |
| @@ -468,16 +466,11 @@ module_extract_integer (emacs_env *env, emacs_value n) | |||
| 468 | } | 466 | } |
| 469 | 467 | ||
| 470 | static emacs_value | 468 | static emacs_value |
| 471 | module_make_integer (emacs_env *env, int64_t n) | 469 | module_make_integer (emacs_env *env, intmax_t n) |
| 472 | { | 470 | { |
| 473 | check_main_thread (); | 471 | check_main_thread (); |
| 474 | eassert (module_non_local_exit_check (env) == emacs_funcall_exit_return); | 472 | eassert (module_non_local_exit_check (env) == emacs_funcall_exit_return); |
| 475 | if (n < MOST_NEGATIVE_FIXNUM) | 473 | if (! (MOST_NEGATIVE_FIXNUM <= n && n <= MOST_POSITIVE_FIXNUM)) |
| 476 | { | ||
| 477 | module_non_local_exit_signal_1 (env, Qunderflow_error, Qnil); | ||
| 478 | return NULL; | ||
| 479 | } | ||
| 480 | if (n > MOST_POSITIVE_FIXNUM) | ||
| 481 | { | 474 | { |
| 482 | module_non_local_exit_signal_1 (env, Qoverflow_error, Qnil); | 475 | module_non_local_exit_signal_1 (env, Qoverflow_error, Qnil); |
| 483 | return NULL; | 476 | return NULL; |
diff --git a/src/emacs-module.h b/src/emacs-module.h index 046959775ac..2759b1cb0f0 100644 --- a/src/emacs-module.h +++ b/src/emacs-module.h | |||
| @@ -142,10 +142,9 @@ struct emacs_env_25 | |||
| 142 | 142 | ||
| 143 | bool (*eq) (emacs_env *env, emacs_value a, emacs_value b); | 143 | bool (*eq) (emacs_env *env, emacs_value a, emacs_value b); |
| 144 | 144 | ||
| 145 | int_fast64_t (*extract_integer) (emacs_env *env, | 145 | intmax_t (*extract_integer) (emacs_env *env, emacs_value value); |
| 146 | emacs_value value); | ||
| 147 | 146 | ||
| 148 | emacs_value (*make_integer) (emacs_env *env, int_fast64_t value); | 147 | emacs_value (*make_integer) (emacs_env *env, intmax_t value); |
| 149 | 148 | ||
| 150 | double (*extract_float) (emacs_env *env, emacs_value value); | 149 | double (*extract_float) (emacs_env *env, emacs_value value); |
| 151 | 150 | ||