]> git.eshelyaron.com Git - emacs.git/commitdiff
* Better long range check
authorAndrea Corallo <akrl@sdf.org>
Tue, 16 Feb 2021 20:49:32 +0000 (21:49 +0100)
committerAndrea Corallo <akrl@sdf.org>
Tue, 16 Feb 2021 20:49:32 +0000 (21:49 +0100)
* src/comp.c (emit_rvalue_from_emacs_uint)
(emit_rvalue_from_emacs_int, emit_rvalue_from_lisp_word_tag)
(emit_rvalue_from_lisp_word): Better long range check.

src/comp.c

index 0ab7ab600a4c29cf70c154ddddabdcc00f53a943..ce9c387568af08b01e8629f4a36b7c1aedef1fe1 100644 (file)
@@ -1166,7 +1166,7 @@ emit_rvalue_from_unsigned_long_long (gcc_jit_type *type, unsigned long long n)
 static gcc_jit_rvalue *
 emit_rvalue_from_emacs_uint (EMACS_UINT val)
 {
-  if (val != (long) val)
+  if (val > LONG_MAX || val < LONG_MIN)
     return emit_rvalue_from_unsigned_long_long (comp.emacs_uint_type, val);
   else
     return gcc_jit_context_new_rvalue_from_long (comp.ctxt,
@@ -1177,7 +1177,7 @@ emit_rvalue_from_emacs_uint (EMACS_UINT val)
 static gcc_jit_rvalue *
 emit_rvalue_from_emacs_int (EMACS_INT val)
 {
-  if (val != (long) val)
+  if (val > LONG_MAX || val < LONG_MIN)
     return emit_rvalue_from_long_long (comp.emacs_int_type, val);
   else
     return gcc_jit_context_new_rvalue_from_long (comp.ctxt,
@@ -1187,7 +1187,7 @@ emit_rvalue_from_emacs_int (EMACS_INT val)
 static gcc_jit_rvalue *
 emit_rvalue_from_lisp_word_tag (Lisp_Word_tag val)
 {
-  if (val != (long) val)
+  if (val > LONG_MAX || val < LONG_MIN)
     return emit_rvalue_from_unsigned_long_long (comp.lisp_word_tag_type, val);
   else
     return gcc_jit_context_new_rvalue_from_long (comp.ctxt,
@@ -1203,7 +1203,7 @@ emit_rvalue_from_lisp_word (Lisp_Word val)
                                               comp.lisp_word_type,
                                               val);
 #else
-  if (val != (long) val)
+  if (val > LONG_MAX || val < LONG_MIN)
     return emit_rvalue_from_unsigned_long_long (comp.lisp_word_type, val);
   else
     return gcc_jit_context_new_rvalue_from_long (comp.ctxt,