lua-users home
lua-l archive

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


Hi,

I am having a problem compiling Lua 5.1-rc2 under vxWorks for an embedded target (the type of target should not matter). I have to make a few changes to get it to compile, because vxWorks has it own header file for target independent compiling. The vxWorks.h header contains information about what type of CPU arch is being built and a few other things.

The issue is the header file "vxWorks.h" needs to be included before any other standard header file. For the most part Lua source files are not concerned with this issue except for lua.c, ldo.c and maybe luac.c files.

I modified the luaconf.h to include vxWorks.h at the bottom of the file as:
#if defined(lua_c)
/* vxWorks does not use 'main' in kernel builds (RTPs is another issue), so rename to a better symbol. */
#define main   vxLuaMain
#endif

#if defined(lua_c) || defined(ldo_c)
#include <vxWorks.h>
#endif

These changes are expected, but the following changes are not expected.

In ldo.c and lua.c move the include of "lua.h" (which includes luaconf.h) to before the standard includes to allow the vxWorks.h header to be included before any standard headers.

File: lua.c

/* moved this define and the lua.h include to above the standard includes --Keith */
#define lua_c

#include "lua.h"

#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "lauxib.h"
#include "lualib.h"
...

File: ldo.c

/* moved these defines and the lua.h include to above the standard includes --Keith */
#define ldo_c
#define LUA_CORE

#include "lua.h"

#include <setjmp.h>
#include <stdlib.h>
#include <string.h>

#include "ldebug.h"
#include "ldo.h"
...

Is this change expected for an embedded system or does someone have a better solution without having to change the lua.c and ldo.c files?

Because vxWorks is an embedded environment and Lua is made for embedded environments would this change break any other environments?
Should the standard Lua source be altered to fix this issue?

I do not believe the changes are vxWorks specific and possibly would fail for other embedded systems too.

I have not completed the porting of Lua-5.1rc2 to vxWorks, but I have ported Lua to vxWorks before with these changes and found no other issues (that I remember). BTW, I am not using the standard Lua makefiles as the IDE (Wind River modified Eclipse IDE) needs to manage the makefiles to build for different CPU types and images.

Sorry, I am bring this up so late in the game. Comments?

Thanks
--Keith