1*192c820dSguenther /* $OpenBSD: pthread_once.c,v 1.3 2018/03/19 03:48:17 guenther Exp $ */
2e65653d7Sbeck /*
3e65653d7Sbeck * Copyright (c) 2004,2005 Ted Unangst <tedu@openbsd.org>s
4e65653d7Sbeck * Copyright (c) 2018 Bob Beck <beck@openbsd.org>
5e65653d7Sbeck *
6e65653d7Sbeck * Permission to use, copy, modify, and distribute this software for any
7e65653d7Sbeck * purpose with or without fee is hereby granted, provided that the above
8e65653d7Sbeck * copyright notice and this permission notice appear in all copies.
9e65653d7Sbeck *
10e65653d7Sbeck * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11e65653d7Sbeck * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12e65653d7Sbeck * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13e65653d7Sbeck * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14e65653d7Sbeck * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15e65653d7Sbeck * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16e65653d7Sbeck * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17e65653d7Sbeck */
18e65653d7Sbeck
19e65653d7Sbeck #include <pthread.h>
20e65653d7Sbeck
21e65653d7Sbeck int
pthread_once(pthread_once_t * once_control,void (* init_routine)(void))22e65653d7Sbeck pthread_once(pthread_once_t *once_control, void (*init_routine)(void))
23e65653d7Sbeck {
24e65653d7Sbeck if (once_control->state == PTHREAD_NEEDS_INIT) {
25e65653d7Sbeck init_routine();
26e65653d7Sbeck once_control->state = PTHREAD_DONE_INIT;
27e65653d7Sbeck }
28e65653d7Sbeck return (0);
29e65653d7Sbeck }
30b252f5a7Sbeck
31b252f5a7Sbeck int
pthread_equal(pthread_t t1,pthread_t t2)32b252f5a7Sbeck pthread_equal(pthread_t t1, pthread_t t2)
33b252f5a7Sbeck {
34b252f5a7Sbeck return (t1 == t2);
35b252f5a7Sbeck }
36b252f5a7Sbeck
37b252f5a7Sbeck pthread_t
pthread_self(void)38b252f5a7Sbeck pthread_self(void)
39b252f5a7Sbeck {
40b252f5a7Sbeck /* needs to differ from 0 inited value. */
41b252f5a7Sbeck return (pthread_t) 1;
42b252f5a7Sbeck }
43*192c820dSguenther DEF_STRONG(pthread_self);
44