xref: /dflybsd-src/lib/libc/gen/_pthread_stubs.c (revision 0402ebbc7d4b6f34d02791995169d25c4aec3b15)
1 /*
2  * Copyright (c) 2001 Daniel Eischen <deischen@FreeBSD.org>.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY DANIEL EISCHEN AND CONTRIBUTORS ``AS IS''
15  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24  * SUCH DAMAGE.
25  *
26  * $FreeBSD: /repoman/r/ncvs/src/lib/libc/gen/_pthread_stubs.c,v 1.1 2001/01/24 12:59:20 deischen Exp $
27  * $DragonFly: src/lib/libc/gen/_pthread_stubs.c,v 1.3 2005/04/26 10:05:08 joerg Exp $
28  */
29 
30 #include <pthread.h>
31 
32 void	*_pthread_getspecific_stub(pthread_key_t);
33 int	_pthread_key_create_stub(pthread_key_t *, void (*)(void *));
34 int	_pthread_key_delete_stub(pthread_key_t);
35 int	_pthread_mutex_destroy_stub(pthread_mutex_t *);
36 int	_pthread_mutex_init_stub(pthread_mutex_t *,
37 				 const pthread_mutexattr_t *);
38 int	_pthread_mutex_lock_stub(pthread_mutex_t *);
39 int	_pthread_mutex_trylock_stub(pthread_mutex_t *);
40 int	_pthread_mutex_unlock_stub(pthread_mutex_t *);
41 int	_pthread_mutexattr_init_stub(pthread_mutexattr_t *);
42 int	_pthread_mutexattr_destroy_stub(pthread_mutexattr_t *);
43 int	_pthread_mutexattr_settype_stub(pthread_mutexattr_t *, int);
44 int	_pthread_once_stub(pthread_once_t *, void (*)(void));
45 int	_pthread_setspecific_stub(pthread_key_t, const void *);
46 
47 /*
48  * Weak symbols: All libc internal usage of these functions should
49  * use the weak symbol versions (_pthread_XXX).  If libpthread is
50  * linked, it will override these functions with (non-weak) routines.
51  * The _pthread_XXX functions are provided solely for internal libc
52  * usage to avoid unwanted cancellation points and to differentiate
53  * between application locks and libc locks (threads holding the
54  * latter can't be allowed to exit/terminate).
55  */
56 __weak_reference(_pthread_getspecific_stub,_pthread_getspecific);
57 __weak_reference(_pthread_key_create_stub,_pthread_key_create);
58 __weak_reference(_pthread_key_delete_stub,_pthread_key_delete);
59 __weak_reference(_pthread_mutex_destroy_stub,_pthread_mutex_destroy);
60 __weak_reference(_pthread_mutex_init_stub,_pthread_mutex_init);
61 __weak_reference(_pthread_mutex_lock_stub,_pthread_mutex_lock);
62 __weak_reference(_pthread_mutex_trylock_stub,_pthread_mutex_trylock);
63 __weak_reference(_pthread_mutex_unlock_stub,_pthread_mutex_unlock);
64 __weak_reference(_pthread_mutexattr_init_stub,_pthread_mutexattr_init);
65 __weak_reference(_pthread_mutexattr_destroy_stub,_pthread_mutexattr_destroy);
66 __weak_reference(_pthread_mutexattr_settype_stub,_pthread_mutexattr_settype);
67 __weak_reference(_pthread_once_stub,_pthread_once);
68 __weak_reference(_pthread_setspecific_stub,_pthread_setspecific);
69 
70 void *
71 _pthread_getspecific_stub(pthread_key_t key __unused)
72 {
73 	return (NULL);
74 }
75 
76 int
77 _pthread_key_create_stub(pthread_key_t *key __unused,
78 			 void (*destructor) (void *) __unused)
79 {
80 	return (0);
81 }
82 
83 int
84 _pthread_key_delete_stub(pthread_key_t key __unused)
85 {
86 	return (0);
87 }
88 
89 int
90 _pthread_mutex_destroy_stub(pthread_mutex_t *mattr __unused)
91 {
92 	return (0);
93 }
94 
95 int
96 _pthread_mutex_init_stub(pthread_mutex_t *mutex __unused,
97 			 const pthread_mutexattr_t *mattr __unused)
98 {
99 	return (0);
100 }
101 
102 int
103 _pthread_mutex_lock_stub(pthread_mutex_t *mutex __unused)
104 {
105 	return (0);
106 }
107 
108 int
109 _pthread_mutex_trylock_stub(pthread_mutex_t *mutex __unused)
110 {
111 	return (0);
112 }
113 
114 int
115 _pthread_mutex_unlock_stub(pthread_mutex_t *mutex __unused)
116 {
117 	return (0);
118 }
119 
120 int
121 _pthread_mutexattr_init_stub(pthread_mutexattr_t *mattr __unused)
122 {
123 	return (0);
124 }
125 
126 int
127 _pthread_mutexattr_destroy_stub(pthread_mutexattr_t *mattr __unused)
128 {
129 	return (0);
130 }
131 
132 int
133 _pthread_mutexattr_settype_stub(pthread_mutexattr_t *mattr __unused,
134 				int type __unused)
135 {
136 	return (0);
137 }
138 
139 int
140 _pthread_once_stub(pthread_once_t *once_control __unused,
141 		   void (*init_routine) (void) __unused)
142 {
143 	return (0);
144 }
145 
146 int
147 _pthread_setspecific_stub(pthread_key_t key __unused,
148 			  const void *value __unused)
149 {
150 	return (0);
151 }
152 
153