-
Notifications
You must be signed in to change notification settings - Fork 202
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support ARM64 #26
support ARM64 #26
Conversation
The Lua API can be used like below: local exdata = require "thread.exdata" exdata(0xdeadbeefLL) -- set the exdata of the current Lua thread local ptr = exdata() -- fetch the exdata of the current Lua thread The exdata value on the Lua land is represented as a cdata object of the ctype "void*". Right now the reading API, i.e., `exdata()` calls without any arguments, can be JIT compiled. Also exposed the following public C API functions for manipulating exdata on the C land: void lua_setexdata(lua_State *L, void *exdata); void *lua_getexdata(lua_State *L); The exdata pointer is initialized to NULL when the main thread is created. Any child Lua threads created will inherit the parent's exdata but still have their own exdata storage. So child Lua threads can always override the inherited parent exdata pointer values. Signed-off-by: Yichun Zhang (agentzh) <[email protected]>
… Lua error will now be raised. Signed-off-by: Yichun Zhang (agentzh) <[email protected]>
@spacewander Will you please drop a note to README for this new |
@agentzh |
coroutine.yield(exdata()) | ||
exdata(ptr2) | ||
coroutine.yield(exdata()) | ||
coroutine.yield(exdata()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor style: this function uses 2 lines indentation, instead of 4 in the rest of this file - should we update it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@thibaultcha Oh, yeah. Good catch. @spacewander Will you please adjust the indentation here a bit? Many thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@spacewander Never mind, I'll do it :)
Merged with the following extra patch: diff --git a/README b/README
index b7dc5ad352..159ee994a4 100644
--- a/README
+++ b/README
@@ -31,7 +31,7 @@ since we still synchronize any upstream changes all the time.
We introduce our own changes which will never merge or haven't yet merged into
the upstream LuaJIT (https://github.com/LuaJIT/LuaJIT), which are
-feature: implemented lua thread exdata.
+feature: implemented the new Lua and C API functions for thread exdata.
The Lua API can be used like below:
@@ -56,6 +56,9 @@ feature: implemented lua thread exdata.
but still have their own exdata storage. So child Lua threads can always
override the inherited parent exdata pointer values.
+ This API is used internally by the OpenResty core so never ever mess
+ with it yourself in the context of OpenResty.
+
* feature: luajit.h: defined the macro OPENRESTY_LUAJIT for our branch of
LuaJIT.
diff --git a/t/exdata.t b/t/exdata.t
index 722fcbfb23..239bb86c18 100644
--- a/t/exdata.t
+++ b/t/exdata.t
@@ -47,10 +47,10 @@ local ptr2 = ffi.cast("void *", u64 + 1)
local ptr3 = ffi.cast("void *", u64 - 2)
local saved_q
local function f()
- coroutine.yield(exdata())
- exdata(ptr2)
- coroutine.yield(exdata())
- coroutine.yield(exdata())
+ coroutine.yield(exdata())
+ exdata(ptr2)
+ coroutine.yield(exdata())
+ coroutine.yield(exdata())
end
exdata(u64) Thanks! |
No description provided.