1*a4ddc2c8Schristos /* $NetBSD: h_pthread_dlopen.c,v 1.1 2013/03/21 16:50:22 christos Exp $ */
2*a4ddc2c8Schristos /*-
3*a4ddc2c8Schristos * Copyright (c) 2013 The NetBSD Foundation, Inc.
4*a4ddc2c8Schristos * All rights reserved.
5*a4ddc2c8Schristos *
6*a4ddc2c8Schristos * This code is derived from software contributed to The NetBSD Foundation
7*a4ddc2c8Schristos * by Emmanuel Dreyfus.
8*a4ddc2c8Schristos *
9*a4ddc2c8Schristos * Redistribution and use in source and binary forms, with or without
10*a4ddc2c8Schristos * modification, are permitted provided that the following conditions
11*a4ddc2c8Schristos * are met:
12*a4ddc2c8Schristos *
13*a4ddc2c8Schristos * 1. Redistributions of source code must retain the above copyright
14*a4ddc2c8Schristos * notice, this list of conditions and the following disclaimer.
15*a4ddc2c8Schristos * 2. Redistributions in binary form must reproduce the above copyright
16*a4ddc2c8Schristos * notice, this list of conditions and the following disclaimer in
17*a4ddc2c8Schristos * the documentation and/or other materials provided with the
18*a4ddc2c8Schristos * distribution.
19*a4ddc2c8Schristos *
20*a4ddc2c8Schristos * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21*a4ddc2c8Schristos * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22*a4ddc2c8Schristos * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23*a4ddc2c8Schristos * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24*a4ddc2c8Schristos * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25*a4ddc2c8Schristos * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
26*a4ddc2c8Schristos * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27*a4ddc2c8Schristos * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
28*a4ddc2c8Schristos * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29*a4ddc2c8Schristos * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
30*a4ddc2c8Schristos * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31*a4ddc2c8Schristos * SUCH DAMAGE.
32*a4ddc2c8Schristos */
33*a4ddc2c8Schristos
34*a4ddc2c8Schristos #include <sys/cdefs.h>
35*a4ddc2c8Schristos __RCSID("$NetBSD: h_pthread_dlopen.c,v 1.1 2013/03/21 16:50:22 christos Exp $");
36*a4ddc2c8Schristos
37*a4ddc2c8Schristos #if 0
38*a4ddc2c8Schristos #include <atf-c.h>
39*a4ddc2c8Schristos #else
40*a4ddc2c8Schristos #include <assert.h>
41*a4ddc2c8Schristos #define ATF_REQUIRE(a) assert(a)
42*a4ddc2c8Schristos #endif
43*a4ddc2c8Schristos #include <unistd.h>
44*a4ddc2c8Schristos #include <pthread.h>
45*a4ddc2c8Schristos
46*a4ddc2c8Schristos int testf_dso_null(void);
47*a4ddc2c8Schristos int testf_dso_mutex_lock(pthread_mutex_t *);
48*a4ddc2c8Schristos int testf_dso_mutex_unlock(pthread_mutex_t *);
49*a4ddc2c8Schristos int testf_dso_pthread_create(pthread_t *, const pthread_attr_t *,
50*a4ddc2c8Schristos void *(*)(void *), void *);
51*a4ddc2c8Schristos
52*a4ddc2c8Schristos int
testf_dso_null(void)53*a4ddc2c8Schristos testf_dso_null(void)
54*a4ddc2c8Schristos {
55*a4ddc2c8Schristos return 0xcafe;
56*a4ddc2c8Schristos }
57*a4ddc2c8Schristos
58*a4ddc2c8Schristos int
testf_dso_mutex_lock(pthread_mutex_t * mtx)59*a4ddc2c8Schristos testf_dso_mutex_lock(pthread_mutex_t *mtx)
60*a4ddc2c8Schristos {
61*a4ddc2c8Schristos ATF_REQUIRE(mtx != NULL);
62*a4ddc2c8Schristos ATF_REQUIRE(pthread_mutex_lock(mtx) == 0);
63*a4ddc2c8Schristos
64*a4ddc2c8Schristos return 0xcafe;
65*a4ddc2c8Schristos }
66*a4ddc2c8Schristos
67*a4ddc2c8Schristos int
testf_dso_mutex_unlock(pthread_mutex_t * mtx)68*a4ddc2c8Schristos testf_dso_mutex_unlock(pthread_mutex_t *mtx)
69*a4ddc2c8Schristos {
70*a4ddc2c8Schristos ATF_REQUIRE(mtx != NULL);
71*a4ddc2c8Schristos ATF_REQUIRE(pthread_mutex_unlock(mtx) == 0);
72*a4ddc2c8Schristos
73*a4ddc2c8Schristos return 0xcafe;
74*a4ddc2c8Schristos }
75*a4ddc2c8Schristos
76*a4ddc2c8Schristos int
testf_dso_pthread_create(pthread_t * thread,const pthread_attr_t * attr,void * (* routine)(void *),void * arg)77*a4ddc2c8Schristos testf_dso_pthread_create(pthread_t *thread, const pthread_attr_t *attr,
78*a4ddc2c8Schristos void *(*routine)(void *), void *arg)
79*a4ddc2c8Schristos {
80*a4ddc2c8Schristos int ret;
81*a4ddc2c8Schristos
82*a4ddc2c8Schristos ret = pthread_create(thread, attr, routine, arg);
83*a4ddc2c8Schristos ATF_REQUIRE(ret == 0);
84*a4ddc2c8Schristos
85*a4ddc2c8Schristos return 0;
86*a4ddc2c8Schristos }
87