diff options
Diffstat (limited to 'sysdeps')
-rw-r--r-- | sysdeps/alpha/bits/setjmp.h | 9 | ||||
-rw-r--r-- | sysdeps/generic/libc-start.c | 59 | ||||
-rw-r--r-- | sysdeps/generic/unwind.h | 53 | ||||
-rw-r--r-- | sysdeps/i386/bits/setjmp.h | 8 | ||||
-rw-r--r-- | sysdeps/powerpc/bits/setjmp.h | 10 | ||||
-rw-r--r-- | sysdeps/sh/bits/setjmp.h | 10 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/i386/sysdep.h | 14 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/ia64/bits/setjmp.h | 9 | ||||
-rw-r--r-- | sysdeps/x86_64/bits/setjmp.h | 8 |
9 files changed, 118 insertions, 62 deletions
diff --git a/sysdeps/alpha/bits/setjmp.h b/sysdeps/alpha/bits/setjmp.h index fcd57d61d1..c603a35554 100644 --- a/sysdeps/alpha/bits/setjmp.h +++ b/sysdeps/alpha/bits/setjmp.h @@ -1,5 +1,5 @@ /* Define the machine-dependent type `jmp_buf'. Alpha version. - Copyright (C) 1992, 1997 Free Software Foundation, Inc. + Copyright (C) 1992, 1997, 2003 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -17,7 +17,10 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -#ifndef _SETJMP_H +#ifndef _BITS_SETJMP_H +#define _BITS_SETJMP_H 1 + +#if !defined _SETJMP_H && !defined _PTHREAD_H # error "Never include <bits/setjmp.h> directly; use <setjmp.h> instead." #endif @@ -80,3 +83,5 @@ typedef long int __jmp_buf[17]; #define _JMPBUF_UNWINDS(_jmpbuf, _address) \ ((void *)(_address) < (void *)((_jmpbuf)[JB_SP])) #endif + +#endif /* bits/setjmp.h */ diff --git a/sysdeps/generic/libc-start.c b/sysdeps/generic/libc-start.c index 351205d636..b98f0a2aa0 100644 --- a/sysdeps/generic/libc-start.c +++ b/sysdeps/generic/libc-start.c @@ -51,12 +51,17 @@ extern void __pthread_initialize_minimal (void) # define LIBC_START_MAIN BP_SYM (__libc_start_main) #endif -STATIC int LIBC_START_MAIN (int (*main) (int, char **, char ** #ifdef MAIN_AUXVEC_ARG - , void * +/* main gets passed a pointer to the auxiliary. */ +# define MAIN_AUXVEC_DECL , void * +# define MAIN_AUXVEC_PARAM , auxvec +#else +# define MAIN_AUXVEC_DECL +# define MAIN_AUXVEC_PARAM #endif - ), +STATIC int LIBC_START_MAIN (int (*main) (int, char **, char ** + MAIN_AUXVEC_DECL), int argc, char *__unbounded *__unbounded ubp_av, #ifdef LIBC_START_MAIN_AUXVEC_ARG @@ -73,11 +78,7 @@ STATIC int LIBC_START_MAIN (int (*main) (int, char **, char ** __attribute__ ((noreturn)); STATIC int -LIBC_START_MAIN (int (*main) (int, char **, char ** -#ifdef MAIN_AUXVEC_ARG - , void * -#endif - ), +LIBC_START_MAIN (int (*main) (int, char **, char ** MAIN_AUXVEC_DECL), int argc, char *__unbounded *__unbounded ubp_av, #ifdef LIBC_START_MAIN_AUXVEC_ARG ElfW(auxv_t) *__unbounded auxvec, @@ -172,10 +173,7 @@ LIBC_START_MAIN (int (*main) (int, char **, char ** if (init) (*init) ( #ifdef INIT_MAIN_ARGS - argc, argv, __environ -# ifdef MAIN_AUXVEC_ARG - , auxvec -# endif + argc, argv, __environ MAIN_AUXVEC_PARAM #endif ); @@ -184,38 +182,45 @@ LIBC_START_MAIN (int (*main) (int, char **, char ** _dl_debug_printf ("\ntransferring control: %s\n\n", argv[0]); #endif -#ifdef HAVE_CANCELBUF - if (setjmp (THREAD_SELF->cancelbuf) == 0) -#endif +#ifdef HAVE_CLEANUP_JMP_BUF + /* Memory for the cancellation buffer. */ + struct pthread_unwind_buf unwind_buf; + + int not_first_call; + not_first_call = setjmp ((struct __jmp_buf_tag *) unwind_buf.cancel_jmp_buf); + if (__builtin_expect (! not_first_call, 1)) { - /* XXX This is where the try/finally handling must be used. */ + struct pthread *self = THREAD_SELF; - result = main (argc, argv, __environ -#ifdef MAIN_AUXVEC_ARG - , auxvec -#endif + /* Store old info. */ + unwind_buf.priv.data.prev = THREAD_GETMEM (self, cleanup_jmp_buf); + unwind_buf.priv.data.cleanup = THREAD_GETMEM (self, cleanup); - ); + /* Store the new cleanup handler info. */ + THREAD_SETMEM (self, cleanup_jmp_buf, &unwind_buf); + + /* Run the program. */ + result = main (argc, argv, __environ MAIN_AUXVEC_PARAM); } -#ifdef HAVE_CANCELBUF else { -# ifdef HAVE_PTR_NTHREADS /* One less thread. Decrement the counter. If it is zero we terminate the entire process. */ result = 0; -# ifdef SHARED +# ifdef SHARED int *const ptr = __libc_pthread_functions.ptr_nthreads; -# else +# else extern int __nptl_nthreads __attribute ((weak)); int *const ptr = &__nptl_nthreads; -# endif +# endif if (! atomic_decrement_and_test (ptr)) -# endif /* Not much left to do but to exit the thread, not the process. */ __exit_thread (0); } +#else + /* Nothing fancy, just call the function. */ + result = main (argc, argv, __environ MAIN_AUXVEC_PARAM); #endif exit (result); diff --git a/sysdeps/generic/unwind.h b/sysdeps/generic/unwind.h index ce43365a31..08d3381175 100644 --- a/sysdeps/generic/unwind.h +++ b/sysdeps/generic/unwind.h @@ -1,26 +1,36 @@ /* Exception handling and frame unwind runtime interface routines. - Copyright (C) 2001 Free Software Foundation, Inc. + Copyright (C) 2001, 2003 Free Software Foundation, Inc. - This file is part of GNU CC. + This file is part of GCC. - GNU CC is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by + GCC is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. - GNU CC is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + GCC is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + License for more details. You should have received a copy of the GNU General Public License - along with GNU CC; see the file COPYING. If not, write to - the Free Software Foundation, 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ + along with GCC; see the file COPYING. If not, write to the Free + Software Foundation, 59 Temple Place - Suite 330, Boston, MA + 02111-1307, USA. */ + +/* As a special exception, if you include this header file into source + files compiled by GCC, this header file does not by itself cause + the resulting executable to be covered by the GNU General Public + License. This exception does not however invalidate any other + reasons why the executable file might be covered by the GNU General + Public License. */ /* This is derived from the C++ ABI for IA-64. Where we diverge for cross-architecture compatibility are noted with "@@@". */ +#ifndef _UNWIND_H +#define _UNWIND_H 1 + #ifdef __cplusplus extern "C" { #endif @@ -31,7 +41,12 @@ extern "C" { inefficient for 32-bit and smaller machines. */ typedef unsigned _Unwind_Word __attribute__((__mode__(__word__))); typedef signed _Unwind_Sword __attribute__((__mode__(__word__))); +#if defined(__ia64__) && defined(__hpux__) +typedef unsigned _Unwind_Ptr __attribute__((__mode__(__word__))); +#else typedef unsigned _Unwind_Ptr __attribute__((__mode__(__pointer__))); +#endif +typedef unsigned _Unwind_Internal_Ptr __attribute__((__mode__(__pointer__))); /* @@@ The IA-64 ABI uses a 64-bit word to identify the producer and consumer of an exception. We'll go along with this for now even on @@ -87,6 +102,7 @@ typedef int _Unwind_Action; #define _UA_CLEANUP_PHASE 2 #define _UA_HANDLER_FRAME 4 #define _UA_FORCE_UNWIND 8 +#define _UA_END_OF_STACK 16 /* This is an opaque type used to refer to a system-specific data structure used by the system unwinder. This context is created and @@ -125,6 +141,9 @@ extern void _Unwind_SetGR (struct _Unwind_Context *, int, _Unwind_Word); extern _Unwind_Ptr _Unwind_GetIP (struct _Unwind_Context *); extern void _Unwind_SetIP (struct _Unwind_Context *, _Unwind_Ptr); +/* @@@ Retrieve the CFA of the given context. */ +extern _Unwind_Word _Unwind_GetCFA (struct _Unwind_Context *); + extern void *_Unwind_GetLanguageSpecificData (struct _Unwind_Context *); extern _Unwind_Ptr _Unwind_GetRegionStart (struct _Unwind_Context *); @@ -135,15 +154,15 @@ extern _Unwind_Ptr _Unwind_GetRegionStart (struct _Unwind_Context *); library and language-specific exception handling semantics. It is specific to the code fragment described by an unwind info block, and it is always referenced via the pointer in the unwind info block, and - hence it has no ABI-specified name. + hence it has no ABI-specified name. Note that this implies that two different C++ implementations can use different names, and have different contents in the language - specific data area. Moreover, that the language specific data + specific data area. Moreover, that the language specific data area contains no version info because name of the function invoked provides more effective versioning by detecting at link time the lack of code to handle the different data format. */ - + typedef _Unwind_Reason_Code (*_Unwind_Personality_Fn) (int, _Unwind_Action, _Unwind_Exception_Class, struct _Unwind_Exception *, struct _Unwind_Context *); @@ -186,6 +205,12 @@ extern _Unwind_Ptr _Unwind_GetDataRelBase (struct _Unwind_Context *); extern _Unwind_Ptr _Unwind_GetTextRelBase (struct _Unwind_Context *); #endif +/* @@@ Given an address, return the entry point of the function that + contains it. */ +extern void * _Unwind_FindEnclosingFunction (void *pc); + #ifdef __cplusplus } #endif + +#endif /* unwind.h */ diff --git a/sysdeps/i386/bits/setjmp.h b/sysdeps/i386/bits/setjmp.h index e5e493bcae..107fe58b35 100644 --- a/sysdeps/i386/bits/setjmp.h +++ b/sysdeps/i386/bits/setjmp.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1997, 1998, 2000, 2001 Free Software Foundation, Inc. +/* Copyright (C) 1997, 1998, 2000, 2001, 2003 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -17,8 +17,10 @@ 02111-1307 USA. */ /* Define the machine-dependent type `jmp_buf'. Intel 386 version. */ +#ifndef _BITS_SETJMP_H +#define _BITS_SETJMP_H 1 -#ifndef _SETJMP_H +#if !defined _SETJMP_H && !defined _PTHREAD_H # error "Never include <bits/setjmp.h> directly; use <setjmp.h> instead." #endif @@ -40,3 +42,5 @@ typedef int __jmp_buf[6]; containing a local variable at ADDRESS. */ #define _JMPBUF_UNWINDS(jmpbuf, address) \ ((void *) (address) < (void *) (jmpbuf)[JB_SP]) + +#endif /* bits/setjmp.h */ diff --git a/sysdeps/powerpc/bits/setjmp.h b/sysdeps/powerpc/bits/setjmp.h index e17bde1351..f849fe23ff 100644 --- a/sysdeps/powerpc/bits/setjmp.h +++ b/sysdeps/powerpc/bits/setjmp.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1997, 1998, 2000 Free Software Foundation, Inc. +/* Copyright (C) 1997, 1998, 2000, 2003 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -17,8 +17,10 @@ 02111-1307 USA. */ /* Define the machine-dependent type `jmp_buf'. PowerPC version. */ +#ifndef _BITS_SETJMP_H +#define _BITS_SETJMP_H 1 -#ifndef _SETJMP_H +#if !defined _SETJMP_H && !defined _PTHREAD_H # error "Never include <bits/setjmp.h> directly; use <setjmp.h> instead." #endif @@ -43,7 +45,7 @@ # define JB_CR 21 /* Condition code registers. */ # define JB_FPRS 22 /* FPRs 14 through 31 are saved, 18*2 words total. */ # define JB_SIZE (58*4) -# endif +# endif #endif #ifndef _ASM @@ -58,3 +60,5 @@ typedef long int __jmp_buf[58]; containing a local variable at ADDRESS. */ #define _JMPBUF_UNWINDS(jmpbuf, address) \ ((void *) (address) < (void *) (jmpbuf)[JB_GPR1]) + +#endif /* bits/setjmp.h */ diff --git a/sysdeps/sh/bits/setjmp.h b/sysdeps/sh/bits/setjmp.h index 55bc66549b..22497703af 100644 --- a/sysdeps/sh/bits/setjmp.h +++ b/sysdeps/sh/bits/setjmp.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1999, 2000 Free Software Foundation, Inc. +/* Copyright (C) 1999, 2000, 2003 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -17,8 +17,10 @@ 02111-1307 USA. */ /* Define the machine-dependent type `jmp_buf'. SH version. */ +#ifndef _BITS_SETJMP_H +#define _BITS_SETJMP_H 1 -#ifndef _SETJMP_H +#if !defined _SETJMP_H && !defined _PTHREAD_H # error "Never include <bits/setjmp.h> directly; use <setjmp.h> instead." #endif @@ -43,10 +45,12 @@ typedef struct #endif #if defined __USE_MISC || defined _ASM -#define JB_SIZE (4 * 15) +# define JB_SIZE (4 * 15) #endif /* Test if longjmp to JMPBUF would unwind the frame containing a local variable at ADDRESS. */ #define _JMPBUF_UNWINDS(jmpbuf, address) \ ((void *) (address) < &(jmpbuf)[0].__regs[7]) + +#endif /* bits/setjmp.h */ diff --git a/sysdeps/unix/sysv/linux/i386/sysdep.h b/sysdeps/unix/sysv/linux/i386/sysdep.h index 2e660c39fc..14984b64f2 100644 --- a/sysdeps/unix/sysv/linux/i386/sysdep.h +++ b/sysdeps/unix/sysv/linux/i386/sysdep.h @@ -164,7 +164,7 @@ __i686.get_pc_thunk.reg: \ # else /* Store (- %eax) into errno through the GOT. */ # define SYSCALL_ERROR_HANDLER \ -0:SETUP_PIC_REG(cx); \ +0:SETUP_PIC_REG(cx); \ addl $_GLOBAL_OFFSET_TABLE_, %ecx; \ xorl %edx, %edx; \ subl %eax, %edx; \ @@ -250,9 +250,9 @@ __i686.get_pc_thunk.reg: \ #define PUSHARGS_1 movl %ebx, %edx; PUSHARGS_0 #define DOARGS_1 _DOARGS_1 (4) #define POPARGS_1 POPARGS_0; movl %edx, %ebx -#define _PUSHARGS_1 pushl %ebx; _PUSHARGS_0 +#define _PUSHARGS_1 pushl %ebx; L(PUSHBX1): _PUSHARGS_0 #define _DOARGS_1(n) movl n(%esp), %ebx; _DOARGS_0(n-4) -#define _POPARGS_1 _POPARGS_0; popl %ebx +#define _POPARGS_1 _POPARGS_0; popl %ebx; L(POPBX1): #define PUSHARGS_2 PUSHARGS_1 #define DOARGS_2 _DOARGS_2 (8) @@ -271,16 +271,16 @@ __i686.get_pc_thunk.reg: \ #define PUSHARGS_4 _PUSHARGS_4 #define DOARGS_4 _DOARGS_4 (24) #define POPARGS_4 _POPARGS_4 -#define _PUSHARGS_4 pushl %esi; _PUSHARGS_3 +#define _PUSHARGS_4 pushl %esi; L(PUSHSI1): _PUSHARGS_3 #define _DOARGS_4(n) movl n(%esp), %esi; _DOARGS_3 (n-4) -#define _POPARGS_4 _POPARGS_3; popl %esi +#define _POPARGS_4 _POPARGS_3; popl %esi; L(POPSI1): #define PUSHARGS_5 _PUSHARGS_5 #define DOARGS_5 _DOARGS_5 (32) #define POPARGS_5 _POPARGS_5 -#define _PUSHARGS_5 pushl %edi; _PUSHARGS_4 +#define _PUSHARGS_5 pushl %edi; L(PUSHDI1): _PUSHARGS_4 #define _DOARGS_5(n) movl n(%esp), %edi; _DOARGS_4 (n-4) -#define _POPARGS_5 _POPARGS_4; popl %edi +#define _POPARGS_5 _POPARGS_4; popl %edi; L(POPDI1): #else /* !__ASSEMBLER__ */ diff --git a/sysdeps/unix/sysv/linux/ia64/bits/setjmp.h b/sysdeps/unix/sysv/linux/ia64/bits/setjmp.h index 3ef2396250..76625753d9 100644 --- a/sysdeps/unix/sysv/linux/ia64/bits/setjmp.h +++ b/sysdeps/unix/sysv/linux/ia64/bits/setjmp.h @@ -1,5 +1,5 @@ /* Define the machine-dependent type `jmp_buf'. Linux/IA-64 version. - Copyright (C) 1999, 2000 Free Software Foundation, Inc. + Copyright (C) 1999, 2000, 2003 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by David Mosberger-Tang <davidm@hpl.hp.com>. @@ -18,7 +18,10 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -#ifndef _SETJMP_H +#ifndef _BITS_SETJMP_H +#define _BITS_SETJMP_H 1 + +#if !defined _SETJMP_H && !defined _PTHREAD_H # error "Never include <bits/setjmp.h> directly; use <setjmp.h> instead." #endif @@ -33,3 +36,5 @@ typedef long __jmp_buf[_JBLEN] __attribute__ ((aligned (16))); /* guarantees 128 variable at ADDRESS. */ #define _JMPBUF_UNWINDS(_jmpbuf, _address) \ ((void *)(_address) < (void *)(((long *)_jmpbuf)[0])) + +#endif /* bits/setjmp.h */ diff --git a/sysdeps/x86_64/bits/setjmp.h b/sysdeps/x86_64/bits/setjmp.h index ba5dd2c112..96646efdda 100644 --- a/sysdeps/x86_64/bits/setjmp.h +++ b/sysdeps/x86_64/bits/setjmp.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2001, 2002 Free Software Foundation, Inc. +/* Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -17,8 +17,10 @@ 02111-1307 USA. */ /* Define the machine-dependent type `jmp_buf'. x86-64 version. */ +#ifndef _BITS_SETJMP_H +#define _BITS_SETJMP_H 1 -#ifndef _SETJMP_H +#if !defined _SETJMP_H && !defined _PTHREAD_H # error "Never include <bits/setjmp.h> directly; use <setjmp.h> instead." #endif @@ -72,3 +74,5 @@ typedef int __jmp_buf[6]; ((void *) (address) < (void *) (jmpbuf)[JB_SP]) # endif #endif + +#endif /* bits/setjmp.h */ |