Blame sysdeps/generic/unwind.h

Packit Service 82fcde
/* Exception handling and frame unwind runtime interface routines.
Packit Service 82fcde
   Copyright (C) 2001-2018 Free Software Foundation, Inc.
Packit Service 82fcde
Packit Service 82fcde
   This file is part of the GNU C Library.
Packit Service 82fcde
Packit Service 82fcde
   The GNU C Library is free software; you can redistribute it and/or
Packit Service 82fcde
   modify it under the terms of the GNU Lesser General Public
Packit Service 82fcde
   License as published by the Free Software Foundation; either
Packit Service 82fcde
   version 2.1 of the License, or (at your option) any later version.
Packit Service 82fcde
Packit Service 82fcde
   The GNU C Library is distributed in the hope that it will be useful,
Packit Service 82fcde
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service 82fcde
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit Service 82fcde
   Lesser General Public License for more details.
Packit Service 82fcde
Packit Service 82fcde
   You should have received a copy of the GNU Lesser General Public
Packit Service 82fcde
   License along with the GNU C Library; if not, see
Packit Service 82fcde
   <http://www.gnu.org/licenses/>.  */
Packit Service 82fcde
Packit Service 82fcde
/* This is derived from the C++ ABI for IA-64.  Where we diverge
Packit Service 82fcde
   for cross-architecture compatibility are noted with "@@@".  */
Packit Service 82fcde
Packit Service 82fcde
#ifndef _UNWIND_H
Packit Service 82fcde
#define _UNWIND_H	1
Packit Service 82fcde
Packit Service 82fcde
#ifdef __cplusplus
Packit Service 82fcde
extern "C" {
Packit Service 82fcde
#endif
Packit Service 82fcde
Packit Service 82fcde
/* Level 1: Base ABI  */
Packit Service 82fcde
Packit Service 82fcde
/* @@@ The IA-64 ABI uses uint64 throughout.  Most places this is
Packit Service 82fcde
   inefficient for 32-bit and smaller machines.  */
Packit Service 82fcde
typedef unsigned _Unwind_Word __attribute__((__mode__(__unwind_word__)));
Packit Service 82fcde
typedef signed _Unwind_Sword __attribute__((__mode__(__unwind_word__)));
Packit Service 82fcde
#if defined(__ia64__) && defined(__hpux__)
Packit Service 82fcde
typedef unsigned _Unwind_Ptr __attribute__((__mode__(__word__)));
Packit Service 82fcde
#else
Packit Service 82fcde
typedef unsigned _Unwind_Ptr __attribute__((__mode__(__pointer__)));
Packit Service 82fcde
#endif
Packit Service 82fcde
typedef unsigned _Unwind_Internal_Ptr __attribute__((__mode__(__pointer__)));
Packit Service 82fcde
Packit Service 82fcde
/* @@@ The IA-64 ABI uses a 64-bit word to identify the producer and
Packit Service 82fcde
   consumer of an exception.  We'll go along with this for now even on
Packit Service 82fcde
   32-bit machines.  We'll need to provide some other option for
Packit Service 82fcde
   16-bit machines and for machines with > 8 bits per byte.  */
Packit Service 82fcde
typedef unsigned _Unwind_Exception_Class __attribute__((__mode__(__DI__)));
Packit Service 82fcde
Packit Service 82fcde
/* The unwind interface uses reason codes in several contexts to
Packit Service 82fcde
   identify the reasons for failures or other actions.  */
Packit Service 82fcde
typedef enum
Packit Service 82fcde
{
Packit Service 82fcde
  _URC_NO_REASON = 0,
Packit Service 82fcde
  _URC_FOREIGN_EXCEPTION_CAUGHT = 1,
Packit Service 82fcde
  _URC_FATAL_PHASE2_ERROR = 2,
Packit Service 82fcde
  _URC_FATAL_PHASE1_ERROR = 3,
Packit Service 82fcde
  _URC_NORMAL_STOP = 4,
Packit Service 82fcde
  _URC_END_OF_STACK = 5,
Packit Service 82fcde
  _URC_HANDLER_FOUND = 6,
Packit Service 82fcde
  _URC_INSTALL_CONTEXT = 7,
Packit Service 82fcde
  _URC_CONTINUE_UNWIND = 8
Packit Service 82fcde
} _Unwind_Reason_Code;
Packit Service 82fcde
Packit Service 82fcde
Packit Service 82fcde
/* The unwind interface uses a pointer to an exception header object
Packit Service 82fcde
   as its representation of an exception being thrown. In general, the
Packit Service 82fcde
   full representation of an exception object is language- and
Packit Service 82fcde
   implementation-specific, but it will be prefixed by a header
Packit Service 82fcde
   understood by the unwind interface.  */
Packit Service 82fcde
Packit Service 82fcde
struct _Unwind_Exception;
Packit Service 82fcde
Packit Service 82fcde
typedef void (*_Unwind_Exception_Cleanup_Fn) (_Unwind_Reason_Code,
Packit Service 82fcde
					      struct _Unwind_Exception *);
Packit Service 82fcde
Packit Service 82fcde
struct _Unwind_Exception
Packit Service 82fcde
{
Packit Service 82fcde
  _Unwind_Exception_Class exception_class;
Packit Service 82fcde
  _Unwind_Exception_Cleanup_Fn exception_cleanup;
Packit Service 82fcde
  _Unwind_Word private_1;
Packit Service 82fcde
  _Unwind_Word private_2;
Packit Service 82fcde
Packit Service 82fcde
  /* @@@ The IA-64 ABI says that this structure must be double-word aligned.
Packit Service 82fcde
     Taking that literally does not make much sense generically.  Instead we
Packit Service 82fcde
     provide the maximum alignment required by any type for the machine.  */
Packit Service 82fcde
} __attribute__((__aligned__));
Packit Service 82fcde
Packit Service 82fcde
Packit Service 82fcde
/* The ACTIONS argument to the personality routine is a bitwise OR of one
Packit Service 82fcde
   or more of the following constants.  */
Packit Service 82fcde
typedef int _Unwind_Action;
Packit Service 82fcde
Packit Service 82fcde
#define _UA_SEARCH_PHASE	1
Packit Service 82fcde
#define _UA_CLEANUP_PHASE	2
Packit Service 82fcde
#define _UA_HANDLER_FRAME	4
Packit Service 82fcde
#define _UA_FORCE_UNWIND	8
Packit Service 82fcde
#define _UA_END_OF_STACK	16
Packit Service 82fcde
Packit Service 82fcde
/* This is an opaque type used to refer to a system-specific data
Packit Service 82fcde
   structure used by the system unwinder. This context is created and
Packit Service 82fcde
   destroyed by the system, and passed to the personality routine
Packit Service 82fcde
   during unwinding.  */
Packit Service 82fcde
struct _Unwind_Context;
Packit Service 82fcde
Packit Service 82fcde
/* Raise an exception, passing along the given exception object.  */
Packit Service 82fcde
extern _Unwind_Reason_Code _Unwind_RaiseException (struct _Unwind_Exception *);
Packit Service 82fcde
Packit Service 82fcde
/* Raise an exception for forced unwinding.  */
Packit Service 82fcde
Packit Service 82fcde
typedef _Unwind_Reason_Code (*_Unwind_Stop_Fn)
Packit Service 82fcde
     (int, _Unwind_Action, _Unwind_Exception_Class,
Packit Service 82fcde
      struct _Unwind_Exception *, struct _Unwind_Context *, void *);
Packit Service 82fcde
Packit Service 82fcde
extern _Unwind_Reason_Code _Unwind_ForcedUnwind (struct _Unwind_Exception *,
Packit Service 82fcde
						 _Unwind_Stop_Fn,
Packit Service 82fcde
						 void *);
Packit Service 82fcde
Packit Service 82fcde
/* Helper to invoke the exception_cleanup routine.  */
Packit Service 82fcde
extern void _Unwind_DeleteException (struct _Unwind_Exception *);
Packit Service 82fcde
Packit Service 82fcde
/* Resume propagation of an existing exception.  This is used after
Packit Service 82fcde
   e.g. executing cleanup code, and not to implement rethrowing.  */
Packit Service 82fcde
extern void _Unwind_Resume (struct _Unwind_Exception *);
Packit Service 82fcde
Packit Service 82fcde
/* @@@ Use unwind data to perform a stack backtrace.  The trace callback
Packit Service 82fcde
   is called for every stack frame in the call chain, but no cleanup
Packit Service 82fcde
   actions are performed.  */
Packit Service 82fcde
typedef _Unwind_Reason_Code (*_Unwind_Trace_Fn)
Packit Service 82fcde
     (struct _Unwind_Context *, void *);
Packit Service 82fcde
Packit Service 82fcde
extern _Unwind_Reason_Code _Unwind_Backtrace (_Unwind_Trace_Fn, void *);
Packit Service 82fcde
Packit Service 82fcde
/* These functions are used for communicating information about the unwind
Packit Service 82fcde
   context (i.e. the unwind descriptors and the user register state) between
Packit Service 82fcde
   the unwind library and the personality routine and landing pad.  Only
Packit Service 82fcde
   selected registers maybe manipulated.  */
Packit Service 82fcde
Packit Service 82fcde
extern _Unwind_Word _Unwind_GetGR (struct _Unwind_Context *, int);
Packit Service 82fcde
extern void _Unwind_SetGR (struct _Unwind_Context *, int, _Unwind_Word);
Packit Service 82fcde
Packit Service 82fcde
extern _Unwind_Ptr _Unwind_GetIP (struct _Unwind_Context *);
Packit Service 82fcde
extern void _Unwind_SetIP (struct _Unwind_Context *, _Unwind_Ptr);
Packit Service 82fcde
Packit Service 82fcde
/* @@@ Retrieve the CFA of the given context.  */
Packit Service 82fcde
extern _Unwind_Word _Unwind_GetCFA (struct _Unwind_Context *);
Packit Service 82fcde
Packit Service 82fcde
extern void *_Unwind_GetLanguageSpecificData (struct _Unwind_Context *);
Packit Service 82fcde
Packit Service 82fcde
extern _Unwind_Ptr _Unwind_GetRegionStart (struct _Unwind_Context *);
Packit Service 82fcde
Packit Service 82fcde
Packit Service 82fcde
/* The personality routine is the function in the C++ (or other language)
Packit Service 82fcde
   runtime library which serves as an interface between the system unwind
Packit Service 82fcde
   library and language-specific exception handling semantics.  It is
Packit Service 82fcde
   specific to the code fragment described by an unwind info block, and
Packit Service 82fcde
   it is always referenced via the pointer in the unwind info block, and
Packit Service 82fcde
   hence it has no ABI-specified name.
Packit Service 82fcde
Packit Service 82fcde
   Note that this implies that two different C++ implementations can
Packit Service 82fcde
   use different names, and have different contents in the language
Packit Service 82fcde
   specific data area.  Moreover, that the language specific data
Packit Service 82fcde
   area contains no version info because name of the function invoked
Packit Service 82fcde
   provides more effective versioning by detecting at link time the
Packit Service 82fcde
   lack of code to handle the different data format.  */
Packit Service 82fcde
Packit Service 82fcde
typedef _Unwind_Reason_Code (*_Unwind_Personality_Fn)
Packit Service 82fcde
     (int, _Unwind_Action, _Unwind_Exception_Class,
Packit Service 82fcde
      struct _Unwind_Exception *, struct _Unwind_Context *);
Packit Service 82fcde
Packit Service 82fcde
/* @@@ The following alternate entry points are for setjmp/longjmp
Packit Service 82fcde
   based unwinding.  */
Packit Service 82fcde
Packit Service 82fcde
struct SjLj_Function_Context;
Packit Service 82fcde
extern void _Unwind_SjLj_Register (struct SjLj_Function_Context *);
Packit Service 82fcde
extern void _Unwind_SjLj_Unregister (struct SjLj_Function_Context *);
Packit Service 82fcde
Packit Service 82fcde
extern _Unwind_Reason_Code _Unwind_SjLj_RaiseException
Packit Service 82fcde
     (struct _Unwind_Exception *);
Packit Service 82fcde
extern _Unwind_Reason_Code _Unwind_SjLj_ForcedUnwind
Packit Service 82fcde
     (struct _Unwind_Exception *, _Unwind_Stop_Fn, void *);
Packit Service 82fcde
extern void _Unwind_SjLj_Resume (struct _Unwind_Exception *);
Packit Service 82fcde
Packit Service 82fcde
/* @@@ The following provide access to the base addresses for text
Packit Service 82fcde
   and data-relative addressing in the LDSA.  In order to stay link
Packit Service 82fcde
   compatible with the standard ABI for IA-64, we inline these.  */
Packit Service 82fcde
Packit Service 82fcde
#ifdef __ia64__
Packit Service 82fcde
#include <stdlib.h>
Packit Service 82fcde
Packit Service 82fcde
static inline _Unwind_Ptr
Packit Service 82fcde
_Unwind_GetDataRelBase (struct _Unwind_Context *_C)
Packit Service 82fcde
{
Packit Service 82fcde
  /* The GP is stored in R1.  */
Packit Service 82fcde
  return _Unwind_GetGR (_C, 1);
Packit Service 82fcde
}
Packit Service 82fcde
Packit Service 82fcde
static inline _Unwind_Ptr
Packit Service 82fcde
_Unwind_GetTextRelBase (struct _Unwind_Context *_C)
Packit Service 82fcde
{
Packit Service 82fcde
  abort ();
Packit Service 82fcde
  return 0;
Packit Service 82fcde
}
Packit Service 82fcde
Packit Service 82fcde
/* @@@ Retrieve the Backing Store Pointer of the given context.  */
Packit Service 82fcde
extern _Unwind_Word _Unwind_GetBSP (struct _Unwind_Context *);
Packit Service 82fcde
#else
Packit Service 82fcde
extern _Unwind_Ptr _Unwind_GetDataRelBase (struct _Unwind_Context *);
Packit Service 82fcde
extern _Unwind_Ptr _Unwind_GetTextRelBase (struct _Unwind_Context *);
Packit Service 82fcde
#endif
Packit Service 82fcde
Packit Service 82fcde
/* @@@ Given an address, return the entry point of the function that
Packit Service 82fcde
   contains it.  */
Packit Service 82fcde
extern void * _Unwind_FindEnclosingFunction (void *pc);
Packit Service 82fcde
Packit Service 82fcde
#ifdef __cplusplus
Packit Service 82fcde
}
Packit Service 82fcde
#endif
Packit Service 82fcde
Packit Service 82fcde
#endif	/* unwind.h */