tst-cleanup4aux.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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. extern void _pthread_cleanup_push (struct _pthread_cleanup_buffer *__buffer,
  20. void (*__routine) (void *),
  21. void *__arg);
  22. extern void _pthread_cleanup_pop (struct _pthread_cleanup_buffer *__buffer,
  23. int __execute);
  24. extern void clh (void *arg);
  25. extern void fn0 (void);
  26. extern void fn1 (void);
  27. extern void fn5 (void);
  28. extern void fn7 (void);
  29. extern void fn9 (void);
  30. static __attribute__((noinline)) void
  31. fn3 (void)
  32. {
  33. /* This is the old LinuxThreads pthread_cleanup_{push,pop}. */
  34. struct _pthread_cleanup_buffer b;
  35. _pthread_cleanup_push (&b, clh, (void *) 4l);
  36. fn0 ();
  37. _pthread_cleanup_pop (&b, 1);
  38. }
  39. static __attribute__((noinline)) void
  40. fn4 (void)
  41. {
  42. pthread_cleanup_push (clh, (void *) 5l);
  43. fn3 ();
  44. pthread_cleanup_pop (1);
  45. }
  46. void
  47. fn5 (void)
  48. {
  49. /* This is the old LinuxThreads pthread_cleanup_{push,pop}. */
  50. struct _pthread_cleanup_buffer b;
  51. _pthread_cleanup_push (&b, clh, (void *) 6l);
  52. fn4 ();
  53. _pthread_cleanup_pop (&b, 1);
  54. }
  55. static __attribute__((noinline)) void
  56. fn6 (void)
  57. {
  58. pthread_cleanup_push (clh, (void *) 7l);
  59. fn0 ();
  60. pthread_cleanup_pop (1);
  61. }
  62. void
  63. fn7 (void)
  64. {
  65. /* This is the old LinuxThreads pthread_cleanup_{push,pop}. */
  66. struct _pthread_cleanup_buffer b;
  67. _pthread_cleanup_push (&b, clh, (void *) 8l);
  68. fn6 ();
  69. _pthread_cleanup_pop (&b, 1);
  70. }
  71. static __attribute__((noinline)) void
  72. fn8 (void)
  73. {
  74. pthread_cleanup_push (clh, (void *) 9l);
  75. fn1 ();
  76. pthread_cleanup_pop (1);
  77. }
  78. void
  79. fn9 (void)
  80. {
  81. /* This is the old LinuxThreads pthread_cleanup_{push,pop}. */
  82. struct _pthread_cleanup_buffer b;
  83. _pthread_cleanup_push (&b, clh, (void *) 10l);
  84. fn8 ();
  85. _pthread_cleanup_pop (&b, 1);
  86. }