]> git.ipfire.org Git - thirdparty/LuaJIT.git/commitdiff
Add lj_num2u64 for number to uint64_t conversion.
authorMike Pall <mike>
Thu, 30 Dec 2010 23:46:29 +0000 (00:46 +0100)
committerMike Pall <mike>
Thu, 30 Dec 2010 23:46:29 +0000 (00:46 +0100)
src/lj_cconv.c
src/lj_obj.h

index 5df33d041b2ea31bbbef0618fa9662056357a241..b123c081cf73dfde4540d31fe672fd7f70718ddf 100644 (file)
@@ -200,13 +200,8 @@ void lj_cconv_ct_ct(CTState *cts, CType *d, CType *s,
     } else if (dsize == 8) {
       if (!(dinfo & CTF_UNSIGNED))
        *(int64_t *)dp = (int64_t)n;
-#ifdef _MSC_VER
-      else if (n >= 9223372036854775808.0)  /* They think it's a feature. */
-       *(uint64_t *)dp = (uint64_t)(int64_t)(n - 9223372036854775808.0) +
-                         U64x(80000000,00000000);
-#endif
       else
-       *(uint64_t *)dp = (uint64_t)n;
+       *(uint64_t *)dp = lj_num2u64(n);
     } else {
       goto err_conv;  /* NYI: conversion to >64 bit integers. */
     }
index d735b0e8c2c551e07c05529777d72c3ea396af68..456aef0b714676eb7d3f3b565bab3bde6bd00c53 100644 (file)
@@ -763,6 +763,17 @@ static LJ_AINLINE int32_t lj_num2bit(lua_Number n)
 #define lj_num2int(n)   ((int32_t)(n))
 #endif
 
+static LJ_AINLINE uint64_t lj_num2u64(lua_Number n)
+{
+#ifdef _MSC_VER
+  if (n >= 9223372036854775808.0)  /* They think it's a feature. */
+    return (uint64_t)(int64_t)(n - 9223372036854775808.0) +
+          U64x(80000000,00000000);
+  else
+#endif
+    return (uint64_t)n;
+}
+
 /* -- Miscellaneous object handling --------------------------------------- */
 
 /* Names and maps for internal and external object tags. */