+#if __DARWIN_C_LEVEL >= __DARWIN_C_FULL && defined(__arm64__)
+
+/* Accessor macros for arm_thread_state64_t pointer fields */
+
+#if __has_feature(ptrauth_calls) && defined(__LP64__)
+#include <ptrauth.h>
+
+#if !__DARWIN_OPAQUE_ARM_THREAD_STATE64 || !__DARWIN_PTRAUTH_ARM_THREAD_STATE64
+#error "Invalid configuration"
+#endif
+
+#define __DARWIN_ARM_THREAD_STATE64_FLAGS_NO_PTRAUTH 0x1
+#define __DARWIN_ARM_THREAD_STATE64_FLAGS_IB_SIGNED_LR 0x2
+
+/* Return pc field of arm_thread_state64_t as a data pointer value */
+#define __darwin_arm_thread_state64_get_pc(ts) \
+ __extension__ ({ const _STRUCT_ARM_THREAD_STATE64 *__tsp = &(ts); \
+ (uintptr_t)(__tsp->__opaque_pc && !(__tsp->__opaque_flags & \
+ __DARWIN_ARM_THREAD_STATE64_FLAGS_NO_PTRAUTH) ? \
+ ptrauth_auth_data(__tsp->__opaque_pc, \
+ ptrauth_key_process_independent_code, \
+ ptrauth_string_discriminator("pc")) : __tsp->__opaque_pc); })
+/* Return pc field of arm_thread_state64_t as a function pointer. May return
+ * NULL if a valid function pointer cannot be constructed, the caller should
+ * fall back to the __darwin_arm_thread_state64_get_pc() macro in that case. */
+#define __darwin_arm_thread_state64_get_pc_fptr(ts) \
+ __extension__ ({ const _STRUCT_ARM_THREAD_STATE64 *__tsp = &(ts); \
+ (__tsp->__opaque_pc && !(__tsp->__opaque_flags & \
+ __DARWIN_ARM_THREAD_STATE64_FLAGS_NO_PTRAUTH) ? \
+ ptrauth_auth_function(__tsp->__opaque_pc, \
+ ptrauth_key_process_independent_code, \
+ ptrauth_string_discriminator("pc")) : NULL); })
+/* Set pc field of arm_thread_state64_t to a function pointer */
+#define __darwin_arm_thread_state64_set_pc_fptr(ts, fptr) \
+ __extension__ ({ _STRUCT_ARM_THREAD_STATE64 *__tsp = &(ts); \
+ __typeof__(fptr) __f = (fptr); __tsp->__opaque_pc = \
+ (__f ? (!(__tsp->__opaque_flags & \
+ __DARWIN_ARM_THREAD_STATE64_FLAGS_NO_PTRAUTH) ? \
+ ptrauth_auth_and_resign(__f, ptrauth_key_function_pointer, 0, \
+ ptrauth_key_process_independent_code, \
+ ptrauth_string_discriminator("pc")) : ptrauth_auth_data(__f, \
+ ptrauth_key_function_pointer, 0)) : __f); })
+/* Return lr field of arm_thread_state64_t as a data pointer value */
+#define __darwin_arm_thread_state64_get_lr(ts) \
+ __extension__ ({ const _STRUCT_ARM_THREAD_STATE64 *__tsp = &(ts); \
+ (uintptr_t)(__tsp->__opaque_lr && !(__tsp->__opaque_flags & ( \
+ __DARWIN_ARM_THREAD_STATE64_FLAGS_NO_PTRAUTH | \
+ __DARWIN_ARM_THREAD_STATE64_FLAGS_IB_SIGNED_LR)) ? \
+ ptrauth_auth_data(__tsp->__opaque_lr, \
+ ptrauth_key_process_independent_code, \
+ ptrauth_string_discriminator("lr")) : __tsp->__opaque_lr); })
+/* Return lr field of arm_thread_state64_t as a function pointer. May return
+ * NULL if a valid function pointer cannot be constructed, the caller should
+ * fall back to the __darwin_arm_thread_state64_get_lr() macro in that case. */
+#define __darwin_arm_thread_state64_get_lr_fptr(ts) \
+ __extension__ ({ const _STRUCT_ARM_THREAD_STATE64 *__tsp = &(ts); \
+ (__tsp->__opaque_lr && !(__tsp->__opaque_flags & ( \
+ __DARWIN_ARM_THREAD_STATE64_FLAGS_NO_PTRAUTH | \
+ __DARWIN_ARM_THREAD_STATE64_FLAGS_IB_SIGNED_LR)) ? \
+ ptrauth_auth_function(__tsp->__opaque_lr, \
+ ptrauth_key_process_independent_code, \
+ ptrauth_string_discriminator("lr")) : NULL); })
+/* Set lr field of arm_thread_state64_t to a function pointer */
+#define __darwin_arm_thread_state64_set_lr_fptr(ts, fptr) \
+ __extension__ ({ _STRUCT_ARM_THREAD_STATE64 *__tsp = &(ts); \
+ __typeof__(fptr) __f = (fptr); __tsp->__opaque_lr = \
+ (__f ? (!(__tsp->__opaque_flags & \
+ __DARWIN_ARM_THREAD_STATE64_FLAGS_NO_PTRAUTH) ? (__tsp->__opaque_flags \
+ &= ~__DARWIN_ARM_THREAD_STATE64_FLAGS_IB_SIGNED_LR , \
+ ptrauth_auth_and_resign(__f, ptrauth_key_function_pointer, 0, \
+ ptrauth_key_process_independent_code, \
+ ptrauth_string_discriminator("lr"))) : ptrauth_auth_data(__f, \
+ ptrauth_key_function_pointer, 0)) : __f); })
+/* Return sp field of arm_thread_state64_t as a data pointer value */
+#define __darwin_arm_thread_state64_get_sp(ts) \
+ __extension__ ({ const _STRUCT_ARM_THREAD_STATE64 *__tsp = &(ts); \
+ (uintptr_t)(__tsp->__opaque_sp && !(__tsp->__opaque_flags & \
+ __DARWIN_ARM_THREAD_STATE64_FLAGS_NO_PTRAUTH) ? \
+ ptrauth_auth_data(__tsp->__opaque_sp, \
+ ptrauth_key_process_independent_data, \
+ ptrauth_string_discriminator("sp")) : __tsp->__opaque_sp); })
+/* Set sp field of arm_thread_state64_t to a data pointer value */
+#define __darwin_arm_thread_state64_set_sp(ts, ptr) \
+ __extension__ ({ _STRUCT_ARM_THREAD_STATE64 *__tsp = &(ts); \
+ void *__p = (void*)(uintptr_t)(ptr); __tsp->__opaque_sp = \
+ (__p && !(__tsp->__opaque_flags & \
+ __DARWIN_ARM_THREAD_STATE64_FLAGS_NO_PTRAUTH) ? \
+ ptrauth_sign_unauthenticated(__p, \
+ ptrauth_key_process_independent_data, \
+ ptrauth_string_discriminator("sp")) : __p); })
+/* Return fp field of arm_thread_state64_t as a data pointer value */
+#define __darwin_arm_thread_state64_get_fp(ts) \
+ __extension__ ({ const _STRUCT_ARM_THREAD_STATE64 *__tsp = &(ts); \
+ (uintptr_t)(__tsp->__opaque_fp && !(__tsp->__opaque_flags & \
+ __DARWIN_ARM_THREAD_STATE64_FLAGS_NO_PTRAUTH) ? \
+ ptrauth_auth_data(__tsp->__opaque_fp, \
+ ptrauth_key_process_independent_data, \
+ ptrauth_string_discriminator("fp")) : __tsp->__opaque_fp); })
+/* Set fp field of arm_thread_state64_t to a data pointer value */
+#define __darwin_arm_thread_state64_set_fp(ts, ptr) \
+ __extension__ ({ _STRUCT_ARM_THREAD_STATE64 *__tsp = &(ts); \
+ void *__p = (void*)(uintptr_t)(ptr); __tsp->__opaque_fp = \
+ (__p && !(__tsp->__opaque_flags & \
+ __DARWIN_ARM_THREAD_STATE64_FLAGS_NO_PTRAUTH) ? \
+ ptrauth_sign_unauthenticated(__p, \
+ ptrauth_key_process_independent_data, \
+ ptrauth_string_discriminator("fp")) : __p); })
+
+/* Strip ptr auth bits from pc, lr, sp and fp field of arm_thread_state64_t */
+#define __darwin_arm_thread_state64_ptrauth_strip(ts) \
+ __extension__ ({ _STRUCT_ARM_THREAD_STATE64 *__tsp = &(ts); \
+ __tsp->__opaque_pc = ((__tsp->__opaque_flags & \
+ __DARWIN_ARM_THREAD_STATE64_FLAGS_NO_PTRAUTH) ? __tsp->__opaque_pc : \
+ ptrauth_strip(__tsp->__opaque_pc, ptrauth_key_process_independent_code)); \
+ __tsp->__opaque_lr = ((__tsp->__opaque_flags & \
+ (__DARWIN_ARM_THREAD_STATE64_FLAGS_NO_PTRAUTH | \
+ __DARWIN_ARM_THREAD_STATE64_FLAGS_IB_SIGNED_LR)) ? __tsp->__opaque_lr : \
+ ptrauth_strip(__tsp->__opaque_lr, ptrauth_key_process_independent_code)); \
+ __tsp->__opaque_sp = ((__tsp->__opaque_flags & \
+ __DARWIN_ARM_THREAD_STATE64_FLAGS_NO_PTRAUTH) ? __tsp->__opaque_sp : \
+ ptrauth_strip(__tsp->__opaque_sp, ptrauth_key_process_independent_data)); \
+ __tsp->__opaque_fp = ((__tsp->__opaque_flags & \
+ __DARWIN_ARM_THREAD_STATE64_FLAGS_NO_PTRAUTH) ? __tsp->__opaque_fp : \
+ ptrauth_strip(__tsp->__opaque_fp, ptrauth_key_process_independent_data)); \
+ __tsp->__opaque_flags |= \
+ __DARWIN_ARM_THREAD_STATE64_FLAGS_NO_PTRAUTH; })
+
+#else /* __has_feature(ptrauth_calls) && defined(__LP64__) */
+
+#if __DARWIN_OPAQUE_ARM_THREAD_STATE64
+
+#ifndef __LP64__
+#error "Invalid configuration"
+#endif
+
+/* Return pc field of arm_thread_state64_t as a data pointer value */
+#define __darwin_arm_thread_state64_get_pc(ts) \
+ ((uintptr_t)((ts).__opaque_pc))
+/* Return pc field of arm_thread_state64_t as a function pointer */
+#define __darwin_arm_thread_state64_get_pc_fptr(ts) \
+ ((ts).__opaque_pc)
+/* Set pc field of arm_thread_state64_t to a function pointer */
+#define __darwin_arm_thread_state64_set_pc_fptr(ts, fptr) \
+ ((ts).__opaque_pc = (fptr))
+/* Return lr field of arm_thread_state64_t as a data pointer value */
+#define __darwin_arm_thread_state64_get_lr(ts) \
+ ((uintptr_t)((ts).__opaque_lr))
+/* Return lr field of arm_thread_state64_t as a function pointer */
+#define __darwin_arm_thread_state64_get_lr_fptr(ts) \
+ ((ts).__opaque_lr)
+/* Set lr field of arm_thread_state64_t to a function pointer */
+#define __darwin_arm_thread_state64_set_lr_fptr(ts, fptr) \
+ ((ts).__opaque_lr = (fptr))
+/* Return sp field of arm_thread_state64_t as a data pointer value */
+#define __darwin_arm_thread_state64_get_sp(ts) \
+ ((uintptr_t)((ts).__opaque_sp))
+/* Set sp field of arm_thread_state64_t to a data pointer value */
+#define __darwin_arm_thread_state64_set_sp(ts, ptr) \
+ ((ts).__opaque_sp = (void*)(uintptr_t)(ptr))
+/* Return fp field of arm_thread_state64_t as a data pointer value */
+#define __darwin_arm_thread_state64_get_fp(ts) \
+ ((uintptr_t)((ts).__opaque_fp))
+/* Set fp field of arm_thread_state64_t to a data pointer value */
+#define __darwin_arm_thread_state64_set_fp(ts, ptr) \
+ ((ts).__opaque_fp = (void*)(uintptr_t)(ptr))
+/* Strip ptr auth bits from pc, lr, sp and fp field of arm_thread_state64_t */
+#define __darwin_arm_thread_state64_ptrauth_strip(ts) \
+ (void)(ts)
+
+#else /* __DARWIN_OPAQUE_ARM_THREAD_STATE64 */
+#if __DARWIN_UNIX03
+
+/* Return pc field of arm_thread_state64_t as a data pointer value */
+#define __darwin_arm_thread_state64_get_pc(ts) \
+ ((ts).__pc)
+/* Return pc field of arm_thread_state64_t as a function pointer */
+#define __darwin_arm_thread_state64_get_pc_fptr(ts) \
+ ((void*)(uintptr_t)((ts).__pc))
+/* Set pc field of arm_thread_state64_t to a function pointer */
+#define __darwin_arm_thread_state64_set_pc_fptr(ts, fptr) \
+ ((ts).__pc = (uintptr_t)(fptr))
+/* Return lr field of arm_thread_state64_t as a data pointer value */
+#define __darwin_arm_thread_state64_get_lr(ts) \
+ ((ts).__lr)
+/* Return lr field of arm_thread_state64_t as a function pointer */
+#define __darwin_arm_thread_state64_get_lr_fptr(ts) \
+ ((void*)(uintptr_t)((ts).__lr))
+/* Set lr field of arm_thread_state64_t to a function pointer */
+#define __darwin_arm_thread_state64_set_lr_fptr(ts, fptr) \
+ ((ts).__lr = (uintptr_t)(fptr))
+/* Return sp field of arm_thread_state64_t as a data pointer value */
+#define __darwin_arm_thread_state64_get_sp(ts) \
+ ((ts).__sp)
+/* Set sp field of arm_thread_state64_t to a data pointer value */
+#define __darwin_arm_thread_state64_set_sp(ts, ptr) \
+ ((ts).__sp = (uintptr_t)(ptr))
+/* Return fp field of arm_thread_state64_t as a data pointer value */
+#define __darwin_arm_thread_state64_get_fp(ts) \
+ ((ts).__fp)
+/* Set fp field of arm_thread_state64_t to a data pointer value */
+#define __darwin_arm_thread_state64_set_fp(ts, ptr) \
+ ((ts).__fp = (uintptr_t)(ptr))
+/* Strip ptr auth bits from pc, lr, sp and fp field of arm_thread_state64_t */
+#define __darwin_arm_thread_state64_ptrauth_strip(ts) \
+ (void)(ts)
+
+#else /* __DARWIN_UNIX03 */
+
+/* Return pc field of arm_thread_state64_t as a data pointer value */
+#define __darwin_arm_thread_state64_get_pc(ts) \
+ ((ts).pc)
+/* Return pc field of arm_thread_state64_t as a function pointer */
+#define __darwin_arm_thread_state64_get_pc_fptr(ts) \
+ ((void*)(uintptr_t)((ts).pc))
+/* Set pc field of arm_thread_state64_t to a function pointer */
+#define __darwin_arm_thread_state64_set_pc_fptr(ts, fptr) \
+ ((ts).pc = (uintptr_t)(fptr))
+/* Return lr field of arm_thread_state64_t as a data pointer value */
+#define __darwin_arm_thread_state64_get_lr(ts) \
+ ((ts).lr)
+/* Return lr field of arm_thread_state64_t as a function pointer */
+#define __darwin_arm_thread_state64_get_lr_fptr(ts) \
+ ((void*)(uintptr_t)((ts).lr))
+/* Set lr field of arm_thread_state64_t to a function pointer */
+#define __darwin_arm_thread_state64_set_lr_fptr(ts, fptr) \
+ ((ts).lr = (uintptr_t)(fptr))
+/* Return sp field of arm_thread_state64_t as a data pointer value */
+#define __darwin_arm_thread_state64_get_sp(ts) \
+ ((ts).sp)
+/* Set sp field of arm_thread_state64_t to a data pointer value */
+#define __darwin_arm_thread_state64_set_sp(ts, ptr) \
+ ((ts).sp = (uintptr_t)(ptr))
+/* Return fp field of arm_thread_state64_t as a data pointer value */
+#define __darwin_arm_thread_state64_get_fp(ts) \
+ ((ts).fp)
+/* Set fp field of arm_thread_state64_t to a data pointer value */
+#define __darwin_arm_thread_state64_set_fp(ts, ptr) \
+ ((ts).fp = (uintptr_t)(ptr))
+/* Strip ptr auth bits from pc, lr, sp and fp field of arm_thread_state64_t */
+#define __darwin_arm_thread_state64_ptrauth_strip(ts) \
+ (void)(ts)
+
+#endif /* __DARWIN_UNIX03 */
+#endif /* __DARWIN_OPAQUE_ARM_THREAD_STATE64 */
+
+#endif /* __has_feature(ptrauth_calls) && defined(__LP64__) */
+#endif /* __DARWIN_C_LEVEL >= __DARWIN_C_FULL && defined(__arm64__) */
+#endif /* !defined(KERNEL) */
+