aboutsummaryrefslogtreecommitdiff
path: root/src/llthread.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/llthread.c')
-rw-r--r--src/llthread.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/llthread.c b/src/llthread.c
index 88d3805..27253e5 100644
--- a/src/llthread.c
+++ b/src/llthread.c
@@ -2,6 +2,11 @@
2# define USE_PTHREAD 2# define USE_PTHREAD
3#endif 3#endif
4 4
5#define LLTHREAD_VERSION_MAJOR 0
6#define LLTHREAD_VERSION_MINOR 1
7#define LLTHREAD_VERSION_PATCH 0
8#define LLTHREAD_VERSION_COMMENT "dev"
9
5#ifndef USE_PTHREAD 10#ifndef USE_PTHREAD
6# include <windows.h> 11# include <windows.h>
7# include <process.h> 12# include <process.h>
@@ -607,6 +612,40 @@ static const struct luaL_Reg l_llthread_meth[] = {
607 612
608//} 613//}
609 614
615//{ version
616
617static int l_llthread_version(lua_State *L){
618 lua_pushnumber(L, LLTHREAD_VERSION_MAJOR);
619 lua_pushnumber(L, LLTHREAD_VERSION_MINOR);
620 lua_pushnumber(L, LLTHREAD_VERSION_PATCH);
621#ifdef LLTHREAD_VERSION_COMMENT
622 if(LLTHREAD_VERSION_COMMENT[0]){
623 lua_pushliteral(L, LLTHREAD_VERSION_COMMENT);
624 return 4;
625 }
626#endif
627 return 3;
628}
629
630static int l_llthread_push_version(lua_State *L){
631 lua_pushnumber(L, LLTHREAD_VERSION_MAJOR);
632 lua_pushliteral(L, ".");
633 lua_pushnumber(L, LLTHREAD_VERSION_MINOR);
634 lua_pushliteral(L, ".");
635 lua_pushnumber(L, LLTHREAD_VERSION_PATCH);
636#ifdef LLTHREAD_VERSION_COMMENT
637 if(LLTHREAD_VERSION_COMMENT[0]){
638 lua_pushliteral(L, "-"LLTHREAD_VERSION_COMMENT);
639 lua_concat(L, 6);
640 }
641 else
642#endif
643 lua_concat(L, 5);
644 return 1;
645}
646
647//}
648
610static int l_llthread_set_logger(lua_State *L){ 649static int l_llthread_set_logger(lua_State *L){
611 lua_settop(L, 1); 650 lua_settop(L, 1);
612 luaL_argcheck(L, lua_isfunction(L, 1), 1, "function expected"); 651 luaL_argcheck(L, lua_isfunction(L, 1), 1, "function expected");
@@ -617,6 +656,7 @@ static int l_llthread_set_logger(lua_State *L){
617static const struct luaL_Reg l_llthreads_lib[] = { 656static const struct luaL_Reg l_llthreads_lib[] = {
618 {"new", l_llthread_new }, 657 {"new", l_llthread_new },
619 {"set_logger", l_llthread_set_logger }, 658 {"set_logger", l_llthread_set_logger },
659 {"version", l_llthread_version },
620 660
621 {NULL, NULL} 661 {NULL, NULL}
622}; 662};
@@ -628,5 +668,10 @@ LLTHREADS_EXPORT_API int LLTHREAD_OPEN_NAME(lua_State *L) {
628 668
629 lua_newtable(L); 669 lua_newtable(L);
630 luaL_setfuncs(L, l_llthreads_lib, 0); 670 luaL_setfuncs(L, l_llthreads_lib, 0);
671
672 lua_pushliteral(L, "_VERSION");
673 l_llthread_push_version(L);
674 lua_rawset(L, -3);
675
631 return 1; 676 return 1;
632} 677}