diff options
Diffstat (limited to 'src/third_party/mac_headers/mach-o/arch.h')
-rw-r--r-- | src/third_party/mac_headers/mach-o/arch.h | 51 |
1 files changed, 48 insertions, 3 deletions
diff --git a/src/third_party/mac_headers/mach-o/arch.h b/src/third_party/mac_headers/mach-o/arch.h index 526c10fc..29b81c5b 100644 --- a/src/third_party/mac_headers/mach-o/arch.h +++ b/src/third_party/mac_headers/mach-o/arch.h @@ -48,7 +48,7 @@ typedef struct { const char *description; } NXArchInfo; -#if __cplusplus +#ifdef __cplusplus extern "C" { #endif /* __cplusplus */ @@ -72,6 +72,36 @@ extern const NXArchInfo *NXGetArchInfoFromName(const char *name); extern const NXArchInfo *NXGetArchInfoFromCpuType(cpu_type_t cputype, cpu_subtype_t cpusubtype); +/* The above interfaces that return pointers to NXArchInfo structs in normal + * cases returns a pointer from the array returned in NXGetAllArchInfos(). + * In some cases when the cputype is CPU_TYPE_I386 or CPU_TYPE_POWERPC it will + * retun malloc(3)'ed NXArchInfo struct which contains a string in the + * description field also a malloc(3)'ed pointer. To allow programs not to + * leak memory they can call NXFreeArchInfo() on pointers returned from the + * above interfaces. Since this is a new API on older systems can use the + * code below. Going forward the above interfaces will only return pointers + * from the array returned in NXGetAllArchInfos(). + */ +extern void NXFreeArchInfo(const NXArchInfo *x); + +/* The code that can be used for NXFreeArchInfo() when it is not available is: + * + * static void NXFreeArchInfo( + * const NXArchInfo *x) + * { + * const NXArchInfo *p; + * + * p = NXGetAllArchInfos(); + * while(p->name != NULL){ + * if(x == p) + * return; + * p++; + * } + * free((char *)x->description); + * free((NXArchInfo *)x); + * } + */ + /* NXFindBestFatArch() is passed a cputype and cpusubtype and a set of * fat_arch structs and selects the best one that matches (if any) and returns * a pointer to that fat_arch struct (or NULL). The fat_arch structs must be @@ -86,6 +116,21 @@ extern struct fat_arch *NXFindBestFatArch(cpu_type_t cputype, struct fat_arch *fat_archs, uint32_t nfat_archs); +/* NXFindBestFatArch_64() is passed a cputype and cpusubtype and a set of + * fat_arch_64 structs and selects the best one that matches (if any) and + * returns a pointer to that fat_arch_64 struct (or NULL). The fat_arch_64 + * structs must be in the host byte order and correct such that the fat_archs64 + * really points to enough memory for nfat_arch structs. It is possible that + * this routine could fail if new cputypes or cpusubtypes are added and an old + * version of this routine is used. But if there is an exact match between the + * cputype and cpusubtype and one of the fat_arch_64 structs this routine will + * always succeed. + */ +extern struct fat_arch_64 *NXFindBestFatArch_64(cpu_type_t cputype, + cpu_subtype_t cpusubtype, + struct fat_arch_64 *fat_archs64, + uint32_t nfat_archs); + /* NXCombineCpuSubtypes() returns the resulting cpusubtype when combining two * different cpusubtypes for the specified cputype. If the two cpusubtypes * can't be combined (the specific subtypes are mutually exclusive) -1 is @@ -98,8 +143,8 @@ extern cpu_subtype_t NXCombineCpuSubtypes(cpu_type_t cputype, cpu_subtype_t cpusubtype1, cpu_subtype_t cpusubtype2); -#if __cplusplus +#ifdef __cplusplus } #endif /* __cplusplus */ -#endif /* _MACH_O_ARCH_H_ */ +#endif /* _MACH_O_ARCH_H_ */
\ No newline at end of file |