Back to index

glibc  2.9
forward.c
Go to the documentation of this file.
00001 /* Copyright (C) 2002, 2003, 2004, 2007 Free Software Foundation, Inc.
00002    This file is part of the GNU C Library.
00003    Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
00004 
00005    The GNU C Library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Lesser General Public
00007    License as published by the Free Software Foundation; either
00008    version 2.1 of the License, or (at your option) any later version.
00009 
00010    The GNU C Library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Lesser General Public License for more details.
00014 
00015    You should have received a copy of the GNU Lesser General Public
00016    License along with the GNU C Library; if not, write to the Free
00017    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00018    02111-1307 USA.  */
00019 
00020 #include <dlfcn.h>
00021 #include <pthreadP.h>
00022 #include <signal.h>
00023 #include <stdlib.h>
00024 
00025 #include <shlib-compat.h>
00026 #include <atomic.h>
00027 #include <sysdep.h>
00028 
00029 
00030 /* Pointers to the libc functions.  */
00031 struct pthread_functions __libc_pthread_functions attribute_hidden;
00032 int __libc_pthread_functions_init attribute_hidden;
00033 
00034 
00035 #define FORWARD2(name, rettype, decl, params, defaction) \
00036 rettype                                                                     \
00037 name decl                                                            \
00038 {                                                                    \
00039   if (!__libc_pthread_functions_init)                                       \
00040     defaction;                                                              \
00041                                                                      \
00042   return PTHFCT_CALL (ptr_##name, params);                                  \
00043 }
00044 
00045 #define FORWARD(name, decl, params, defretval) \
00046   FORWARD2 (name, int, decl, params, return defretval)
00047 
00048 
00049 FORWARD (pthread_attr_destroy, (pthread_attr_t *attr), (attr), 0)
00050 
00051 #if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_1)
00052 FORWARD (__pthread_attr_init_2_0, (pthread_attr_t *attr), (attr), 0)
00053 compat_symbol (libc, __pthread_attr_init_2_0, pthread_attr_init, GLIBC_2_0);
00054 #endif
00055 
00056 FORWARD (__pthread_attr_init_2_1, (pthread_attr_t *attr), (attr), 0)
00057 versioned_symbol (libc, __pthread_attr_init_2_1, pthread_attr_init, GLIBC_2_1);
00058 
00059 FORWARD (pthread_attr_getdetachstate,
00060         (const pthread_attr_t *attr, int *detachstate), (attr, detachstate),
00061         0)
00062 FORWARD (pthread_attr_setdetachstate, (pthread_attr_t *attr, int detachstate),
00063         (attr, detachstate), 0)
00064 
00065 FORWARD (pthread_attr_getinheritsched,
00066         (const pthread_attr_t *attr, int *inherit), (attr, inherit), 0)
00067 FORWARD (pthread_attr_setinheritsched, (pthread_attr_t *attr, int inherit),
00068         (attr, inherit), 0)
00069 
00070 FORWARD (pthread_attr_getschedparam,
00071         (const pthread_attr_t *attr, struct sched_param *param),
00072         (attr, param), 0)
00073 FORWARD (pthread_attr_setschedparam,
00074         (pthread_attr_t *attr, const struct sched_param *param),
00075         (attr, param), 0)
00076 
00077 FORWARD (pthread_attr_getschedpolicy,
00078         (const pthread_attr_t *attr, int *policy), (attr, policy), 0)
00079 FORWARD (pthread_attr_setschedpolicy, (pthread_attr_t *attr, int policy),
00080         (attr, policy), 0)
00081 
00082 FORWARD (pthread_attr_getscope,
00083         (const pthread_attr_t *attr, int *scope), (attr, scope), 0)
00084 FORWARD (pthread_attr_setscope, (pthread_attr_t *attr, int scope),
00085         (attr, scope), 0)
00086 
00087 
00088 FORWARD (pthread_condattr_destroy, (pthread_condattr_t *attr), (attr), 0)
00089 FORWARD (pthread_condattr_init, (pthread_condattr_t *attr), (attr), 0)
00090 
00091 #if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_3_2)
00092 FORWARD2 (__pthread_cond_broadcast_2_0, int attribute_compat_text_section,
00093          (pthread_cond_2_0_t *cond), (cond), return 0)
00094 compat_symbol (libc, __pthread_cond_broadcast_2_0, pthread_cond_broadcast,
00095               GLIBC_2_0);
00096 #endif
00097 FORWARD (__pthread_cond_broadcast, (pthread_cond_t *cond), (cond), 0)
00098 versioned_symbol (libc, __pthread_cond_broadcast, pthread_cond_broadcast,
00099                 GLIBC_2_3_2);
00100 
00101 #if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_3_2)
00102 FORWARD2 (__pthread_cond_destroy_2_0, int attribute_compat_text_section,
00103          (pthread_cond_2_0_t *cond), (cond), return 0)
00104 compat_symbol (libc, __pthread_cond_destroy_2_0, pthread_cond_destroy,
00105               GLIBC_2_0);
00106 #endif
00107 FORWARD (__pthread_cond_destroy, (pthread_cond_t *cond), (cond), 0)
00108 versioned_symbol (libc, __pthread_cond_destroy, pthread_cond_destroy,
00109                 GLIBC_2_3_2);
00110 
00111 #if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_3_2)
00112 FORWARD2 (__pthread_cond_init_2_0, int attribute_compat_text_section,
00113          (pthread_cond_2_0_t *cond, const pthread_condattr_t *cond_attr),
00114          (cond, cond_attr), return 0)
00115 compat_symbol (libc, __pthread_cond_init_2_0, pthread_cond_init, GLIBC_2_0);
00116 #endif
00117 FORWARD (__pthread_cond_init,
00118         (pthread_cond_t *cond, const pthread_condattr_t *cond_attr),
00119         (cond, cond_attr), 0)
00120 versioned_symbol (libc, __pthread_cond_init, pthread_cond_init, GLIBC_2_3_2);
00121 
00122 #if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_3_2)
00123 FORWARD2 (__pthread_cond_signal_2_0, int attribute_compat_text_section,
00124          (pthread_cond_2_0_t *cond), (cond), return 0)
00125 compat_symbol (libc, __pthread_cond_signal_2_0, pthread_cond_signal,
00126               GLIBC_2_0);
00127 #endif
00128 FORWARD (__pthread_cond_signal, (pthread_cond_t *cond), (cond), 0)
00129 versioned_symbol (libc, __pthread_cond_signal, pthread_cond_signal,
00130                 GLIBC_2_3_2);
00131 
00132 #if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_3_2)
00133 FORWARD2 (__pthread_cond_wait_2_0, int attribute_compat_text_section,
00134          (pthread_cond_2_0_t *cond, pthread_mutex_t *mutex), (cond, mutex),
00135          return 0)
00136 compat_symbol (libc, __pthread_cond_wait_2_0, pthread_cond_wait,
00137               GLIBC_2_0);
00138 #endif
00139 FORWARD (__pthread_cond_wait, (pthread_cond_t *cond, pthread_mutex_t *mutex),
00140         (cond, mutex), 0)
00141 versioned_symbol (libc, __pthread_cond_wait, pthread_cond_wait,
00142                 GLIBC_2_3_2);
00143 
00144 #if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_3_2)
00145 FORWARD2 (__pthread_cond_timedwait_2_0, int attribute_compat_text_section,
00146          (pthread_cond_2_0_t *cond, pthread_mutex_t *mutex,
00147           const struct timespec *abstime), (cond, mutex, abstime),
00148          return 0)
00149 compat_symbol (libc, __pthread_cond_timedwait_2_0, pthread_cond_timedwait,
00150               GLIBC_2_0);
00151 #endif
00152 FORWARD (__pthread_cond_timedwait,
00153         (pthread_cond_t *cond, pthread_mutex_t *mutex,
00154          const struct timespec *abstime), (cond, mutex, abstime), 0)
00155 versioned_symbol (libc, __pthread_cond_timedwait, pthread_cond_timedwait,
00156                 GLIBC_2_3_2);
00157 
00158 
00159 FORWARD (pthread_equal, (pthread_t thread1, pthread_t thread2),
00160         (thread1, thread2), 1)
00161 
00162 
00163 /* Use an alias to avoid warning, as pthread_exit is declared noreturn.  */
00164 FORWARD2 (__pthread_exit, void, (void *retval), (retval), exit (EXIT_SUCCESS))
00165 strong_alias (__pthread_exit, pthread_exit);
00166 
00167 
00168 FORWARD (pthread_getschedparam,
00169         (pthread_t target_thread, int *policy, struct sched_param *param),
00170         (target_thread, policy, param), 0)
00171 FORWARD (pthread_setschedparam,
00172         (pthread_t target_thread, int policy,
00173          const struct sched_param *param), (target_thread, policy, param), 0)
00174 
00175 
00176 FORWARD (pthread_mutex_destroy, (pthread_mutex_t *mutex), (mutex), 0)
00177 
00178 FORWARD (pthread_mutex_init,
00179         (pthread_mutex_t *mutex, const pthread_mutexattr_t *mutexattr),
00180         (mutex, mutexattr), 0)
00181 
00182 FORWARD (pthread_mutex_lock, (pthread_mutex_t *mutex), (mutex), 0)
00183 
00184 FORWARD (pthread_mutex_unlock, (pthread_mutex_t *mutex), (mutex), 0)
00185 
00186 
00187 FORWARD2 (pthread_self, pthread_t, (void), (), return 0)
00188 
00189 
00190 FORWARD (pthread_setcancelstate, (int state, int *oldstate), (state, oldstate),
00191         0)
00192 
00193 FORWARD (pthread_setcanceltype, (int type, int *oldtype), (type, oldtype), 0)
00194 
00195 #define return /* value is void */
00196 FORWARD2(__pthread_unwind,
00197         void attribute_hidden __attribute ((noreturn)) __cleanup_fct_attribute
00198         attribute_compat_text_section,
00199         (__pthread_unwind_buf_t *buf), (buf), {
00200                      /* We cannot call abort() here.  */
00201                      INTERNAL_SYSCALL_DECL (err);
00202                      INTERNAL_SYSCALL (kill, err, 1, SIGKILL);
00203                    })
00204 #undef return