summaryrefslogtreecommitdiff
path: root/mono/utils/mono-tls.c
blob: 007dc4e6d225bd81336071a0fcda25750b5b8091 (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
/*
 * mono-tls.c: Low-level TLS support
 *
 * Copyright 2013 Xamarin, Inc (http://www.xamarin.com)
 */

#include <config.h>

#include "mono-tls.h"

static int tls_offsets [TLS_KEY_NUM];
static gboolean tls_offset_set [TLS_KEY_NUM];

/*
 * mono_tls_key_get_offset:
 *
 *   Return the TLS offset used by the TLS var identified by KEY, previously initialized by a call to
 * mono_tls_key_set_offset (). Return -1 if the offset is not known.
 */
int
mono_tls_key_get_offset (MonoTlsKey key)
{
	g_assert (tls_offset_set [key]);
	return tls_offsets [key];
}

/*
 * mono_tls_key_set_offset:
 *
 *   Set the TLS offset used by the TLS var identified by KEY.
 */
void
mono_tls_key_set_offset (MonoTlsKey key, int offset)
{
	tls_offsets [key] = offset;
	tls_offset_set [key] = TRUE;
}