diff options
author | Mike Pall <mike> | 2012-07-07 20:36:35 +0200 |
---|---|---|
committer | Mike Pall <mike> | 2012-07-07 20:36:35 +0200 |
commit | 6a67fa8a4b2b038e0dca676303545da47f2b9773 (patch) | |
tree | 4e34a2e21e2a5a9b4a7a59056967f5920266db13 /src | |
parent | 7c056488d96434fc9996ba8b2b2a684f03472b62 (diff) | |
download | luajit-6a67fa8a4b2b038e0dca676303545da47f2b9773.tar.gz luajit-6a67fa8a4b2b038e0dca676303545da47f2b9773.tar.bz2 luajit-6a67fa8a4b2b038e0dca676303545da47f2b9773.zip |
Finally fix target detection for msvcbuild.bat.
Famous last words.
Diffstat (limited to 'src')
-rw-r--r-- | src/host/genminilua.lua | 4 | ||||
-rw-r--r-- | src/host/minilua.c | 204 | ||||
-rw-r--r-- | src/msvcbuild.bat | 20 |
3 files changed, 11 insertions, 217 deletions
diff --git a/src/host/genminilua.lua b/src/host/genminilua.lua index 7282cf16..587d5a8d 100644 --- a/src/host/genminilua.lua +++ b/src/host/genminilua.lua | |||
@@ -62,7 +62,7 @@ int main(int argc, char **argv){ | |||
62 | lua_State *L = luaL_newstate(); | 62 | lua_State *L = luaL_newstate(); |
63 | int i; | 63 | int i; |
64 | luaL_openlibs(L); | 64 | luaL_openlibs(L); |
65 | if (argc < 2) return 1; | 65 | if (argc < 2) return sizeof(void *); |
66 | lua_createtable(L, 0, 1); | 66 | lua_createtable(L, 0, 1); |
67 | lua_pushstring(L, argv[1]); | 67 | lua_pushstring(L, argv[1]); |
68 | lua_rawseti(L, -2, 0); | 68 | lua_rawseti(L, -2, 0); |
@@ -226,7 +226,7 @@ local function strip_unused3(src) | |||
226 | src = gsub(src, "trydecpoint%(ls,seminfo%)", | 226 | src = gsub(src, "trydecpoint%(ls,seminfo%)", |
227 | "luaX_lexerror(ls,\"malformed number\",TK_NUMBER)") | 227 | "luaX_lexerror(ls,\"malformed number\",TK_NUMBER)") |
228 | src = gsub(src, "int c=luaZ_lookahead%b();", "") | 228 | src = gsub(src, "int c=luaZ_lookahead%b();", "") |
229 | src = gsub(src, "luaL_register%(L,\"coroutine\",co_funcs%);\nreturn 2;", | 229 | src = gsub(src, "luaL_register%(L,[^,]*,co_funcs%);\nreturn 2;", |
230 | "return 1;") | 230 | "return 1;") |
231 | src = gsub(src, "getfuncname%b():", "NULL:") | 231 | src = gsub(src, "getfuncname%b():", "NULL:") |
232 | src = gsub(src, "getobjname%b():", "NULL:") | 232 | src = gsub(src, "getobjname%b():", "NULL:") |
diff --git a/src/host/minilua.c b/src/host/minilua.c index 4db07033..77e6349c 100644 --- a/src/host/minilua.c +++ b/src/host/minilua.c | |||
@@ -1198,56 +1198,6 @@ luaV_execute(L,1); | |||
1198 | L->nCcalls--; | 1198 | L->nCcalls--; |
1199 | luaC_checkGC(L); | 1199 | luaC_checkGC(L); |
1200 | } | 1200 | } |
1201 | static void resume(lua_State*L,void*ud){ | ||
1202 | StkId firstArg=cast(StkId,ud); | ||
1203 | CallInfo*ci=L->ci; | ||
1204 | if(L->status==0){ | ||
1205 | if(luaD_precall(L,firstArg-1,(-1))!=0) | ||
1206 | return; | ||
1207 | } | ||
1208 | else{ | ||
1209 | L->status=0; | ||
1210 | if(!f_isLua(ci)){ | ||
1211 | if(luaD_poscall(L,firstArg)) | ||
1212 | L->top=L->ci->top; | ||
1213 | } | ||
1214 | else | ||
1215 | L->base=L->ci->base; | ||
1216 | } | ||
1217 | luaV_execute(L,cast_int(L->ci-L->base_ci)); | ||
1218 | } | ||
1219 | static int resume_error(lua_State*L,const char*msg){ | ||
1220 | L->top=L->ci->base; | ||
1221 | setsvalue(L,L->top,luaS_new(L,msg)); | ||
1222 | incr_top(L); | ||
1223 | return 2; | ||
1224 | } | ||
1225 | static int lua_resume(lua_State*L,int nargs){ | ||
1226 | int status; | ||
1227 | if(L->status!=1&&(L->status!=0||L->ci!=L->base_ci)) | ||
1228 | return resume_error(L,"cannot resume non-suspended coroutine"); | ||
1229 | if(L->nCcalls>=200) | ||
1230 | return resume_error(L,"C stack overflow"); | ||
1231 | L->baseCcalls=++L->nCcalls; | ||
1232 | status=luaD_rawrunprotected(L,resume,L->top-nargs); | ||
1233 | if(status!=0){ | ||
1234 | L->status=cast_byte(status); | ||
1235 | luaD_seterrorobj(L,status,L->top); | ||
1236 | L->ci->top=L->top; | ||
1237 | } | ||
1238 | else{ | ||
1239 | status=L->status; | ||
1240 | } | ||
1241 | --L->nCcalls; | ||
1242 | return status; | ||
1243 | } | ||
1244 | static int lua_yield(lua_State*L,int nresults){ | ||
1245 | if(L->nCcalls>L->baseCcalls) | ||
1246 | luaG_runerror(L,"attempt to yield across metamethod/C-call boundary"); | ||
1247 | L->base=L->top-nresults; | ||
1248 | L->status=1; | ||
1249 | return-1; | ||
1250 | } | ||
1251 | static int luaD_pcall(lua_State*L,Pfunc func,void*u, | 1201 | static int luaD_pcall(lua_State*L,Pfunc func,void*u, |
1252 | ptrdiff_t old_top,ptrdiff_t ef){ | 1202 | ptrdiff_t old_top,ptrdiff_t ef){ |
1253 | int status; | 1203 | int status; |
@@ -2362,18 +2312,6 @@ luaZ_freebuffer(L,&g->buff); | |||
2362 | freestack(L,L); | 2312 | freestack(L,L); |
2363 | (*g->frealloc)(g->ud,fromstate(L),state_size(LG),0); | 2313 | (*g->frealloc)(g->ud,fromstate(L),state_size(LG),0); |
2364 | } | 2314 | } |
2365 | static lua_State*luaE_newthread(lua_State*L){ | ||
2366 | lua_State*L1=tostate(luaM_malloc(L,state_size(lua_State))); | ||
2367 | luaC_link(L,obj2gco(L1),8); | ||
2368 | preinit_state(L1,G(L)); | ||
2369 | stack_init(L1,L); | ||
2370 | setobj(L,gt(L1),gt(L)); | ||
2371 | L1->hookmask=L->hookmask; | ||
2372 | L1->basehookcount=L->basehookcount; | ||
2373 | L1->hook=L->hook; | ||
2374 | resethookcount(L1); | ||
2375 | return L1; | ||
2376 | } | ||
2377 | static void luaE_freethread(lua_State*L,lua_State*L1){ | 2315 | static void luaE_freethread(lua_State*L,lua_State*L1){ |
2378 | luaF_close(L1,L1->stack); | 2316 | luaF_close(L1,L1->stack); |
2379 | freestack(L,L1); | 2317 | freestack(L,L1); |
@@ -5413,34 +5351,12 @@ L->ci->top=L->top+size; | |||
5413 | } | 5351 | } |
5414 | return res; | 5352 | return res; |
5415 | } | 5353 | } |
5416 | static void lua_xmove(lua_State*from,lua_State*to,int n){ | ||
5417 | int i; | ||
5418 | if(from==to)return; | ||
5419 | api_checknelems(from,n); | ||
5420 | luai_apicheck(from,G(from)==G(to)); | ||
5421 | luai_apicheck(from,to->ci->top-to->top>=n); | ||
5422 | from->top-=n; | ||
5423 | for(i=0;i<n;i++){ | ||
5424 | setobj(to,to->top++,from->top+i); | ||
5425 | } | ||
5426 | } | ||
5427 | static void lua_setlevel(lua_State*from,lua_State*to){ | ||
5428 | to->nCcalls=from->nCcalls; | ||
5429 | } | ||
5430 | static lua_CFunction lua_atpanic(lua_State*L,lua_CFunction panicf){ | 5354 | static lua_CFunction lua_atpanic(lua_State*L,lua_CFunction panicf){ |
5431 | lua_CFunction old; | 5355 | lua_CFunction old; |
5432 | old=G(L)->panic; | 5356 | old=G(L)->panic; |
5433 | G(L)->panic=panicf; | 5357 | G(L)->panic=panicf; |
5434 | return old; | 5358 | return old; |
5435 | } | 5359 | } |
5436 | static lua_State*lua_newthread(lua_State*L){ | ||
5437 | lua_State*L1; | ||
5438 | luaC_checkGC(L); | ||
5439 | L1=luaE_newthread(L); | ||
5440 | setthvalue(L,L->top,L1); | ||
5441 | api_incr_top(L); | ||
5442 | return L1; | ||
5443 | } | ||
5444 | static int lua_gettop(lua_State*L){ | 5360 | static int lua_gettop(lua_State*L){ |
5445 | return cast_int(L->top-L->base); | 5361 | return cast_int(L->top-L->base); |
5446 | } | 5362 | } |
@@ -5594,10 +5510,6 @@ case 2:return pvalue(o); | |||
5594 | default:return NULL; | 5510 | default:return NULL; |
5595 | } | 5511 | } |
5596 | } | 5512 | } |
5597 | static lua_State*lua_tothread(lua_State*L,int idx){ | ||
5598 | StkId o=index2adr(L,idx); | ||
5599 | return(!ttisthread(o))?NULL:thvalue(o); | ||
5600 | } | ||
5601 | static void lua_pushnil(lua_State*L){ | 5513 | static void lua_pushnil(lua_State*L){ |
5602 | setnilvalue(L->top); | 5514 | setnilvalue(L->top); |
5603 | api_incr_top(L); | 5515 | api_incr_top(L); |
@@ -5876,9 +5788,6 @@ luaZ_init(L,&z,reader,data); | |||
5876 | status=luaD_protectedparser(L,&z,chunkname); | 5788 | status=luaD_protectedparser(L,&z,chunkname); |
5877 | return status; | 5789 | return status; |
5878 | } | 5790 | } |
5879 | static int lua_status(lua_State*L){ | ||
5880 | return L->status; | ||
5881 | } | ||
5882 | static int lua_error(lua_State*L){ | 5791 | static int lua_error(lua_State*L){ |
5883 | api_checknelems(L,1); | 5792 | api_checknelems(L,1); |
5884 | luaG_errormsg(L); | 5793 | luaG_errormsg(L); |
@@ -6508,114 +6417,6 @@ static const luaL_Reg base_funcs[]={ | |||
6508 | {"unpack",luaB_unpack}, | 6417 | {"unpack",luaB_unpack}, |
6509 | {NULL,NULL} | 6418 | {NULL,NULL} |
6510 | }; | 6419 | }; |
6511 | static const char*const statnames[]= | ||
6512 | {"running","suspended","normal","dead"}; | ||
6513 | static int costatus(lua_State*L,lua_State*co){ | ||
6514 | if(L==co)return 0; | ||
6515 | switch(lua_status(co)){ | ||
6516 | case 1: | ||
6517 | return 1; | ||
6518 | case 0:{ | ||
6519 | lua_Debug ar; | ||
6520 | if(lua_getstack(co,0,&ar)>0) | ||
6521 | return 2; | ||
6522 | else if(lua_gettop(co)==0) | ||
6523 | return 3; | ||
6524 | else | ||
6525 | return 1; | ||
6526 | } | ||
6527 | default: | ||
6528 | return 3; | ||
6529 | } | ||
6530 | } | ||
6531 | static int luaB_costatus(lua_State*L){ | ||
6532 | lua_State*co=lua_tothread(L,1); | ||
6533 | luaL_argcheck(L,co,1,"coroutine expected"); | ||
6534 | lua_pushstring(L,statnames[costatus(L,co)]); | ||
6535 | return 1; | ||
6536 | } | ||
6537 | static int auxresume(lua_State*L,lua_State*co,int narg){ | ||
6538 | int status=costatus(L,co); | ||
6539 | if(!lua_checkstack(co,narg)) | ||
6540 | luaL_error(L,"too many arguments to resume"); | ||
6541 | if(status!=1){ | ||
6542 | lua_pushfstring(L,"cannot resume %s coroutine",statnames[status]); | ||
6543 | return-1; | ||
6544 | } | ||
6545 | lua_xmove(L,co,narg); | ||
6546 | lua_setlevel(L,co); | ||
6547 | status=lua_resume(co,narg); | ||
6548 | if(status==0||status==1){ | ||
6549 | int nres=lua_gettop(co); | ||
6550 | if(!lua_checkstack(L,nres+1)) | ||
6551 | luaL_error(L,"too many results to resume"); | ||
6552 | lua_xmove(co,L,nres); | ||
6553 | return nres; | ||
6554 | } | ||
6555 | else{ | ||
6556 | lua_xmove(co,L,1); | ||
6557 | return-1; | ||
6558 | } | ||
6559 | } | ||
6560 | static int luaB_coresume(lua_State*L){ | ||
6561 | lua_State*co=lua_tothread(L,1); | ||
6562 | int r; | ||
6563 | luaL_argcheck(L,co,1,"coroutine expected"); | ||
6564 | r=auxresume(L,co,lua_gettop(L)-1); | ||
6565 | if(r<0){ | ||
6566 | lua_pushboolean(L,0); | ||
6567 | lua_insert(L,-2); | ||
6568 | return 2; | ||
6569 | } | ||
6570 | else{ | ||
6571 | lua_pushboolean(L,1); | ||
6572 | lua_insert(L,-(r+1)); | ||
6573 | return r+1; | ||
6574 | } | ||
6575 | } | ||
6576 | static int luaB_auxwrap(lua_State*L){ | ||
6577 | lua_State*co=lua_tothread(L,lua_upvalueindex(1)); | ||
6578 | int r=auxresume(L,co,lua_gettop(L)); | ||
6579 | if(r<0){ | ||
6580 | if(lua_isstring(L,-1)){ | ||
6581 | luaL_where(L,1); | ||
6582 | lua_insert(L,-2); | ||
6583 | lua_concat(L,2); | ||
6584 | } | ||
6585 | lua_error(L); | ||
6586 | } | ||
6587 | return r; | ||
6588 | } | ||
6589 | static int luaB_cocreate(lua_State*L){ | ||
6590 | lua_State*NL=lua_newthread(L); | ||
6591 | luaL_argcheck(L,lua_isfunction(L,1)&&!lua_iscfunction(L,1),1, | ||
6592 | "Lua function expected"); | ||
6593 | lua_pushvalue(L,1); | ||
6594 | lua_xmove(L,NL,1); | ||
6595 | return 1; | ||
6596 | } | ||
6597 | static int luaB_cowrap(lua_State*L){ | ||
6598 | luaB_cocreate(L); | ||
6599 | lua_pushcclosure(L,luaB_auxwrap,1); | ||
6600 | return 1; | ||
6601 | } | ||
6602 | static int luaB_yield(lua_State*L){ | ||
6603 | return lua_yield(L,lua_gettop(L)); | ||
6604 | } | ||
6605 | static int luaB_corunning(lua_State*L){ | ||
6606 | if(lua_pushthread(L)) | ||
6607 | lua_pushnil(L); | ||
6608 | return 1; | ||
6609 | } | ||
6610 | static const luaL_Reg co_funcs[]={ | ||
6611 | {"create",luaB_cocreate}, | ||
6612 | {"resume",luaB_coresume}, | ||
6613 | {"running",luaB_corunning}, | ||
6614 | {"status",luaB_costatus}, | ||
6615 | {"wrap",luaB_cowrap}, | ||
6616 | {"yield",luaB_yield}, | ||
6617 | {NULL,NULL} | ||
6618 | }; | ||
6619 | static void auxopen(lua_State*L,const char*name, | 6420 | static void auxopen(lua_State*L,const char*name, |
6620 | lua_CFunction f,lua_CFunction u){ | 6421 | lua_CFunction f,lua_CFunction u){ |
6621 | lua_pushcfunction(L,u); | 6422 | lua_pushcfunction(L,u); |
@@ -6640,8 +6441,7 @@ lua_setglobal(L,"newproxy"); | |||
6640 | } | 6441 | } |
6641 | static int luaopen_base(lua_State*L){ | 6442 | static int luaopen_base(lua_State*L){ |
6642 | base_open(L); | 6443 | base_open(L); |
6643 | luaL_register(L,"coroutine",co_funcs); | 6444 | return 1; |
6644 | return 2; | ||
6645 | } | 6445 | } |
6646 | #define aux_getn(L,n)(luaL_checktype(L,n,5),luaL_getn(L,n)) | 6446 | #define aux_getn(L,n)(luaL_checktype(L,n,5),luaL_getn(L,n)) |
6647 | static int tinsert(lua_State*L){ | 6447 | static int tinsert(lua_State*L){ |
@@ -7887,7 +7687,7 @@ int main(int argc,char**argv){ | |||
7887 | lua_State*L=luaL_newstate(); | 7687 | lua_State*L=luaL_newstate(); |
7888 | int i; | 7688 | int i; |
7889 | luaL_openlibs(L); | 7689 | luaL_openlibs(L); |
7890 | if(argc<2)return 1; | 7690 | if(argc<2)return sizeof(void*); |
7891 | lua_createtable(L,0,1); | 7691 | lua_createtable(L,0,1); |
7892 | lua_pushstring(L,argv[1]); | 7692 | lua_pushstring(L,argv[1]); |
7893 | lua_rawseti(L,-2,0); | 7693 | lua_rawseti(L,-2,0); |
diff --git a/src/msvcbuild.bat b/src/msvcbuild.bat index a5ae16ac..ba5230ec 100644 --- a/src/msvcbuild.bat +++ b/src/msvcbuild.bat | |||
@@ -29,20 +29,14 @@ | |||
29 | if exist minilua.exe.manifest^ | 29 | if exist minilua.exe.manifest^ |
30 | %LJMT% -manifest minilua.exe.manifest -outputresource:minilua.exe | 30 | %LJMT% -manifest minilua.exe.manifest -outputresource:minilua.exe |
31 | 31 | ||
32 | @set DASMFLAGS=-D WIN -D JIT -D FFI -D P64 | ||
33 | @set LJARCH=x64 | ||
34 | @minilua | ||
35 | @if errorlevel 8 goto :X64 | ||
32 | @set DASMFLAGS=-D WIN -D JIT -D FFI | 36 | @set DASMFLAGS=-D WIN -D JIT -D FFI |
33 | @set DASMX64=-D P64 | 37 | @set LJARCH=x86 |
34 | @if "%TARGET_CPU%"=="AMD64" goto :X64 | ||
35 | @if "%TARGET_CPU%"=="X64" goto :X64 | ||
36 | @if "%TARGET_CPU%"=="x64" goto :X64 | ||
37 | @if "%CPU%"=="AMD64" goto :X64 | ||
38 | @if "%CPU%"=="X64" goto :X64 | ||
39 | @if "%CPU%"=="x64" goto :X64 | ||
40 | @if "%Platform%"=="AMD64" goto :X64 | ||
41 | @if "%Platform%"=="X64" goto :X64 | ||
42 | @if "%Platform%"=="x64" goto :X64 | ||
43 | @set DASMX64= | ||
44 | :X64 | 38 | :X64 |
45 | minilua %DASM% -LN %DASMFLAGS% %DASMX64% -o host\buildvm_arch.h vm_x86.dasc | 39 | minilua %DASM% -LN %DASMFLAGS% -o host\buildvm_arch.h vm_x86.dasc |
46 | @if errorlevel 1 goto :BAD | 40 | @if errorlevel 1 goto :BAD |
47 | 41 | ||
48 | %LJCOMPILE% /I "." /I %DASMDIR% host\buildvm*.c | 42 | %LJCOMPILE% /I "." /I %DASMDIR% host\buildvm*.c |
@@ -103,7 +97,7 @@ if exist luajit.exe.manifest^ | |||
103 | 97 | ||
104 | @del *.obj *.manifest minilua.exe buildvm.exe | 98 | @del *.obj *.manifest minilua.exe buildvm.exe |
105 | @echo. | 99 | @echo. |
106 | @echo === Successfully built LuaJIT === | 100 | @echo === Successfully built LuaJIT for Windows/%LJARCH% === |
107 | 101 | ||
108 | @goto :END | 102 | @goto :END |
109 | :BAD | 103 | :BAD |