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