X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Frts%2FPrimOps.hc;h=e288b328b7263825ac39c0b2d2f5e3d59fe81906;hb=b72dbd57fd2ee3129a73fb54e77f697e04b3646c;hp=0d9caefc89159a9a15f47da01330dd76458328e6;hpb=8ad8c309e8d8e70811415574b43fae6bce396054;p=ghc-hetmet.git diff --git a/ghc/rts/PrimOps.hc b/ghc/rts/PrimOps.hc index 0d9caef..e288b32 100644 --- a/ghc/rts/PrimOps.hc +++ b/ghc/rts/PrimOps.hc @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------------- - * $Id: PrimOps.hc,v 1.48 2000/03/20 15:49:56 panne Exp $ + * $Id: PrimOps.hc,v 1.52 2000/05/10 11:02:00 simonmar Exp $ * * (c) The GHC Team, 1998-2000 * @@ -324,14 +324,14 @@ FN_(newMutVarzh_fast) -------------------------------------------------------------------------- */ #ifndef PAR -FN_(makeForeignObjzh_fast) +FN_(mkForeignObjzh_fast) { /* R1.p = ptr to foreign object, */ StgForeignObj *result; FB_ - HP_CHK_GEN_TICKY(sizeofW(StgForeignObj), NO_PTRS, makeForeignObjzh_fast,); + HP_CHK_GEN_TICKY(sizeofW(StgForeignObj), NO_PTRS, mkForeignObjzh_fast,); TICK_ALLOC_PRIM(sizeofW(StgHeader), sizeofW(StgForeignObj)-sizeofW(StgHeader), 0); CCS_ALLOC(CCCS,sizeofW(StgForeignObj)); /* ccs prof */ @@ -888,6 +888,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; @@ -1017,7 +1058,7 @@ FN_(delayzh_fast) /* Add on ticks_since_select, since these will be subtracted at * the next awaitEvent call. */ -#if defined(HAVE_SETITIMER) +#if defined(HAVE_SETITIMER) || defined(mingw32_TARGET_OS) CurrentTSO->block_info.delay = R1.i + ticks_since_select; #else CurrentTSO->block_info.target = R1.i + getourtimeofday();