update for HEAD-2003091401
[reactos.git] / lib / msvcrt / process / threadx.c
index 12a63f6..a4c5281 100644 (file)
@@ -6,6 +6,9 @@
 #include <msvcrt/process.h>
 
 
+/*
+ * @unimplemented
+ */
 unsigned long _beginthreadex(
     void* security,
     unsigned stack_size,
@@ -14,13 +17,35 @@ unsigned long _beginthreadex(
     unsigned initflag,
     unsigned* thrdaddr)
 {
-    errno = ENOSYS;
-    return (unsigned long)-1;
+  HANDLE NewThread;
+
+  /*
+   * Just call the API function. Any CRT specific processing is done in
+   * DllMain DLL_THREAD_ATTACH
+   */
+  NewThread = CreateThread ( security, stack_size,
+    (LPTHREAD_START_ROUTINE)start_address,
+    arglist, initflag, (PULONG)thrdaddr );
+  if (NULL == NewThread)
+    {
+    /* FIXME map GetLastError() to errno */
+    __set_errno ( ENOSYS );
+    }
+
+  return (unsigned long) NewThread;
 }
 
 
+/*
+ * @implemented
+ */
 void _endthreadex(unsigned retval)
 {
+  /*
+   * Just call the API function. Any CRT specific processing is done in
+   * DllMain DLL_THREAD_DETACH
+   */
+  ExitThread(retval);
 }
 
 /* EOF */