int nlmUnloadSignaled(int wait) { shutdown_pending = 1; if (wait) { while (wait_to_finish) { NXThreadYield(); } } return 0; }
/* the FAQ indicates we need to provide at least 20 bytes (160 bits) of seed */ int RAND_poll(void) { unsigned long l; unsigned long tsc; int i; /* There are several options to gather miscellaneous data * but for now we will loop checking the time stamp counter (rdtsc) and * the SuperHighResolutionTimer. Each iteration will collect 8 bytes * of data but it is treated as only 1 byte of entropy. The call to * ThreadSwitchWithDelay() will introduce additional variability into * the data returned by rdtsc. * * Applications can agument the seed material by adding additional * stuff with RAND_add() and should probably do so. */ l = GetProcessSwitchCount(); RAND_add(&l,sizeof(l),1); /* need to cast the void* to unsigned long here */ l = (unsigned long)RunningProcess; RAND_add(&l,sizeof(l),1); for( i=2; i<ENTROPY_NEEDED; i++) { #ifdef __MWERKS__ asm { rdtsc mov tsc, eax } #else asm volatile("rdtsc":"=A" (tsc)); #endif RAND_add(&tsc, sizeof(tsc), 1); l = GetSuperHighResolutionTimer(); RAND_add(&l, sizeof(l), 0); # if defined(NETWARE_LIBC) NXThreadYield(); # else /* NETWARE_CLIB */ ThreadSwitchWithDelay(); # endif } return 1; }
static void mpm_term(void) { RemoveConsoleHandler(); wait_to_finish = 0; NXThreadYield(); }
_WCRTLINK void __AccessSemaphore( semaphore_object *obj ) { TID tid; tid = GetCurrentThreadId(); #if defined( _NETWARE_CLIB ) if( tid == 0 ) return; #endif if( obj->owner != tid ) { #if defined( _M_I86 ) DosSemRequest( &obj->semaphore, -1L ); #else #if !defined( __NETWARE__ ) if( obj->initialized == 0 ) { #if defined( __RUNTIME_CHECKS__ ) && defined( _M_IX86 ) if( obj == &InitSemaphore ) { __fatal_runtime_error( "Bad semaphore lock", 1 ); } #endif __AccessSemaphore( &InitSemaphore ); if( obj->initialized == 0 ) { #if defined( __NT__ ) obj->semaphore = __NTGetCriticalSection(); #elif defined( __QNX__ ) __qsem_init( &obj->semaphore, 1, 1 ); #elif defined( __LINUX__ ) // TODO: Access semaphore under Linux! #elif defined( __RDOS__ ) obj->semaphore = RdosCreateSection(); #elif defined( __RDOSDEV__ ) RdosInitKernelSection(&obj->semaphore); #else DosCreateMutexSem( NULL, &obj->semaphore, 0, FALSE ); #endif obj->initialized = 1; } __ReleaseSemaphore( &InitSemaphore ); } #endif #if defined( __NETWARE__ ) while( obj->semaphore != 0 ) { #if defined (_NETWARE_CLIB) ThreadSwitch(); #else NXThreadYield(); #endif } obj->semaphore = 1; obj->initialized = 1; #elif defined( __NT__ ) EnterCriticalSection( obj->semaphore ); #elif defined( __QNX__ ) __qsem_wait( &obj->semaphore ); #elif defined( __LINUX__ ) // TODO: Wait for semaphore under Linux! #elif defined( __RDOS__ ) RdosEnterSection( obj->semaphore ); #elif defined( __RDOSDEV__ ) RdosEnterKernelSection( &obj->semaphore ); #else DosRequestMutexSem( obj->semaphore, SEM_INDEFINITE_WAIT ); #endif #endif obj->owner = tid; } obj->count++; }