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. */
26 #if defined _WIN32 && ! defined __CYGWIN__
27 /* Use Windows threads. */
29 # define WIN32_LEAN_AND_MEAN /* avoid including junk */
35 /* Use POSIX threads. */
41 #if defined _WIN32 && ! defined __CYGWIN__
42 /* Use Windows threads. */
45 call_once (once_flag
*flagp
, void (*func
) (void))
47 glwthread_once (flagp
, func
);
51 /* Use POSIX threads. */
54 call_once (once_flag
*flagp
, void (*func
) (void))
56 # if defined __CYGWIN__
57 /* Verify that once_flag and pthread_once_t are of the same size. */
58 struct _
{ int v
[sizeof (once_flag
) == sizeof (pthread_once_t
) ? 1 : -1]; };
59 pthread_once ((pthread_once_t
*) flagp
, func
);
61 pthread_once (flagp
, func
);