ReactOS  0.4.15-dev-1068-g467feb9
thread.c File Reference
#include <precomp.h>
#include <malloc.h>
#include <process.h>
Include dependency graph for thread.c:

Go to the source code of this file.

Classes

struct  _beginthread_trampoline_t
 

Typedefs

typedef void(* _beginthread_start_routine_t) (void *)
 
typedef unsigned int(__stdcall_beginthreadex_start_routine_t) (void *)
 

Functions

static DWORD CALLBACK _beginthread_trampoline (LPVOID arg)
 
uintptr_t _beginthread (_beginthread_start_routine_t start_address, unsigned int stack_size, void *arglist)
 
void CDECL _endthread (void)
 

Typedef Documentation

◆ _beginthread_start_routine_t

typedef void(* _beginthread_start_routine_t) (void *)

Definition at line 25 of file thread.c.

◆ _beginthreadex_start_routine_t

typedef unsigned int(__stdcall * _beginthreadex_start_routine_t) (void *)

Definition at line 26 of file thread.c.

Function Documentation

◆ _beginthread()

uintptr_t _beginthread ( _beginthread_start_routine_t  start_address,
unsigned int  stack_size,
void arglist 
)

Definition at line 55 of file thread.c.

59 {
60  _beginthread_trampoline_t* trampoline;
61  HANDLE thread;
62 
63  TRACE("(%p, %d, %p)\n", start_address, stack_size, arglist);
64 
65  trampoline = malloc(sizeof(*trampoline));
66  if(!trampoline) {
67  *_errno() = EAGAIN;
68  return -1;
69  }
70 
72  trampoline, CREATE_SUSPENDED, NULL);
73  if(!thread) {
74  free(trampoline);
75  *_errno() = EAGAIN;
76  return -1;
77  }
78 
79  trampoline->thread = thread;
80  trampoline->start_address = start_address;
81  trampoline->arglist = arglist;
82 
83  if(ResumeThread(thread) == -1) {
84  free(trampoline);
85  *_errno() = EAGAIN;
86  return -1;
87  }
88 
89  return (uintptr_t)thread;
90 }
static DWORD CALLBACK _beginthread_trampoline(LPVOID arg)
Definition: thread.c:39
#define free
Definition: debug_ros.c:5
#define CREATE_SUSPENDED
Definition: winbase.h:178
unsigned int uintptr_t
Definition: crtdefs.h:300
HANDLE WINAPI DECLSPEC_HOTPATCH CreateThread(IN LPSECURITY_ATTRIBUTES lpThreadAttributes, IN DWORD dwStackSize, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter, IN DWORD dwCreationFlags, OUT LPDWORD lpThreadId)
Definition: thread.c:136
smooth NULL
Definition: ftsmooth.c:416
Definition: arc.h:35
#define TRACE(s)
Definition: solgame.cpp:4
_CRTIMP int *__cdecl _errno(void)
Definition: errno.c:19
static HANDLE thread
Definition: service.c:33
_beginthread_start_routine_t start_address
Definition: thread.c:32
DWORD WINAPI ResumeThread(IN HANDLE hThread)
Definition: thread.c:566
#define malloc
Definition: debug_ros.c:4
va_lists_t arglist[FMT_ARGMAX+1]
Definition: format.c:284

◆ _beginthread_trampoline()

static DWORD CALLBACK _beginthread_trampoline ( LPVOID  arg)
static

Definition at line 39 of file thread.c.

40 {
41  _beginthread_trampoline_t local_trampoline;
43 
44  memcpy(&local_trampoline,arg,sizeof(local_trampoline));
45  data->handle = local_trampoline.thread;
46  free(arg);
47 
48  local_trampoline.start_address(local_trampoline.arglist);
49  return 0;
50 }
#define free
Definition: debug_ros.c:5
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
_beginthread_start_routine_t start_address
Definition: thread.c:32
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
thread_data_t * msvcrt_get_thread_data(void)
Definition: tls.c:31

Referenced by _beginthread().

◆ _endthread()

void CDECL _endthread ( void  )

Definition at line 95 of file thread.c.

96 {
97  TRACE("(void)\n");
98 
99  /* FIXME */
100  ExitThread(0);
101 }
VOID WINAPI ExitThread(IN DWORD uExitCode)
Definition: thread.c:364
#define TRACE(s)
Definition: solgame.cpp:4

Referenced by DefragThread(), init(), processRequest(), test_thread_func(), and test_thread_func_ex().