From e334463d067390506436c8edf203fb8f1b34ff66 Mon Sep 17 00:00:00 2001 From: "Clifford T. Matthews" Date: Mon, 15 Jun 2009 13:27:02 -0600 Subject: [PATCH] Compiles and links for Mac OS X on powerpc. Doesn't run though, trouble with size of packed structures (e.g. fcbrec). --- src/cfm.c | 12 +++++------- src/config/arch/powerpc/powerpc.h | 13 +++++++++++++ src/config/arch/powerpc/powerpc.make | 12 +++++++++++- src/config/front-ends/sdl/sdlwin.c | 2 +- src/config/sound/sdl/sdl-sound.c | 3 --- src/emustubs.c | 6 +++++- src/emutrap.c | 12 ++++++------ src/emutraptables.c | 6 +++--- src/float4.c | 4 ++-- src/gestalt.c | 4 ++-- src/include/rsys/floatconv.h | 6 ++++++ src/include/rsys/launch.c | 2 +- src/include/rsys/memsize.h | 2 +- src/interfacelib.c | 17 +++++++++++++++-- src/launch.c | 2 +- src/main.c | 2 +- src/mathlib.c | 9 +++++++-- src/mixed_mode.c | 2 +- src/mkvol/mkvol_internal.h | 7 +------ src/unix_like.c | 10 +++------- src/windInit.c | 2 +- util/configure.sh | 22 +++++++++++++++++++++- 22 files changed, 107 insertions(+), 50 deletions(-) diff --git a/src/cfm.c b/src/cfm.c index 8105c9b..afb853f 100644 --- a/src/cfm.c +++ b/src/cfm.c @@ -1,13 +1,11 @@ /* Copyright 2000 by Abacus Research and * Development, Inc. All rights reserved. */ +#if defined (CFM_PROBLEMS) -#if defined (powerpc) +#warning "No CFM support for now, even though it limped previously." -#if !defined (OMIT_RCSID_STRINGS) -char ROMlib_rcsid_cfm[] = - "$Id: cfm.c 63 2004-12-24 18:19:43Z ctm $"; -#endif +#elif defined (powerpc) /* * In addition to fleshing this out, it probably makes sense to use mmap @@ -1042,7 +1040,7 @@ load_loader_section (const void *addr, memset (&init_block, 0xFA, sizeof init_block); init_routine = (uint32 (*)(uint32)) SYN68K_TO_US (init_addr[0]); init_toc = (uint32) SYN68K_TO_US (init_addr[1]); -#if defined (powerpc) +#if defined (powerpc) || defined (__ppc__) retval = ppc_call (init_toc, init_routine, (uint32) &init_block); #else warning_unexpected (NULL_STRING); @@ -1159,7 +1157,7 @@ typedef enum { ICACHE } flush_type_t; PRIVATE void cacheflush (void *start, uint32 length, flush_type_t flush) { -#if defined (powerpc) +#if defined (powerpc) || defined (__ppc__) enum { CACHE_LINE_SIZE = 32, }; char *p, *ep; diff --git a/src/config/arch/powerpc/powerpc.h b/src/config/arch/powerpc/powerpc.h index 7cce491..cd07a3d 100644 --- a/src/config/arch/powerpc/powerpc.h +++ b/src/config/arch/powerpc/powerpc.h @@ -13,5 +13,18 @@ extern uint32 ppc_call (uint32 toc, uint32 (*func)(uint32), uint32 arg); +/* + * Using __ppc__ to detect that we're going to have problems with the + * Code Fragment Manager is a "short-term" (heh!) hack to allow us to + * build the Mac OS X PPC version before switching to the GNU Build + * system where we can either use configure to figure out if cfm.c + * will build or have the free time (right!) to figure out what needs + * to be done to get cfm.c "working" again. + */ + +#if defined(__ppc__) +# define CFM_PROBLEMS +#endif + #endif /* !_ARCH_POWERPC_H_ */ diff --git a/src/config/arch/powerpc/powerpc.make b/src/config/arch/powerpc/powerpc.make index 988f061..cf13023 100644 --- a/src/config/arch/powerpc/powerpc.make +++ b/src/config/arch/powerpc/powerpc.make @@ -9,5 +9,15 @@ TARGET_CFLAGS += -D_GNU_SOURCE # ppc_call.o: ppc_call.c # $(TARGET_GCC) $(TARGET_CFLAGS) -mcall-aix -c $< + +# -mcall-aix was used when we were compiling on Linux and experimenting with +# running powerpc code using a native powerpc processor. The ability to run +# native powerpc code is not likely to work (initially) under the Mac OS X +# port. + +ifeq (,$(findstring macosx,$(TARGET))) + CALL_AIX_FLAG = -mcall-aix +endif + ppc_stubs.o: ppc_stubs.c ppc_stubs.h - $(TARGET_GCC) $(TARGET_CFLAGS) -mcall-aix -c $< + $(TARGET_GCC) $(TARGET_CFLAGS) $(CALL_AIX_FLAG) -c $< diff --git a/src/config/front-ends/sdl/sdlwin.c b/src/config/front-ends/sdl/sdlwin.c index 1df4ffa..0886d2a 100644 --- a/src/config/front-ends/sdl/sdlwin.c +++ b/src/config/front-ends/sdl/sdlwin.c @@ -19,7 +19,7 @@ char ROMlib_rcsid_sdlwin[] = "$Id: sdlwin.c 63 2004-12-24 18:19:43Z ctm $"; #include "sdlevents.h" #include "syswm_map.h" -#if defined (linux) && !defined (powerpc) +#if defined (linux) && !defined (powerpc) && !defined (__ppc__) #define USE_SDL_EVENT_THREAD #include "sdlX.h" #endif diff --git a/src/config/sound/sdl/sdl-sound.c b/src/config/sound/sdl/sdl-sound.c index 6d2741b..aa518d5 100644 --- a/src/config/sound/sdl/sdl-sound.c +++ b/src/config/sound/sdl/sdl-sound.c @@ -36,9 +36,6 @@ static int num_samples; #define BUFSIZE (1 << (LOGBUFSIZE+1)) /* +1 as bug workaround */ -/* Stack size for child thread */ -#define STACKSIZE 16384 - static int semid = -1; /* Semaphore id */ static int sound_on = 0; /* 1 if we are generating interrupts */ static boolean_t have_sound_p; /* TRUE if sound is supported */ diff --git a/src/emustubs.c b/src/emustubs.c index 1b86abf..a0b3d3c 100644 --- a/src/emustubs.c +++ b/src/emustubs.c @@ -3047,7 +3047,11 @@ STUB (QuickTime) NULL, QuickTime); } -#if defined (powerpc) +#if defined (__ppc__) + +#warning "Need to get CFM going before we can enable this glue." + +#elif defined (powerpc) /* * modeswitch is special; we don't return to from where we came. diff --git a/src/emutrap.c b/src/emutrap.c index 8d8010a..75528b6 100644 --- a/src/emutrap.c +++ b/src/emutrap.c @@ -42,7 +42,7 @@ PUBLIC syn68k_addr_t PascalToCCall(syn68k_addr_t ignoreme, ptocblock_t *infop) { unsigned short pth, ptv; LONGINT args[11], retval; -#if defined (powerpc) +#if defined (powerpc) || defined (__ppc__) Point points[11]; int point_count = 0; #endif @@ -94,7 +94,7 @@ PUBLIC syn68k_addr_t PascalToCCall(syn68k_addr_t ignoreme, ptocblock_t *infop) ptv = POPSW(); pth = POPSW(); #if !defined(LITTLEENDIAN) -#if !defined (powerpc) +#if !defined (powerpc) && !defined (__ppc__) args[count++] = (ptv << 16) | pth; #else points[point_count].h = pth; @@ -221,7 +221,7 @@ CToPascalCall_m68k(void *wheretogo, unsigned long long magic, va_list ap) case 3: ul = va_arg(ap, ULONGINT); #if !defined(LITTLEENDIAN) -#if !defined (powerpc) +#if !defined (powerpc) && !defined (__ppc__) PUSHUW(ul); PUSHUW(ul >> 16); #else @@ -277,7 +277,7 @@ CToPascalCall_m68k(void *wheretogo, unsigned long long magic, va_list ap) return retval; } -#if defined (powerpc) +#if defined (powerpc) || defined (__ppc__) PRIVATE long CToRoutineDescriptorCall (const RoutineDescriptor *p, unsigned long long magic, @@ -344,7 +344,7 @@ CToRoutineDescriptorCall (const RoutineDescriptor *p, unsigned long long magic, case 3: /* point */ { arg = (uint32) va_arg (ap, unsigned long); -#if defined (powerpc) +#if defined (powerpc) || defined (__ppc__) arg = *(uint32 *)arg; #endif arg = (CW ((uint16) arg) | @@ -483,7 +483,7 @@ PUBLIC long CToPascalCall(void *wheretogo, unsigned long magic_in, ...) } va_start(ap, magic_in); -#if defined (powerpc) +#if defined (powerpc) || defined (__ppc__) if (is_routine_descriptor_ptr (wheretogo)) retval = CToRoutineDescriptorCall ((RoutineDescriptor *) wheretogo, magic, ap); diff --git a/src/emutraptables.c b/src/emutraptables.c index d02778f..260c293 100644 --- a/src/emutraptables.c +++ b/src/emutraptables.c @@ -676,7 +676,7 @@ toolstuff_t toolstuff[0x400] = { { { _Unimplemented, -1 }, (void *) 0 }, { { _Unimplemented, -1 }, (void *) 0 }, { { _Unimplemented, -1 }, (void *) 0 }, -#if !defined (powerpc) +#if (!defined (powerpc) && !defined (__ppc__)) || defined (CFM_PROBLEMS) { { _Unimplemented, -1 }, (void *) 0 }, { { _Unimplemented, -1 }, (void *) 0 }, /* AA5A */ #else @@ -846,7 +846,7 @@ toolstuff_t toolstuff[0x400] = { { { _Unimplemented, -1 }, (void *) 0 }, { { _Unimplemented, -1 }, (void *) 0 }, { { _Unimplemented, -1 }, (void *) 0 }, -#if defined (powerpc) +#if defined (powerpc) && !defined (__ppc__) { { _modeswitch, -1 }, (void *) 0 }, #else { { _Unimplemented, -1 }, (void *) 0 }, @@ -1194,7 +1194,7 @@ toolstuff_t pstuff[] = { { { _Key1Trans, -1 }, (void *) 0}, { { _Key2Trans, -1 }, (void *) 0}, - { { NULL /* was C_ROMlib_licensefilt */, NULL /* was PTOC_ROMlib_licensefilt */ }, (void *) 0 }, + { { NULL /* was C_ROMlib_licensefilt */, 0 /* was PTOC_ROMlib_licensefilt */ }, (void *) 0 }, { { C_unixmount, PTOC_unixmount }, (void *) 0 }, { { C_GestaltTablesOnly, PTOC_GestaltTablesOnly }, (void *) 0 }, { { C_sound_timer_handler, 0 }, (void *) 0 }, diff --git a/src/float4.c b/src/float4.c index ee9c021..c28f130 100644 --- a/src/float4.c +++ b/src/float4.c @@ -303,7 +303,7 @@ P_SAVED0D1A0A1_2 (PUBLIC pascal trap, void, ROMlib_Fsetenv, INTEGER *, asm ("fldenv %0" : : "m" (i387_env)); } #endif -#elif defined(__alpha) || defined (powerpc) +#elif defined(__alpha) || defined (powerpc) || defined (__ppc__) #warning ROMlib_Fsetenv not implemented! signal(SIGFPE, SIG_IGN); #else @@ -382,7 +382,7 @@ P_SAVED0D1A0A1_2 (PUBLIC pascal trap, void, ROMlib_Fgetenv, INTEGER *, else env |= PRECISION_MODE_HIGH_BIT; -#elif defined(__alpha) || defined(powerpc) +#elif defined(__alpha) || defined(powerpc) || defined (__ppc__) #warning ROMlib_Fgetenv not properly implemented! env = 0; #else diff --git a/src/gestalt.c b/src/gestalt.c index 0370ab2..c506b72 100644 --- a/src/gestalt.c +++ b/src/gestalt.c @@ -127,7 +127,7 @@ PRIVATE gestaltentry_t gtable[] = { different info on 030*/ }, #endif -#if defined (powerpc) +#if defined (powerpc) || defined(__ppc__) { gestaltNativeCPUtype, gestaltCPU750, }, { gestaltMachineType, gestaltMacQuadra610, }, /* change this */ @@ -349,7 +349,7 @@ gestalt_set_physical_gestalt_callback (void) (long) US_TO_SYN68K (P_PhysicalGestalt), gtable); } -#if defined (powerpc) +#if defined (powerpc) || defined (__ppc__) PUBLIC void gestalt_set_cpu_type (uint32 type) { diff --git a/src/include/rsys/floatconv.h b/src/include/rsys/floatconv.h index dd5a241..77a71f6 100644 --- a/src/include/rsys/floatconv.h +++ b/src/include/rsys/floatconv.h @@ -23,6 +23,12 @@ #include #include "rsys/float.h" +/* + * Unlike most of the rest of Executor's source, we're not using __ppc__ + * in our tests below, because the code involved won't compile on Mac OS X + * 10.5.7, with gcc 4.0.1. + */ + #if defined (powerpc) #include #endif diff --git a/src/include/rsys/launch.c b/src/include/rsys/launch.c index f74c2c9..cdccb60 100644 --- a/src/include/rsys/launch.c +++ b/src/include/rsys/launch.c @@ -390,7 +390,7 @@ cfm_launch (Handle cfrg0, OSType desired_arch, FSSpecPtr fsp) --n_descripts, cfirp = (cfir_t *) ((char *) cfirp + CFIR_LENGTH(cfirp))) ; -#if defined (powerpc) +#if defined (powerpc) || defined (__ppc__) if (CFIR_ISA_X(cfirp) == desired_arch_x) { Ptr mainAddr; diff --git a/src/include/rsys/memsize.h b/src/include/rsys/memsize.h index f23a457..57ad6a8 100644 --- a/src/include/rsys/memsize.h +++ b/src/include/rsys/memsize.h @@ -8,7 +8,7 @@ #define MIN_SYSZONE_SIZE (128 * 1024) #define MAX_SYSZONE_SIZE (2047 * 1024 * 1024) -#if !defined (powerpc) +#if !defined (powerpc) && !defined (__ppc__) #define DEFAULT_SYSZONE_SIZE (512 * 1024) #else diff --git a/src/interfacelib.c b/src/interfacelib.c index a10325b..842f146 100644 --- a/src/interfacelib.c +++ b/src/interfacelib.c @@ -2,7 +2,7 @@ * Development, Inc. All rights reserved. */ -#if defined (powerpc) +#if defined (powerpc) || defined (__ppc__) #if !defined (OMIT_RCSID_STRINGS) char ROMlib_rcsid_interfacelib[] = @@ -2881,7 +2881,9 @@ interfacelib_map[] = { "DisposeHandle", DisposHandle, }, { "UpdateDialog", C_UpdtDialog, }, { "TestDeviceAttribute", C_TestDeviceAttribute, }, +#if !defined (CFM_PROBLEMS) { "CloseConnection", C_CloseConnection, }, +#endif { "GetControlReference", C_GetCRefCon, }, { "RemoveResource", C_RmveResource, }, { "EndUpdate", C_EndUpdate, }, @@ -3018,7 +3020,9 @@ interfacelib_map[] = // { "FSRead", C_FSRead, }, { "SelectDialogItemText", C_SelIText, }, { "GetIndResource", C_GetIndResource, }, +#if !defined (CFM_PROBLEMS) { "GetSharedLibrary", C_GetSharedLibrary, }, +#endif // { "SetEOF", C_SetEOF, }, { "SystemZone", SystemZone, }, { "GetWMgrPort", C_GetWMgrPort, }, @@ -3440,7 +3444,9 @@ interfacelib_map[] = { "LwrText", LowerText_stub, }, { "FracSqrt", C_FracSqrt, }, { "GetDefFontSize", GetDefFontSize, }, +#if !defined(CFM_PROBLEMS) { "GetDiskFragment", C_GetDiskFragment, }, +#endif { "InvalRgn", C_InvalRgn, }, { "CloseWindow", C_CloseWindow, }, { "ShieldCursor", ShieldCursor_PC, }, @@ -3688,7 +3694,9 @@ interfacelib_map[] = { "LMSetGrayRgn", LMSetGrayRgn, }, { "GDeviceChanged", C_GDeviceChanged, }, { "HSV2RGB", C_HSV2RGB, }, +#if !defined (CFM_PROBLEMS) { "GetMemFragment", C_GetMemFragment, }, +#endif // { "GetComponentVersion", C_GetComponentVersion, }, { "EraseOval", C_EraseOval, }, { "GetPattern", C_GetPattern, }, @@ -4224,8 +4232,13 @@ ROMlib_GetInterfaceLib (Str63 library, OSType arch, LoadFlags loadflags, } else { +#if !defined (CFM_PROBLEMS) cid = ROMlib_new_connection (1); - if (!cidp) +#else +#warning "Can't do the right thing without CFM" + cid = 0; +#endif + if (!cid) retval = fragNoMem; else { diff --git a/src/launch.c b/src/launch.c index 572d5ff..c0c2a19 100644 --- a/src/launch.c +++ b/src/launch.c @@ -440,7 +440,7 @@ cfm_launch (Handle cfrg0, OSType desired_arch, FSSpecPtr fsp) cfirp = ROMlib_find_cfrg (cfrg0, desired_arch, kApplicationCFrag, (StringPtr) ""); -#if defined (powerpc) +#if (defined (powerpc) || defined (__ppc__)) && !defined (CFM_PROBLEMS) if (cfirp) { Ptr mainAddr; diff --git a/src/main.c b/src/main.c index 1e3dd63..4b22bb4 100644 --- a/src/main.c +++ b/src/main.c @@ -434,7 +434,7 @@ capable of color.", "your system.", opt_no_arg, NULL }, -#if defined (RELEASE_INTERNAL) || defined (powerpc) +#if defined (powerpc) || defined (__ppc__) { "ppc", "try to execute the PPC native code if possible (UNSUPPORTED)", opt_no_arg, NULL }, #endif diff --git a/src/mathlib.c b/src/mathlib.c index 239aec5..9a59460 100644 --- a/src/mathlib.c +++ b/src/mathlib.c @@ -2,7 +2,7 @@ * Development, Inc. All rights reserved. */ -#if defined (powerpc) +#if defined (powerpc) || defined (__ppc__) #if !defined (OMIT_RCSID_STRINGS) char ROMlib_rcsid_mathlib[] = @@ -380,8 +380,13 @@ ROMlib_GetMathLib (Str63 library, OSType arch, LoadFlags loadflags, } else { +#if !defined (CFM_PROBLEMS) cid = ROMlib_new_connection (1); - if (!cidp) +#else +#warning "Will not work until CFM is viable" + cid = 0; +#endif + if (!cid) retval = fragNoMem; else { diff --git a/src/mixed_mode.c b/src/mixed_mode.c index e980f5a..99ae9c5 100644 --- a/src/mixed_mode.c +++ b/src/mixed_mode.c @@ -2,7 +2,7 @@ * Development, Inc. All rights reserved. */ -#if defined (powerpc) +#if defined (powerpc) || defined (__ppc__) #if !defined (OMIT_RCSID_STRINGS) char ROMlib_rcsid_mixed_mode[] = diff --git a/src/mkvol/mkvol_internal.h b/src/mkvol/mkvol_internal.h index 81a2ed1..1a37292 100644 --- a/src/mkvol/mkvol_internal.h +++ b/src/mkvol/mkvol_internal.h @@ -2,11 +2,6 @@ * Development, Inc. All rights reserved. */ -/* #if !defined (OMIT_RCSID_STRINGS) -char ROMlib_rcsid_mkvol_h[] = - "$Id: mkvol_internal.h 63 2004-12-24 18:19:43Z ctm $"; -#endif */ - #include #include #include @@ -20,7 +15,7 @@ char ROMlib_rcsid_mkvol_h[] = #if defined(__alpha) || defined(i386) || defined(__BORLANDC__) #define LITTLEENDIAN -#elif defined(mc68000) || defined (powerpc) +#elif defined(mc68000) || defined (powerpc) || defined (__ppc__) #else #error "I don't know enough about this machine" #endif diff --git a/src/unix_like.c b/src/unix_like.c index 76eee93..ddedec4 100644 --- a/src/unix_like.c +++ b/src/unix_like.c @@ -103,7 +103,7 @@ guess_good_memory_settings (void) new_appl_size = physical_memory () / 4; -#if defined (powerpc) +#if defined (powerpc) || defined (__ppc__) /* This hack prevents Photoshop 5.5 demo from complaining that we don't have enough memory when we run on a 64 MB Linux machine. Our division @@ -211,10 +211,6 @@ ROMlib_launch_native_app (int n_filenames, char **filenames) return 0; } -#if !(defined (__GNUC__) && defined (__GNUC_MINOR__) && ((__GNUC__ == 2 && __GNUC_MINOR__ == 7 && defined (__i386__)) || defined (RELEASE_INTERNAL) || defined (powerpc) || defined (__alpha))) -#warning THIS IS NOT A PRODUCTION BUILD -#endif - /* * There is a very bad problem associated with the use of the db * shared libraries under Linux. Specifically, the calling convention @@ -306,7 +302,7 @@ mmap_lowglobals (void) #if !defined (MACOSX) -#if !defined (powerpc) +#if !defined (powerpc) && !defined (__ppc__) PRIVATE caddr_t round_up_to_page_size (unsigned long addr) { @@ -412,7 +408,7 @@ mmap_permanent_memory (unsigned long amount_wanted) / (1024 * 1024) * (1024 * 1024)); } -#if !defined (powerpc) +#if !defined (powerpc) && !defined (__ppc__) { caddr_t addr_wanted; diff --git a/src/windInit.c b/src/windInit.c index 8507aa4..dc47257 100644 --- a/src/windInit.c +++ b/src/windInit.c @@ -228,7 +228,7 @@ Executor may die without warning because of this mismatch", 0, 0, "OK", NULL, NULL, NULL, NULL, NULL); break; case launch_ppc_only: -#if !defined (powerpc) +#if !defined (powerpc) && !defined (__ppc__) system_error ("That application is PowerPC-only. This version of " "Executor doesn't run PowerPC applications. " "You need to find an M68k version of that application.", diff --git a/util/configure.sh b/util/configure.sh index cfaa93b..3360e2b 100755 --- a/util/configure.sh +++ b/util/configure.sh @@ -225,6 +225,16 @@ case ${canonical_target} in fi ;; + powerpc-unknown-macosx) + target_os='macosx' + target_syn68k='macosx' + target_arch='powerpc' # how we refer to it + target_gcc_arch='ppc' # how gcc -arch wants us to call it + if [ x"${target_file_format}" = x"" ]; then + # default linux file format; this may change + target_file_format='mach-o' + fi + ;; *) echo "Fatal error: unknown target \`${canonical_target}'. Exiting." @@ -267,6 +277,12 @@ case ${canonical_host} in objc='yes' ;; + powerpc-unknown-macosx) + host_os='macosx' + host_arch='powerpc' + objc='yes' + ;; + *) echo "Fatal error: unknown host \`${canonical_host}'. Exiting." exit 1 @@ -496,6 +512,10 @@ ${util_dir}/subst.pl \ @sound_make@:${sound_make} \ @executor_make@:${executor_make} < ${root}/src/config/Makefile.in > ./tmp-Makefile.in +if [ x"${target_gcc_arch}" = x"" ]; then + target_gcc_arch = "$target_arch" +fi + sed -e "s:@symbol_prefix@:${symbol_prefix}:g s:@target@:${target}:g @@ -520,7 +540,7 @@ sed -e "s:@symbol_prefix@:${symbol_prefix}:g s:@syn68k_target@:${syn68k_target}:g s:@cflags@:${cflags}:g s:@egcs_dcconvert_workaround@:${egcs_dcconvert_workaround}:g - s:@arch@:${target_arch}:g" < ./tmp-Makefile.in > ./Makefile + s:@arch@:${target_gcc_arch}:g" < ./tmp-Makefile.in > ./Makefile rm -f ./tmp-Makefile.in if [ x"${syn68k}" = x"yes" ]; then