//
// Created by Fear1ess on 2021/3/31.
//

#ifndef REYUNSDK_WD_SYSCALL_H
#define REYUNSDK_WD_SYSCALL_H

#define WD_SYSCALL_BASE 0xcd
#define WDNUM(x) (x + WD_SYSCALL_BASE)


#ifdef __arm__
#define WDSYSCALL(cmd, args...) wd_syscall_arm(WDNUM(cmd), ##args)
#define WD_SYS_mmap SYS_mmap2
#define WD_SYS_fstatat SYS_fstatat64
#endif

#ifdef __aarch64__
#define WDSYSCALL(cmd, args...) wd_syscall_aarch64(WDNUM(cmd), ##args)
#define WD_SYS_mmap SYS_mmap
#define WD_SYS_fstatat SYS_newfstatat
#endif

#ifdef x86
#define WDSYSCALL(cmd, args...) wd_syscall_x86(WDNUM(cmd), ##args)
#define WD_SYS_mmap SYS_mmap
#endif

#ifdef x86_64
#define WDSYSCALL(cmd, args...) wd_syscall_x64(WDNUM(cmd), ##args)
#define WD_SYS_mmap SYS_mmap
#endif

#define IMPORTWDSYSCALL  \
__attribute__((visibility("hidden"))) extern long wd_syscall_arm(int cmd, ...);\
__attribute__((visibility("hidden"))) extern long wd_syscall_aarch64(int cmd, ...);\
__attribute__((visibility("hidden"))) extern long wd_syscall_x86(int cmd, ...);\
__attribute__((visibility("hidden"))) extern long wd_syscall_x64(int cmd, ...);

long wd_set_errno(int n);


#endif //REYUNSDK_WD_SYSCALL_H
