lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Luiz,

the attached amendments work fine in OS/2 with Paul Smith's GCC 4.46 for OS/2.

Please note that I am not a professional programmer.

Alex


OS/2-specific changes to the Makefile
-------------------------------------

#LIBS= -lm $(SYSLIBS) $(MYLIBS)
LIBS= -lm -lreadline -lhistory -lncurses $(MYLIBS)
...
os2:
    $(MAKE) all "LUA_T=lua.exe" MYCFLAGS="-O2 -static-libgcc -fomit-frame-pointer -D__ST_MT_ERRNO__ -DLUA_USE_LINUX -DLUA_ANSI" SYSLIBS="-ldl -lreadline" lua.exe
    $(MAKE) all "LUAC_T=luac.exe" MYCFLAGS="-O2 -static-libgcc -fomit-frame-pointer -D__ST_MT_ERRNO__ -DLUA_USE_LINUX -DLUA_ANSI" SYSLIBS="-ldl -lreadline" luac.exe


Changes to lmathlib.c (or to be included in a compatibility file for Solaris, OS/2, DOS, etc.)
----------------------------------------------------------------------------------------------

#ifdef __OS2__
#define log2  logb
#endif

static int math_log (lua_State *L) {
....


Changes to lua.c
----------------

lua.c:

int main (int argc, char **argv) {
  int status, result;
  lua_State *L = luaL_newstate();  /* create state */
  /* 2.3.0 RC 2 OS2/eCS fix provided by Dave Yeo on OS/2 world.com to avoid
     segmentation faults with mathematical functions (SIGFPEs issued by
     libc065.dll with trunc, sinh, cosh, etc.) and also to speed up double
     arithmetic significantly.
     See: http://www.os2world.com/forum/index.php/topic,496.msg4679.html#msg4679 */
#ifdef __OS2__
  short fcr;
  __asm__ volatile ("fstcw           %0 \n"
                    "or         $63, %0 \n"
                    "fldcw           %0 \n"
                    : "=m"(fcr));
#endif
  if (L == NULL) {
    l_message(argv[0], "cannot create state: not enough memory");
    return EXIT_FAILURE;
  }