diff options
author | David Walter Seikel | 2012-01-23 23:36:30 +1000 |
---|---|---|
committer | David Walter Seikel | 2012-01-23 23:36:30 +1000 |
commit | 6523585c66c04cea54df50013df8886b589847d8 (patch) | |
tree | 0b22aee7064166d88595eda260ca2d17c0773da5 /libraries/luajit-2.0/src/lj_tab.h | |
parent | Update the EFL to what I'm actually using, coz I'm using some stuff not yet r... (diff) | |
download | SledjHamr-6523585c66c04cea54df50013df8886b589847d8.zip SledjHamr-6523585c66c04cea54df50013df8886b589847d8.tar.gz SledjHamr-6523585c66c04cea54df50013df8886b589847d8.tar.bz2 SledjHamr-6523585c66c04cea54df50013df8886b589847d8.tar.xz |
Add luaproc and LuaJIT libraries.
Two versions of LuaJIT, the stable release, and the dev version. Try the dev version first, until ih fails badly.
Diffstat (limited to '')
-rw-r--r-- | libraries/luajit-2.0/src/lj_tab.h | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/libraries/luajit-2.0/src/lj_tab.h b/libraries/luajit-2.0/src/lj_tab.h new file mode 100644 index 0000000..76e96f1 --- /dev/null +++ b/libraries/luajit-2.0/src/lj_tab.h | |||
@@ -0,0 +1,67 @@ | |||
1 | /* | ||
2 | ** Table handling. | ||
3 | ** Copyright (C) 2005-2011 Mike Pall. See Copyright Notice in luajit.h | ||
4 | */ | ||
5 | |||
6 | #ifndef _LJ_TAB_H | ||
7 | #define _LJ_TAB_H | ||
8 | |||
9 | #include "lj_obj.h" | ||
10 | |||
11 | /* Hash constants. Tuned using a brute force search. */ | ||
12 | #define HASH_BIAS (-0x04c11db7) | ||
13 | #define HASH_ROT1 14 | ||
14 | #define HASH_ROT2 5 | ||
15 | #define HASH_ROT3 13 | ||
16 | |||
17 | /* Scramble the bits of numbers and pointers. */ | ||
18 | static LJ_AINLINE uint32_t hashrot(uint32_t lo, uint32_t hi) | ||
19 | { | ||
20 | #if LJ_TARGET_X86ORX64 | ||
21 | /* Prefer variant that compiles well for a 2-operand CPU. */ | ||
22 | lo ^= hi; hi = lj_rol(hi, HASH_ROT1); | ||
23 | lo -= hi; hi = lj_rol(hi, HASH_ROT2); | ||
24 | hi ^= lo; hi -= lj_rol(lo, HASH_ROT3); | ||
25 | #else | ||
26 | lo ^= hi; | ||
27 | lo = lo - lj_rol(hi, HASH_ROT1); | ||
28 | hi = lo ^ lj_rol(hi, HASH_ROT1 + HASH_ROT2); | ||
29 | hi = hi - lj_rol(lo, HASH_ROT3); | ||
30 | #endif | ||
31 | return hi; | ||
32 | } | ||
33 | |||
34 | #define hsize2hbits(s) ((s) ? ((s)==1 ? 1 : 1+lj_fls((uint32_t)((s)-1))) : 0) | ||
35 | |||
36 | LJ_FUNCA GCtab *lj_tab_new(lua_State *L, uint32_t asize, uint32_t hbits); | ||
37 | #if LJ_HASJIT | ||
38 | LJ_FUNC GCtab * LJ_FASTCALL lj_tab_new1(lua_State *L, uint32_t ahsize); | ||
39 | #endif | ||
40 | LJ_FUNCA GCtab * LJ_FASTCALL lj_tab_dup(lua_State *L, const GCtab *kt); | ||
41 | LJ_FUNC void LJ_FASTCALL lj_tab_free(global_State *g, GCtab *t); | ||
42 | LJ_FUNCA void lj_tab_reasize(lua_State *L, GCtab *t, uint32_t nasize); | ||
43 | |||
44 | /* Caveat: all getters except lj_tab_get() can return NULL! */ | ||
45 | |||
46 | LJ_FUNCA cTValue * LJ_FASTCALL lj_tab_getinth(GCtab *t, int32_t key); | ||
47 | LJ_FUNC cTValue *lj_tab_getstr(GCtab *t, GCstr *key); | ||
48 | LJ_FUNCA cTValue *lj_tab_get(lua_State *L, GCtab *t, cTValue *key); | ||
49 | |||
50 | /* Caveat: all setters require a write barrier for the stored value. */ | ||
51 | |||
52 | LJ_FUNCA TValue *lj_tab_newkey(lua_State *L, GCtab *t, cTValue *key); | ||
53 | LJ_FUNC TValue *lj_tab_setinth(lua_State *L, GCtab *t, int32_t key); | ||
54 | LJ_FUNC TValue *lj_tab_setstr(lua_State *L, GCtab *t, GCstr *key); | ||
55 | LJ_FUNC TValue *lj_tab_set(lua_State *L, GCtab *t, cTValue *key); | ||
56 | |||
57 | #define inarray(t, key) ((MSize)(key) < (MSize)(t)->asize) | ||
58 | #define arrayslot(t, i) (&tvref((t)->array)[(i)]) | ||
59 | #define lj_tab_getint(t, key) \ | ||
60 | (inarray((t), (key)) ? arrayslot((t), (key)) : lj_tab_getinth((t), (key))) | ||
61 | #define lj_tab_setint(L, t, key) \ | ||
62 | (inarray((t), (key)) ? arrayslot((t), (key)) : lj_tab_setinth(L, (t), (key))) | ||
63 | |||
64 | LJ_FUNCA int lj_tab_next(lua_State *L, GCtab *t, TValue *key); | ||
65 | LJ_FUNCA MSize LJ_FASTCALL lj_tab_len(GCtab *t); | ||
66 | |||
67 | #endif | ||