source: libcfa/src/exception.h @ 979df46

arm-ehjacob/cs343-translationnew-astnew-ast-unique-expr
Last change on this file since 979df46 was 979df46, checked in by Andrew Beach <ajbeach@…>, 21 months ago

Initial cancellation interface, required for default operation.

  • Property mode set to 100644
File size: 2.2 KB
Line 
1//
2// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
3//
4// The contents of this file are covered under the licence agreement in the
5// file "LICENCE" distributed with Cforall.
6//
7// exception.h -- Builtins for exception handling.
8//
9// Author           : Andrew Beach
10// Created On       : Mon Jun 26 15:11:00 2017
11// Last Modified By : Andrew Beach
12// Last Modified On : Fri Mar 27 10:16:00 2020
13// Update Count     : 9
14//
15
16#pragma once
17
18
19#ifdef __cforall
20extern "C" {
21#endif
22
23struct __cfaehm_base_exception_t;
24typedef struct __cfaehm_base_exception_t exception_t;
25struct __cfaehm_base_exception_t_vtable {
26        const struct __cfaehm_base_exception_t_vtable * parent;
27        size_t size;
28        void (*copy)(struct __cfaehm_base_exception_t *this,
29                     struct __cfaehm_base_exception_t * other);
30        void (*free)(struct __cfaehm_base_exception_t *this);
31        const char * (*msg)(struct __cfaehm_base_exception_t *this);
32};
33struct __cfaehm_base_exception_t {
34        struct __cfaehm_base_exception_t_vtable const * virtual_table;
35};
36extern struct __cfaehm_base_exception_t_vtable
37        ___cfaehm_base_exception_t_vtable_instance;
38
39
40void __cfaehm_cancel_stack(exception_t * except) __attribute__((noreturn));
41
42// Used in throw statement translation.
43void __cfaehm_throw_terminate(exception_t * except) __attribute__((noreturn));
44void __cfaehm_rethrow_terminate() __attribute__((noreturn));
45void __cfaehm_throw_resume(exception_t * except);
46
47// Function catches termination exceptions.
48void __cfaehm_try_terminate(
49    void (*try_block)(),
50    void (*catch_block)(int index, exception_t * except),
51    int (*match_block)(exception_t * except));
52
53// Clean-up the exception in catch blocks.
54void __cfaehm_cleanup_terminate(void * except);
55
56// Data structure creates a list of resume handlers.
57struct __cfaehm_try_resume_node {
58    struct __cfaehm_try_resume_node * next;
59    _Bool (*handler)(exception_t * except);
60};
61
62// These act as constructor and destructor for the resume node.
63void __cfaehm_try_resume_setup(
64    struct __cfaehm_try_resume_node * node,
65    _Bool (*handler)(exception_t * except));
66void __cfaehm_try_resume_cleanup(
67    struct __cfaehm_try_resume_node * node);
68
69// Check for a standard way to call fake deconstructors.
70struct __cfaehm_cleanup_hook {};
71
72#ifdef __cforall
73}
74#endif
Note: See TracBrowser for help on using the repository browser.