9#include <plugin-version.h>
12#include <c-family/c-pragma.h>
13#include <c-family/c-common.h>
17#include <unordered_map>
20#define is_alpha(c) (((c)>64 && (c)<91) || ((c)>96 && (c)<123))
22#if defined(_WIN32) || defined(WIN32)
23#define VISIBLE __declspec(dllexport)
25#define VISIBLE __attribute__((__visibility__("default")))
28#define UNUSED __attribute__((__unused__))
51 asm_header = build_stmt(fun->function_start_locus, ASM_EXPR,
asm_header_text, NULL_TREE, NULL_TREE, NULL_TREE, NULL_TREE);
57static std::unordered_map<struct function*, struct seh_function*>
func_seh_map = {};
78 std::stringstream label_decl;
82 error(
"%<#pragma REACTOS seh%> is not allowed outside functions");
86 if ((pragma_lex(&
x) != CPP_OPEN_PAREN) ||
87 (pragma_lex(&
arg) != CPP_NAME) ||
88 (pragma_lex(&
x) != CPP_CLOSE_PAREN) ||
89 (pragma_lex(&
x) != CPP_EOF))
91 error(
"%<#pragma REACTOS seh%> needs one parameter%>");
95 const char*
op = IDENTIFIER_POINTER(
arg);
100 else if (
strcmp(
op,
"finally") == 0)
104 error(
"Wrong argument for %<#pragma REACTOS seh%>. Expected \"except\" or \"finally\"");
110 cfun->machine->accesses_prev_frame = 1;
118 struct function* fun = DECL_STRUCT_FUNCTION(fndef);
128 if (DECL_FUNCTION_PERSONALITY(fndef) !=
nullptr)
130 error(
"Function %s has a personality. Are you mixing SEH with C++ exceptions ?",
131 IDENTIFIER_POINTER(fndef));
136 std::stringstream asm_str;
137 asm_str <<
".seh_handler __C_specific_handler";
139 asm_str <<
", @unwind";
141 asm_str <<
", @except";
143 asm_str <<
"\t.seh_handlerdata\n";
144 asm_str <<
"\t.long " << seh_fun->
count <<
"\n";
145 asm_str <<
"\t.seh_code";
148 asm_str.str().c_str(),
165 struct plugin_gcc_version *
version)
167 if (!plugin_default_version_check (
version, &gcc_version))
169 std::cerr <<
"This GCC plugin is for version " << GCCPLUGIN_VERSION_MAJOR <<
"." << GCCPLUGIN_VERSION_MINOR <<
"\n";
int strcmp(const char *String1, const char *String2)
char * strncpy(char *DstString, const char *SrcString, ACPI_SIZE Count)
static const WCHAR version[]
GLint GLint GLint GLint GLint x
GLuint GLuint GLsizei count
GLenum GLuint GLenum GLsizei const GLchar * buf
static short search(int val, const short *table, int size)
static void handle_seh_pragma(cpp_reader *UNUSED parser)
static struct seh_function * get_seh_function()
static void register_seh_pragmas(void *UNUSED event_data, void *UNUSED user_data)
int VISIBLE plugin_is_GPL_compatible
static std::unordered_map< struct function *, struct seh_function * > func_seh_map
static void finish_seh_function(void *event_data, void *UNUSED user_data)
VISIBLE int plugin_init(struct plugin_name_args *info, struct plugin_gcc_version *version)
seh_function(struct function *fun)