Fix parameter name.
[glibc/pb-stable.git] / linuxthreads / ptlongjmp.c
blobc89d28bccde9d5b1ca69fd0cfcdb729977d161e1
1 /* Linuxthreads - a simple clone()-based implementation of Posix */
2 /* threads for Linux. */
3 /* Copyright (C) 1998 Xavier Leroy (Xavier.Leroy@inria.fr) */
4 /* */
5 /* This program is free software; you can redistribute it and/or */
6 /* modify it under the terms of the GNU Library General Public License */
7 /* as published by the Free Software Foundation; either version 2 */
8 /* of the License, or (at your option) any later version. */
9 /* */
10 /* This program is distributed in the hope that it will be useful, */
11 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
12 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
13 /* GNU Library General Public License for more details. */
15 /* Redefine siglongjmp and longjmp so that they interact correctly
16 with cleanup handlers */
18 #include <setjmp.h>
19 #include "pthread.h"
20 #include "internals.h"
22 /* These functions are not declared anywhere since they shouldn't be
23 used at another place but here. */
24 extern void __libc_siglongjmp (sigjmp_buf env, int val)
25 __attribute__ ((noreturn));
26 extern void __libc_longjmp (sigjmp_buf env, int val)
27 __attribute__ ((noreturn));
30 void __pthread_cleanup_upto (__jmp_buf target, char *targetframe)
32 pthread_descr self = thread_self();
33 struct _pthread_cleanup_buffer * c;
35 for (c = THREAD_GETMEM(self, p_cleanup);
36 c != NULL && _JMPBUF_UNWINDS(target, c);
37 c = c->__prev)
39 #if _STACK_GROWS_DOWN
40 if ((char *) c <= targetframe)
42 c = NULL;
43 break;
45 #elif _STACK_GROWS_UP
46 if ((char *) c >= targetframe)
48 c = NULL;
49 break;
51 #else
52 # error "Define either _STACK_GROWS_DOWN or _STACK_GROWS_UP"
53 #endif
54 c->__routine(c->__arg);
56 THREAD_SETMEM(self, p_cleanup, c);
57 if (THREAD_GETMEM(self, p_in_sighandler)
58 && _JMPBUF_UNWINDS(target, THREAD_GETMEM(self, p_in_sighandler)))
59 THREAD_SETMEM(self, p_in_sighandler, NULL);
62 #ifdef SHARED
63 void siglongjmp (sigjmp_buf env, int val)
65 __libc_siglongjmp (env, val);
68 void longjmp (jmp_buf env, int val)
70 __libc_longjmp (env, val);
72 #endif