+load_return_t
+fatfile_getarch_affinity(
+ struct vnode *vp,
+ vm_offset_t data_ptr,
+ struct fat_arch *archret,
+ int affinity)
+{
+ load_return_t lret;
+ int handler = (exec_archhandler_ppc.path[0] != 0);
+ cpu_type_t primary_type, fallback_type;
+
+ if (handler && affinity) {
+ primary_type = CPU_TYPE_POWERPC;
+ fallback_type = cpu_type();
+ } else {
+ primary_type = cpu_type();
+ fallback_type = CPU_TYPE_POWERPC;
+ }
+ /*
+ * Ignore all architectural bits when determining if an image
+ * in a fat file should be skipped or graded.
+ */
+ lret = fatfile_getarch2(vp, data_ptr, primary_type,
+ CPU_ARCH_MASK, archret);
+ if ((lret != 0) && handler) {
+ lret = fatfile_getarch2(vp, data_ptr, fallback_type,
+ CPU_SUBTYPE_LIB64, archret);
+ }
+ return lret;
+}
+
+/**********************************************************************
+ * Routine: fatfile_getarch()
+ *
+ * Function: Locate the architecture-dependant contents of a fat
+ * file that match this CPU.
+ *
+ * Args: vp: The vnode for the fat file.
+ * header: A pointer to the fat file header.
+ * archret (out): Pointer to fat_arch structure to hold
+ * the results.
+ *
+ * Returns: KERN_SUCCESS: Valid architecture found.
+ * KERN_FAILURE: No valid architecture found.
+ **********************************************************************/
+load_return_t
+fatfile_getarch(
+ struct vnode *vp,
+ vm_offset_t data_ptr,
+ struct fat_arch *archret)
+{
+ return fatfile_getarch2(vp, data_ptr, cpu_type(),
+ CPU_SUBTYPE_LIB64, archret);
+}
+
+/**********************************************************************
+ * Routine: fatfile_getarch_with_bits()
+ *
+ * Function: Locate the architecture-dependant contents of a fat
+ * file that match this CPU.
+ *
+ * Args: vp: The vnode for the fat file.
+ * archbits: Architecture specific feature bits
+ * header: A pointer to the fat file header.
+ * archret (out): Pointer to fat_arch structure to hold
+ * the results.
+ *
+ * Returns: KERN_SUCCESS: Valid architecture found.
+ * KERN_FAILURE: No valid architecture found.
+ **********************************************************************/
+load_return_t
+fatfile_getarch_with_bits(
+ struct vnode *vp,
+ integer_t archbits,
+ vm_offset_t data_ptr,
+ struct fat_arch *archret)
+{
+ return fatfile_getarch2(vp, data_ptr, archbits | cpu_type(),
+ CPU_SUBTYPE_LIB64, archret);
+}