exp2l: Work around a NetBSD 10.0/i386 bug.
[gnulib.git] / lib / call_once.c
blob9ef517bdd7e08d9f8b97e167b1970c7e8d03101d
1 /* ISO C 11 once-only initialization.
2 Copyright (C) 2005-2024 Free Software Foundation, Inc.
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 /* Written by Bruno Haible <bruno@clisp.org>, 2005, 2019.
18 Based on GCC's gthr-posix.h, gthr-posix95.h, gthr-win32.h. */
20 #include <config.h>
22 #include <threads.h>
24 #include <errno.h>
26 #if defined _WIN32 && ! defined __CYGWIN__
27 /* Use Windows threads. */
29 # define WIN32_LEAN_AND_MEAN /* avoid including junk */
30 # include <windows.h>
32 # include <stdlib.h>
34 #else
35 /* Use POSIX threads. */
37 # include <pthread.h>
39 #endif
41 #if defined _WIN32 && ! defined __CYGWIN__
42 /* Use Windows threads. */
44 void
45 call_once (once_flag *flagp, void (*func) (void))
47 glwthread_once (flagp, func);
50 #else
51 /* Use POSIX threads. */
53 void
54 call_once (once_flag *flagp, void (*func) (void))
56 pthread_once (flagp, func);
59 #endif