This method call compile_header_strucs method that has to be refined
# Compile C headers
# This method call compile_header_strucs method that has to be refined
fun compile_header do
self.header.add_decl("#include <stdlib.h>")
self.header.add_decl("#include <stdio.h>")
self.header.add_decl("#include <string.h>")
# longjmp !
self.header.add_decl("#include <setjmp.h>\n")
self.header.add_decl("#include <sys/types.h>\n")
self.header.add_decl("#include <unistd.h>\n")
self.header.add_decl("#include <stdint.h>\n")
self.header.add_decl("#ifdef __linux__")
self.header.add_decl(" #include <endian.h>")
self.header.add_decl("#endif")
self.header.add_decl("#include <inttypes.h>\n")
self.header.add_decl("#include \"gc_chooser.h\"")
if modelbuilder.toolcontext.opt_trace.value then self.header.add_decl("#include \"traces.h\"")
self.header.add_decl("#ifdef __APPLE__")
self.header.add_decl(" #include <TargetConditionals.h>")
self.header.add_decl(" #include <syslog.h>")
self.header.add_decl(" #include <libkern/OSByteOrder.h>")
self.header.add_decl(" #define be32toh(x) OSSwapBigToHostInt32(x)")
self.header.add_decl("#endif")
self.header.add_decl("#ifdef _WIN32")
self.header.add_decl(" #define be32toh(val) _byteswap_ulong(val)")
self.header.add_decl("#endif")
self.header.add_decl("#ifdef ANDROID")
self.header.add_decl(" #ifndef be32toh")
self.header.add_decl(" #define be32toh(val) betoh32(val)")
self.header.add_decl(" #endif")
self.header.add_decl(" #include <android/log.h>")
self.header.add_decl(" #define PRINT_ERROR(...) (void)__android_log_print(ANDROID_LOG_WARN, \"Nit\", __VA_ARGS__)")
self.header.add_decl("#elif TARGET_OS_IPHONE")
self.header.add_decl(" #define PRINT_ERROR(...) syslog(LOG_ERR, __VA_ARGS__)")
self.header.add_decl("#else")
self.header.add_decl(" #define PRINT_ERROR(...) fprintf(stderr, __VA_ARGS__)")
self.header.add_decl("#endif")
compile_header_structs
compile_nitni_structs
compile_catch_stack
var gccd_disable = modelbuilder.toolcontext.opt_no_gcc_directive.value
if gccd_disable.has("noreturn") or gccd_disable.has("all") then
# Signal handler function prototype
self.header.add_decl("void fatal_exit(int);")
else
self.header.add_decl("void fatal_exit(int) __attribute__ ((noreturn));")
end
if gccd_disable.has("likely") or gccd_disable.has("all") then
self.header.add_decl("#define likely(x) (x)")
self.header.add_decl("#define unlikely(x) (x)")
else if gccd_disable.has("correct-likely") then
# invert the `likely` definition
# Used by masochists to bench the worst case
self.header.add_decl("#define likely(x) __builtin_expect((x),0)")
self.header.add_decl("#define unlikely(x) __builtin_expect((x),1)")
else
self.header.add_decl("#define likely(x) __builtin_expect((x),1)")
self.header.add_decl("#define unlikely(x) __builtin_expect((x),0)")
end
# Global variable used by intern methods
self.header.add_decl("extern int glob_argc;")
self.header.add_decl("extern char **glob_argv;")
self.header.add_decl("extern val *glob_sys;")
end
src/compiler/abstract_compiler.nit:739,2--806,4