aboutsummaryrefslogtreecommitdiff
path: root/CRT/except.h
blob: 7f39eac7a5f77023e7e0c61fe6958a332dcf85c2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#ifndef EXCEPT_H
#define EXCEPT_H 1

#ifndef __SEH__
#error "SEH not supported by your toolchain!"
#endif

#ifdef __try1
#undef __try1
#endif

#ifdef __except1
#undef __except1
#endif

#define __dpptry(handler, counter)                                                                                     \
    __asm__ goto(                                                                                                      \
        ".seh_handler __C_specific_handler, @except\n\t"                                                               \
        ".seh_handlerdata\n\t"                                                                                         \
        ".long 1\n\t"                                                                                                  \
        ".rva .l_startw" #counter ", .l_endw" #counter ", " #handler ", .l_exceptw" #counter                           \
        "\n\t"                                                                                                         \
        ".section .text\n"                                                                                             \
        ".l_startw" #counter ":" :: ::except);

#define __dppexcept(counter)                                                                                           \
    goto end;                                                                                                          \
    except:                                                                                                            \
    __asm__(".l_exceptw" #counter ":");

#define __dpptryend(counter)                                                                                           \
    end:                                                                                                               \
    __asm__(".l_endw" #counter ":");

#endif