From dd700b8430d8b0043acb928cb61a77e69038ce8c Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Sat, 18 Jun 2011 07:26:53 -0600 Subject: [PATCH] PPC repairs --- src/racket/src/jitcommon.c | 16 ++++++++-------- src/racket/src/mzrt.h | 25 +++++++++++++++++++++++++ src/racket/src/thread.c | 2 +- 3 files changed, 34 insertions(+), 9 deletions(-) diff --git a/src/racket/src/jitcommon.c b/src/racket/src/jitcommon.c index bc4ad57d23..4446b21dc3 100644 --- a/src/racket/src/jitcommon.c +++ b/src/racket/src/jitcommon.c @@ -1578,7 +1578,7 @@ static int common4b(mz_jit_state *jitter, void *_data) CHECK_LIMIT(); if (i == 2) { refno = _jit.x.pc; - jit_movi_p(JIT_R0, scheme_false); + (void)jit_movi_p(JIT_R0, scheme_false); mz_epilog(JIT_V1); CHECK_LIMIT(); } else @@ -1637,13 +1637,13 @@ static int common4b(mz_jit_state *jitter, void *_data) ref3 = jit_beqr_p(jit_forward(), JIT_R2, JIT_V1); mz_get_local_p(JIT_V1, JIT_LOCAL3); - jit_jmpi(refloop); + (void)jit_jmpi(refloop); /* Success! */ mz_patch_branch(ref3); if (i == 2) { - jit_movi_p(JIT_R0, scheme_true); + (void)jit_movi_p(JIT_R0, scheme_true); } else { if (i == 1) { /* pop second argument, which we don't need */ @@ -2278,7 +2278,7 @@ static int common10(mz_jit_state *jitter, void *_data) mz_epilog(JIT_R2); refno = _jit.x.pc; - jit_movi_p(JIT_R0, scheme_false); + (void)jit_movi_p(JIT_R0, scheme_false); mz_epilog(JIT_R2); /* R1 has fixnum ... check non-negative and them proc type */ @@ -2309,7 +2309,7 @@ static int common10(mz_jit_state *jitter, void *_data) (void)jit_finish(sjc.check_arity_code); jit_retval(JIT_R0); (void)jit_beqi_i(refno, JIT_R0, 0); - jit_movi_p(JIT_R0, scheme_true); + (void)jit_movi_p(JIT_R0, scheme_true); mz_epilog(JIT_R2); CHECK_LIMIT(); @@ -2321,14 +2321,14 @@ static int common10(mz_jit_state *jitter, void *_data) jit_ldxi_s(JIT_R0, JIT_R0, &SCHEME_CLOSURE_DATA_FLAGS(((Scheme_Closure_Data *)0x0))); ref_nc = jit_bmsi_i(jit_forward(), JIT_R0, CLOS_HAS_REST); (void)jit_bner_i(refno, JIT_V1, JIT_R2); - jit_movi_p(JIT_R0, scheme_true); + (void)jit_movi_p(JIT_R0, scheme_true); mz_epilog(JIT_R2); CHECK_LIMIT(); /* has rest arg: */ mz_patch_branch(ref_nc); jit_subi_i(JIT_R2, JIT_R2, 1); (void)jit_bltr_i(refno, JIT_V1, JIT_R2); - jit_movi_p(JIT_R0, scheme_true); + (void)jit_movi_p(JIT_R0, scheme_true); mz_epilog(JIT_R2); CHECK_LIMIT(); @@ -2342,7 +2342,7 @@ static int common10(mz_jit_state *jitter, void *_data) (void)jit_bgtr_i(refno, JIT_V1, JIT_R2); CHECK_LIMIT(); - jit_movi_p(JIT_R0, scheme_true); + (void)jit_movi_p(JIT_R0, scheme_true); mz_epilog(JIT_R2); __END_SHORT_JUMPS__(1); diff --git a/src/racket/src/mzrt.h b/src/racket/src/mzrt.h index e57ec0b984..51648c0567 100644 --- a/src/racket/src/mzrt.h +++ b/src/racket/src/mzrt.h @@ -123,6 +123,31 @@ static MZ_INLINE int mzrt_cas(volatile size_t *addr, size_t old, size_t new_val) : "m"(*addr), "r" (new_val), "a"(old) : "memory"); return (int) result; +# elif defined(__POWERPC__) || defined(__powerpc__) || defined(__ppc__) || defined(__PPC__) \ + || defined(__powerpc64__) || defined(__ppc64__) + size_t oldval; + int result = 0; +# if defined(__powerpc64__) || defined(__ppc64__) || defined(__64BIT__) +# define CAS_I_SIZE "d" +# else +# define CAS_I_SIZE "w" +# endif + /* This code is based on Boehm GC's libatomic */ + __asm__ __volatile__( + "1:l" CAS_I_SIZE "arx %0,0,%2\n" /* load and reserve */ + "cmpw %0, %4\n" /* if load is not equal to */ + "bne 2f\n" /* old, fail */ + "st" CAS_I_SIZE "cx. %3,0,%2\n" /* else store conditional */ + "bne- 1b\n" /* retry if lost reservation */ + "li %1,1\n" /* result = 1; */ + "2:\n" + : "=&r"(oldval), "=&r"(result) + : "r"(addr), "r"(new_val), "r"(old), "1"(result) + : "memory", "cc"); + + return result; +# else +# error mzrt_cas not defined on this platform # endif #elif defined(__GNUC__) && !defined(__INTEL_COMPILER) diff --git a/src/racket/src/thread.c b/src/racket/src/thread.c index f1ad0224d5..db3839ba4e 100644 --- a/src/racket/src/thread.c +++ b/src/racket/src/thread.c @@ -204,7 +204,7 @@ static void inform_GC(int master_gc, int major_gc, intptr_t pre_used, intptr_t p THREAD_LOCAL_DECL(static volatile short delayed_break_ready); THREAD_LOCAL_DECL(static Scheme_Thread *main_break_target_thread); -THREAD_LOCAL_DECL(Scheme_Sleep_Proc scheme_place_sleep_); +THREAD_LOCAL_DECL(Scheme_Sleep_Proc scheme_place_sleep); HOOK_SHARED_OK void (*scheme_sleep)(float seconds, void *fds); HOOK_SHARED_OK void (*scheme_notify_multithread)(int on); HOOK_SHARED_OK void (*scheme_wakeup_on_input)(void *fds);