// 平台差异的最小公共面:信号上下文寄存器、宿主登记段。Darwin 与 Linux 各一份定义,其余差异见 compat/linux/compat_linux.h。 // Minimal common surface of platform differences: signal-context registers and host registration sections. One definition each for Darwin and Linux; // other differences are in compat/linux/compat_linux.h. #pragma once #if defined(__APPLE__) #define UC_X(uc, i) ((uc)->uc_mcontext->__ss.__x[i]) #define UC_PC(uc) ((uc)->uc_mcontext->__ss.__pc) #define UC_LR(uc) ((uc)->uc_mcontext->__ss.__lr) #define UC_FP(uc) ((uc)->uc_mcontext->__ss.__fp) #define UC_SP(uc) ((uc)->uc_mcontext->__ss.__sp) #define UC_ESR(uc) ((uint64_t)(uc)->uc_mcontext->__es.__esr) // 登记段:Mach-O 段名 "__DATA,<名>" // Registration section: Mach-O section name "__DATA," #define DM_SECT(name) section("__DATA," name) #else #define UC_X(uc, i) ((uc)->uc_mcontext.regs[i]) #define UC_PC(uc) ((uc)->uc_mcontext.pc) #define UC_LR(uc) ((uc)->uc_mcontext.regs[30]) #define UC_FP(uc) ((uc)->uc_mcontext.regs[29]) #define UC_SP(uc) ((uc)->uc_mcontext.sp) #define UC_ESR(uc) dm_uc_esr(uc) // 登记段:ELF 段名须是 C 标识符,链接器才给 __start_<名> / __stop_<名>;retain 防 --gc-sections 丢弃 // Registration section: the ELF section name must be a C identifier for the linker to provide __start_ / __stop_; retain keeps --gc-sections from dropping it #define DM_SECT(name) section(name), retain #endif // 触摸产品(iOS 包、Android 包):设置缺省、掉落过滤规则、自动补增益这类「产品缺省开、Mac 宿主对拍时缺省关」的开关看它,不看 TARGET_OS_IPHONE。 // 展开时才读 TARGET_OS_IPHONE,用处须已包含 TargetConditionals(Linux 由 compat_linux.h 定义)。 // Touch product (iOS build, Android build): switches that are "on by default in the product, off by default for Mac host parity" (settings defaults, loot filter rules, auto-buff) // check this rather than TARGET_OS_IPHONE. TARGET_OS_IPHONE is read at expansion, so the use site must already include TargetConditionals (compat_linux.h defines it on Linux). #if defined(__ANDROID__) #define DM_TOUCH_PRODUCT 1 #else #define DM_TOUCH_PRODUCT TARGET_OS_IPHONE #endif