# include <process.h> /* For _beginthreadex, _endthreadex */
# endif
-# include <windows.h>
+# if defined(GC_BUILD) || !defined(GC_DONT_INCLUDE_WINDOWS_H)
+# include <windows.h>
+# endif
# ifdef __cplusplus
extern "C" {
# define GC_ExitThread _GC_ExitThread
# endif
-# ifdef GC_INSIDE_DLL
- /* Export GC DllMain to be invoked from client DllMain. */
-# ifdef GC_UNDERSCORE_STDCALL
-# define GC_DllMain _GC_DllMain
+# ifndef DECLSPEC_NORETURN
+ /* Typically defined in winnt.h. */
+# if defined(WINAPI)
+# define DECLSPEC_NORETURN /* empty */
+# else
+# define DECLSPEC_NORETURN __declspec(noreturn)
# endif
- GC_API BOOL WINAPI GC_DllMain(HINSTANCE /* inst */, ULONG /* reason */,
- LPVOID /* reserved */);
-# endif /* GC_INSIDE_DLL */
+# endif
# if !defined(_UINTPTR_T) && !defined(_UINTPTR_T_DEFINED) \
&& !defined(UINTPTR_MAX)
# else
typedef uintptr_t GC_uintptr_t;
# endif
-# define GC_WIN32_SIZE_T GC_uintptr_t
+
+# ifdef _WIN64
+# define GC_WIN32_SIZE_T GC_uintptr_t
+# elif defined(WINAPI) /* windows.h included */
+# define GC_WIN32_SIZE_T DWORD
+# else
+# define GC_WIN32_SIZE_T unsigned long
+# endif
+
+# ifdef GC_INSIDE_DLL
+ /* Export GC DllMain to be invoked from client DllMain. */
+# ifdef GC_UNDERSCORE_STDCALL
+# define GC_DllMain _GC_DllMain
+# endif
+# if defined(WINAPI) /* windows.h included */
+ GC_API BOOL WINAPI GC_DllMain(HINSTANCE /* inst */,
+ ULONG /* reason */,
+ LPVOID /* reserved */);
+# else
+ GC_API int __stdcall GC_DllMain(void *, unsigned long, void *);
+# endif
+# endif /* GC_INSIDE_DLL */
/* All threads must be created using GC_CreateThread or */
/* GC_beginthreadex, or must explicitly call GC_register_my_thread */
/* Currently the collector expects all threads to fall through and */
/* terminate normally, or call GC_endthreadex() or GC_ExitThread, */
/* so that the thread is properly unregistered. */
- GC_API HANDLE WINAPI GC_CreateThread(
+# if defined(WINAPI) /* windows.h included */
+ GC_API HANDLE WINAPI GC_CreateThread(
LPSECURITY_ATTRIBUTES /* lpThreadAttributes */,
GC_WIN32_SIZE_T /* dwStackSize */,
LPTHREAD_START_ROUTINE /* lpStartAddress */,
LPVOID /* lpParameter */, DWORD /* dwCreationFlags */,
LPDWORD /* lpThreadId */);
-# ifndef DECLSPEC_NORETURN
- /* Typically defined in winnt.h. */
-# define DECLSPEC_NORETURN /* empty */
-# endif
-
- GC_API DECLSPEC_NORETURN void WINAPI GC_ExitThread(
+ GC_API DECLSPEC_NORETURN void WINAPI GC_ExitThread(
DWORD /* dwExitCode */);
+# else
+ struct _SECURITY_ATTRIBUTES;
+ GC_API void *__stdcall GC_CreateThread(struct _SECURITY_ATTRIBUTES *,
+ GC_WIN32_SIZE_T,
+ unsigned long (__stdcall *)(void *),
+ void *, unsigned long, unsigned long *);
+ GC_API DECLSPEC_NORETURN void __stdcall GC_ExitThread(unsigned long);
+# endif
# if !defined(_WIN32_WCE) && !defined(__CEGCC__)
GC_API GC_uintptr_t GC_CALL GC_beginthreadex(