From fb46f06881b405f6c4214a1fa1a65c62a3b66786 Mon Sep 17 00:00:00 2001 From: Charlie Fenton Date: Wed, 20 Feb 2008 12:04:56 +0000 Subject: [PATCH] - Mac client: Fix bug which erroneously set powerpc_emulated_on_i386 true for X86_64 native applications. svn path=/trunk/boinc/; revision=14766 --- checkin_notes | 7 +++++++ client/app_start.C | 30 ++++++++++++++++++++++++------ 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/checkin_notes b/checkin_notes index 90e42e2cc4..fdbce29cfc 100644 --- a/checkin_notes +++ b/checkin_notes @@ -1469,3 +1469,10 @@ Charlie Feb 19 2008 Mac_Saver_ModuleView.h screensaver.cpp screensaver_win.cpp + +Charlie Feb 20 2008 + - Mac client: Fix bug which erroneously set powerpc_emulated_on_i386 + true for X86_64 native applications. + + client/ + app_graphics.C diff --git a/client/app_start.C b/client/app_start.C index d0ef8d083d..034a086657 100644 --- a/client/app_start.C +++ b/client/app_start.C @@ -860,7 +860,7 @@ union headeru { // Read the mach-o headers to determine the architectures // supported by executable file. -// Returns 1 if application can run natively on i386 Macs, else returns 0. +// Returns 1 if application can run natively on i386 / x86_64 Macs, else returns 0. // int ACTIVE_TASK::is_native_i386_app(char* exec_path) { FILE *f; @@ -870,6 +870,8 @@ int ACTIVE_TASK::is_native_i386_app(char* exec_path) { fat_arch fatHeader; uint32_t n, i, len; + uint32_t theMagic; + integer_t theType; f = boinc_fopen(exec_path, "rb"); if (!f) { @@ -880,21 +882,37 @@ int ACTIVE_TASK::is_native_i386_app(char* exec_path) { myHeader.fat.nfat_arch = 0; fread(&myHeader, 1, sizeof(fat_header), f); - switch (myHeader.mach.magic) { + theMagic = myHeader.mach.magic; + switch (theMagic) { + case MH_CIGAM: case MH_MAGIC: - if (myHeader.mach.cputype == CPU_TYPE_I386) { - result = 1; // Single-architecture i386 file + case MH_MAGIC_64: + case MH_CIGAM_64: + theType = myHeader.mach.cputype; + if ((theMagic == MH_CIGAM) || (theMagic == MH_CIGAM_64)) { + theType = OSSwapInt32(theType); + } + if ((theType == CPU_TYPE_I386) || (theType == CPU_TYPE_X86_64)) { + result = 1; // Single-architecture i386or x86_64 file } break; + case FAT_MAGIC: case FAT_CIGAM: - n = _OSSwapInt32(myHeader.fat.nfat_arch); + n = myHeader.fat.nfat_arch; + if (theMagic == FAT_CIGAM) { + n = OSSwapInt32(myHeader.fat.nfat_arch); + } // Multiple architecture (fat) file for (i=0; i