66283b4a01e4712061a231c89b45496e173f4b70
1 /* $Id: tls.c,v 1.11 2003/03/17 22:39:09 gdalsnes Exp $
3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS system libraries
5 * FILE: lib/kernel32/thread/tls.c
6 * PURPOSE: Thread functions
7 * PROGRAMMER: Ariadne ( ariadne@xs4all.nl)
8 * Tls functions are modified from WINE
13 /* INCLUDES ******************************************************************/
18 #include <kernel32/kernel32.h>
21 /* FUNCTIONS *****************************************************************/
29 Index
= RtlFindClearBitsAndSet (NtCurrentPeb()->TlsBitmap
, 1, 0);
30 if (Index
== (ULONG
)-1)
32 SetLastErrorByStatus(STATUS_NO_MEMORY
);
36 NtCurrentTeb()->TlsSlots
[Index
] = 0;
44 TlsFree(DWORD dwTlsIndex
)
46 if (dwTlsIndex
>= TLS_MINIMUM_AVAILABLE
)
48 SetLastErrorByStatus(STATUS_INVALID_PARAMETER
);
53 if (RtlAreBitsSet(NtCurrentPeb()->TlsBitmap
, dwTlsIndex
, 1))
56 * clear the tls cells (slots) in all threads
57 * of the current process
59 NtSetInformationThread(NtCurrentThread(),
63 RtlClearBits(NtCurrentPeb()->TlsBitmap
,
73 TlsGetValue(DWORD dwTlsIndex
)
77 if (dwTlsIndex
>= TLS_MINIMUM_AVAILABLE
)
79 SetLastErrorByStatus(STATUS_INVALID_PARAMETER
);
83 Value
= NtCurrentTeb()->TlsSlots
[dwTlsIndex
];
86 SetLastError(NO_ERROR
);
92 TlsSetValue(DWORD dwTlsIndex
, LPVOID lpTlsValue
)
94 if (dwTlsIndex
>= TLS_MINIMUM_AVAILABLE
)
96 SetLastErrorByStatus(STATUS_INVALID_PARAMETER
);
99 NtCurrentTeb()->TlsSlots
[dwTlsIndex
] = lpTlsValue
;