summaryrefslogtreecommitdiff
path: root/src/lj_ctype.h
diff options
context:
space:
mode:
authorMike Pall <mike>2011-11-14 14:15:57 +0100
committerMike Pall <mike>2011-11-14 14:18:25 +0100
commit71d00a56dbab6c29c0346093dbe530d7b7608be4 (patch)
tree5e28e19b4d2f20168d5ee0e4fe500b1e2b233c1c /src/lj_ctype.h
parente9eb4fdb4a08baaa2d9190187a6c38d5b3f8b091 (diff)
downloadluajit2-71d00a56dbab6c29c0346093dbe530d7b7608be4.tar.gz
FFI: Add callback support (for x86/x64).
Diffstat (limited to 'src/lj_ctype.h')
-rw-r--r--src/lj_ctype.h22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/lj_ctype.h b/src/lj_ctype.h
index 49f28108..da313851 100644
--- a/src/lj_ctype.h
+++ b/src/lj_ctype.h
@@ -151,6 +151,25 @@ typedef struct CType {
#define CTHASH_SIZE 128 /* Number of hash anchors. */
#define CTHASH_MASK (CTHASH_SIZE-1)
+/* Simplify target-specific configuration. Checked in lj_ccall.h. */
+#define CCALL_MAX_GPR 8
+#define CCALL_MAX_FPR 8
+
+typedef LJ_ALIGN(8) union FPRCBArg { double d; float f; } FPRCBArg;
+
+/* C callback state. Defined here, to avoid dragging in lj_ccall.h. */
+
+typedef LJ_ALIGN(8) struct CCallback {
+ FPRCBArg fpr[CCALL_MAX_FPR]; /* Arguments/results in FPRs. */
+ intptr_t gpr[CCALL_MAX_GPR]; /* Arguments/results in GPRs. */
+ intptr_t *stack; /* Pointer to arguments on stack. */
+ void *mcode; /* Machine code for callback func. pointers. */
+ CTypeID1 *cbid; /* Callback type table. */
+ MSize sizeid; /* Size of callback type table. */
+ MSize topid; /* Highest unused callback type table slot. */
+ MSize slot; /* Current callback slot. */
+} CCallback;
+
/* C type state. */
typedef struct CTState {
CType *tab; /* C type table. */
@@ -159,7 +178,8 @@ typedef struct CTState {
lua_State *L; /* Lua state (needed for errors and allocations). */
global_State *g; /* Global state. */
GCtab *finalizer; /* Map of cdata to finalizer. */
- GCtab *metatype; /* Map of CTypeID to metatable. */
+ GCtab *miscmap; /* Map of -CTypeID to metatable and cb slot to func. */
+ CCallback cb; /* Temporary callback state. */
CTypeID1 hash[CTHASH_SIZE]; /* Hash anchors for C type table. */
} CTState;