aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/generic
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2003-04-12 00:58:26 +0000
committerUlrich Drepper <drepper@redhat.com>2003-04-12 00:58:26 +0000
commit09d65ff393e9183eecba1e5cb877e95dbdd3d4a4 (patch)
treeb618ac607f17c1d683f1ea1e4d34415e4ea8e7f8 /sysdeps/generic
parent877e51b20f69ce1927c4978134d0c2afbbf856ad (diff)
downloadglibc-09d65ff393e9183eecba1e5cb877e95dbdd3d4a4.zip
glibc-09d65ff393e9183eecba1e5cb877e95dbdd3d4a4.tar.gz
glibc-09d65ff393e9183eecba1e5cb877e95dbdd3d4a4.tar.bz2
Update.
2003-04-11 Ulrich Drepper <drepper@redhat.com> * sysdeps/generic/libc-start.c: Cleanup MAIN_AUXVEC_ARG handling. Remove HAVE_CANCELBUF code. Replace with code using the new initializers for unwind-based cleanup handling. * sysdeps/generic/unwind.h: Update from latest gcc version. * sysdeps/unix/sysv/linux/i386/sysdep.h: Define labels in a few places to allow unwind data generation. * sysdeps/i386/bits/setjmp.h: Allow file to be included multiple times. * sysdeps/x86_64/bits/setjmp.h: Likewise. * sysdeps/sh/bits/setjmp.h: Likewise. * sysdeps/powerpc/bits/setjmp.h: Likewise. * sysdeps/unix/sysv/linux/ia64/bits/setjmp.h: Likewise. * sysdeps/alpha/bits/setjmp.h: Likewise.
Diffstat (limited to 'sysdeps/generic')
-rw-r--r--sysdeps/generic/libc-start.c59
-rw-r--r--sysdeps/generic/unwind.h53
2 files changed, 71 insertions, 41 deletions
diff --git a/sysdeps/generic/libc-start.c b/sysdeps/generic/libc-start.c
index 351205d..b98f0a2 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 ce43365..08d3381 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 */