mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-12 22:17:26 +01:00
7 lines
9.5 KiB
Go
7 lines
9.5 KiB
Go
// Code generated by file2byteslice. DO NOT EDIT.
|
|
// (gofmt is fine after generating)
|
|
|
|
package main
|
|
|
|
var coffeecatch_h_go = []byte("// Code generated by file2byteslice. DO NOT EDIT.\n// (gofmt is fine after generating)\n\n// +build ebitenmobilegobind\n\npackage main\n\nvar coffeecatch_h = []byte(\"/* CoffeeCatch, a tiny native signal handler/catcher for JNI code.\\n * (especially for Android/Dalvik)\\n *\\n * Copyright (c) 2013, Xavier Roche (http://www.httrack.com/)\\n * All rights reserved.\\n * See the \\\"License\\\" section below for the licensing terms.\\n *\\n * Description:\\n *\\n * Allows to \\\"gracefully\\\" recover from a signal (segv, sibus...) as if it was\\n * a Java exception. It will not gracefully recover from allocator/mutexes\\n * corruption etc., however, but at least \\\"most\\\" gentle crashes (null pointer\\n * dereferencing, integer division, stack overflow etc.) should be handled\\n * without too much troubles.\\n *\\n * The handler is thread-safe, but client must have exclusive control on the\\n * signal handlers (ie. the library is installing its own signal handlers on\\n * top of the existing ones).\\n *\\n * You must build all your libraries with `-funwind-tables', to get proper\\n * unwinding information on all binaries. On ARM, you may also use the\\n * `--no-merge-exidx-entries` linker switch, to solve certain issues with\\n * unwinding (the switch is possibly not needed anymore).\\n * On Android, this can be achieved by using this line in the Android.mk file\\n * in each library block:\\n * LOCAL_CFLAGS := -funwind-tables -Wl,--no-merge-exidx-entries\\n *\\n * Example:\\n *\\n * COFFEE_TRY() {\\n * call_some_native_function()\\n * } COFFEE_CATCH() {\\n * const char*const message = coffeecatch_get_message();\\n * jclass cls = (*env)->FindClass(env, \\\"java/lang/RuntimeException\\\");\\n * (*env)->ThrowNew(env, cls, strdup(message));\\n * } COFFEE_END();\\n *\\n * Implementation notes:\\n *\\n * Currently the library is installing both alternate stack and signal\\n * handlers for known signals (SIGABRT, SIGILL, SIGTRAP, SIGBUS, SIGFPE,\\n * SIGSEGV, SIGSTKFLT), and is using sigsetjmp()/siglongjmp() to return to\\n * \\\"userland\\\" (compared to signal handler context). As a security, an alarm\\n * is started as soon as a fatal signal is detected (ie. not something the\\n * JVM will handle) to kill the process after a grace period. Be sure your\\n * program will exit quickly after the error is caught, or call alarm(0)\\n * to cancel the pending time-bomb.\\n * The signal handlers had to be written with caution, because the virtual\\n * machine might be using signals (including SEGV) to handle JIT compiler,\\n * and some clever optimizations (such as NullPointerException handling)\\n * We are using several signal-unsafe functions, namely:\\n * - siglongjmp() to return to userland\\n * - pthread_getspecific() to get thread-specific setup\\n *\\n * License:\\n *\\n * Copyright (c) 2013, Xavier Roche (http://www.httrack.com/)\\n * All rights reserved.\\n *\\n * Redistribution and use in source and binary forms, with or without\\n * modification, are permitted provided that the following conditions are met:\\n *\\n * 1. Redistributions of source code must retain the above copyright notice, this\\n * list of conditions and the following disclaimer.\\n * 2. Redistributions in binary form must reproduce the above copyright notice,\\n * this list of conditions and the following disclaimer in the documentation\\n * and/or other materials provided with the distribution.\\n *\\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \\\"AS IS\\\" AND\\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\\n * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\\n * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR\\n * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\\n * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\\n * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\\n * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\\n * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\\n */\\n\\n#ifndef COFFEECATCH_H\\n#define COFFEECATCH_H\\n\\n#include <stdint.h>\\n#include <sys/types.h>\\n\\n#ifdef __cplusplus\\nextern \\\"C\\\" {\\n#endif\\n\\n/**\\n * Setup crash handler to enter in a protected section. If a recognized signal\\n * is received in this section, the execution will be diverted to the\\n * COFFEE_CATCH() block.\\n *\\n * Note: you MUST use the following pattern when using this macro:\\n * COFFEE_TRY() {\\n * .. protected section without exit point\\n * } COFFEE_CATCH() {\\n * .. handler section without exit point\\n * } COFFEE_END();\\n *\\n * You can not exit the protected section block, or the handler section block,\\n * using statements such as \\\"return\\\", because the cleanup code would not be\\n * executed.\\n *\\n * It is advised to enclose this complete try/catch/end block in a dedicated\\n * function declared extern or __attribute__ ((noinline)).\\n *\\n * Example:\\n *\\n * void my_native_function(JNIEnv* env, jobject object, jint *retcode) {\\n * COFFEE_TRY() {\\n * *retcode = call_dangerous_function(env, object);\\n * } COFFEE_CATCH() {\\n * const char*const message = coffeecatch_get_message();\\n * jclass cls = (*env)->FindClass(env, \\\"java/lang/RuntimeException\\\");\\n * (*env)->ThrowNew(env, cls, strdup(message));\\n * *retcode = -1;\\n * } COFFEE_END();\\n * }\\n *\\n * In addition, the following restrictions MUST be followed:\\n * - the function must be declared extern, or with the special attribute\\n * __attribute__ ((noinline)).\\n * - you must not use local variables before the complete try/catch/end block,\\n * or define them as \\\"volatile\\\".\\n * - your function should not ignore the crash silently, as the library will\\n * ensure the process is killed after a grace period (typically 30s) to\\n * prevent any deadlock that may occur if the crash was caught inside a\\n * non-signal-safe function, for example (such as malloc()).\\n *\\nCOFFEE_TRY()\\n **/\\n\\n/**\\n * Declare the signal handler block. This block will be executed if a signal\\n * was received, and recognized, in the previous COFFEE_TRY() {} section.\\n * You may call audit functions in this block, such as coffeecatch_get_signal()\\n * or coffeecatch_get_message().\\n *\\nCOFFEE_CATCH()\\n **/\\n\\n/**\\n * Declare the end of the COFFEE_TRY()/COFFEE_CATCH() section.\\n * Diagnostic functions must not be called beyond this point.\\n *\\nCOFFEE_END()\\n **/\\n\\n/**\\n * Get the signal associated with the crash.\\n * This function can only be called inside a COFFEE_CATCH() block.\\n */\\nextern int coffeecatch_get_signal(void);\\n\\n/**\\n * Get the full error message associated with the crash.\\n * This function can only be called inside a COFFEE_CATCH() block, and the\\n * returned pointer is only valid within this block. (you may want to copy\\n * the string in a static buffer, or use strdup())\\n */\\nconst char* coffeecatch_get_message(void);\\n\\n/**\\n * Raise an abort() signal in the current thread. If the current code section\\n * is protected, the 'exp', 'file' and 'line' information are stored for\\n * further audit.\\n */\\nextern void coffeecatch_abort(const char* exp, const char* file, int line);\\n\\n/**\\n * Assertion check. If the expression is false, an abort() signal is raised\\n * using coffeecatch_abort().\\n */\\n#define coffeecatch_assert(EXP) (void)( (EXP) || (coffeecatch_abort(#EXP, __FILE__, __LINE__), 0) )\\n\\n/**\\n * Get the backtrace size, or 0 upon error.\\n * This function can only be called inside a COFFEE_CATCH() block.\\n */\\nextern size_t coffeecatch_get_backtrace_size(void);\\n\\n/**\\n * Get the backtrace pointer, or 0 upon error.\\n * This function can only be called inside a COFFEE_CATCH() block.\\n */\\nextern uintptr_t coffeecatch_get_backtrace(ssize_t index);\\n\\n/**\\n * Enumerate the backtrace with information.\\n * This function can only be called inside a COFFEE_CATCH() block.\\n */\\nextern void coffeecatch_get_backtrace_info(void (*fun)(void *arg,\\n const char *module,\\n uintptr_t addr,\\n const char *function,\\n uintptr_t offset), void *arg);\\n\\n/**\\n * Cancel any pending alarm() triggered after a signal was caught.\\n * Calling this function is dangerous, because it exposes the process to\\n * a possible deadlock if the signal was caught due to internal low-level\\n * library error (mutex being in a locked state, for example).\\n */\\nextern int coffeecatch_cancel_pending_alarm(void);\\n\\n/** Internal functions & definitions, not to be used directly. **/\\n#include <setjmp.h>\\nextern int coffeecatch_inside(void);\\nextern int coffeecatch_setup(void);\\nextern sigjmp_buf* coffeecatch_get_ctx(void);\\nextern void coffeecatch_cleanup(void);\\n#define COFFEE_TRY() \\\\\\n if (coffeecatch_inside() || \\\\\\n (coffeecatch_setup() == 0 \\\\\\n && sigsetjmp(*coffeecatch_get_ctx(), 1) == 0))\\n#define COFFEE_CATCH() else\\n#define COFFEE_END() coffeecatch_cleanup()\\n/** End of internal functions & definitions. **/\\n\\n#ifdef __cplusplus\\n}\\n#endif\\n\\n#endif\\n\\n\")\n")
|