35 #include <rtt/rtt-config.h> 38 #define ORO_MEMORY_POOL 44 #ifdef ORO_BUILD_LOGGING 46 # warning "Logging needs rtalloc!" 55 void l_message (
const char *pname,
const char *msg);
60 #include <sys/types.h> 72 #if defined(LUA_RTT_CORBA) 80 #define LuaComponent LuaTLSFComponent 82 #define LuaComponent LuaComponent 85 #define INIT_FILE "~/.rttlua" 90 #if defined(LUA_RTT_CORBA) 99 #ifdef ORO_BUILD_RTALLOC 100 size_t memSize = ORO_DEFAULT_RTALLOC_SIZE;
106 rtMem = malloc(memSize);
109 if ((
size_t)-1 == freeMem)
111 cerr <<
"Invalid memory pool size of " << memSize
112 <<
" bytes (TLSF has a several kilobyte overhead)." <<
endl;
116 cout <<
"Real-time memory: " << freeMem <<
" bytes free of " 117 << memSize <<
" allocated." <<
endl;
119 #endif // ORO_BUILD_RTALLOC 121 #ifdef ORO_BUILD_LOGGING 129 #if defined(LUA_RTT_CORBA) 136 if(0 == strcmp(
"--", argv[argc - orb_argc])) {
137 orb_sep = argv[argc - orb_argc];
138 argv[argc - orb_argc] = argv[0];
139 orb_argv = &argv[argc - orb_argc];
149 TaskContextServer::InitOrb(orb_argc, orb_argv);
153 TaskContextServer::Create( dc,
true,
true );
156 TaskContextServer::ThreadOrb();
158 catch( CORBA::Exception &e ) {
159 log(
Error) << argv[0] <<
" ORO_main : CORBA exception raised!" <<
Logger::nl;
167 log(
Error) <<
"Uncaught exception." << endlog();
175 argv[argc] = dc?NULL:orb_sep;
187 if(stat(init_exp.we_wordv[0], &stb) != -1) {
188 if((stb.st_mode & S_IFMT) != S_IFREG)
189 cout <<
"rttlua: warning: init file " << init_exp.we_wordv[0] <<
" is not a regular file" <<
endl;
197 #if defined(LUA_RTT_CORBA) 199 TaskContextServer::ShutdownOrb();
200 TaskContextServer::DestroyOrb();
206 #ifdef ORO_BUILD_LOGGING 211 #ifdef ORO_BUILD_RTALLOC 214 std::cout <<
"TLSF bytes allocated=" << memSize
215 <<
" overhead=" << (memSize - freeMem)
218 <<
" still-allocated=" << (
get_used_size(rtMem) - (memSize - freeMem))
int dofile(lua_State *L, const char *name)
int dostring(lua_State *L, const char *s, const char *name)
void l_message(const char *pname, const char *msg)
static std::ostream & nl(std::ostream &__os)
size_t get_max_size(void *mem_pool)
virtual void deleteAllCategories()
static void set_category_factory(creator_function_t creator_function)
#define CORBA_EXCEPTION_INFO(x)
virtual bool connectPeers(TaskContext *peer)
size_t init_memory_pool(size_t mem_pool_size, void *mem_pool)
int main_args(lua_State *L, int argc, char **argv)
void destroy_memory_pool(void *mem_pool)
struct lua_State lua_State
int ORO_main(int argc, char **argv)
static log4cpp::Category * createOCLCategory(const std::string &name, log4cpp::Category *parent, log4cpp::Priority::Value priority)
basic_ostreams & endl(basic_ostreams &s)
static HierarchyMaintainer & getDefaultMaintainer()
bool exec_file(const std::string &file)
size_t get_used_size(void *mem_pool)
LuaStateHandle getLuaState()