Skip to content

Commit

Permalink
Set Carry Flag If Returned Value Is Between [-1, -4095]
Browse files Browse the repository at this point in the history
Based off of how we handle the carry flag for x86.
  • Loading branch information
CuriousTommy committed Feb 12, 2024
1 parent 542043e commit 59096eb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions gen/bsdsyscalls/SYS.h
Original file line number Diff line number Diff line change
Expand Up @@ -476,11 +476,14 @@ pseudo: ;\
*/

#ifdef DARLING
// In addition to changing the macro to use __darling_handle_svc instead of the
// syscall (svc) instruction, We are also setting the carry flag as well.
#define DO_SYSCALL(num, cerror) \
mov x16, #(num) %%\
PUSH_FRAME %%\
bl __darling_handle_svc %%\
POP_FRAME %%\
cmn x0, #4095 %%\
b.cc 2f %%\
ARM64_STACK_PROLOG %%\
PUSH_FRAME %%\
Expand Down
3 changes: 3 additions & 0 deletions libsyscall/custom/SYS.h
Original file line number Diff line number Diff line change
Expand Up @@ -476,11 +476,14 @@ pseudo: ;\
*/

#ifdef DARLING
// In addition to changing the macro to use __darling_handle_svc instead of the
// syscall (svc) instruction, We are also setting the carry flag as well.
#define DO_SYSCALL(num, cerror) \
mov x16, #(num) %%\
PUSH_FRAME %%\
bl __darling_handle_svc %%\
POP_FRAME %%\
cmn x0, #4095 %%\
b.cc 2f %%\
ARM64_STACK_PROLOG %%\
PUSH_FRAME %%\
Expand Down

0 comments on commit 59096eb

Please sign in to comment.