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