1*799ab823SJérôme Duval /*-
2*799ab823SJérôme Duval * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3*799ab823SJérôme Duval *
4*799ab823SJérôme Duval * Copyright (c) 2011 Ed Schouten <ed@FreeBSD.org>
5*799ab823SJérôme Duval * All rights reserved.
6*799ab823SJérôme Duval *
7*799ab823SJérôme Duval * Redistribution and use in source and binary forms, with or without
8*799ab823SJérôme Duval * modification, are permitted provided that the following conditions
9*799ab823SJérôme Duval * are met:
10*799ab823SJérôme Duval * 1. Redistributions of source code must retain the above copyright
11*799ab823SJérôme Duval * notice, this list of conditions and the following disclaimer.
12*799ab823SJérôme Duval * 2. Redistributions in binary form must reproduce the above copyright
13*799ab823SJérôme Duval * notice, this list of conditions and the following disclaimer in the
14*799ab823SJérôme Duval * documentation and/or other materials provided with the distribution.
15*799ab823SJérôme Duval *
16*799ab823SJérôme Duval * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17*799ab823SJérôme Duval * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18*799ab823SJérôme Duval * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19*799ab823SJérôme Duval * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20*799ab823SJérôme Duval * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21*799ab823SJérôme Duval * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22*799ab823SJérôme Duval * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23*799ab823SJérôme Duval * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24*799ab823SJérôme Duval * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25*799ab823SJérôme Duval * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26*799ab823SJérôme Duval * SUCH DAMAGE.
27*799ab823SJérôme Duval *
28*799ab823SJérôme Duval * $FreeBSD$
29*799ab823SJérôme Duval */
30*799ab823SJérôme Duval
31*799ab823SJérôme Duval #include <pthread.h>
32*799ab823SJérôme Duval
33*799ab823SJérôme Duval #include "threads.h"
34*799ab823SJérôme Duval
35*799ab823SJérôme Duval void
call_once(once_flag * flag,void (* func)(void))36*799ab823SJérôme Duval call_once(once_flag *flag, void (*func)(void))
37*799ab823SJérôme Duval {
38*799ab823SJérôme Duval
39*799ab823SJérôme Duval (void)pthread_once((pthread_once_t *)flag, func);
40*799ab823SJérôme Duval }
41*799ab823SJérôme Duval
42*799ab823SJérôme Duval _Static_assert(sizeof(once_flag) == sizeof(pthread_once_t),
43*799ab823SJérôme Duval "once_flag must be of the same size as pthread_once_t");
44