Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add fix for emscripten on exit
  • Loading branch information
ddevault committed Nov 16, 2014
1 parent 8d6175b commit d2044e7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
12 changes: 7 additions & 5 deletions CMakeLists.txt
Expand Up @@ -5,16 +5,18 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "bin/")
add_definitions("-Wall")
set(CMAKE_BUILD_TYPE Debug)

if(EMSCRIPTEN)
set(CMAKE_EXE_LINKER_FLAGS "-O2")
set(CMAKE_C_FLAGS "-O2")
endif()

if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(INSTRUCTION_SET_PATH "${PROJECT_SOURCE_DIR}/tables/" CACHE PATH "Location to install instruction set tables.")
else()
set(INSTRUCTION_SET_PATH "/usr/share/scas/instruction_sets/" CACHE PATH "Location to install instruction set tables.")
endif()

if(EMSCRIPTEN)
set(CMAKE_EXE_LINKER_FLAGS "-O2")
set(CMAKE_C_FLAGS "-O2")
set(INSTRUCTION_SET_PATH "/" CACHE PATH "Location to install instruction set tables.")
endif()

add_definitions(-DINSTRUCTION_SET_PATH="${INSTRUCTION_SET_PATH}/")

include_directories(
Expand Down
9 changes: 9 additions & 0 deletions common/log.c
Expand Up @@ -2,6 +2,9 @@
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#ifdef EMSCRIPTEN
#include <emscripten.h>
#endif

int v = 0;
int indent = 0;
Expand Down Expand Up @@ -34,7 +37,13 @@ void scas_abort(char *format, ...) {
vfprintf(stderr, format, args);
va_end(args);
fprintf(stderr, "\n");
#ifdef EMSCRIPTEN
EM_ASM(
throw 'aborting';
);
#else
exit(1);
#endif
}

void scas_log(int verbosity, char* format, ...) {
Expand Down

0 comments on commit d2044e7

Please sign in to comment.