tst-cleanup4aux.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /* Copyright (C) 2003 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3. Contributed by Jakub Jelinek <jakub@redhat.com>, 2003.
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the 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. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library; if not, see
  14. <http://www.gnu.org/licenses/>. */
  15. #include <pthread.h>
  16. #include <stdio.h>
  17. #include <stdlib.h>
  18. #include <unistd.h>
  19. #if defined(__GLIBC__) || defined(__UCLIBC__)
  20. extern void _pthread_cleanup_push (struct _pthread_cleanup_buffer *__buffer,
  21. void (*__routine) (void *),
  22. void *__arg);
  23. extern void _pthread_cleanup_pop (struct _pthread_cleanup_buffer *__buffer,
  24. int __execute);
  25. extern void clh (void *arg);
  26. extern void fn0 (void);
  27. extern void fn1 (void);
  28. extern void fn5 (void);
  29. extern void fn7 (void);
  30. extern void fn9 (void);
  31. static __attribute__((noinline)) void
  32. fn3 (void)
  33. {
  34. /* This is the old LinuxThreads pthread_cleanup_{push,pop}. */
  35. struct _pthread_cleanup_buffer b;
  36. _pthread_cleanup_push (&b, clh, (void *) 4l);
  37. fn0 ();
  38. _pthread_cleanup_pop (&b, 1);
  39. }
  40. static __attribute__((noinline)) void
  41. fn4 (void)
  42. {
  43. pthread_cleanup_push (clh, (void *) 5l);
  44. fn3 ();
  45. pthread_cleanup_pop (1);
  46. }
  47. void
  48. fn5 (void)
  49. {
  50. /* This is the old LinuxThreads pthread_cleanup_{push,pop}. */
  51. struct _pthread_cleanup_buffer b;
  52. _pthread_cleanup_push (&b, clh, (void *) 6l);
  53. fn4 ();
  54. _pthread_cleanup_pop (&b, 1);
  55. }
  56. static __attribute__((noinline)) void
  57. fn6 (void)
  58. {
  59. pthread_cleanup_push (clh, (void *) 7l);
  60. fn0 ();
  61. pthread_cleanup_pop (1);
  62. }
  63. void
  64. fn7 (void)
  65. {
  66. /* This is the old LinuxThreads pthread_cleanup_{push,pop}. */
  67. struct _pthread_cleanup_buffer b;
  68. _pthread_cleanup_push (&b, clh, (void *) 8l);
  69. fn6 ();
  70. _pthread_cleanup_pop (&b, 1);
  71. }
  72. static __attribute__((noinline)) void
  73. fn8 (void)
  74. {
  75. pthread_cleanup_push (clh, (void *) 9l);
  76. fn1 ();
  77. pthread_cleanup_pop (1);
  78. }
  79. void
  80. fn9 (void)
  81. {
  82. /* This is the old LinuxThreads pthread_cleanup_{push,pop}. */
  83. struct _pthread_cleanup_buffer b;
  84. _pthread_cleanup_push (&b, clh, (void *) 10l);
  85. fn8 ();
  86. _pthread_cleanup_pop (&b, 1);
  87. }
  88. #endif