*
* --------------------------------------------------------------------------*/
+#define _WIN32_WINNT 0x0500
+
#include "Rts.h"
#if defined(THREADED_RTS)
-#include "OSThreads.h"
#include "RtsUtils.h"
+#include <windows.h>
/* For reasons not yet clear, the entire contents of process.h is protected
* by __STRICT_ANSI__ not being defined.
shutdownThread()
{
_endthreadex(0);
+ barf("_endthreadex returned"); // avoid gcc warning
}
int
return GetCurrentThreadId();
}
+rtsBool
+osThreadIsAlive(OSThreadId id)
+{
+ DWORD exit_code;
+ HANDLE hdl;
+ if (!(hdl = OpenThread(THREAD_QUERY_INFORMATION,FALSE,id))) {
+ sysErrorBelch("osThreadIsAlive: OpenThread");
+ stg_exit(EXIT_FAILURE);
+ }
+ if (!GetExitCodeThread(hdl, &exit_code)) {
+ sysErrorBelch("osThreadIsAlive: GetExitCodeThread");
+ stg_exit(EXIT_FAILURE);
+ }
+ return (exit_code == STILL_ACTIVE);
+}
+
#ifdef USE_CRITICAL_SECTIONS
void
initMutex (Mutex* pMut)
// r is allowed to be NULL - it can mean that either there was an
// error or the stored value is in fact NULL.
if (GetLastError() != NO_ERROR) {
- barf("getThreadLocalVar: key not found");
+ sysErrorBelch("getThreadLocalVar");
+ stg_exit(EXIT_FAILURE);
}
#endif
return r;
BOOL b;
b = TlsSetValue(*key, value);
if (!b) {
- barf("setThreadLocalVar: %d", GetLastError());
+ sysErrorBelch("setThreadLocalVar");
+ stg_exit(EXIT_FAILURE);
+ }
+}
+
+void
+freeThreadLocalKey (ThreadLocalKey *key)
+{
+ BOOL r;
+ r = TlsFree(*key);
+ if (r == 0) {
+ DWORD dw = GetLastError();
+ barf("freeThreadLocalKey failed: %lu", dw);
}
}
(unsigned*)&pId) == 0);
}
+nat
+getNumberOfProcessors (void)
+{
+ static nat nproc = 0;
+
+ if (nproc == 0) {
+ SYSTEM_INFO si;
+ GetSystemInfo(&si);
+ nproc = si.dwNumberOfProcessors;
+ }
+
+ return nproc;
+}
+
+void
+setThreadAffinity (nat n STG_UNUSED, nat m STG_UNUSED)
+{
+ /* ToDo */
+}
+
#else /* !defined(THREADED_RTS) */
int