int _tmain(int argc, _TCHAR* argv[]) { if(argc < 2){ printf("ObjctScript " OS_VERSION " Copyright (C) 2012 Evgeniy Golovin ([email protected])\n"); printf("Latest version and source code: https://github.com/unitpoint/objectscript\n"); printf("\n"); printf("Usage: %s script [args]\n", argv[0]); exit(1); } // craete ObjectScript instance OS * os = OS::create(); // save allocated memory at start point int start_mem_usage = os->getAllocatedBytes(); // set needed settings os->setSetting(OS_SETTING_CREATE_DEBUG_INFO, true); os->setSetting(OS_SETTING_CREATE_DEBUG_OPCODES, true); os->setSetting(OS_SETTING_CREATE_COMPILED_FILE, true); // create program arguments os->newObject(); for(int i = 0; i < argc; i++){ os->pushStackValue(-1); os->pushNumber(i-1); os->pushString(getString(os, argv[i])); os->setProperty(); } // we can use the program arguments as global arg variable inside of our script os->setGlobal("arg"); // set global getTimeSec function so we can check time inside of our script os->setGlobal(def("getTimeSec", getTimeSec)); // run main stript // os->require("c:\\Sources\\OS\\proj.win32\\profile_benchmark\\scripts\\n-body.os"); // getString(os, argv[1])); // os->require("c:\\Sources\\OS\\unit-tests-os\\operators.os"); // getString(os, argv[1])); // os->require(getString(os, argv[1])); os->require(getString(os, argv[1]), true, 0, OS_SOURCECODE_AUTO); { int mem_allocated = os->getAllocatedBytes()/1024; int mem_cached = os->getCachedBytes()/1024; // run gc full step os->gcFull(); int after_mem_allocated = os->getAllocatedBytes()/1024; int after_mem_cached = os->getCachedBytes()/1024; // output some debug memory usage info printf("\n\n[before GC] memory used: %d Kb, cached: %d Kb, allocated: %d Kb\n[after GC] memory used: %d Kb, cached: %d Kb, allocated: %d Kb\n", mem_allocated - mem_cached, mem_cached, mem_allocated, after_mem_allocated - after_mem_cached, after_mem_cached, after_mem_allocated ); #ifdef OS_DEBUG printf("\nNotice: debug build uses much more memory than release build\n"); #endif } // release the ObjectScript instance os->release(); return 0; }
int _tmain(int argc, _TCHAR* argv[]) { // craete ObjectScript instance OS * os = OS::create(); // run program os->require("../../examples-os/run_os_prog.os"); // release the ObjectScript instance os->release(); return 0; }
int _tmain(int argc, _TCHAR* argv[]) { // craete ObjectScript instance OS * os = OS::create(); registerTestClass(os); registerNewTestClass(os); initMyModule(os); os->setGlobal(def("getcwd", getcwdString)); os->setGlobal(def("printTestStruct", printTestStruct)); os->setGlobal(def("changeTestStruct", changeTestStruct)); // run program os->require("../../examples-os/bind.os"); // release the ObjectScript instance os->release(); return 0; }
int main(int argc, char * argv[]) #endif { initStartTime(); printf("ObjectScript FastCGI Process Manager %s\n", OS_FCGI_VERSION); printf("%s\n", OS_COPYRIGHT); printf("%s\n", OS_OPENSOURCE); if(FCGX_Init()){ // #ifdef _MSC_VER printf("Error: initialization is failed\n"); // #endif exit(1); } int threads; { OS * os = OS::create(); #ifdef _MSC_VER const char * config_flename = "conf\\etc\\os-fcgi\\conf.os"; if(!os->isFileExist(config_flename)){ config_flename = "..\\..\\conf\\etc\\os-fcgi\\conf.os"; // os->isFileExist(config_flename); } #else const char * config_flename = "/etc/os-fcgi/conf.os"; #endif os->require(config_flename, false, 1); threads = (os->getProperty(-1, "threads"), os->popInt()); OS::String listen = (os->getProperty(-1, "listen"), os->popString(":9000")); os->release(); int listen_queue_backlog = 400; listen_socket = FCGX_OpenSocket(listen, listen_queue_backlog); if(listen_socket < 0){ printf("Error: listen address is incorrect %s\n", listen.toChar()); // log("listen_socket < 0 \n"); exit(1); } // #ifdef _MSC_VER printf("listen: %s\n", listen.toChar()); // #endif } #ifndef _MSC_VER const int MAX_THREAD_COUNT = 64; if(threads < 1){ threads = 1; }else if(threads > MAX_THREAD_COUNT){ threads = MAX_THREAD_COUNT; } printf("threads: %d\n", threads); demonize(); pthread_t id[MAX_THREAD_COUNT]; for(int i = 1; i < threads; i++){ pthread_create(&id[i], NULL, doit, NULL); } #else threads = 1; printf("threads: %d\n", threads); #endif doit(NULL); return 0; }