#define AARCH64_RET_VOID 0
#define AARCH64_RET_INT64 1
#define AARCH64_RET_INT128 2
#define AARCH64_RET_UNUSED3 3
#define AARCH64_RET_UNUSED4 4
#define AARCH64_RET_UNUSED5 5
#define AARCH64_RET_UNUSED6 6
#define AARCH64_RET_UNUSED7 7
#define AARCH64_RET_S4 8
#define AARCH64_RET_S3 9
#define AARCH64_RET_S2 10
#define AARCH64_RET_S1 11
#define AARCH64_RET_D4 12
#define AARCH64_RET_D3 13
#define AARCH64_RET_D2 14
#define AARCH64_RET_D1 15
#define AARCH64_RET_Q4 16
#define AARCH64_RET_Q3 17
#define AARCH64_RET_Q2 18
#define AARCH64_RET_Q1 19
#define AARCH64_RET_UINT8 20
#define AARCH64_RET_UINT16 22
#define AARCH64_RET_UINT32 24
#define AARCH64_RET_SINT8 26
#define AARCH64_RET_SINT16 28
#define AARCH64_RET_SINT32 30
#define AARCH64_RET_MASK 31
#define AARCH64_RET_IN_MEM (1 << 5)
#define AARCH64_RET_NEED_COPY (1 << 6)
#define AARCH64_FLAG_ARG_V_BIT 7
#define AARCH64_FLAG_ARG_V (1 << AARCH64_FLAG_ARG_V_BIT)
#define AARCH64_FLAG_VARARG (1 << 8)
#define N_X_ARG_REG 8
#define N_V_ARG_REG 8
#define CALL_CONTEXT_SIZE (N_V_ARG_REG * 16 + N_X_ARG_REG * 8)
#if defined(FFI_EXEC_STATIC_TRAMP)
#define AARCH64_TRAMP_MAP_SHIFT 14
#define AARCH64_TRAMP_MAP_SIZE (1 << AARCH64_TRAMP_MAP_SHIFT)
#define AARCH64_TRAMP_SIZE 32
#endif
#ifdef LIBFFI_ASM
#if defined(HAVE_ARM64E_PTRAUTH)
#define SIGN_LR pacibsp
#define SIGN_LR_WITH_REG(x) pacib lr, x
#define AUTH_LR_AND_RET retab
#define AUTH_LR_WITH_REG(x) autib lr, x
#define BRANCH_AND_LINK_TO_REG blraaz
#define SIGN_LR_LINUX_ONLY
#define BRANCH_TO_REG braaz
#define PAC_CFI_WINDOW_SAVE
#define GNU_PROPERTY_AARCH64_POINTER_AUTH 0
#elif defined(__ARM_FEATURE_PAC_DEFAULT)
#define GNU_PROPERTY_AARCH64_POINTER_AUTH (1 << 1)
#define PAC_CFI_WINDOW_SAVE cfi_window_save
#define TMP_REG x9
#define BRANCH_TO_REG br
#define BRANCH_AND_LINK_TO_REG blr
#define SIGN_LR_LINUX_ONLY SIGN_LR
#if (__ARM_FEATURE_PAC_DEFAULT & 1) == 1
#define SIGN_LR hint #25
#define AUTH_LR hint #29
#else
#define SIGN_LR hint #27
#define AUTH_LR hint #31
#endif
#define AUTH_LR_WITH_REG(x) _auth_lr_with_reg x
.macro _auth_lr_with_reg modifier
mov TMP_REG, sp
mov sp, \modifier
AUTH_LR
mov sp, TMP_REG
.endm
#define SIGN_LR_WITH_REG(x) _sign_lr_with_reg x
.macro _sign_lr_with_reg modifier
mov TMP_REG, sp
mov sp, \modifier
SIGN_LR
mov sp, TMP_REG
.endm
#define AUTH_LR_AND_RET _auth_lr_and_ret modifier
.macro _auth_lr_and_ret modifier
AUTH_LR
ret
.endm
#undef TMP_REG
#else
#define SIGN_LR
#define SIGN_LR_WITH_REG(x)
#define AUTH_LR_AND_RET ret
#define AUTH_LR_WITH_REG(x)
#define BRANCH_AND_LINK_TO_REG blr
#define SIGN_LR_LINUX_ONLY
#define BRANCH_TO_REG br
#define PAC_CFI_WINDOW_SAVE
#define GNU_PROPERTY_AARCH64_POINTER_AUTH 0
#endif
#endif