Skip to content

Commit

Permalink
[BOX32] Fixed long double handling on printf like functions
Browse files Browse the repository at this point in the history
  • Loading branch information
ptitSeb committed Nov 18, 2024
1 parent 5629887 commit 4257fdd
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/libtools/myalign32.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 4257fdd

Please sign in to comment.