1 //===- SJLJ-Exception.h - SetJmp/LongJmp Exception Handling -----*- C++ -*-===//
3 // This file defines the data structures and API used by the Setjmp/Longjmp
4 // exception handling runtime library.
6 //===----------------------------------------------------------------------===//
8 #ifndef SJLJ_EXCEPTION_H
9 #define SJLJ_EXCEPTION_H
11 #include "Exception.h"
13 struct llvm_sjlj_exception {
14 // JmpBuffer - This is the buffer which was longjmp'd with.
18 // LongJmpValue - The value passed into longjmp, which the corresponding
19 // setjmp should return. Note that this value will never be equal to 0.
23 // BaseException - The language independent portion of the exception state.
24 // This is at the end of the record so that we can add additional members to
25 // this structure without breaking binary compatibility.
27 llvm_exception BaseException;
31 // __llvm_sjljeh_throw_longjmp - This function creates the longjmp exception
32 // and returns. It takes care of mapping the longjmp value from 0 -> 1 as
33 // appropriate. The caller should immediately call llvm.unwind after this
35 void __llvm_sjljeh_throw_longjmp(void *JmpBuffer, int Val) throw();
37 // __llvm_sjljeh_init_setjmpmap - This funciton initializes the pointer
38 // provided to an empty setjmp map, and should be called on entry to a
39 // function which calls setjmp.
40 void __llvm_sjljeh_init_setjmpmap(void **SetJmpMap) throw();
42 // __llvm_sjljeh_destroy_setjmpmap - This function frees all memory associated
43 // with the specified setjmpmap structure. It should be called on all exits
44 // (returns or unwinds) from the function which calls ...init_setjmpmap.
45 void __llvm_sjljeh_destroy_setjmpmap(void **SetJmpMap) throw();
47 // __llvm_sjljeh_add_setjmp_to_map - This function adds or updates an entry to
48 // the map, to indicate which setjmp should be returned to if a longjmp
50 void __llvm_sjljeh_add_setjmp_to_map(void **SetJmpMap, void *JmpBuf,
51 unsigned SetJmpID) throw();
53 // __llvm_sjljeh_is_longjmp_exception - This function returns true if the
54 // current uncaught exception is a longjmp exception. This is the first step
55 // of catching a sjlj exception.
56 bool __llvm_sjljeh_is_longjmp_exception() throw();
58 // __llvm_sjljeh_get_longjmp_value - This function returns the value that the
59 // setjmp call should "return". This requires that the current uncaught
60 // exception be a sjlj exception, though it does not require the exception to
61 // be caught by this function.
62 int __llvm_sjljeh_get_longjmp_value() throw();
64 // __llvm_sjljeh_try_catching_longjmp_exception - This function checks to see
65 // if the current uncaught longjmp exception matches any of the setjmps
66 // collected in the setjmpmap structure. If so, it catches and destroys the
67 // exception, returning the index of the setjmp which caught the exception.
68 // If not, it leaves the exception uncaught and returns a value of ~0.
69 unsigned __llvm_sjljeh_try_catching_longjmp_exception(void **SetJmpMap)