123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 |
- #ifndef _LINUX_AARCH64_SYSDEP_H
- #define _LINUX_AARCH64_SYSDEP_H 1
- #include <common/sysdep.h>
- #include <sys/syscall.h>
- #ifndef __ASSEMBLER__
- #include <errno.h>
- #endif
- #undef SYS_ify
- #define SYS_ify(syscall_name) (__NR_##syscall_name)
- #ifdef __ASSEMBLER__
- #define ASM_SIZE_DIRECTIVE(name) .size name,.-name
- #ifndef L
- # define L(name) .L##name
- #endif
- #define ENTRY(name) \
- .globl C_SYMBOL_NAME(name)
- .type C_SYMBOL_NAME(name),%function
- .align 4
- C_LABEL(name) \
- cfi_startproc
- #define ENTRY_ALIGN(name, align) \
- .globl C_SYMBOL_NAME(name)
- .type C_SYMBOL_NAME(name),%function
- .p2align align
- C_LABEL(name) \
- cfi_startproc
- #undef END
- #define END(name) \
- cfi_endproc
- ASM_SIZE_DIRECTIVE(name)
- # undef PSEUDO
- # define PSEUDO(name, syscall_name, args) \
- .text
- ENTRY (name)
- DO_CALL (syscall_name, args)
- cmn x0, #4095; \
- b.cs .Lsyscall_error
- # undef PSEUDO_END
- # define PSEUDO_END(name) \
- SYSCALL_ERROR_HANDLER \
- END (name)
- # undef PSEUDO_NOERRNO
- # define PSEUDO_NOERRNO(name, syscall_name, args) \
- .text
- ENTRY (name)
- DO_CALL (syscall_name, args)
- # undef PSEUDO_END_NOERRNO
- # define PSEUDO_END_NOERRNO(name) \
- END (name)
- # define ret_NOERRNO ret
- # undef PSEUDO_ERRVAL
- # define PSEUDO_ERRVAL(name, syscall_name, args) \
- .text
- ENTRY (name) \
- DO_CALL (syscall_name, args)
- neg x0, x0
- # undef PSEUDO_END_ERRVAL
- # define PSEUDO_END_ERRVAL(name) \
- END (name)
- # define ret_ERRVAL ret
- #if defined NOT_IN_libc
- # define SYSCALL_ERROR .Lsyscall_error
- # define SYSCALL_ERROR_HANDLER \
- .Lsyscall_error: \
- adrp x1, :gottprel:errno
- neg w2, w0
- ldr x1, [x1, :gottprel_lo12:errno]
- mrs x3, tpidr_el0
- mov x0, -1
- str w2, [x1, x3]
- ret
- #else
- # define SYSCALL_ERROR __syscall_error
- # define SYSCALL_ERROR_HANDLER \
- .Lsyscall_error: \
- b __syscall_error
- #endif
- # undef DO_CALL
- # define DO_CALL(syscall_name, args) \
- mov x8, SYS_ify (syscall_name)
- svc 0
- #endif
- #endif
|