about summary refs log tree commit diff stats
path: root/src/libtools
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2024-12-02 10:50:21 +0100
committerGitHub <noreply@github.com>2024-12-02 10:50:21 +0100
commit83ed8ebb22da6d77f8f15af43bf316bd14e93ed3 (patch)
tree209f87e967585d29b49af00c191c2e4a30bf976e /src/libtools
parent88aab487f111ba280048fd7e240e2b62d45eeba8 (diff)
downloadbox64-83ed8ebb22da6d77f8f15af43bf316bd14e93ed3.tar.gz
box64-83ed8ebb22da6d77f8f15af43bf316bd14e93ed3.zip
Android Long Double handling (#2101)
* [ANDROID] Try to handle LongDouble in vaarg correctly

* [ANDROID] Try to enable test07

* [WRAPPED] Fixed Android long double handling (#2096)

* [WRAPPED] Fixed Android long double handling

* [WRAPPED] Force casting to uintptr_t

* [WRAPPED] Fixed a typing issue, removed a warning in the CI

---------

Co-authored-by: rajdakin <rajdakin@gmail.com>
Diffstat (limited to 'src/libtools')
-rw-r--r--src/libtools/myalign.c58
1 files changed, 58 insertions, 0 deletions
diff --git a/src/libtools/myalign.c b/src/libtools/myalign.c
index d34e0b8e..599ce904 100644
--- a/src/libtools/myalign.c
+++ b/src/libtools/myalign.c
@@ -123,6 +123,21 @@ void myStackAlign(x64emu_t* emu, const char* fmt, uint64_t* st, uint64_t* mystac
                     mystack++;
                 memcpy(mystack, st, 16);
                 st+=2; mystack+=2;
+                #elif defined(ANDROID)
+                // there is 128bits long double on native and x64 side
+                // need to align stacks to 128bits boundaries
+                if((((uintptr_t)mystack)&0xf)!=0)
+                    mystack++;
+                if(xmm) {
+                    memcpy(mystack, &emu->xmm[x++], 16);
+                    st+=2; mystack+=2;
+                    --xmm;
+                } else {
+                    if((((uintptr_t)st)&0xf)!=0)
+                        st++;
+                    memcpy(mystack, st, 16);
+                    st+=2; mystack+=2;
+                }
                 #else
                 // there is 128bits long double on ARM64, but they need 128bit alignment
                 if((((uintptr_t)mystack)&0xf)!=0)
@@ -366,6 +381,21 @@ void myStackAlignW(x64emu_t* emu, const char* fmt, uint64_t* st, uint64_t* mysta
                     mystack++;
                 memcpy(mystack, st, 16);
                 st+=2; mystack+=2;
+                #elif defined(ANDROID)
+                // there is 128bits long double on native and x64 side
+                // need to align stacks to 128bits boundaries
+                if((((uintptr_t)mystack)&0xf)!=0)
+                    mystack++;
+                if(xmm) {
+                    memcpy(mystack, &emu->xmm[x++], 16);
+                    st+=2; mystack+=2;
+                    --xmm;
+                } else {
+                    if((((uintptr_t)st)&0xf)!=0)
+                        st++;
+                    memcpy(mystack, st, 16);
+                    st+=2; mystack+=2;
+                }
                 #else
                 // there is 128bits long double on ARM64, but they need 128bit alignment
                 if((((uintptr_t)mystack)&0xf)!=0)
@@ -743,6 +773,20 @@ void myStackAlignValist(x64emu_t* emu, const char* fmt, uint64_t* mystack, x64_v
                     mystack++;
                 memcpy(mystack, st, 16);
                 st+=2; mystack+=2;
+                #elif defined(ANDROID)
+                // there is 128bits long double on native and x64 side
+                // need to align stacks to 128bits boundaries
+                if((((uintptr_t)mystack)&0xf)!=0)
+                    mystack++;
+                if(fprs<X64_VA_MAX_XMM) {
+                    memcpy(mystack, &area[fprs/8], 16);
+                    fprs+=16; mystack+=2;
+                } else {
+                    if((((uintptr_t)st)&0xf)!=0)
+                        st++;
+                    memcpy(mystack, st, 16);
+                    st+=2; mystack+=2;
+                }
                 #else
                 // there is 128bits long double on ARM64, but they need 128bit alignment
                 if((((uintptr_t)mystack)&0xf)!=0)
@@ -888,6 +932,20 @@ void myStackAlignWValist(x64emu_t* emu, const char* fmt, uint64_t* mystack, x64_
                     mystack++;
                 memcpy(mystack, st, 16);
                 st+=2; mystack+=2;
+                #elif defined(ANDROID)
+                // there is 128bits long double on native and x64 side
+                // need to align stacks to 128bits boundaries
+                if((((uintptr_t)mystack)&0xf)!=0)
+                    mystack++;
+                if(fprs<X64_VA_MAX_XMM) {
+                    memcpy(mystack, &area[fprs/8], 16);
+                    fprs+=16; mystack+=2;
+                } else {
+                    if((((uintptr_t)st)&0xf)!=0)
+                        st++;
+                    memcpy(mystack, st, 16);
+                    st+=2; mystack+=2;
+                }
                 #else
                 // there is 128bits long double on ARM64, but they need 128bit alignment
                 if((((uintptr_t)mystack)&0xf)!=0)