Exemplo n.º 1
0
MFUNC(modulefact, MCnop)
{
  // one argument expected
  MFnargsCheck(1);

  if(MFisInt(MFarg(1))) {
    long value = MFlong(MFarg(1));
    if (value > 0) 
      MFreturn(MFlong(fact(value)));
  } 

  MFreturn(MFcopy(MVargs));
} MFEND
Exemplo n.º 2
0
} MFEND


///////////////////////////////////////////////////////////////////////////////
MFUNC ( kernelPid, MCnop )
{ MFnargsCheck( 0 );
  MFreturn( MFlong(MFprocId()) );
} MFEND
Exemplo n.º 3
0
} MFEND


///////////////////////////////////////////////////////////////////////////////
MFUNC( busyWaiting, MCnop )
{ MFnargsCheck( 1 );
  MFargCheck  ( 1, DOM_INT );

    unsigned long sec = (unsigned long) MFlong( MFarg(1) );
    if( sec < 0L || sec > 60*60*24L ) 
        MFerror( "Integer is out of range 0..86400" );

    unsigned long   t1, t2;
    // 64Bit Windows: sizeof(int)<>sizeof(size_t)
    for( t1 = t2 = static_cast<unsigned long>(time(NULL)); (t2-t1) < sec; 
	 t2 = static_cast<unsigned long>(time(NULL)) ) ;
    MFreturn( MFcopy(MVnull) );
} MFEND
Exemplo n.º 4
0
} MFEND


///////////////////////////////////////////////////////////////////////////////
MFUNC( sleep, MCnop )
{ MFnargsCheck( 1 );
  MFargCheck  ( 1, DOM_INT );

  unsigned long sec = (unsigned long) MFlong( MFarg(1) );
  if( sec < 0L || sec > 60*60*24UL )   
      MFerror( "Integer is out of range 0..86400" );

#if   (defined MACINTOSH)
    MFerror( "Sorry, not supported on this platform" );
#elif (defined WIN32)
    Sleep( sec*1000UL );
#else
    sleep( sec );
#endif

    MFreturn( MFcopy(MVnull) );
} MFEND