80 lines
2.3 KiB
C
80 lines
2.3 KiB
C
/*
|
|
* JoeyDev
|
|
* Copyright (C) 2018-2023 Scott Duensing <scott@kangaroopunch.com>
|
|
*
|
|
* This software is provided 'as-is', without any express or implied
|
|
* warranty. In no event will the authors be held liable for any damages
|
|
* arising from the use of this software.
|
|
*
|
|
* Permission is granted to anyone to use this software for any purpose,
|
|
* including commercial applications, and to alter it and redistribute it
|
|
* freely, subject to the following restrictions:
|
|
*
|
|
* 1. The origin of this software must not be misrepresented; you must not
|
|
* claim that you wrote the original software. If you use this software
|
|
* in a product, an acknowledgment in the product documentation would be
|
|
* appreciated but is not required.
|
|
* 2. Altered source versions must be plainly marked as such, and must not be
|
|
* misrepresented as being the original software.
|
|
* 3. This notice may not be removed or altered from any source distribution.
|
|
*/
|
|
|
|
|
|
#ifndef COMPILER_H
|
|
#define COMPILER_H
|
|
|
|
|
|
#include "libtcc.h"
|
|
#include "sigsegv.h"
|
|
|
|
#if HAVE_SIGSEGV_RECOVERY
|
|
#include <setjmp.h>
|
|
#include <signal.h>
|
|
#if defined _WIN32 && !defined __CYGWIN__
|
|
// Windows doesn't have sigset_t.
|
|
typedef int sigset_t;
|
|
#define sigemptyset(set)
|
|
#define sigprocmask(how,set,oldset)
|
|
#endif
|
|
#endif
|
|
|
|
|
|
enum CompilerErrorsE {
|
|
COMPILER_ERROR_NONE = 0,
|
|
COMPILER_ERROR_ALREADY_RUNNING,
|
|
COMPILER_ERROR_IN_CODE,
|
|
COMPILER_ERROR_CANNOT_RELOCATE,
|
|
COMPILER_ERROR_NO_ENTRYPOINT,
|
|
COMPILER_ERROR_SIGHANDLER_FAILED,
|
|
COMPILER_ERROR_SEGFAULT,
|
|
COMPILER_ERROR_COUNT
|
|
};
|
|
|
|
|
|
struct CompilerContextS;
|
|
|
|
|
|
typedef void (*CompilerCallback)(struct CompilerContextS **context);
|
|
|
|
|
|
typedef struct CompilerContextS {
|
|
TCCState *s;
|
|
int compilerResult;
|
|
int programResult;
|
|
CompilerCallback callback;
|
|
void *userData;
|
|
#if HAVE_SIGSEGV_RECOVERY
|
|
volatile int runPass;
|
|
jmp_buf runJump;
|
|
sigset_t runSigSet;
|
|
#endif
|
|
} CompilerContextT;
|
|
|
|
|
|
void compilerDeleteContext(CompilerContextT **context);
|
|
gboolean compilerHadError(CompilerContextT **context);
|
|
CompilerContextT *compilerNewContext(CompilerCallback callback, void *userData);
|
|
void compilerRunRecipe(CompilerContextT *context, char *recipe, char *input, char *outputPath);
|
|
|
|
|
|
#endif // COMPILER_H
|