Skip to content

Commit

Permalink
add support of MinGW
Browse files Browse the repository at this point in the history
  • Loading branch information
TerryE committed Feb 21, 2019
1 parent b237bc0 commit 4320c7a
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 29 deletions.
2 changes: 1 addition & 1 deletion app/lua/linit.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ extern const luaR_entry lua_rotable_base[];
#define LUA_ROTABLES lua_rotable_core
#define LUA_LIBS lua_libs_core
#endif

#ifdef _MSC_VER
//MSVC requires us to declare these sections before we refer to them
#pragma section(__ROSECNAME(A), read)
Expand Down
20 changes: 9 additions & 11 deletions app/lua/lrotable.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,31 +64,29 @@ int luaR_isrotable(void *p);
*/
#if defined(LUA_CROSS_COMPILER)

#if defined(_MSC_VER)
//msvc build uses these dummy vars to locate the beginning and ending addresses of the RO data
extern cons char _ro_start[], _ro_end[];
#define IN_RODATA_AREA(p) (((const char*)(p)) >= _ro_start && ((const char *)(p)) <= _ro_end)
#else /* one of the POSIX variants */
#if defined(__CYGWIN__)
#define _RODATA_END __end__
#elif defined(__MINGW32__)
#define _RODATA_END end
#else
#define _RODATA_END _edata
#endif
extern const char _RODATA_END[];
#define IN_RODATA_AREA(p) (((const char *)(p)) < _RODATA_END)

#if defined(_MSC_VER)
//msvc build uses dummy vars to locate the beginning and ending addresses of the RO data
extern const int _ro_start;
extern const int _ro_end;
//and this is how we see if something is in the RO section
#undef IN_RODATA_AREA
#define IN_RODATA_AREA(p) (((const int*)(p)) >= &_ro_start && ((const int *)(p)) <= &_ro_end)
#endif

#endif /* defined(_MSC_VER) */

#else /* xtensa tool chain for ESP target */

extern const char _irom0_text_start[];
extern const char _irom0_text_end[];
#define IN_RODATA_AREA(p) (((const char *)(p)) >= _irom0_text_start && ((const char *)(p)) <= _irom0_text_end)

#endif
#endif /* defined(LUA_CROSS_COMPILER) */

/* Return 1 if the given pointer is a rotable */
#define luaR_isrotable(p) IN_RODATA_AREA(p)
Expand Down
1 change: 1 addition & 0 deletions app/lua/luac_cross/luac.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ static TString *corename(lua_State *L, const TString *filename)
{
const char *fn = getstr(filename)+1;
const char *s = strrchr(fn, '/');
if (!s) s = strrchr(fn, '\\');
s = s ? s + 1 : fn;
while (*s == '.') s++;
const char *e = strchr(s, '.');
Expand Down
23 changes: 10 additions & 13 deletions app/lua/luaconf.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,9 @@
#endif


#if defined(LUA_CROSS_COMPILER)
#ifdef _MSC_VER
#else
#if defined(LUA_CROSS_COMPILER) && !defined(_MSC_VER) && !defined(__MINGW32__)
#define LUA_USE_LINUX
#endif
#endif

#if defined(LUA_USE_LINUX)
#define LUA_USE_POSIX
Expand Down Expand Up @@ -767,18 +764,18 @@ union luai_Cast { double l_d; long l_l; };
{ if ((c)->status == 0) (c)->status = -1; }
#define luai_jmpbuf int /* dummy variable */

#elif defined(LUA_USE_ULONGJMP)
#else
#if defined(LUA_USE_ULONGJMP)
/* in Unix, try _longjmp/_setjmp (more efficient) */
#define LUAI_THROW(L,c) _longjmp((c)->b, 1)
#define LUAI_TRY(L,c,a) if (_setjmp((c)->b) == 0) { a }
#define luai_jmpbuf jmp_buf

#define LONGJMP(a,b) _longjmp(a,b)
#define SETJMP(a) _setjmp(a)
#else
/* default handling with long jumps */
#define LUAI_THROW(L,c) longjmp((c)->b, 1)
#define LUAI_TRY(L,c,a) if (setjmp((c)->b) == 0) { a }
#define LONGJMP(a,b) longjmp(a,b)
#define SETJMP(a) setjmp(a)
#endif
#define LUAI_THROW(L,c) LONGJMP((c)->b, 1)
#define LUAI_TRY(L,c,a) if (SETJMP((c)->b) == 0) { a }
#define luai_jmpbuf jmp_buf

#endif


Expand Down
11 changes: 7 additions & 4 deletions app/uzlib/uzlib.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,24 @@
#define uz_malloc os_malloc
#define uz_free os_free

#else /* POSIX */
#else /* Host */

#include <stdint.h>
#include <stdlib.h>

extern int dbg_break(void);
#ifdef _MSC_VER //msvc requires old name for longjmp
#if defined(_MSC_VER) || defined(__MINGW32__) //msvc requires old name for longjmp
#define UZLIB_THROW(v) {dbg_break();longjmp(unwindAddr, (v));}
#define UZLIB_SETJMP(n) setjmp(n)
#else
#define UZLIB_THROW(v) {dbg_break();_longjmp(unwindAddr, (v));}
#define UZLIB_SETJMP(n) _setjmp(n)
#endif
#define UZLIB_SETJMP _setjmp

#define uz_malloc malloc
#define uz_free free

#endif
#endif /* defined(__XTENSA__) */

extern jmp_buf unwindAddr;

Expand Down

0 comments on commit 4320c7a

Please sign in to comment.