_WCRTLINK void_nptr sbrk( int increment ) { void *cstg; if( increment > 0 ) { increment = __ROUND_UP_SIZE_4K( increment ); cstg = RdosAllocateMem( increment ); if( cstg != NULL ) { return( cstg ); } } return( (void_nptr)-1 ); }
unsigned long __CBeginThreadEx( void *security, unsigned stack_size, thread_fnex *start_addr, void *arglist, unsigned initflag, unsigned *thrdaddr ) { thread_args *td; HANDLE th; if( __TlsIndex == NO_INDEX ) { if( !__NTThreadInit() ) return( 0 ); __InitMultipleThread(); } td = malloc( sizeof( *td ) ); if( td == NULL ) { _RWD_errno = ENOMEM; return( 0 ); } stack_size = __ROUND_UP_SIZE_4K( stack_size ); td->rtn = start_addr; td->argument = arglist; th = CreateThread( (LPSECURITY_ATTRIBUTES)security, (DWORD)stack_size, (LPTHREAD_START_ROUTINE)&begin_thread_helper, (LPVOID) td, (DWORD)initflag, (LPDWORD)thrdaddr ); if( th == NULL ) free( td ); return( (unsigned long)th ); }
int __CBeginThread( thread_fn *start_addr, int prio, const char *thread_name, unsigned stack_size, void *arglist ) /************************************************************/ { thread_args *td; int th; int wait_handle; if( __TlsIndex == NO_INDEX ) { if( !__RdosThreadInit() ) return( -1L ); __InitMultipleThread(); } td = malloc( sizeof( *td ) ); if( td == NULL ) { _RWD_errno = ENOMEM; return( -1L ); } stack_size = __ROUND_UP_SIZE_4K( stack_size ); wait_handle = RdosCreateWait(); td->rtn = start_addr; td->argument = arglist; td->signal = RdosCreateSignal(); RdosResetSignal( td->signal ); RdosAddWaitForSignal( wait_handle, td->signal, 0 ); __create_thread(begin_thread_helper, prio, thread_name, td, stack_size); RdosWaitForever( wait_handle ); RdosFreeSignal( td->signal ); RdosCloseWait( wait_handle ); th = td->tid; free( td ); return( th ); }
int __CBeginThread( thread_fn *start_addr, void *stack_bottom, unsigned stack_size, void *arglist ) /************************************************************/ { DWORD tid; thread_args *td; HANDLE th; stack_bottom = stack_bottom; /* parameter not used for NT version */ if( __TlsIndex == NO_INDEX ) { if( !__NTThreadInit() ) return( -1L ); __InitMultipleThread(); } td = malloc( sizeof( *td ) ); if( td == NULL ) { _RWD_errno = ENOMEM; return( -1L ); } stack_size = __ROUND_UP_SIZE_4K( stack_size ); td->rtn = start_addr; td->argument = arglist; th = CreateThread( NULL, stack_size, (LPTHREAD_START_ROUTINE)&begin_thread_helper, (LPVOID) td, CREATE_SUSPENDED, &tid ); if( th ) { td->thread_handle = th; ResumeThread( th ); } else { // we didn't create the thread so it isn't going to free this free( td ); th = (HANDLE)-1L; } return( (int)th ); }