weaks.c 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. /* The weak pthread functions for Linux.
  2. Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Library General Public License as
  6. published by the Free Software Foundation; either version 2 of the
  7. License, or (at your option) any later version.
  8. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Library General Public License for more details.
  12. You should have received a copy of the GNU Library General Public
  13. License along with the GNU C Library; see the file COPYING.LIB. If not,
  14. write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  15. Boston, MA 02111-1307, USA. */
  16. #define _GNU_SOURCE
  17. #include <errno.h>
  18. #include <limits.h>
  19. #include <stdlib.h>
  20. /**********************************************************************/
  21. /* Weaks for application/library use.
  22. *
  23. * We need to define weaks here to cover all the pthread functions that
  24. * libc itself will use so that we aren't forced to link libc.so to
  25. * libpthread.so. When an application doesn't use pthreads support,
  26. * the locking functions used by libc itself basically become no-ops.
  27. * However, if the application uses pthreads, then it will pull in
  28. * libpthread.so whose symbols will override these weaks magically
  29. * turning the internal libc mutex calls from no-ops to real locking
  30. * calls.
  31. */
  32. /* glibc itself defines all these, but we don't need them in uClibc
  33. *
  34. * Verified by comparing to glibc's linuxthreads/forward.c and defined
  35. * only those that are in the glibc abi.
  36. * The commented aliases are ones that were previously defined in uClibc
  37. * and which I left in for documentation.
  38. */
  39. static int __pthread_return_0 __P ((void));
  40. static int __pthread_return_0 (void) { return 0; }
  41. /*
  42. weak_alias (__pthread_return_0, pthread_attr_destroy)
  43. weak_alias (__pthread_return_0, pthread_attr_getdetachstate)
  44. weak_alias (__pthread_return_0, pthread_attr_getinheritsched)
  45. weak_alias (__pthread_return_0, pthread_attr_getschedparam)
  46. weak_alias (__pthread_return_0, pthread_attr_getschedpolicy)
  47. weak_alias (__pthread_return_0, pthread_attr_getscope)
  48. weak_alias (__pthread_return_0, pthread_attr_getstackaddr)
  49. weak_alias (__pthread_return_0, pthread_attr_getstacksize)
  50. weak_alias (__pthread_return_0, pthread_attr_init)
  51. weak_alias (__pthread_return_0, pthread_attr_setdetachstate)
  52. weak_alias (__pthread_return_0, pthread_attr_setinheritsched)
  53. weak_alias (__pthread_return_0, pthread_attr_setschedparam)
  54. weak_alias (__pthread_return_0, pthread_attr_setschedpolicy)
  55. weak_alias (__pthread_return_0, pthread_attr_setscope)
  56. weak_alias (__pthread_return_0, pthread_attr_setstackaddr)
  57. weak_alias (__pthread_return_0, pthread_attr_setstacksize)
  58. weak_alias (__pthread_return_0, pthread_cond_broadcast)
  59. weak_alias (__pthread_return_0, pthread_cond_destroy)
  60. weak_alias (__pthread_return_0, pthread_cond_init)
  61. weak_alias (__pthread_return_0, pthread_cond_signal)
  62. weak_alias (__pthread_return_0, pthread_cond_timedwait)
  63. weak_alias (__pthread_return_0, pthread_cond_wait)
  64. weak_alias (__pthread_return_0, pthread_condattr_destroy)
  65. weak_alias (__pthread_return_0, pthread_condattr_init)
  66. weak_alias (__pthread_return_0, pthread_getschedparam)
  67. weak_alias (__pthread_return_0, pthread_getcancelstate)
  68. weak_alias (__pthread_return_0, pthread_getconcurrency)
  69. weak_alias (__pthread_return_0, pthread_mutex_destroy)
  70. weak_alias (__pthread_return_0, pthread_mutex_init)
  71. weak_alias (__pthread_return_0, pthread_mutex_lock)
  72. weak_alias (__pthread_return_0, pthread_mutex_trylock)
  73. weak_alias (__pthread_return_0, pthread_mutex_unlock)
  74. weak_alias (__pthread_return_0, pthread_mutexattr_destroy)
  75. weak_alias (__pthread_return_0, pthread_mutexattr_gettype)
  76. weak_alias (__pthread_return_0, pthread_mutexattr_init)
  77. weak_alias (__pthread_return_0, pthread_mutexattr_settype)
  78. weak_alias (__pthread_return_0, pthread_rwlock_destroy)
  79. weak_alias (__pthread_return_0, pthread_rwlock_init)
  80. weak_alias (__pthread_return_0, pthread_rwlock_rdlock)
  81. weak_alias (__pthread_return_0, pthread_rwlock_tryrdlock)
  82. weak_alias (__pthread_return_0, pthread_rwlock_trywrlock)
  83. weak_alias (__pthread_return_0, pthread_rwlock_unlock)
  84. weak_alias (__pthread_return_0, pthread_rwlock_wrlock)
  85. weak_alias (__pthread_return_0, pthread_rwlockattr_destroy)
  86. weak_alias (__pthread_return_0, pthread_rwlockattr_getpshared)
  87. weak_alias (__pthread_return_0, pthread_rwlockattr_init)
  88. weak_alias (__pthread_return_0, pthread_rwlockattr_setpshared)
  89. weak_alias (__pthread_return_0, pthread_self)
  90. weak_alias (__pthread_return_0, pthread_setcancelstate)
  91. weak_alias (__pthread_return_0, pthread_setcanceltype)
  92. weak_alias (__pthread_return_0, pthread_setconcurrency)
  93. weak_alias (__pthread_return_0, pthread_setschedparam)
  94. static int __pthread_return_1 __P ((void));
  95. static int __pthread_return_1 (void) { return 1; }
  96. weak_alias (__pthread_return_1, pthread_equal)
  97. void weak_function pthread_exit (void *retval)
  98. {
  99. exit (EXIT_SUCCESS);
  100. }
  101. */
  102. /**********************************************************************/
  103. /* Weaks used internally by the C library. */
  104. weak_alias (__pthread_return_0, __pthread_mutex_init)
  105. weak_alias (__pthread_return_0, __pthread_mutex_lock)
  106. weak_alias (__pthread_return_0, __pthread_mutex_trylock)
  107. weak_alias (__pthread_return_0, __pthread_mutex_unlock)
  108. #ifdef __UCLIBC_HAS_THREADS_NATIVE__
  109. weak_alias (__pthread_return_0, pthread_mutexattr_init)
  110. weak_alias (__pthread_return_0, pthread_mutexattr_settype)
  111. weak_alias (__pthread_return_0, pthread_mutexattr_destroy)
  112. #endif
  113. /**********************************************************************/