X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Frts%2FPrimOps.hc;h=015e34a228b267e8e1555c5645dbbf8084c63ef0;hb=b682cf8d64f44ce16eddac9b5efbe01e993bfbe7;hp=27f6f844ede75c8c6c3a21a32b8733b7d03b33db;hpb=cd6055bc01f2b38bcd77b1b6943dda8dff3cb818;p=ghc-hetmet.git diff --git a/ghc/rts/PrimOps.hc b/ghc/rts/PrimOps.hc index 27f6f84..015e34a 100644 --- a/ghc/rts/PrimOps.hc +++ b/ghc/rts/PrimOps.hc @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------------- - * $Id: PrimOps.hc,v 1.50 2000/04/11 20:44:19 panne Exp $ + * $Id: PrimOps.hc,v 1.53 2000/08/07 23:37:23 qrczak Exp $ * * (c) The GHC Team, 1998-2000 * @@ -263,13 +263,14 @@ W_ GHC_ZCCReturnable_static_info[0]; FE_ \ } -newByteArray(Char, sizeof(C_)) -newByteArray(Int, sizeof(I_)); -newByteArray(Word, sizeof(W_)); -newByteArray(Addr, sizeof(P_)); -newByteArray(Float, sizeof(StgFloat)); -newByteArray(Double, sizeof(StgDouble)); -newByteArray(StablePtr, sizeof(StgStablePtr)); +newByteArray(Char, 1) +/* Char arrays really contain only 8-bit bytes for compatibility. */ +newByteArray(Int, sizeof(I_)) +newByteArray(Word, sizeof(W_)) +newByteArray(Addr, sizeof(P_)) +newByteArray(Float, sizeof(StgFloat)) +newByteArray(Double, sizeof(StgDouble)) +newByteArray(StablePtr, sizeof(StgStablePtr)) FN_(newArrayzh_fast) { @@ -888,6 +889,47 @@ FN_(takeMVarzh_fast) FE_ } +FN_(tryTakeMVarzh_fast) +{ + StgMVar *mvar; + StgClosure *val; + const StgInfoTable *info; + + FB_ + /* args: R1 = MVar closure */ + + mvar = (StgMVar *)R1.p; + +#ifdef SMP + info = LOCK_CLOSURE(mvar); +#else + info = GET_INFO(mvar); +#endif + + if (info == &EMPTY_MVAR_info) { + +#ifdef SMP + /* unlock the MVar */ + mvar->header.info = &EMPTY_MVAR_info; +#endif + + /* HACK: we need a pointer to pass back, so we abuse NO_FINALIZER_closure */ + RET_NP(0, &NO_FINALIZER_closure); + } + + val = mvar->value; + mvar->value = (StgClosure *)&END_TSO_QUEUE_closure; + + /* do this last... we might have locked the MVar in the SMP case, + * and writing the info pointer will unlock it. + */ + SET_INFO(mvar,&EMPTY_MVAR_info); + + TICK_RET_UNBOXED_TUP(1); + RET_NP(1,val); + FE_ +} + FN_(putMVarzh_fast) { StgMVar *mvar;