2 * Copyright © 2024 Nick Bowler
4 * Helpers for hosts using native Windows threading API.
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 #define WIN32_LEAN_AND_MEAN
22 #include "windows-once.h"
25 #define tls_key_valid (tls_key != TLS_OUT_OF_INDEXES)
27 static void init_once_cb(void);
29 static void *tls_get(void)
31 return TlsGetValue(tls_key);
34 static BOOL tls_set(void *p)
36 return TlsSetValue(tls_key, p);
39 static void init_once_with_tls(void)
45 static int init_once(void)
47 static glwthread_once_t ctrl = GLWTHREAD_ONCE_INIT;
49 glwthread_once(&ctrl, init_once_with_tls);