]> git.ipfire.org Git - thirdparty/LuaJIT.git/commitdiff
Cleanup architecture, ABI and OS definitions.
authorMike Pall <mike>
Tue, 16 Nov 2010 13:06:59 +0000 (14:06 +0100)
committerMike Pall <mike>
Tue, 16 Nov 2010 14:03:40 +0000 (15:03 +0100)
19 files changed:
src/Makefile
src/buildvm.c
src/lib_io.c
src/lib_os.c
src/lib_package.c
src/lj_alloc.c
src/lj_arch.h
src/lj_asm.c
src/lj_err.c
src/lj_errmsg.h
src/lj_frame.h
src/lj_gdbjit.c
src/lj_jit.h
src/lj_lib.h
src/lj_mcode.c
src/lj_obj.h
src/lj_target_x86.h
src/luaconf.h
src/luajit.c

index bae6691ed7be2936febd09effcf854e6c2e59004..da9f67b28eee12451c2aafa7bd589d5f0afab850 100644 (file)
@@ -336,7 +336,7 @@ ifeq (Windows,$(TARGET_SYS))
   LUAJIT_SO= $(TARGET_DLLNAME)
   LUAJIT_T= luajit.exe
   ifneq ($(HOST_SYS),$(TARGET_SYS))
-    HOST_XCFLAGS+= -malign-double
+    HOST_XCFLAGS+= -malign-double -DLUAJIT_OS=LUAJIT_OS_WINDOWS
   endif
   # Mixed mode is not supported on Windows. And static mode doesn't work well.
   # C modules cannot be loaded, because they bind to lua51.dll.
index 382550b82f6513c659ea1047715a91e0c4190743..72e612c194eb8250d380b935269a9602d907643f 100644 (file)
@@ -23,7 +23,7 @@
 #include "lj_dispatch.h"
 #include "luajit.h"
 
-#ifdef LUA_USE_WIN
+#if defined(_WIN32)
 #include <fcntl.h>
 #include <io.h>
 #endif
@@ -64,11 +64,12 @@ static int collect_reloc(BuildCtx *ctx, uint8_t *addr, int idx, int type);
 #define DASM_ALIGNED_WRITES    1
 
 /* Embed architecture-specific DynASM encoder and backend. */
-#if LJ_TARGET_X86ORX64
+#if LJ_TARGET_X86
 #include "../dynasm/dasm_x86.h"
-#if LJ_32
 #include "buildvm_x86.h"
-#elif defined(_WIN64)
+#elif LJ_TARGET_X64
+#include "../dynasm/dasm_x86.h"
+#if LJ_ABI_WIN
 #include "buildvm_x64win.h"
 #else
 #include "buildvm_x64.h"
@@ -449,7 +450,7 @@ int main(int argc, char **argv)
 
   if (ctx->outname[0] == '-' && ctx->outname[1] == '\0') {
     ctx->fp = stdout;
-#ifdef LUA_USE_WIN
+#if defined(_WIN32)
     if (binmode)
       _setmode(_fileno(stdout), _O_BINARY);  /* Yuck. */
 #endif
index 787fdc6bc1871dbef5fb29e128bfaa9f182b6059..878b98af03465f6962b7dde11929d4c8e6ff4337 100644 (file)
@@ -114,9 +114,9 @@ static int io_file_close(lua_State *L, IOFileUD *iof)
   if ((iof->type & IOFILE_TYPE_MASK) == IOFILE_TYPE_FILE) {
     ok = (fclose(iof->fp) == 0);
   } else if ((iof->type & IOFILE_TYPE_MASK) == IOFILE_TYPE_PIPE) {
-#if defined(LUA_USE_POSIX)
+#if LJ_TARGET_POSIX
     ok = (pclose(iof->fp) != -1);
-#elif defined(LUA_USE_WIN)
+#elif LJ_TARGET_WINDOWS
     ok = (_pclose(iof->fp) != -1);
 #else
     ok = 0;
@@ -289,7 +289,7 @@ LJLIB_CF(io_method_seek)
     ,
     ofs = 0;
   )
-#if defined(LUA_USE_POSIX)
+#if LJ_TARGET_POSIX
   res = fseeko(fp, (int64_t)ofs, opt);
 #elif _MSC_VER >= 1400
   res = _fseeki64(fp, (int64_t)ofs, opt);
@@ -300,7 +300,7 @@ LJLIB_CF(io_method_seek)
 #endif
   if (res)
     return io_pushresult(L, 0, NULL);
-#if defined(LUA_USE_POSIX)
+#if LJ_TARGET_POSIX
   ofs = cast_num(ftello(fp));
 #elif _MSC_VER >= 1400
   ofs = cast_num(_ftelli64(fp));
@@ -374,13 +374,13 @@ LJLIB_CF(io_open)
 
 LJLIB_CF(io_popen)
 {
-#if defined(LUA_USE_POSIX) || defined(LUA_USE_WIN)
+#if LJ_TARGET_POSIX || LJ_TARGET_WINDOWS
   const char *fname = strdata(lj_lib_checkstr(L, 1));
   GCstr *s = lj_lib_optstr(L, 2);
   const char *mode = s ? strdata(s) : "r";
   IOFileUD *iof = io_file_new(L);
   iof->type = IOFILE_TYPE_PIPE;
-#ifdef LUA_USE_POSIX
+#if LJ_TARGET_POSIX
   fflush(NULL);
   iof->fp = popen(fname, mode);
 #else
index 8f08616f73a6782fd5441bb0a02b32f27367cc1a..690bffe8e5d761e3a3ebfc982d820ab7e858357a 100644 (file)
 #include "lauxlib.h"
 #include "lualib.h"
 
-#ifdef LUA_USE_POSIX
+#include "lj_obj.h"
+#include "lj_err.h"
+#include "lj_lib.h"
+
+#if LJ_TARGET_POSIX
 #include <unistd.h>
 #else
 #include <stdio.h>
 #endif
 
-#include "lj_obj.h"
-#include "lj_err.h"
-#include "lj_lib.h"
-
 /* ------------------------------------------------------------------------ */
 
 #define LJLIB_MODULE_os
@@ -66,7 +66,7 @@ LJLIB_CF(os_rename)
 
 LJLIB_CF(os_tmpname)
 {
-#ifdef LUA_USE_POSIX
+#if LJ_TARGET_POSIX
   char buf[15+1];
   int fp;
   strcpy(buf, "/tmp/lua_XXXXXX");
index 5678ca4a99386ae39ace2ee5550aabf1069987b2..1757a94431fa409968b30584ed6986db5317af18 100644 (file)
@@ -27,7 +27,7 @@
 #define PACKAGE_LIB_FAIL       "open"
 #define setprogdir(L)          ((void)0)
 
-#if defined(LUA_DL_DLOPEN)
+#if LJ_TARGET_DLOPEN
 
 #include <dlfcn.h>
 
@@ -50,7 +50,7 @@ static lua_CFunction ll_sym(lua_State *L, void *lib, const char *sym)
   return f;
 }
 
-#elif defined(LUA_DL_DLL)
+#elif LJ_TARGET_WINDOWS
 
 #define WIN32_LEAN_AND_MEAN
 #include <windows.h>
@@ -107,7 +107,7 @@ static lua_CFunction ll_sym(lua_State *L, void *lib, const char *sym)
 #undef PACKAGE_LIB_FAIL
 #define PACKAGE_LIB_FAIL       "absent"
 
-#define DLMSG  "dynamic libraries not enabled; check your Lua installation"
+#define DLMSG  "dynamic libraries not enabled; no support for target OS"
 
 static void ll_unloadlib(void *lib)
 {
index 2c686597ff7402fd853b3b216adccc69ced42234..2f3fb473f8b1c77c56b167b65ae704b4a2acb128 100644 (file)
@@ -72,7 +72,7 @@
 
 #define IS_DIRECT_BIT          (SIZE_T_ONE)
 
-#ifdef LUA_USE_WIN
+#if LJ_TARGET_WINDOWS
 
 #define WIN32_LEAN_AND_MEAN
 #include <windows.h>
@@ -166,13 +166,12 @@ static LJ_AINLINE int CALL_MUNMAP(void *ptr, size_t size)
 #if LJ_64
 /* 64 bit mode needs special support for allocating memory in the lower 2GB. */
 
-#if defined(__linux__)
+#if LJ_TARGET_LINUX
 
 /* Actually this only gives us max. 1GB in current Linux kernels. */
 #define CALL_MMAP(s)   mmap(NULL, (s), MMAP_PROT, MAP_32BIT|MMAP_FLAGS, -1, 0)
 
-#elif (defined(__MACH__) && defined(__APPLE__)) || \
-      defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+#elif LJ_TARGET_OSX || defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
 
 /* OSX and FreeBSD mmap() use a naive first-fit linear search.
 ** That's perfect for us. Except that -pagezero_size must be set for OSX,
@@ -233,7 +232,7 @@ static LJ_AINLINE void *CALL_MMAP(size_t size)
 #define DIRECT_MMAP(s)         CALL_MMAP(s)
 #define CALL_MUNMAP(a, s)      munmap((a), (s))
 
-#ifdef __linux__
+#if LJ_TARGET_LINUX
 /* Need to define _GNU_SOURCE to get the mremap prototype. */
 #define CALL_MREMAP(addr, osz, nsz, mv) mremap((addr), (osz), (nsz), (mv))
 #define CALL_MREMAP_NOMOVE     0
@@ -420,7 +419,7 @@ typedef struct malloc_state *mstate;
   (((S) + (DEFAULT_GRANULARITY - SIZE_T_ONE))\
    & ~(DEFAULT_GRANULARITY - SIZE_T_ONE))
 
-#ifdef LUA_USE_WIN
+#if LJ_TARGET_WINDOWS
 #define mmap_align(S)  granularity_align(S)
 #else
 #define mmap_align(S)  page_align(S)
index 7f1fe93ce27c3cef359c7ab92ecd2f58b498fa3c..f9cb12e7f50780639b90c044f45596f526d3de53 100644 (file)
@@ -8,7 +8,6 @@
 
 #include "lua.h"
 
-
 /* Target endianess. */
 #define LUAJIT_LE      0
 #define LUAJIT_BE      1
 #define LUAJIT_ARCH_PPCSPE     4
 #define LUAJIT_ARCH_ppcspe     4
 
+/* Target OS. */
+#define LUAJIT_OS_OTHER                0
+#define LUAJIT_OS_WINDOWS      1
+#define LUAJIT_OS_LINUX                2
+#define LUAJIT_OS_OSX          3
+#define LUAJIT_OS_BSD          4
+#define LUAJIT_OS_POSIX                5
 
 /* Select native target if no target defined. */
 #ifndef LUAJIT_TARGET
 
 #endif
 
-/* Set target properties. */
+/* Select native OS if no target OS defined. */
+#ifndef LUAJIT_OS
+
+#if defined(_WIN32)
+#define LUAJIT_OS      LUAJIT_OS_WINDOWS
+#elif defined(__linux__)
+#define LUAJIT_OS      LUAJIT_OS_LINUX
+#elif defined(__MACH__) && defined(__APPLE__)
+#define LUAJIT_OS      LUAJIT_OS_OSX
+#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || \
+      defined(__NetBSD__) || defined(__OpenBSD__)
+#define LUAJIT_OS      LUAJIT_OS_BSD
+#elif defined(__solaris__) || defined(__CYGWIN__)
+#define LUAJIT_OS      LUAJIT_OS_POSIX
+#else
+#define LUAJIT_OS      LUAJIT_OS_OTHER
+#endif
+
+#endif
+
+/* Set target OS properties. */
+#if LUAJIT_OS == LUAJIT_OS_WINDOWS
+#define LJ_OS_NAME     "Windows"
+#elif LUAJIT_OS == LUAJIT_OS_LINUX
+#define LJ_OS_NAME     "Linux"
+#elif LUAJIT_OS == LUAJIT_OS_OSX
+#define LJ_OS_NAME     "OSX"
+#elif LUAJIT_OS == LUAJIT_OS_BSD
+#define LJ_OS_NAME     "BSD"
+#elif LUAJIT_OS == LUAJIT_OS_POSIX
+#define LJ_OS_NAME     "Posix"
+#else
+#define LJ_OS_NAME     "Other"
+#endif
+
+#define LJ_TARGET_WINDOWS      (LUAJIT_OS == LUAJIT_OS_WINDOWS)
+#define LJ_TARGET_LINUX                (LUAJIT_OS == LUAJIT_OS_LINUX)
+#define LJ_TARGET_OSX          (LUAJIT_OS == LUAJIT_OS_OSX)
+#define LJ_TARGET_POSIX                (LUAJIT_OS > LUAJIT_OS_WINDOWS)
+#define LJ_TARGET_DLOPEN       LJ_TARGET_POSIX
+
+/* Set target architecture properties. */
 #if LUAJIT_TARGET == LUAJIT_ARCH_X86
 
 #define LJ_ARCH_NAME           "x86"
 #define LJ_ARCH_BITS           32
 #define LJ_ARCH_ENDIAN         LUAJIT_LE
+#define LJ_ARCH_BITENDIAN      LUAJIT_LE
+#define LJ_ARCH_HASFPU         1
+#define LJ_ABI_WIN             LJ_TARGET_WINDOWS
 #define LJ_TARGET_X86          1
 #define LJ_TARGET_X86ORX64     1
-#define LJ_PAGESIZE            4096
 #define LJ_TARGET_EHRETREG     0
 #define LJ_TARGET_MASKSHIFT    1
 #define LJ_TARGET_MASKROT      1
 #define LJ_ARCH_NAME           "x64"
 #define LJ_ARCH_BITS           64
 #define LJ_ARCH_ENDIAN         LUAJIT_LE
+#define LJ_ARCH_BITENDIAN      LUAJIT_LE
+#define LJ_ARCH_HASFPU         1
+#define LJ_ABI_WIN             LJ_TARGET_WINDOWS
 #define LJ_TARGET_X64          1
 #define LJ_TARGET_X86ORX64     1
-#define LJ_PAGESIZE            4096
 #define LJ_TARGET_EHRETREG     0
 #define LJ_TARGET_MASKSHIFT    1
 #define LJ_TARGET_MASKROT      1
 #define LJ_ARCH_NAME           "ppcspe"
 #define LJ_ARCH_BITS           32
 #define LJ_ARCH_ENDIAN         LUAJIT_BE
+#define LJ_ARCH_BITENDIAN      LUAJIT_BE
+#define LJ_ARCH_HASFPU         1
+#define LJ_ABI_SOFTFP          1
+#define LJ_ABI_EABI            1
 #define LJ_TARGET_PPC          1
 #define LJ_TARGET_PPCSPE       1
-#define LJ_PAGESIZE            4096
 #define LJ_TARGET_EHRETREG     3
 #define LJ_TARGET_MASKSHIFT    0
 #define LJ_TARGET_MASKROT      1
 #error "No target architecture defined"
 #endif
 
+#ifndef LJ_PAGESIZE
+#define LJ_PAGESIZE            4096
+#endif
+
 /* Check for minimum required compiler versions. */
 #if defined(__GNUC__)
 #if LJ_TARGET_X64
index 322799e6f58e81afbed62d6fbf6500114e7855f8..80dda36adea9764dc0c48d6aed721a3f3e53069c 100644 (file)
@@ -1345,7 +1345,7 @@ static void asm_gencall(ASMState *as, const CCallInfo *ci, IRRef *args)
   for (n = 0; n < nargs; n++) {  /* Setup args. */
     IRIns *ir = IR(args[n]);
     Reg r;
-#if LJ_64 && defined(_WIN64)
+#if LJ_64 && LJ_ABI_WIN
     /* Windows/x64 argument registers are strictly positional. */
     r = irt_isnum(ir->t) ? (fpr <= REGARG_LASTFPR ? fpr : 0) : (gprs & 31);
     fpr++; gprs >>= 5;
@@ -3518,11 +3518,7 @@ static void asm_setup_regsp(ASMState *as, GCtrace *T)
       const CCallInfo *ci = &lj_ir_callinfo[ir->op2];
 #if LJ_64
       /* NYI: add stack slots for x64 calls with many args. */
-#ifdef _WIN64
-      lua_assert(CCI_NARGS(ci) <= 4);
-#else
-      lua_assert(CCI_NARGS(ci) <= 6);  /* Safe lower bound. */
-#endif
+      lua_assert(CCI_NARGS(ci) <= (LJ_ABI_WIN ? 4 : 6));
       ir->prev = REGSP_HINT(irt_isnum(ir->t) ? RID_FPRET : RID_RET);
 #else
       /* NYI: not fastcall-aware, but doesn't matter (yet). */
index 5a6aac83fb9480c84a0154bddb07351701af8543..8a80c9c8ffd37115747bee04013435dc6fade731 100644 (file)
 ** EXT is mandatory on POSIX/x64 since the interpreter doesn't save r12/r13.
 */
 
-#if defined(__GNUC__)
-#if LJ_TARGET_X64 || defined(LUAJIT_UNWIND_EXTERNAL)
+#if defined(__GNUC__) && (LJ_TARGET_X64 || defined(LUAJIT_UNWIND_EXTERNAL))
 #define LJ_UNWIND_EXT  1
-#endif
-#elif defined(LUA_USE_WIN)
-#if LJ_TARGET_X64
+#elif LJ_TARGET_X64 && LJ_TARGET_WINDOWS
 #define LJ_UNWIND_EXT  1
 #endif
-#endif
 
 /* -- Error messages ------------------------------------------------------ */
 
@@ -604,7 +600,7 @@ static void err_raise_ext(int errcode)
 }
 #endif
 
-#elif defined(_WIN64)
+#elif LJ_TARGET_X64 && LJ_TARGET_WINDOWS
 
 /*
 ** Someone in Redmond owes me several days of my life. A lot of this is
index 4891b74ef1acf9e628b371f9cd8ef7f8cde7780d..4fe8e1b1c313a2a782c78001985623837e44e7a0 100644 (file)
@@ -57,7 +57,7 @@ ERRDEF(NOENV, "no calling environment")
 ERRDEF(CYIELD, "attempt to yield across C-call boundary")
 ERRDEF(BADLU,  "bad light userdata pointer")
 ERRDEF(NOGCMM, "bad action while in __gc metamethod")
-#ifdef LUA_USE_WIN
+#if LJ_TARGET_WINDOWS
 ERRDEF(BADFPU, "bad FPU precision (use D3DCREATE_FPU_PRESERVE with DirectX)")
 #endif
 
index c4931072806429ae137aedcb5a659b658ad1f197..143a6812f1e1a5c177757b18f93e59eb49209499 100644 (file)
@@ -69,7 +69,7 @@ enum {
 #define CFRAME_SIZE_JIT                CFRAME_SIZE
 #define CFRAME_SHIFT_MULTRES   0
 #elif LJ_TARGET_X64
-#if _WIN64
+#if LJ_ABI_WIN
 #define CFRAME_OFS_PREV                (13*8)
 #define CFRAME_OFS_PC          (25*4)
 #define CFRAME_OFS_L           (24*4)
index 30aab774ba036f0559033f70669f5700a1cdc63e..d106bb5dc356eb02c28802bef7cb49d64ee80796 100644 (file)
@@ -335,7 +335,7 @@ static const ELFheader elfhdr_template = {
   .eclass = LJ_64 ? 2 : 1,
   .eendian = LJ_ENDIAN_SELECT(1, 2),
   .eversion = 1,
-#if defined(__linux__)
+#if LJ_TARGET_LINUX
   .eosabi = 0,  /* Nope, it's not 3. */
 #elif defined(__FreeBSD__)
   .eosabi = 9,
index 7737793196eefe9b2c94458be663b142cef76d6e..d309f828fb9cba4776e2782ace6052390d362983 100644 (file)
@@ -55,7 +55,7 @@
   (JIT_F_OPT_2|JIT_F_OPT_FWD|JIT_F_OPT_DSE|JIT_F_OPT_ABC|JIT_F_OPT_FUSE)
 #define JIT_F_OPT_DEFAULT      JIT_F_OPT_3
 
-#if defined(LUA_USE_WIN) || LJ_64
+#if LJ_TARGET_WINDOWS || LJ_64
 /* See: http://blogs.msdn.com/oldnewthing/archive/2003/10/08/55239.aspx */
 #define JIT_P_sizemcode_DEFAULT                64
 #else
index 814c9739af427d9b383bab5bb41546cfd3ac1094..6782e725dd06907b41e649efe0167bb1d85753f7 100644 (file)
@@ -49,7 +49,7 @@ LJ_FUNC int lj_lib_checkopt(lua_State *L, int narg, int def, const char *lst);
 #define lj_lib_upvalue(L, n) \
   (&gcref((L->base-1)->fr.func)->fn.c.upvalue[(n)-1])
 
-#ifdef LUA_USE_WIN
+#if LJ_TARGET_WINDOWS
 #define lj_lib_checkfpu(L) \
   do { setnumV(L->top++, (lua_Number)1437217655); \
     if (lua_tointeger(L, -1) != 1437217655) lj_err_caller(L, LJ_ERR_BADFPU); \
index 9b1cae000086823411f489d3a0e5851f671e7b1b..720021757e85bede013f13b9b19a6a9bfdfce705 100644 (file)
@@ -19,7 +19,7 @@
 
 /* -- OS-specific functions ----------------------------------------------- */
 
-#if defined(LUA_USE_WIN)
+#if LJ_TARGET_WINDOWS
 
 #define WIN32_LEAN_AND_MEAN
 #include <windows.h>
@@ -49,7 +49,7 @@ static void mcode_setprot(void *p, size_t sz, DWORD prot)
   VirtualProtect(p, sz, prot, &oprot);
 }
 
-#elif defined(LUA_USE_POSIX)
+#elif LJ_TARGET_POSIX
 
 #include <sys/mman.h>
 
@@ -82,7 +82,7 @@ static void mcode_setprot(void *p, size_t sz, int prot)
 
 #elif LJ_64
 
-#error "Missing OS support for allocating executable memory"
+#error "Missing OS support for explicit placement of executable memory"
 
 #else
 
index 4baa62d8ca9d46ada515f948bca55938ace9ce5a..c7b653f3b77eee546330f3b5df5b55153d6278f8 100644 (file)
@@ -719,7 +719,7 @@ static LJ_AINLINE int32_t lj_num2bit(lua_Number n)
   return (int32_t)o.u32.lo;
 }
 
-#if (defined(__i386__) || defined(_M_IX86)) && !defined(__SSE2__)
+#if LJ_TARGET_X86 && !defined(__SSE2__)
 #define lj_num2int(n)   lj_num2bit((n))
 #else
 #define lj_num2int(n)   ((int32_t)(n))
index ad4e3d1abb75c9e5277326d58750c44db2edf9b1..03c52770a01e35f9fedc487c9d19bac98a7043f5 100644 (file)
@@ -40,7 +40,7 @@ enum {
 
   /* These definitions must match with the *.dasc file(s): */
   RID_BASE = RID_EDX,          /* Interpreter BASE. */
-#if LJ_64 && !defined(_WIN64)
+#if LJ_64 && !LJ_ABI_WIN
   RID_PC = RID_EBX,            /* Interpreter PC. */
   RID_DISPATCH = RID_R14D,     /* Interpreter DISPATCH table. */
 #else
@@ -74,7 +74,7 @@ enum {
 /* ABI-specific register sets. */
 #define RSET_ACD       (RID2RSET(RID_EAX)|RID2RSET(RID_ECX)|RID2RSET(RID_EDX))
 #if LJ_64
-#ifdef _WIN64
+#if LJ_ABI_WIN
 /* Windows x64 ABI. */
 #define RSET_SCRATCH \
   (RSET_ACD|RSET_RANGE(RID_R8D, RID_R11D+1)|RSET_RANGE(RID_XMM0, RID_XMM5+1))
@@ -117,7 +117,7 @@ enum {
 ** SPS_FIRST: First spill slot for general use. Reserve min. two 32 bit slots.
 */
 #if LJ_64
-#ifdef _WIN64
+#if LJ_ABI_WIN
 #define SPS_FIXED      (4*2)
 #define SPS_FIRST      (4*2)   /* Don't use callee register save area. */
 #else
index 4506b5fbead6b6c8c1e9a2e0412daa62688d03f1..7278b3ef5da36779e57a6b9018a9fdff0987c224 100644 (file)
@@ -9,19 +9,8 @@
 #include <limits.h>
 #include <stddef.h>
 
-/* Try to determine supported features for a couple of standard platforms. */
-#if defined(_WIN32)
-#define LUA_USE_WIN
-#define LUA_DL_DLL
-#elif defined(__linux__) || defined(__solaris__) || defined(__CYGWIN__) || \
-      defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || \
-      defined(__FreeBSD_kernel__) || (defined(__MACH__) && defined(__APPLE__))
-#define LUA_USE_POSIX
-#define LUA_DL_DLOPEN
-#endif
-
 /* Default path for loading Lua and C modules with require(). */
-#ifdef LUA_USE_WIN
+#if defined(_WIN32)
 /*
 ** In Windows, any exclamation mark ('!') in the path is replaced by the
 ** path of the directory of the executable file of the current process.
@@ -58,7 +47,7 @@
 #define LUA_INIT       "LUA_INIT"
 
 /* Special file system characters. */
-#ifdef LUA_USE_WIN
+#if defined(_WIN32)
 #define LUA_DIRSEP     "\\"
 #else
 #define LUA_DIRSEP     "/"
index e8024479edba206ef50fead4ec4d26e779fa2de5..2e85f01df195b0d489e5f0da827633dbff580810 100644 (file)
 #include "lualib.h"
 #include "luajit.h"
 
-#if defined(LUA_USE_POSIX)
+#include "lj_arch.h"
+
+#if LJ_TARGET_POSIX
 #include <unistd.h>
 #define lua_stdin_is_tty()     isatty(0)
-#elif defined(LUA_USE_WIN)
+#elif LJ_TARGET_WINDOWS
 #include <io.h>
 #ifdef __BORLANDC__
 #define lua_stdin_is_tty()     isatty(_fileno(stdin))