// Linux 替身:mach/mach.h —— 实际定义见 compat_linux.h(-include 强制先含) // Linux stand-in: mach/mach.h -- the actual definitions are in compat_linux.h (force-included with -include) #pragma once #include // ---- 线程诊断接口:Linux 上一律返回失败,调用方走「拿不到」分支(暂停取寄存器、线程信息、实时策略都只用于诊断 / 调优) ---- // ---- Thread diagnostic interfaces: always fail on Linux, callers take their "unavailable" branch (suspend-and-read-registers, thread info and real-time policy are only for diagnostics / tuning) ---- typedef int boolean_t; typedef int *thread_info_t, *thread_state_t, *thread_policy_t; typedef int thread_flavor_t, thread_state_flavor_t, thread_policy_flavor_t; typedef mach_port_t *thread_act_array_t; typedef struct { int seconds, microseconds; } time_value_t; typedef struct { time_value_t user_time, system_time; int cpu_usage, policy, run_state, flags, suspend_count, sleep_time; } thread_basic_info_data_t; typedef struct { uint64_t pth_user_time, pth_system_time; int32_t pth_cpu_usage, pth_policy, pth_run_state, pth_flags, pth_sleep_time, pth_curpri, pth_priority, pth_maxpriority; char pth_name[64]; } thread_extended_info_data_t; typedef struct { uint64_t __x[29], __fp, __lr, __sp, __pc; uint32_t __cpsr, __pad; } arm_thread_state64_t; #define THREAD_BASIC_INFO 3 #define THREAD_BASIC_INFO_COUNT ((mach_msg_type_number_t)(sizeof(thread_basic_info_data_t) / sizeof(int))) #define THREAD_EXTENDED_INFO 5 #define THREAD_EXTENDED_INFO_COUNT ((mach_msg_type_number_t)(sizeof(thread_extended_info_data_t) / sizeof(int))) #define ARM_THREAD_STATE64 6 #define ARM_THREAD_STATE64_COUNT ((mach_msg_type_number_t)(sizeof(arm_thread_state64_t) / sizeof(int))) #define __darwin_arm_thread_state64_get_pc(s) ((s).__pc) #define __darwin_arm_thread_state64_get_lr(s) ((s).__lr) #define __darwin_arm_thread_state64_get_fp(s) ((s).__fp) #define __darwin_arm_thread_state64_get_sp(s) ((s).__sp) static inline kern_return_t thread_info(mach_port_t t, thread_flavor_t f, thread_info_t o, mach_msg_type_number_t *n) { (void)t; (void)f; (void)o; (void)n; return KERN_FAILURE; } static inline kern_return_t thread_suspend(mach_port_t t) { (void)t; return KERN_FAILURE; } static inline kern_return_t thread_resume(mach_port_t t) { (void)t; return KERN_FAILURE; } static inline kern_return_t thread_get_state(mach_port_t t, thread_state_flavor_t f, thread_state_t s, mach_msg_type_number_t *n) { (void)t; (void)f; (void)s; (void)n; return KERN_FAILURE; } static inline kern_return_t task_threads(mach_port_t task, thread_act_array_t *a, mach_msg_type_number_t *n) { (void)task; *a = 0; *n = 0; return KERN_FAILURE; } static inline kern_return_t vm_deallocate(mach_port_t task, vm_address_t a, vm_size_t n) { (void)task; (void)a; (void)n; return KERN_SUCCESS; } // libSystem 私有:本线程 {指令, 周期};Linux 版给 0(可改用 perf_event_open) | libSystem private: this thread's {instructions, cycles}; Linux gives 0 (perf_event_open could be used instead) static inline int thread_selfcounts(int type, void *buf, size_t nbytes) { (void)type; memset(buf, 0, nbytes); return -1; }