summaryrefslogtreecommitdiff
path: root/create.c
diff options
context:
space:
mode:
authorrpj <rpj>1998-07-11 05:12:55 +0000
committerrpj <rpj>1998-07-11 05:12:55 +0000
commit8f3727444fc67c56dc1e1b26bdcb2f41d19320ec (patch)
treea57c838ab5edb5b5300870a579c4d520bcf2c2c8 /create.c
parentcafd80143a1ab0b51ba086a2c742311d2b1bf0b6 (diff)
Preliminary implementation. Lot's of FIXME's.
Diffstat (limited to 'create.c')
-rw-r--r--create.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/create.c b/create.c
index 8474085..daae84f 100644
--- a/create.c
+++ b/create.c
@@ -7,6 +7,10 @@
*/
#include "pthread.h"
+#include "implement.h"
+
+/* FIXME: There must be a Win32 routine to get this value. */
+DWORD pthread_threads_count = 0;
int
pthread_create(pthread_t *thread, const pthread_attr_t *attr,
@@ -15,4 +19,49 @@ pthread_create(pthread_t *thread, const pthread_attr_t *attr,
/* Call Win32 CreateThread.
Map attributes as correctly as possible.
*/
+ HANDLE handle;
+
+ /* FIXME: I don't have doco on attributes so these aren't
+ included yet. Threads will be started with Win32 defaults:
+ unsuspended and with default stack size.
+ */
+ DWORD flags = 0;
+ DWORD stack = 0;
+ LPSECURITY_ATTRIBUTES security = NULL;
+
+ /* FIXME: This needs to be moved into process space.
+ Perhaps into a structure that contains all
+ per thread info that is Win32 thread specific but
+ not visible from the pthreads API, and
+ accessible through HANDLE (or pthread_t).
+ */
+ SECURITY_ATTRIBUTES security_attr;
+ DWORD threadID;
+
+ if (pthread_threads_count >= PTHREAD_THREADS_MAX)
+ return EAGAIN;
+
+ switch (attr)
+ {
+ case NULL:
+ /* Use POSIX default attributes */
+ break;
+ default:
+ /* Map attributes */
+ break;
+ }
+
+ /* FIXME: I don't have error return values to work with so
+ I'm assuming this always succeeds (obviously not).
+ */
+ handle = CreateThread(security,
+ stack,
+ start_routine,
+ arg,
+ flags,
+ &threadID);
+
+ *thread = (pthread_t) handle;
+ pthread_threads_count++;
+ return 0;
}