2 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
23 #ifndef _MACH_O_ARCH_H_
24 #define _MACH_O_ARCH_H_
26 * Copyright (c) 1997 Apple Computer, Inc.
28 * Functions that deal with information about architectures.
33 #include <mach/machine.h>
34 #include <architecture/byte_order.h>
36 /* The NXArchInfo structs contain the architectures symbolic name
37 * (such as "ppc"), its CPU type and CPU subtype as defined in
38 * mach/machine.h, the byte order for the architecture, and a
39 * describing string (such as "PowerPC").
40 * There will both be entries for specific CPUs (such as ppc604e) as
41 * well as generic "family" entries (such as ppc).
46 cpu_subtype_t cpusubtype
;
47 enum NXByteOrder byteorder
;
48 const char *description
;
53 #endif /* __cplusplus */
55 /* NXGetAllArchInfos() returns a pointer to an array of all known
56 * NXArchInfo structures. The last NXArchInfo is marked by a NULL name.
58 extern const NXArchInfo
*NXGetAllArchInfos(void);
60 /* NXGetLocalArchInfo() returns the NXArchInfo for the local host, or NULL
63 extern const NXArchInfo
*NXGetLocalArchInfo(void);
65 /* NXGetArchInfoFromName() and NXGetArchInfoFromCpuType() return the
66 * NXArchInfo from the architecture's name or cputype/cpusubtype
67 * combination. A cpusubtype of CPU_SUBTYPE_MULTIPLE can be used
68 * to request the most general NXArchInfo known for the given cputype.
69 * NULL is returned if no matching NXArchInfo can be found.
71 extern const NXArchInfo
*NXGetArchInfoFromName(const char *name
);
72 extern const NXArchInfo
*NXGetArchInfoFromCpuType(cpu_type_t cputype
,
73 cpu_subtype_t cpusubtype
);
75 /* NXFindBestFatArch() is passed a cputype and cpusubtype and a set of
76 * fat_arch structs and selects the best one that matches (if any) and returns
77 * a pointer to that fat_arch struct (or NULL). The fat_arch structs must be
78 * in the host byte order and correct such that the fat_archs really points to
79 * enough memory for nfat_arch structs. It is possible that this routine could
80 * fail if new cputypes or cpusubtypes are added and an old version of this
81 * routine is used. But if there is an exact match between the cputype and
82 * cpusubtype and one of the fat_arch structs this routine will always succeed.
84 extern struct fat_arch
*NXFindBestFatArch(cpu_type_t cputype
,
85 cpu_subtype_t cpusubtype
,
86 struct fat_arch
*fat_archs
,
89 /* NXFindBestFatArch_64() is passed a cputype and cpusubtype and a set of
90 * fat_arch_64 structs and selects the best one that matches (if any) and
91 * returns a pointer to that fat_arch_64 struct (or NULL). The fat_arch_64
92 * structs must be in the host byte order and correct such that the fat_archs64
93 * really points to enough memory for nfat_arch structs. It is possible that
94 * this routine could fail if new cputypes or cpusubtypes are added and an old
95 * version of this routine is used. But if there is an exact match between the
96 * cputype and cpusubtype and one of the fat_arch_64 structs this routine will
99 extern struct fat_arch_64
*NXFindBestFatArch_64(cpu_type_t cputype
,
100 cpu_subtype_t cpusubtype
,
101 struct fat_arch_64
*fat_archs64
,
102 uint32_t nfat_archs
);
104 /* NXCombineCpuSubtypes() returns the resulting cpusubtype when combining two
105 * different cpusubtypes for the specified cputype. If the two cpusubtypes
106 * can't be combined (the specific subtypes are mutually exclusive) -1 is
107 * returned indicating it is an error to combine them. This can also fail and
108 * return -1 if new cputypes or cpusubtypes are added and an old version of
109 * this routine is used. But if the cpusubtypes are the same they can always
110 * be combined and this routine will return the cpusubtype pass in.
112 extern cpu_subtype_t
NXCombineCpuSubtypes(cpu_type_t cputype
,
113 cpu_subtype_t cpusubtype1
,
114 cpu_subtype_t cpusubtype2
);
118 #endif /* __cplusplus */
120 #endif /* _MACH_O_ARCH_H_ */