[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] r18587: {} Also rename thrpool to thr to make builds happy. (torvm/trunk/build/win32/src/torvm-w32)
Author: coderman
Date: 2009-02-17 05:45:48 -0500 (Tue, 17 Feb 2009)
New Revision: 18587
Added:
torvm/trunk/build/win32/src/torvm-w32/thr.c
torvm/trunk/build/win32/src/torvm-w32/thr.h
Removed:
torvm/trunk/build/win32/src/torvm-w32/thrpool.c
torvm/trunk/build/win32/src/torvm-w32/thrpool.h
Log:
Also rename thrpool to thr to make builds happy.
Added: torvm/trunk/build/win32/src/torvm-w32/thr.c
===================================================================
--- torvm/trunk/build/win32/src/torvm-w32/thr.c (rev 0)
+++ torvm/trunk/build/win32/src/torvm-w32/thr.c 2009-02-17 10:45:48 UTC (rev 18587)
@@ -0,0 +1,191 @@
+#include "torvm.h"
+/*XXX ignore threading until bundle merge completed so buildbot is happy now.*/
+#if 0
+/* Some statics to keep track of things...
+ * XXX: note that this is inherently unaware of a thread handle
+ * allocated by an external process with privs in the Tor VM process.
+ * Inter-process threading and locking is explicitly not provided.
+ */
+LPCRITICAL_SECTION s_thridx_cs = NULL;
+DWORD s_thrcount = 0;
+struct s_thrinfo * s_thrlist = NULL;
+
+BOOL createcs (LPCRITICAL_SECTION cs)
+{
+ /* The high bit is set to pre-allocate any necessary resources so that
+ * a low memory condition does introduce an exception leading to ugly
+ * failure recovery...
+ */
+ if (!InitializeCriticalSectionAndSpinCount(&CriticalSection, 0x80000400) ) return FALSE;
+ return TRUE;
+}
+
+BOOL destroycs (LPCRITICAL_SECTION cs)
+{
+ return TRUE;
+}
+
+BOOL entercs (LPCRITICAL_SECTION cs)
+{
+ return TRUE;
+}
+
+BOOL leavecs (LPCRITICAL_SECTION cs)
+{
+ return TRUE;
+}
+
+BOOL createlock (LPHANDLE lockptr)
+{
+ *lockptr = CreateMutex(0, FALSE, 0);
+ return TRUE;
+}
+
+BOOL destroylock (HANDLE lockptr)
+{
+ return TRUE;
+}
+
+BOOL trylock (HANDLE lock)
+{
+ return TRUE;
+}
+
+BOOL waitlock (HANDLE lock,
+ DWORD mstimout)
+{
+ return TRUE;
+}
+
+BOOL unlock (HANDLE lock)
+{
+ return TRUE;
+}
+
+
+/* Semaphore signalling primitives. */
+BOOL createsem (LPHANDLE semptr,
+ LONG limit,
+ BOOL startsignaled)
+{
+ DWORD icount = 0;
+ if (limit > MAX_SEM_COUNT) limit = MAX_SEM_COUNT;
+ if (startsignaled == TRUE) icount = limit;
+ *semptr = CreateSemaphore(
+ 0, // default security attributes
+ icount, // initial count
+ limit, // maximum count
+ 0 // unnamed semaphore
+ );
+ return TRUE;
+}
+
+BOOL destroysem (HANDLE semptr)
+{
+ return TRUE;
+}
+
+BOOL trysem (HANDLE semptr)
+{
+ return TRUE;
+}
+
+BOOL waitsem (HANDLE semptr,
+ DWORD mstimout)
+{
+ return TRUE;
+}
+
+BOOL signalsem (HANDLE semptr)
+{
+ return TRUE;
+}
+
+BOOL createthr (PFnThreadMain thrmain,
+ LPDWORD thrid,
+ BOOL suspended)
+{
+ LPTHREAD_START_ROUTINE f = (LPTHREAD_START_ROUTINE) thrmain;
+ DWORD tid;
+ DWORD cflags = 0;
+ HANDLE newthr;
+ if (suspended) cflags |= CREATE_SUSPENDED;
+ newthr = CreateThread(
+ NULL, // default security attributes
+ 0, // use default stack size
+ f,
+ arg,
+ cflags,
+ &tid);
+ return TRUE;
+}
+
+BOOL destroythr (HANDLE thr)
+{
+ return TRUE;
+}
+
+BOOL pausethr (HANDLE thr)
+{
+ return TRUE;
+}
+
+BOOL resumethr (HANDLE thr)
+{
+ return TRUE;
+}
+
+VOID exitthr (DWORD exitcode)
+{
+ return TRUE;
+}
+
+BOOL checkthr (HANDLE thr,
+ LPDWORD retval)
+{
+ return TRUE;
+}
+
+BOOL waitforthr (HANDLE thr,
+ DWORD mstimout,
+ LPDWORD retval)
+{
+ return TRUE;
+}
+
+BOOL waitforallthr (const HANDLE *thrlist,
+ DWORD count,
+ DWORD mstimout)
+{
+ return TRUE;
+}
+
+BOOL waitforanythr (const HANDLE *thrlist,
+ DWORD count,
+ DWORD mstimout,
+ LPHANDLE signaledhnd)
+{
+ return TRUE;
+}
+
+BOOL setupthrctx (VOID)
+{
+ s_thridx_cs = 0;
+ return TRUE;
+}
+
+VOID cleanupthrctx (VOID)
+{
+ return;
+}
+
+BOOL enumthrhnds (LPHANDLE *hndlist)
+{
+ return TRUE;
+}
+
+VOID destroythrhnds (LPHANDLE hndlist)
+{
+ return;
+}
+#endif /* XXX end if 0 */
Added: torvm/trunk/build/win32/src/torvm-w32/thr.h
===================================================================
--- torvm/trunk/build/win32/src/torvm-w32/thr.h (rev 0)
+++ torvm/trunk/build/win32/src/torvm-w32/thr.h 2009-02-17 10:45:48 UTC (rev 18587)
@@ -0,0 +1,94 @@
+/* Copyright (C) 2008-2009 The Tor Project, Inc.
+ * See LICENSE file for rights and terms.
+ */
+#ifndef __thr_h__
+#define __thr_h__
+
+#include "torvm.h"
+/*XXX ignore threading until bundle merge completed so buildbot is happy now.*/
+#if 0
+/* XXX: these should probably be macros or inline but for now the
+ * strack frames are useful for debugging.
+ */
+/* Critical section primitives. */
+BOOL createcs (LPCRITICAL_SECTION cs);
+BOOL destroycs (LPCRITICAL_SECTION cs);
+BOOL entercs (LPCRITICAL_SECTION cs);
+BOOL leavecs (LPCRITICAL_SECTION cs);
+
+/* Mutex primitives. */
+BOOL createlock (LPHANDLE lockptr);
+BOOL destroylock (HANDLE lockptr);
+BOOL trylock (HANDLE lock);
+BOOL waitlock (HANDLE lock,
+ DWORD mstimout);
+BOOL unlock (HANDLE lock);
+
+/* Semaphore signalling primitives. */
+BOOL createsem (LPHANDLE semptr,
+ LONG limit,
+ BOOL startsignaled);
+BOOL destroysem (HANDLE semptr);
+BOOL trysem (HANDLE semptr);
+BOOL waitsem (HANDLE semptr,
+ DWORD mstimout);
+BOOL signalsem (HANDLE semptr);
+
+/* Thread primitives. */
+typedef DWORD (__stdcall *PFnThreadMain)(LPVOID param);
+BOOL createthr (PFnThreadMain thrmain,
+ LPDWORD thrid,
+ BOOL suspended);
+BOOL destroythr (HANDLE thr);
+BOOL pausethr (HANDLE thr);
+BOOL resumethr (HANDLE thr);
+VOID exitthr (DWORD exitcode);
+BOOL checkthr (HANDLE thr,
+ LPDWORD retval);
+BOOL waitforthr (HANDLE thr,
+ DWORD mstimout,
+ LPDWORD retval);
+BOOL waitforallthr (const HANDLE *thrlist,
+ DWORD count,
+ DWORD mstimout);
+BOOL waitforanythr (const HANDLE *thrlist,
+ DWORD count,
+ DWORD mstimout,
+ LPHANDLE signaledhnd);
+
+/* IMPORTANT: the main process thread needs to initialze various thread
+ * tracking structures at start to ensure the helper routines below have
+ * the context needed to keep track of all threads and ids.
+ */
+BOOL setupthrctx (VOID);
+
+/* Must be called from main before exit to clean up allocated structures.
+ * Provided in anticipation of memory profiling where dangling
+ * allocations introduce false positives.
+ */
+VOID cleanupthrctx (VOID);
+
+/* Keep a list of threads so that we know their relative IDs and can forcibly
+ * terminate them if needed. The logging code in particular uses relative
+ * thread IDs indicative of create order rather than the sometimes opaque
+ * system assigned identifiers or handles.
+ */
+struct s_thrinfo {
+ HANDLE hnd;
+ DWORD id;
+ LONG num;
+ struct s_thrinfo *next;
+};
+
+LONG mythrnum (VOID);
+BOOL getthrnum (HANDLE thr,
+ LONG * num);
+LONG numthreads (VOID);
+
+/* Enumerate all known thread handles. Caller must destory hndlist after
+ * successful invocation. XXX: handle inheritance only part solved here.
+ */
+BOOL enumthrhnds (LPHANDLE *hndlist);
+VOID destroythrhnds (LPHANDLE hndlist);
+#endif /* XXX end if 0 */
+#endif /* thr_h */
Deleted: torvm/trunk/build/win32/src/torvm-w32/thrpool.c
===================================================================
--- torvm/trunk/build/win32/src/torvm-w32/thrpool.c 2009-02-17 10:38:46 UTC (rev 18586)
+++ torvm/trunk/build/win32/src/torvm-w32/thrpool.c 2009-02-17 10:45:48 UTC (rev 18587)
@@ -1 +0,0 @@
-#include "thrpool.h"
Deleted: torvm/trunk/build/win32/src/torvm-w32/thrpool.h
===================================================================
--- torvm/trunk/build/win32/src/torvm-w32/thrpool.h 2009-02-17 10:38:46 UTC (rev 18586)
+++ torvm/trunk/build/win32/src/torvm-w32/thrpool.h 2009-02-17 10:45:48 UTC (rev 18587)
@@ -1,9 +0,0 @@
-/* Copyright (C) 2008 The Tor Project, Inc.
- * See LICENSE file for rights and terms.
- */
-#ifndef __thrpool_h__
-#define __thrpool_h__
-
-#include "torvm.h"
-
-#endif /* thrpool_h */