about summary refs log tree commit diff stats
path: root/src/libtools
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2024-11-18 11:07:44 +0100
committerptitSeb <sebastien.chev@gmail.com>2024-11-18 11:07:44 +0100
commit4257fdded3b89b739fe4ee8a56593494c5a69720 (patch)
treecdd7764438ca6286db763622489bce2407f15cbb /src/libtools
parent56298870f68294b76ef963dd2ea0864789b811c3 (diff)
downloadbox64-4257fdded3b89b739fe4ee8a56593494c5a69720.tar.gz
box64-4257fdded3b89b739fe4ee8a56593494c5a69720.zip
[BOX32] Fixed long double handling on printf like functions
Diffstat (limited to 'src/libtools')
-rwxr-xr-xsrc/libtools/myalign32.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/libtools/myalign32.c b/src/libtools/myalign32.c
index f38776b6..8776731f 100755
--- a/src/libtools/myalign32.c
+++ b/src/libtools/myalign32.c
@@ -21,6 +21,7 @@ void myStackAlign32(const char* fmt, uint32_t* st, uint64_t* mystack)
     const char* p = fmt;
     int state = 0;
     double d;
+    long double ld;
     while(*p)
     {
         switch(state) {
@@ -109,7 +110,10 @@ void myStackAlign32(const char* fmt, uint32_t* st, uint64_t* mystack)
                 st+=3; mystack+=2;
                 #else
                 LD2D((void*)st, &d);
-                *(long double*)mystack = (long double)d;
+                ld = d;
+                if(((uintptr_t)mystack)&0xf)    // align the long double
+                    mystack++;
+                memcpy(mystack, &ld, 16);
                 st+=3; mystack+=2;
                 #endif
                 state = 0;
@@ -927,7 +931,10 @@ void myStackAlignW32(const char* fmt, uint32_t* st, uint64_t* mystack)
                 st+=3; mystack+=2;
                 #else
                 LD2D((void*)st, &d);
-                *(long double*)mystack = (long double)d;
+                if(((uintptr_t)mystack)&0xf)    // align the long double
+                    mystack++;
+                ld = d;
+                memcpy(mystack, &ld, 16);
                 st+=3; mystack+=2;
                 #endif
                 state = 0;