/* * TCC - Tiny C Compiler * * Copyright (c) 2001-2004 Fabrice Bellard * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "tcc.h" /********************************************************/ /* global variables */ /* use GNU C extensions */ ST_DATA int gnu_ext = 1; /* use TinyCC extensions */ ST_DATA int tcc_ext = 1; /* XXX: get rid of this ASAP */ ST_DATA struct TCCState *tcc_state; static int nb_states; /********************************************************/ #if ONE_SOURCE #include "tccpp.c" #include "tccgen.c" #include "tccelf.c" #include "tccrun.c" #ifdef TCC_TARGET_I386 #include "i386-gen.c" #include "i386-link.c" #include "i386-asm.c" #endif #ifdef TCC_TARGET_ARM #include "arm-gen.c" #include "arm-link.c" #include "arm-asm.c" #endif #ifdef TCC_TARGET_ARM64 #include "arm64-gen.c" #include "arm64-link.c" #endif #ifdef TCC_TARGET_C67 #include "c67-gen.c" #include "c67-link.c" #include "tcccoff.c" #endif #ifdef TCC_TARGET_X86_64 #include "x86_64-gen.c" #include "x86_64-link.c" #include "i386-asm.c" #endif #ifdef CONFIG_TCC_ASM #include "tccasm.c" #endif #ifdef TCC_TARGET_PE #include "tccpe.c" #endif #endif /* ONE_SOURCE */ /********************************************************/ #ifndef CONFIG_TCC_ASM ST_FUNC void asm_instr(void) { tcc_error("inline asm() not supported"); } ST_FUNC void asm_global_instr(void) { tcc_error("inline asm() not supported"); } #endif /********************************************************/ #ifdef _WIN32 ST_FUNC char *normalize_slashes(char *path) { char *p; for (p = path; *p; ++p) if (*p == '\\') *p = '/'; return path; } static HMODULE tcc_module; /* on win32, we suppose the lib and includes are at the location of 'tcc.exe' */ static void tcc_set_lib_path_w32(TCCState *s) { char path[1024], *p; GetModuleFileNameA(tcc_module, path, sizeof path); p = tcc_basename(normalize_slashes(strlwr(path))); if (p > path) --p; *p = 0; tcc_set_lib_path(s, path); } #ifdef TCC_TARGET_PE static void tcc_add_systemdir(TCCState *s) { char buf[1000]; GetSystemDirectory(buf, sizeof buf); tcc_add_library_path(s, normalize_slashes(buf)); } #endif #ifdef LIBTCC_AS_DLL BOOL WINAPI DllMain (HINSTANCE hDll, DWORD dwReason, LPVOID lpReserved) { if (DLL_PROCESS_ATTACH == dwReason) tcc_module = hDll; return TRUE; } #endif #endif /********************************************************/ /* copy a string and truncate it. */ ST_FUNC char *pstrcpy(char *buf, int buf_size, const char *s) { char *q, *q_end; int c; if (buf_size > 0) { q = b
when defined(js):
import asyncjs
export asyncjs
else:
import asyncmacro, asyncfutures
export asyncmacro, asyncfutures