Back to index

glibc  2.9
tst-cleanup4aux.c
Go to the documentation of this file.
00001 /* Copyright (C) 2003 Free Software Foundation, Inc.
00002    This file is part of the GNU C Library.
00003    Contributed by Jakub Jelinek <jakub@redhat.com>, 2003.
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 <pthread.h>
00021 #include <stdio.h>
00022 #include <stdlib.h>
00023 #include <unistd.h>
00024 
00025 extern void _pthread_cleanup_push (struct _pthread_cleanup_buffer *__buffer,
00026                                    void (*__routine) (void *),
00027                                    void *__arg);
00028 extern void _pthread_cleanup_pop (struct _pthread_cleanup_buffer *__buffer,
00029                                   int __execute);
00030 
00031 extern void clh (void *arg);
00032 extern void fn0 (void);
00033 extern void fn1 (void);
00034 extern void fn5 (void);
00035 extern void fn7 (void);
00036 extern void fn9 (void);
00037 
00038 
00039 static __attribute__((noinline)) void
00040 fn3 (void)
00041 {
00042   /* This is the old LinuxThreads pthread_cleanup_{push,pop}.  */
00043      struct _pthread_cleanup_buffer b;
00044   _pthread_cleanup_push (&b, clh, (void *) 4l);
00045 
00046   fn0 ();
00047 
00048   _pthread_cleanup_pop (&b, 1);
00049 }
00050 
00051 
00052 static __attribute__((noinline)) void
00053 fn4 (void)
00054 {
00055   pthread_cleanup_push (clh, (void *) 5l);
00056 
00057   fn3 ();
00058 
00059   pthread_cleanup_pop (1);
00060 }
00061 
00062 
00063 void
00064 fn5 (void)
00065 {
00066   /* This is the old LinuxThreads pthread_cleanup_{push,pop}.  */
00067      struct _pthread_cleanup_buffer b;
00068   _pthread_cleanup_push (&b, clh, (void *) 6l);
00069 
00070   fn4 ();
00071 
00072   _pthread_cleanup_pop (&b, 1);
00073 }
00074 
00075 
00076 static __attribute__((noinline)) void
00077 fn6 (void)
00078 {
00079   pthread_cleanup_push (clh, (void *) 7l);
00080 
00081   fn0 ();
00082 
00083   pthread_cleanup_pop (1);
00084 }
00085 
00086 
00087 void
00088 fn7 (void)
00089 {
00090   /* This is the old LinuxThreads pthread_cleanup_{push,pop}.  */
00091      struct _pthread_cleanup_buffer b;
00092   _pthread_cleanup_push (&b, clh, (void *) 8l);
00093 
00094   fn6 ();
00095 
00096   _pthread_cleanup_pop (&b, 1);
00097 }
00098 
00099 
00100 static __attribute__((noinline)) void
00101 fn8 (void)
00102 {
00103   pthread_cleanup_push (clh, (void *) 9l);
00104 
00105   fn1 ();
00106 
00107   pthread_cleanup_pop (1);
00108 }
00109 
00110 
00111 void
00112 fn9 (void)
00113 {
00114   /* This is the old LinuxThreads pthread_cleanup_{push,pop}.  */
00115      struct _pthread_cleanup_buffer b;
00116   _pthread_cleanup_push (&b, clh, (void *) 10l);
00117 
00118   fn8 ();
00119 
00120   _pthread_cleanup_pop (&b, 1);
00121 }