Merge from vendor branch BZIP:
[dragonfly.git] / lib / libc / gen / _pthread_stubs.c
CommitLineData
17ea2221
MD
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 $
19c7a913 27 * $DragonFly: src/lib/libc/gen/_pthread_stubs.c,v 1.4 2005/05/09 12:43:40 davidxu Exp $
17ea2221
MD
28 */
29
30#include <pthread.h>
31
cd73ef72
JS
32void *_pthread_getspecific_stub(pthread_key_t);
33int _pthread_key_create_stub(pthread_key_t *, void (*)(void *));
34int _pthread_key_delete_stub(pthread_key_t);
35int _pthread_mutex_destroy_stub(pthread_mutex_t *);
36int _pthread_mutex_init_stub(pthread_mutex_t *,
37 const pthread_mutexattr_t *);
38int _pthread_mutex_lock_stub(pthread_mutex_t *);
39int _pthread_mutex_trylock_stub(pthread_mutex_t *);
40int _pthread_mutex_unlock_stub(pthread_mutex_t *);
41int _pthread_mutexattr_init_stub(pthread_mutexattr_t *);
42int _pthread_mutexattr_destroy_stub(pthread_mutexattr_t *);
43int _pthread_mutexattr_settype_stub(pthread_mutexattr_t *, int);
44int _pthread_once_stub(pthread_once_t *, void (*)(void));
45int _pthread_setspecific_stub(pthread_key_t, const void *);
46
19c7a913
DX
47/* define a null pthread structure just to satisfy _pthread_self */
48struct pthread {
49};
50
51static struct pthread main_thread;
52
17ea2221
MD
53/*
54 * Weak symbols: All libc internal usage of these functions should
55 * use the weak symbol versions (_pthread_XXX). If libpthread is
56 * linked, it will override these functions with (non-weak) routines.
57 * The _pthread_XXX functions are provided solely for internal libc
58 * usage to avoid unwanted cancellation points and to differentiate
59 * between application locks and libc locks (threads holding the
60 * latter can't be allowed to exit/terminate).
61 */
5dd49d16
JS
62__weak_reference(_pthread_getspecific_stub,_pthread_getspecific);
63__weak_reference(_pthread_key_create_stub,_pthread_key_create);
64__weak_reference(_pthread_key_delete_stub,_pthread_key_delete);
65__weak_reference(_pthread_mutex_destroy_stub,_pthread_mutex_destroy);
66__weak_reference(_pthread_mutex_init_stub,_pthread_mutex_init);
67__weak_reference(_pthread_mutex_lock_stub,_pthread_mutex_lock);
68__weak_reference(_pthread_mutex_trylock_stub,_pthread_mutex_trylock);
69__weak_reference(_pthread_mutex_unlock_stub,_pthread_mutex_unlock);
70__weak_reference(_pthread_mutexattr_init_stub,_pthread_mutexattr_init);
71__weak_reference(_pthread_mutexattr_destroy_stub,_pthread_mutexattr_destroy);
72__weak_reference(_pthread_mutexattr_settype_stub,_pthread_mutexattr_settype);
73__weak_reference(_pthread_once_stub,_pthread_once);
74__weak_reference(_pthread_setspecific_stub,_pthread_setspecific);
19c7a913 75__weak_reference(_pthread_self_stub,_pthread_self);
17ea2221
MD
76
77void *
cd73ef72 78_pthread_getspecific_stub(pthread_key_t key __unused)
17ea2221
MD
79{
80 return (NULL);
81}
82
83int
cd73ef72
JS
84_pthread_key_create_stub(pthread_key_t *key __unused,
85 void (*destructor) (void *) __unused)
17ea2221
MD
86{
87 return (0);
88}
89
90int
cd73ef72 91_pthread_key_delete_stub(pthread_key_t key __unused)
17ea2221
MD
92{
93 return (0);
94}
95
96int
cd73ef72 97_pthread_mutex_destroy_stub(pthread_mutex_t *mattr __unused)
17ea2221
MD
98{
99 return (0);
100}
101
102int
cd73ef72
JS
103_pthread_mutex_init_stub(pthread_mutex_t *mutex __unused,
104 const pthread_mutexattr_t *mattr __unused)
17ea2221
MD
105{
106 return (0);
107}
108
109int
cd73ef72 110_pthread_mutex_lock_stub(pthread_mutex_t *mutex __unused)
17ea2221
MD
111{
112 return (0);
113}
114
115int
cd73ef72 116_pthread_mutex_trylock_stub(pthread_mutex_t *mutex __unused)
17ea2221
MD
117{
118 return (0);
119}
120
121int
cd73ef72 122_pthread_mutex_unlock_stub(pthread_mutex_t *mutex __unused)
17ea2221
MD
123{
124 return (0);
125}
126
127int
cd73ef72 128_pthread_mutexattr_init_stub(pthread_mutexattr_t *mattr __unused)
17ea2221
MD
129{
130 return (0);
131}
132
133int
cd73ef72 134_pthread_mutexattr_destroy_stub(pthread_mutexattr_t *mattr __unused)
17ea2221
MD
135{
136 return (0);
137}
138
139int
cd73ef72
JS
140_pthread_mutexattr_settype_stub(pthread_mutexattr_t *mattr __unused,
141 int type __unused)
17ea2221
MD
142{
143 return (0);
144}
145
146int
cd73ef72
JS
147_pthread_once_stub(pthread_once_t *once_control __unused,
148 void (*init_routine) (void) __unused)
17ea2221
MD
149{
150 return (0);
151}
152
19c7a913
DX
153struct pthread *
154_pthread_self_stub(void)
155{
156 return (&main_thread);
157}
17ea2221 158int
cd73ef72
JS
159_pthread_setspecific_stub(pthread_key_t key __unused,
160 const void *value __unused)
17ea2221
MD
161{
162 return (0);
163}
164