Release 960606
[wine/multimedia.git] / win32 / thread.c
blobb538002ee2ab0418c6b4505d1ae4118d927c3497
1 /*
2 * Win32 kernel functions
4 * Copyright 1995 Martin von Loewis
5 */
7 #include <stdio.h>
8 #include <unistd.h>
9 #include <string.h>
10 #include "windows.h"
11 #include "winbase.h"
12 #include "winerror.h"
13 #include "kernel32.h"
14 #include "stddebug.h"
15 #include "debug.h"
16 #include "xmalloc.h"
18 /***********************************************************************
19 * GetCurrentThreadId (KERNEL32.200)
22 int GetCurrentThreadId(void)
24 return getpid();
27 /***********************************************************************
28 * GetThreadContext (KERNEL32.294)
30 BOOL GetThreadContext(HANDLE hThread, void *lpContext)
32 return FALSE;
34 /***********************************************************************
35 * GetCurrentThread (KERNEL32.200)
37 HANDLE GetCurrentThread(void)
39 return 0;
42 /**********************************************************************
43 * Critical Sections are currently ignored
45 void InitializeCriticalSection(CRITICAL_SECTION *lpCrit)
47 memset(lpCrit,0,sizeof(CRITICAL_SECTION));
50 void EnterCriticalSection(CRITICAL_SECTION* lpCrit)
52 if (lpCrit->LockCount)
53 fprintf( stderr, "Error: re-entering critical section %08lx\n",
54 (DWORD)lpCrit );
55 lpCrit->LockCount++;
58 void LeaveCriticalSection(CRITICAL_SECTION* lpCrit)
60 if (!lpCrit->LockCount)
61 fprintf( stderr, "Error: leaving critical section %08lx again\n",
62 (DWORD)lpCrit );
63 lpCrit->LockCount--;
66 void DeleteCriticalSection(CRITICAL_SECTION* lpCrit)
68 return;
71 /***********************************************************************
72 * Tls is available only for the single thread
74 static LPVOID* Tls=0;
75 static int TlsCount=0;
77 DWORD TlsAlloc()
79 if(!Tls){
80 TlsCount++;
81 Tls=xmalloc(sizeof(LPVOID));
82 return 0;
84 Tls=xrealloc(Tls,sizeof(LPVOID)*(++TlsCount));
85 return TlsCount-1;
88 void TlsFree(DWORD index)
90 /*FIXME: should remember that it has been freed */
91 return;
94 LPVOID TlsGetValue(DWORD index)
96 if(index>=TlsCount)
98 /* FIXME: Set last error*/
99 return 0;
101 return Tls[index];
104 void TlsSetValue(DWORD index,LPVOID value)
106 if(index>=TlsCount)
108 /* FIXME: Set last error*/
109 return;
111 Tls[index]=value;