blob: 96a6011f9677dd6b2b1b139544a4a66daa1cde2f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
/*=============================================================================
**
** Source: tls.c
**
** Purpose: Test to ensure TlsAlloc and TlsFree are working when we try
** to allocate the guaranted minimum number of indicies.
**
**
**===========================================================================*/
#include <palsuite.h>
#define NUM_OF_INDEX 64
/* Minimum guaranteed is at least 64 for all systems.*/
/**
* main
*
* executable entry point
*/
INT __cdecl main( INT argc, CHAR **argv )
{
DWORD dwIndexes[NUM_OF_INDEX];
int i,j;
/* PAL initialization */
if( (PAL_Initialize(argc, argv)) != 0 )
{
return FAIL;
}
/* Allocate a bunch of TLS indexes. */
for( i = 0; i < NUM_OF_INDEX; i++ )
{
if( (dwIndexes[i] = TlsAlloc()) == TLS_OUT_OF_INDEXES )
{/*ERROR */
DWORD dwError = GetLastError();
Fail("TlsAlloc() returned -1 with error %d"
"when trying to allocate %d index\n",
dwError,
i);
}
}
/* Free the TLS indexes.*/
for( j = 0; j < NUM_OF_INDEX; j++ )
{
if( TlsFree(dwIndexes[j]) == 0 )
{/* ERROR */
DWORD dwError = GetLastError();
Fail("TlsFree() returned 0 with error %d"
"when trying to free %d index\n",
dwError,
i);
}
}
PAL_Terminate();
return PASS;
}
|