diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2009-07-01 13:16:40 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2009-07-01 13:16:40 -0300 |
| commit | 3abe3da9fb9baf24e4e9e1cfb0212cce00d70fee (patch) | |
| tree | 472484d4d48fef9c7ecc143d1eb88f608a93ad4a | |
| parent | eb8499c8e03b96071b40b6659f72391f1c6a2a12 (diff) | |
| download | lua-3abe3da9fb9baf24e4e9e1cfb0212cce00d70fee.tar.gz lua-3abe3da9fb9baf24e4e9e1cfb0212cce00d70fee.tar.bz2 lua-3abe3da9fb9baf24e4e9e1cfb0212cce00d70fee.zip | |
new module 'lbitlib.c' for bitwise operations
| -rw-r--r-- | linit.c | 3 | ||||
| -rw-r--r-- | luaconf.h | 50 | ||||
| -rw-r--r-- | lualib.h | 5 | ||||
| -rw-r--r-- | makefile | 3 |
4 files changed, 38 insertions, 23 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: linit.c,v 1.17 2009/05/01 13:37:11 roberto Exp roberto $ | 2 | ** $Id: linit.c,v 1.18 2009/05/01 13:46:35 roberto Exp roberto $ |
| 3 | ** Initialization of libraries for lua.c | 3 | ** Initialization of libraries for lua.c |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -24,6 +24,7 @@ static const luaL_Reg loadedlibs[] = { | |||
| 24 | {LUA_IOLIBNAME, luaopen_io}, | 24 | {LUA_IOLIBNAME, luaopen_io}, |
| 25 | {LUA_OSLIBNAME, luaopen_os}, | 25 | {LUA_OSLIBNAME, luaopen_os}, |
| 26 | {LUA_STRLIBNAME, luaopen_string}, | 26 | {LUA_STRLIBNAME, luaopen_string}, |
| 27 | {LUA_BITLIBNAME, luaopen_bit}, | ||
| 27 | {LUA_MATHLIBNAME, luaopen_math}, | 28 | {LUA_MATHLIBNAME, luaopen_math}, |
| 28 | {NULL, NULL} | 29 | {NULL, NULL} |
| 29 | }; | 30 | }; |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: luaconf.h,v 1.104 2009/03/26 12:57:01 roberto Exp roberto $ | 2 | ** $Id: luaconf.h,v 1.105 2009/06/18 18:19:36 roberto Exp roberto $ |
| 3 | ** Configuration file for Lua | 3 | ** Configuration file for Lua |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -142,14 +142,6 @@ | |||
| 142 | 142 | ||
| 143 | 143 | ||
| 144 | /* | 144 | /* |
| 145 | @@ LUA_INTEGER is the integral type used by lua_pushinteger/lua_tointeger. | ||
| 146 | ** CHANGE that if ptrdiff_t is not adequate on your machine. (On most | ||
| 147 | ** machines, ptrdiff_t gives a good choice between int or long.) | ||
| 148 | */ | ||
| 149 | #define LUA_INTEGER ptrdiff_t | ||
| 150 | |||
| 151 | |||
| 152 | /* | ||
| 153 | @@ LUA_API is a mark for all core API functions. | 145 | @@ LUA_API is a mark for all core API functions. |
| 154 | @@ LUALIB_API is a mark for all standard library functions. | 146 | @@ LUALIB_API is a mark for all standard library functions. |
| 155 | ** CHANGE them if you need to define those functions in some special way. | 147 | ** CHANGE them if you need to define those functions in some special way. |
| @@ -403,24 +395,22 @@ | |||
| 403 | 395 | ||
| 404 | 396 | ||
| 405 | /* | 397 | /* |
| 406 | @@ LUAI_UINT32 is an unsigned integer with at least 32 bits. | 398 | @@ LUA_INT32 is an signed integer with exactly 32 bits. |
| 407 | @@ LUAI_INT32 is an signed integer with at least 32 bits. | ||
| 408 | @@ LUAI_UMEM is an unsigned integer big enough to count the total | 399 | @@ LUAI_UMEM is an unsigned integer big enough to count the total |
| 409 | @* memory used by Lua. | 400 | @* memory used by Lua. |
| 410 | @@ LUAI_MEM is a signed integer big enough to count the total memory | 401 | @@ LUAI_MEM is a signed integer big enough to count the total memory |
| 411 | @* used by Lua. | 402 | @* used by Lua. |
| 412 | ** CHANGE here if for some weird reason the default definitions are not | 403 | ** CHANGE here if for some weird reason the default definitions are not |
| 413 | ** good enough for your machine. (The definitions in the 'else' | 404 | ** good enough for your machine. Probably you do not need to change |
| 414 | ** part always works, but may waste space on machines with 64-bit | 405 | ** this. |
| 415 | ** longs.) Probably you do not need to change this. | ||
| 416 | */ | 406 | */ |
| 417 | #if LUAI_BITSINT >= 32 | 407 | #if LUAI_BITSINT >= 32 |
| 418 | #define LUAI_UINT32 unsigned int | 408 | #define LUA_INT32 int |
| 419 | #define LUAI_UMEM size_t | 409 | #define LUAI_UMEM size_t |
| 420 | #define LUAI_MEM ptrdiff_t | 410 | #define LUAI_MEM ptrdiff_t |
| 421 | #else | 411 | #else |
| 422 | /* 16-bit ints */ | 412 | /* 16-bit ints */ |
| 423 | #define LUAI_UINT32 unsigned long | 413 | #define LUA_INT32 long |
| 424 | #define LUAI_UMEM unsigned long | 414 | #define LUAI_UMEM unsigned long |
| 425 | #define LUAI_MEM long | 415 | #define LUAI_MEM long |
| 426 | #endif | 416 | #endif |
| @@ -553,8 +543,20 @@ | |||
| 553 | 543 | ||
| 554 | 544 | ||
| 555 | /* | 545 | /* |
| 546 | @@ LUA_INTEGER is the integral type used by lua_pushinteger/lua_tointeger. | ||
| 547 | ** CHANGE that if ptrdiff_t is not adequate on your machine. (On most | ||
| 548 | ** machines, ptrdiff_t gives a good choice between int or long.) | ||
| 549 | */ | ||
| 550 | #define LUA_INTEGER ptrdiff_t | ||
| 551 | |||
| 552 | |||
| 553 | /* | ||
| 556 | @@ lua_number2int is a macro to convert lua_Number to int. | 554 | @@ lua_number2int is a macro to convert lua_Number to int. |
| 557 | @@ lua_number2integer is a macro to convert lua_Number to lua_Integer. | 555 | @@ lua_number2integer is a macro to convert lua_Number to lUA_INTEGER. |
| 556 | @@ lua_number2uint is a macro to convert a lua_Number to an unsigned | ||
| 557 | @* LUA_INT32. | ||
| 558 | @@ lua_uint2number is a macro to convert an unsigned LUA_INT32 | ||
| 559 | @* to a lua_Number. | ||
| 558 | ** CHANGE them if you know a faster way to convert a lua_Number to | 560 | ** CHANGE them if you know a faster way to convert a lua_Number to |
| 559 | ** int (with any rounding method and without throwing errors) in your | 561 | ** int (with any rounding method and without throwing errors) in your |
| 560 | ** system. In Pentium machines, a naive typecast from double to int | 562 | ** system. In Pentium machines, a naive typecast from double to int |
| @@ -571,25 +573,33 @@ | |||
| 571 | #define lua_number2int(i,d) __asm fld d __asm fistp i | 573 | #define lua_number2int(i,d) __asm fld d __asm fistp i |
| 572 | #define lua_number2integer(i,n) lua_number2int(i, n) | 574 | #define lua_number2integer(i,n) lua_number2int(i, n) |
| 573 | 575 | ||
| 576 | #else | ||
| 574 | /* the next trick should work on any Pentium, but sometimes clashes | 577 | /* the next trick should work on any Pentium, but sometimes clashes |
| 575 | with a DirectX idiosyncrasy */ | 578 | with a DirectX idiosyncrasy */ |
| 576 | #else | ||
| 577 | 579 | ||
| 578 | union luai_Cast { double l_d; long l_l; }; | 580 | union luai_Cast { double l_d; long l_l; }; |
| 579 | #define lua_number2int(i,d) \ | 581 | #define lua_number2int(i,d) \ |
| 580 | { volatile union luai_Cast u; u.l_d = (d) + 6755399441055744.0; (i) = u.l_l; } | 582 | { volatile union luai_Cast u; u.l_d = (d) + 6755399441055744.0; (i) = u.l_l; } |
| 581 | #define lua_number2integer(i,n) lua_number2int(i, n) | 583 | #define lua_number2integer(i,n) lua_number2int(i, n) |
| 584 | #define lua_number2uint(i,n) lua_number2int(i, n) | ||
| 582 | 585 | ||
| 583 | #endif | 586 | #endif |
| 584 | 587 | ||
| 585 | 588 | ||
| 586 | /* this option always works, but may be slow */ | ||
| 587 | #else | 589 | #else |
| 590 | /* this option always works, but may be slow */ | ||
| 588 | #define lua_number2int(i,d) ((i)=(int)(d)) | 591 | #define lua_number2int(i,d) ((i)=(int)(d)) |
| 589 | #define lua_number2integer(i,d) ((i)=(lua_Integer)(d)) | 592 | #define lua_number2integer(i,d) ((i)=(LUA_INTEGER)(d)) |
| 593 | #define lua_number2uint(i,d) ((i)=(unsigned LUA_INT32)(d)) | ||
| 590 | 594 | ||
| 591 | #endif | 595 | #endif |
| 592 | 596 | ||
| 597 | |||
| 598 | /* on several machines, coercion from unsigned to double is too slow, | ||
| 599 | so avoid that if possible */ | ||
| 600 | #define lua_uint2number(u) \ | ||
| 601 | ((LUA_INT32)(u) < 0 ? (lua_Number)(u) : (lua_Number)(LUA_INT32)(u)) | ||
| 602 | |||
| 593 | /* }================================================================== */ | 603 | /* }================================================================== */ |
| 594 | 604 | ||
| 595 | 605 | ||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lualib.h,v 1.36 2005/12/27 17:12:00 roberto Exp roberto $ | 2 | ** $Id: lualib.h,v 1.37 2006/09/11 14:07:24 roberto Exp roberto $ |
| 3 | ** Lua standard libraries | 3 | ** Lua standard libraries |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -30,6 +30,9 @@ LUALIB_API int (luaopen_os) (lua_State *L); | |||
| 30 | #define LUA_STRLIBNAME "string" | 30 | #define LUA_STRLIBNAME "string" |
| 31 | LUALIB_API int (luaopen_string) (lua_State *L); | 31 | LUALIB_API int (luaopen_string) (lua_State *L); |
| 32 | 32 | ||
| 33 | #define LUA_BITLIBNAME "bit" | ||
| 34 | LUALIB_API int (luaopen_bit) (lua_State *L); | ||
| 35 | |||
| 33 | #define LUA_MATHLIBNAME "math" | 36 | #define LUA_MATHLIBNAME "math" |
| 34 | LUALIB_API int (luaopen_math) (lua_State *L); | 37 | LUALIB_API int (luaopen_math) (lua_State *L); |
| 35 | 38 | ||
| @@ -59,7 +59,7 @@ CORE_O= lapi.o lcode.o lctype.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o \ | |||
| 59 | ltm.o lundump.o lvm.o lzio.o ltests.o | 59 | ltm.o lundump.o lvm.o lzio.o ltests.o |
| 60 | AUX_O= lauxlib.o | 60 | AUX_O= lauxlib.o |
| 61 | LIB_O= lbaselib.o ldblib.o liolib.o lmathlib.o loslib.o ltablib.o lstrlib.o \ | 61 | LIB_O= lbaselib.o ldblib.o liolib.o lmathlib.o loslib.o ltablib.o lstrlib.o \ |
| 62 | loadlib.o linit.o | 62 | lbitlib.o loadlib.o linit.o |
| 63 | 63 | ||
| 64 | LUA_T= lua | 64 | LUA_T= lua |
| 65 | LUA_O= lua.o | 65 | LUA_O= lua.o |
| @@ -112,6 +112,7 @@ lapi.o: lapi.c lua.h luaconf.h lapi.h llimits.h lstate.h lobject.h ltm.h \ | |||
| 112 | lvm.h makefile | 112 | lvm.h makefile |
| 113 | lauxlib.o: lauxlib.c lua.h luaconf.h lauxlib.h makefile | 113 | lauxlib.o: lauxlib.c lua.h luaconf.h lauxlib.h makefile |
| 114 | lbaselib.o: lbaselib.c lua.h luaconf.h lauxlib.h lualib.h makefile | 114 | lbaselib.o: lbaselib.c lua.h luaconf.h lauxlib.h lualib.h makefile |
| 115 | lbitlib.o: lbitlib.c lua.h luaconf.h lauxlib.h lualib.h makefile | ||
| 115 | lcode.o: lcode.c lua.h luaconf.h lcode.h llex.h lobject.h llimits.h \ | 116 | lcode.o: lcode.c lua.h luaconf.h lcode.h llex.h lobject.h llimits.h \ |
| 116 | lzio.h lmem.h lopcodes.h lparser.h ldebug.h lstate.h ltm.h ldo.h lgc.h \ | 117 | lzio.h lmem.h lopcodes.h lparser.h ldebug.h lstate.h ltm.h ldo.h lgc.h \ |
| 117 | ltable.h makefile | 118 | ltable.h makefile |
