1272343Sngie/*	$NetBSD: h_pthread_dlopen.c,v 1.1 2013/03/21 16:50:22 christos Exp $ */
2272343Sngie/*-
3272343Sngie * Copyright (c) 2013 The NetBSD Foundation, Inc.
4272343Sngie * All rights reserved.
5272343Sngie *
6272343Sngie * This code is derived from software contributed to The NetBSD Foundation
7272343Sngie * by Emmanuel Dreyfus.
8272343Sngie *
9272343Sngie * Redistribution and use in source and binary forms, with or without
10272343Sngie * modification, are permitted provided that the following conditions
11272343Sngie * are met:
12272343Sngie *
13272343Sngie * 1. Redistributions of source code must retain the above copyright
14272343Sngie *    notice, this list of conditions and the following disclaimer.
15272343Sngie * 2. Redistributions in binary form must reproduce the above copyright
16272343Sngie *    notice, this list of conditions and the following disclaimer in
17272343Sngie *    the documentation and/or other materials provided with the
18272343Sngie *    distribution.
19272343Sngie *
20272343Sngie * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21272343Sngie * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22272343Sngie * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23272343Sngie * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
24272343Sngie * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25272343Sngie * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
26272343Sngie * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27272343Sngie * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
28272343Sngie * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29272343Sngie * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
30272343Sngie * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31272343Sngie * SUCH DAMAGE.
32272343Sngie */
33272343Sngie
34272343Sngie#include <sys/cdefs.h>
35272343Sngie__RCSID("$NetBSD: h_pthread_dlopen.c,v 1.1 2013/03/21 16:50:22 christos Exp $");
36272343Sngie
37272343Sngie#if 0
38272343Sngie#include <atf-c.h>
39272343Sngie#else
40272343Sngie#include <assert.h>
41272343Sngie#define ATF_REQUIRE(a)	assert(a)
42272343Sngie#endif
43272343Sngie#include <unistd.h>
44272343Sngie#include <pthread.h>
45272343Sngie
46272343Sngieint testf_dso_null(void);
47272343Sngieint testf_dso_mutex_lock(pthread_mutex_t *);
48272343Sngieint testf_dso_mutex_unlock(pthread_mutex_t *);
49272343Sngieint testf_dso_pthread_create(pthread_t *, const pthread_attr_t *,
50272343Sngie    void *(*)(void *), void *);
51272343Sngie
52272343Sngieint
53272343Sngietestf_dso_null(void)
54272343Sngie{
55272343Sngie	return 0xcafe;
56272343Sngie}
57272343Sngie
58272343Sngieint
59272343Sngietestf_dso_mutex_lock(pthread_mutex_t *mtx)
60272343Sngie{
61272343Sngie	ATF_REQUIRE(mtx != NULL);
62272343Sngie	ATF_REQUIRE(pthread_mutex_lock(mtx) == 0);
63272343Sngie
64272343Sngie	return 0xcafe;
65272343Sngie}
66272343Sngie
67272343Sngieint
68272343Sngietestf_dso_mutex_unlock(pthread_mutex_t *mtx)
69272343Sngie{
70272343Sngie	ATF_REQUIRE(mtx != NULL);
71272343Sngie	ATF_REQUIRE(pthread_mutex_unlock(mtx) == 0);
72272343Sngie
73272343Sngie	return 0xcafe;
74272343Sngie}
75272343Sngie
76272343Sngieint
77272343Sngietestf_dso_pthread_create(pthread_t *thread, const pthread_attr_t *attr,
78272343Sngie    void *(*routine)(void *), void *arg)
79272343Sngie{
80272343Sngie	int ret;
81272343Sngie
82272343Sngie	ret = pthread_create(thread, attr, routine, arg);
83272343Sngie	ATF_REQUIRE(ret == 0);
84272343Sngie
85272343Sngie	return 0;
86272343Sngie}
87