Merge pull request #819 from brendanzagaeski/patch-1
[mono.git] / mono / utils / mono-tls.c
1 /*
2  * mono-tls.c: Low-level TLS support
3  *
4  * Copyright 2013 Xamarin, Inc (http://www.xamarin.com)
5  */
6
7 #include <config.h>
8
9 #include "mono-tls.h"
10
11 static int tls_offsets [TLS_KEY_NUM];
12 static gboolean tls_offset_set [TLS_KEY_NUM];
13
14 /*
15  * mono_tls_key_get_offset:
16  *
17  *   Return the TLS offset used by the TLS var identified by KEY, previously initialized by a call to
18  * mono_tls_key_set_offset (). Return -1 if the offset is not known.
19  */
20 int
21 mono_tls_key_get_offset (MonoTlsKey key)
22 {
23         g_assert (tls_offset_set [key]);
24         return tls_offsets [key];
25 }
26
27 /*
28  * mono_tls_key_set_offset:
29  *
30  *   Set the TLS offset used by the TLS var identified by KEY.
31  */
32 void
33 mono_tls_key_set_offset (MonoTlsKey key, int offset)
34 {
35         tls_offsets [key] = offset;
36         tls_offset_set [key] = TRUE;
37 }