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"
14 struct llvm_sjlj_exception {
15 // JmpBuffer - This is the buffer which was longjmp'd with.
19 // LongJmpValue - The value passed into longjmp, which the corresponding
20 // setjmp should return. Note that this value will never be equal to 0.
24 // BaseException - The language independent portion of the exception state.
25 // This is at the end of the record so that we can add additional members to
26 // this structure without breaking binary compatibility.
28 llvm_exception BaseException;
32 // __llvm_sjljeh_throw_longjmp - This function creates the longjmp exception
33 // and returns. It takes care of mapping the longjmp value from 0 -> 1 as
34 // appropriate. The caller should immediately call llvm.unwind after this
36 void __llvm_sjljeh_throw_longjmp(void *JmpBuffer, int Val) throw();
38 // __llvm_sjljeh_init_setjmpmap - This funciton initializes the pointer
39 // provided to an empty setjmp map, and should be called on entry to a
40 // function which calls setjmp.
41 void __llvm_sjljeh_init_setjmpmap(void **SetJmpMap) throw();
43 // __llvm_sjljeh_destroy_setjmpmap - This function frees all memory associated
44 // with the specified setjmpmap structure. It should be called on all exits
45 // (returns or unwinds) from the function which calls ...init_setjmpmap.
46 void __llvm_sjljeh_destroy_setjmpmap(void **SetJmpMap) throw();
48 // __llvm_sjljeh_add_setjmp_to_map - This function adds or updates an entry to
49 // the map, to indicate which setjmp should be returned to if a longjmp
51 void __llvm_sjljeh_add_setjmp_to_map(void **SetJmpMap, void *JmpBuf,
52 unsigned SetJmpID) throw();
54 // __llvm_sjljeh_is_longjmp_exception - This function returns true if the
55 // current uncaught exception is a longjmp exception. This is the first step
56 // of catching a sjlj exception.
57 bool __llvm_sjljeh_is_longjmp_exception() throw();
59 // __llvm_sjljeh_get_longjmp_value - This function returns the value that the
60 // setjmp call should "return". This requires that the current uncaught
61 // exception be a sjlj exception, though it does not require the exception to
62 // be caught by this function.
63 int __llvm_sjljeh_get_longjmp_value() throw();
65 // __llvm_sjljeh_try_catching_longjmp_exception - This function checks to see
66 // if the current uncaught longjmp exception matches any of the setjmps
67 // collected in the setjmpmap structure. If so, it catches and destroys the
68 // exception, returning the index of the setjmp which caught the exception.
69 // If not, it leaves the exception uncaught and returns a value of ~0.
70 unsigned __llvm_sjljeh_try_catching_longjmp_exception(void **SetJmpMap)