Skip to content

Commit

Permalink
Cygwin: Allow cross-builds to non-Cygwin targets.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Pall committed Apr 3, 2016
1 parent 62af101 commit 4ab6367
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/lj_alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ static LJ_AINLINE void *CALL_MMAP(size_t size)
return ptr;
}

#elif LJ_TARGET_OSX || LJ_TARGET_PS4 || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) || defined(__sun__) || defined(__CYGWIN__)
#elif LJ_TARGET_OSX || LJ_TARGET_PS4 || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) || defined(__sun__) || LJ_TARGET_CYGWIN

/* 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,
Expand Down
9 changes: 6 additions & 3 deletions src/lj_arch.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@
defined(__NetBSD__) || defined(__OpenBSD__) || \
defined(__DragonFly__)) && !defined(__ORBIS__)
#define LUAJIT_OS LUAJIT_OS_BSD
#elif (defined(__sun__) && defined(__svr4__)) || defined(__CYGWIN__)
#elif (defined(__sun__) && defined(__svr4__))
#define LUAJIT_OS LUAJIT_OS_POSIX
#elif defined(__CYGWIN__)
#define LJ_TARGET_CYGWIN 1
#define LUAJIT_OS LUAJIT_OS_POSIX
#else
#define LUAJIT_OS LUAJIT_OS_OTHER
Expand Down Expand Up @@ -133,7 +136,7 @@
#define LJ_ARCH_NAME "x86"
#define LJ_ARCH_BITS 32
#define LJ_ARCH_ENDIAN LUAJIT_LE
#if LJ_TARGET_WINDOWS || __CYGWIN__
#if LJ_TARGET_WINDOWS || LJ_TARGET_CYGWIN
#define LJ_ABI_WIN 1
#else
#define LJ_ABI_WIN 0
Expand All @@ -151,7 +154,7 @@
#define LJ_ARCH_NAME "x64"
#define LJ_ARCH_BITS 64
#define LJ_ARCH_ENDIAN LUAJIT_LE
#if LJ_TARGET_WINDOWS || __CYGWIN__
#if LJ_TARGET_WINDOWS || LJ_TARGET_CYGWIN
#define LJ_ABI_WIN 1
#else
#define LJ_ABI_WIN 0
Expand Down
8 changes: 4 additions & 4 deletions src/lj_clib.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ LJ_NORET LJ_NOINLINE static void clib_error_(lua_State *L)

#define clib_error(L, fmt, name) clib_error_(L)

#if defined(__CYGWIN__)
#if LJ_TARGET_CYGWIN
#define CLIB_SOPREFIX "cyg"
#else
#define CLIB_SOPREFIX "lib"
#endif

#if LJ_TARGET_OSX
#define CLIB_SOEXT "%s.dylib"
#elif defined(__CYGWIN__)
#elif LJ_TARGET_CYGWIN
#define CLIB_SOEXT "%s.dll"
#else
#define CLIB_SOEXT "%s.so"
Expand All @@ -56,14 +56,14 @@ LJ_NORET LJ_NOINLINE static void clib_error_(lua_State *L)
static const char *clib_extname(lua_State *L, const char *name)
{
if (!strchr(name, '/')
#ifdef __CYGWIN__
#if LJ_TARGET_CYGWIN
&& !strchr(name, '\\')
#endif
) {
if (!strchr(name, '.')) {
name = lj_str_pushf(L, CLIB_SOEXT, name);
L->top--;
#ifdef __CYGWIN__
#if LJ_TARGET_CYGWIN
} else {
return name;
#endif
Expand Down

0 comments on commit 4ab6367

Please sign in to comment.