1 /* $Id: tls.c,v 1.14 2004/01/23 21:16:04 ekohl 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 "../include/debug.h"
21 /* FUNCTIONS *****************************************************************/
32 Index
= RtlFindClearBitsAndSet (NtCurrentPeb()->TlsBitmap
, 1, 0);
33 if (Index
== (ULONG
)-1)
35 SetLastErrorByStatus(STATUS_NO_MEMORY
);
39 NtCurrentTeb()->TlsSlots
[Index
] = 0;
51 TlsFree(DWORD dwTlsIndex
)
53 if (dwTlsIndex
>= TLS_MINIMUM_AVAILABLE
)
55 SetLastErrorByStatus(STATUS_INVALID_PARAMETER
);
60 if (RtlAreBitsSet(NtCurrentPeb()->TlsBitmap
, dwTlsIndex
, 1))
63 * clear the tls cells (slots) in all threads
64 * of the current process
66 NtSetInformationThread(NtCurrentThread(),
70 RtlClearBits(NtCurrentPeb()->TlsBitmap
,
84 TlsGetValue(DWORD dwTlsIndex
)
88 if (dwTlsIndex
>= TLS_MINIMUM_AVAILABLE
)
90 SetLastErrorByStatus(STATUS_INVALID_PARAMETER
);
94 Value
= NtCurrentTeb()->TlsSlots
[dwTlsIndex
];
97 SetLastError(NO_ERROR
);
107 TlsSetValue(DWORD dwTlsIndex
, LPVOID lpTlsValue
)
109 if (dwTlsIndex
>= TLS_MINIMUM_AVAILABLE
)
111 SetLastErrorByStatus(STATUS_INVALID_PARAMETER
);
114 NtCurrentTeb()->TlsSlots
[dwTlsIndex
] = lpTlsValue
;