MCPcopy Create free account
hub / github.com/boostorg/build / GC_CreateThread

Function GC_CreateThread

v2/engine/boehm_gc/win32_threads.c:1029–1068  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1027}
1028
1029GC_API HANDLE WINAPI GC_CreateThread(
1030 LPSECURITY_ATTRIBUTES lpThreadAttributes,
1031 DWORD dwStackSize, LPTHREAD_START_ROUTINE lpStartAddress,
1032 LPVOID lpParameter, DWORD dwCreationFlags, LPDWORD lpThreadId )
1033{
1034 HANDLE thread_h = NULL;
1035
1036 thread_args *args;
1037
1038 if (!parallel_initialized) GC_init_parallel();
1039 /* make sure GC is initialized (i.e. main thread is attached,
1040 tls initialized) */
1041
1042# if DEBUG_WIN32_THREADS
1043 GC_printf("About to create a thread from 0x%x\n", GetCurrentThreadId());
1044# endif
1045 if (GC_win32_dll_threads) {
1046 return CreateThread(lpThreadAttributes, dwStackSize, lpStartAddress,
1047 lpParameter, dwCreationFlags, lpThreadId);
1048 } else {
1049 args = GC_malloc_uncollectable(sizeof(thread_args));
1050 /* Handed off to and deallocated by child thread. */
1051 if (0 == args) {
1052 SetLastError(ERROR_NOT_ENOUGH_MEMORY);
1053 return NULL;
1054 }
1055
1056 /* set up thread arguments */
1057 args -> start = lpStartAddress;
1058 args -> param = lpParameter;
1059
1060 GC_need_to_lock = TRUE;
1061 thread_h = CreateThread(lpThreadAttributes,
1062 dwStackSize, GC_win32_start,
1063 args, dwCreationFlags,
1064 lpThreadId);
1065 if( thread_h == 0 ) GC_free( args );
1066 return thread_h;
1067 }
1068}
1069
1070void WINAPI GC_ExitThread(DWORD dwExitCode)
1071{

Callers 3

WinMainFunction · 0.85
fork_a_threadFunction · 0.85
WinMainFunction · 0.85

Calls 4

GC_printfFunction · 0.85
GC_malloc_uncollectableFunction · 0.85
GC_freeFunction · 0.85
GC_init_parallelFunction · 0.70

Tested by 2

fork_a_threadFunction · 0.68
WinMainFunction · 0.68