shithub: femtolisp

Download patch

ref: 63647b5d871fe95713a88c18324782f84c4b88dc
parent: 1c35aa34f2b5b603beb8242861722293988d0ff2
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Tue Mar 7 17:34:45 EST 2023

workaround for arm64 double→uint64 conversion

--- a/operators.c
+++ b/operators.c
@@ -140,6 +140,7 @@
 uint64_t conv_to_uint64(void *data, numerictype_t tag)
 {
     uint64_t i=0;
+    int64_t s=0;
     switch (tag) {
     case T_INT8:   i = (uint64_t)*(int8_t*)data; break;
     case T_UINT8:  i = (uint64_t)*(uint8_t*)data; break;
@@ -153,15 +154,16 @@
         if (*(float*)data >= 0)
             i = (uint64_t)*(float*)data;
         else
-            i = (uint64_t)(int64_t)*(float*)data;
+            i = s = (int64_t)*(float*)data;
         break;
     case T_DOUBLE:
         if (*(double*)data >= 0)
             i = (uint64_t)*(double*)data;
         else
-            i = (uint64_t)(int64_t)*(double*)data;
+            i = s = (int64_t)*(double*)data;
         break;
     }
+    USED(s);
     return i;
 }