~ubuntu-branches/ubuntu/quantal/uclibc/quantal

« back to all changes in this revision

Viewing changes to libpthread/nptl/forward.c

  • Committer: Bazaar Package Importer
  • Author(s): Hector Oron
  • Date: 2011-06-11 03:06:20 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20110611030620-ywjfvyuqvrpsm282
Tags: 0.9.32-1
* New upstream release
* Add myself as maintainer
* Bump standards version 
* Add Vcs-Git, Vcs-Browser and Homepage fields
* Add watch file 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (C) 2002, 2003, 2004, 2007 Free Software Foundation, Inc.
 
2
   This file is part of the GNU C Library.
 
3
   Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
 
4
 
 
5
   The GNU C Library is free software; you can redistribute it and/or
 
6
   modify it under the terms of the GNU Lesser General Public
 
7
   License as published by the Free Software Foundation; either
 
8
   version 2.1 of the License, or (at your option) any later version.
 
9
 
 
10
   The GNU C Library is distributed in the hope that it will be useful,
 
11
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
13
   Lesser General Public License for more details.
 
14
 
 
15
   You should have received a copy of the GNU Lesser General Public
 
16
   License along with the GNU C Library; if not, write to the Free
 
17
   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
 
18
   02111-1307 USA.  */
 
19
 
 
20
#include <dlfcn.h>
 
21
#include <pthreadP.h>
 
22
#include <signal.h>
 
23
#include <stdlib.h>
 
24
 
 
25
#include <atomic.h>
 
26
#include <sysdep.h>
 
27
 
 
28
 
 
29
/* Pointers to the libc functions.  */
 
30
struct pthread_functions __libc_pthread_functions attribute_hidden;
 
31
int __libc_pthread_functions_init attribute_hidden;
 
32
 
 
33
 
 
34
#define FORWARD2(name, rettype, decl, params, defaction) \
 
35
rettype                                                                       \
 
36
name decl                                                                     \
 
37
{                                                                             \
 
38
  if (!__libc_pthread_functions_init) {                                       \
 
39
    defaction;                                                                \
 
40
  } else {                                                                    \
 
41
    return PTHFCT_CALL (ptr_##name, params);                                  \
 
42
  }                                                                           \
 
43
}
 
44
 
 
45
#define FORWARD(name, decl, params, defretval) \
 
46
  FORWARD2 (name, int, decl, params, return defretval)
 
47
 
 
48
 
 
49
FORWARD (pthread_attr_destroy, (pthread_attr_t *attr), (attr), 0)
 
50
 
 
51
FORWARD (__pthread_attr_init_2_1, (pthread_attr_t *attr), (attr), 0)
 
52
weak_alias(__pthread_attr_init_2_1, pthread_attr_init)
 
53
 
 
54
FORWARD (pthread_attr_getdetachstate,
 
55
         (const pthread_attr_t *attr, int *detachstate), (attr, detachstate),
 
56
         0)
 
57
FORWARD (pthread_attr_setdetachstate, (pthread_attr_t *attr, int detachstate),
 
58
         (attr, detachstate), 0)
 
59
 
 
60
FORWARD (pthread_attr_getinheritsched,
 
61
         (const pthread_attr_t *attr, int *inherit), (attr, inherit), 0)
 
62
FORWARD (pthread_attr_setinheritsched, (pthread_attr_t *attr, int inherit),
 
63
         (attr, inherit), 0)
 
64
 
 
65
FORWARD (pthread_attr_getschedparam,
 
66
         (const pthread_attr_t *attr, struct sched_param *param),
 
67
         (attr, param), 0)
 
68
FORWARD (pthread_attr_setschedparam,
 
69
         (pthread_attr_t *attr, const struct sched_param *param),
 
70
         (attr, param), 0)
 
71
 
 
72
FORWARD (pthread_attr_getschedpolicy,
 
73
         (const pthread_attr_t *attr, int *policy), (attr, policy), 0)
 
74
FORWARD (pthread_attr_setschedpolicy, (pthread_attr_t *attr, int policy),
 
75
         (attr, policy), 0)
 
76
 
 
77
FORWARD (pthread_attr_getscope,
 
78
         (const pthread_attr_t *attr, int *scope), (attr, scope), 0)
 
79
FORWARD (pthread_attr_setscope, (pthread_attr_t *attr, int scope),
 
80
         (attr, scope), 0)
 
81
 
 
82
 
 
83
FORWARD (pthread_condattr_destroy, (pthread_condattr_t *attr), (attr), 0)
 
84
FORWARD (pthread_condattr_init, (pthread_condattr_t *attr), (attr), 0)
 
85
 
 
86
FORWARD (__pthread_cond_broadcast, (pthread_cond_t *cond), (cond), 0)
 
87
weak_alias(__pthread_cond_broadcast, pthread_cond_broadcast)
 
88
 
 
89
FORWARD (__pthread_cond_destroy, (pthread_cond_t *cond), (cond), 0)
 
90
weak_alias(__pthread_cond_destroy, pthread_cond_destroy)
 
91
 
 
92
FORWARD (__pthread_cond_init,
 
93
         (pthread_cond_t *cond, const pthread_condattr_t *cond_attr),
 
94
         (cond, cond_attr), 0)
 
95
weak_alias(__pthread_cond_init, pthread_cond_init)
 
96
 
 
97
FORWARD (__pthread_cond_signal, (pthread_cond_t *cond), (cond), 0)
 
98
weak_alias(__pthread_cond_signal, pthread_cond_signal)
 
99
 
 
100
FORWARD (__pthread_cond_wait, (pthread_cond_t *cond, pthread_mutex_t *mutex),
 
101
         (cond, mutex), 0)
 
102
weak_alias(__pthread_cond_wait, pthread_cond_wait)
 
103
 
 
104
FORWARD (__pthread_cond_timedwait,
 
105
         (pthread_cond_t *cond, pthread_mutex_t *mutex,
 
106
          const struct timespec *abstime), (cond, mutex, abstime), 0)
 
107
weak_alias(__pthread_cond_timedwait, pthread_cond_timedwait)
 
108
 
 
109
 
 
110
FORWARD (pthread_equal, (pthread_t thread1, pthread_t thread2),
 
111
         (thread1, thread2), 1)
 
112
 
 
113
 
 
114
/* Use an alias to avoid warning, as pthread_exit is declared noreturn.  */
 
115
FORWARD2 (__pthread_exit, void, (void *retval), (retval), exit (EXIT_SUCCESS))
 
116
strong_alias (__pthread_exit, pthread_exit);
 
117
 
 
118
 
 
119
FORWARD (pthread_getschedparam,
 
120
         (pthread_t target_thread, int *policy, struct sched_param *param),
 
121
         (target_thread, policy, param), 0)
 
122
FORWARD (pthread_setschedparam,
 
123
         (pthread_t target_thread, int policy,
 
124
          const struct sched_param *param), (target_thread, policy, param), 0)
 
125
 
 
126
 
 
127
FORWARD (pthread_mutex_destroy, (pthread_mutex_t *mutex), (mutex), 0)
 
128
 
 
129
FORWARD (pthread_mutex_init,
 
130
         (pthread_mutex_t *mutex, const pthread_mutexattr_t *mutexattr),
 
131
         (mutex, mutexattr), 0)
 
132
 
 
133
FORWARD (pthread_mutex_lock, (pthread_mutex_t *mutex), (mutex), 0)
 
134
weak_alias (pthread_mutex_lock, __pthread_mutex_lock)
 
135
 
 
136
FORWARD (pthread_mutex_unlock, (pthread_mutex_t *mutex), (mutex), 0)
 
137
weak_alias (pthread_mutex_unlock, __pthread_mutex_unlock)
 
138
 
 
139
FORWARD2 (pthread_self, pthread_t, (void), (), return 0)
 
140
 
 
141
 
 
142
FORWARD (pthread_setcancelstate, (int state, int *oldstate), (state, oldstate),
 
143
         0)
 
144
 
 
145
FORWARD (pthread_setcanceltype, (int type, int *oldtype), (type, oldtype), 0)
 
146
 
 
147
#define return /* value is void */
 
148
FORWARD2(_pthread_cleanup_push_defer,
 
149
         void, (struct _pthread_cleanup_buffer *buffer, void (*routine)(void *), void *arg),
 
150
         (buffer, routine, arg),
 
151
         { buffer->__routine = routine; buffer->__arg = arg; });
 
152
 
 
153
FORWARD2(_pthread_cleanup_pop_restore,
 
154
         void, (struct _pthread_cleanup_buffer *buffer, int execute),
 
155
         (buffer, execute),
 
156
         if (execute) { buffer->__routine(buffer->__arg); });
 
157
 
 
158
FORWARD2(__pthread_unwind,
 
159
         void attribute_hidden __attribute ((noreturn)) __cleanup_fct_attribute,
 
160
         (__pthread_unwind_buf_t *buf), (buf), {
 
161
                       /* We cannot call abort() here.  */
 
162
                       INTERNAL_SYSCALL_DECL (err);
 
163
                       INTERNAL_SYSCALL (kill, err, 1, SIGKILL);
 
164
                     })
 
165
#undef return