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