wahern / cqueues

Continuation Queues: Embeddable asynchronous networking, threading, and notification framework for Lua on Unix.
http://25thandclement.com/~william/projects/cqueues.html
MIT License
244 stars 37 forks source link

Add workaround for LuaJIT not supporting >47bit pointers #225

Closed daurnimator closed 5 years ago

daurnimator commented 5 years ago

Cqueues mostly uses lightuserdata as unique keys. It's hacky, but the best workaround seems to be just masking off the top bits.

Solves #223

daurnimator commented 5 years ago

Annoyingly, this makes building with LuaJIT different to building with plain Lua 5.1. I wonder if distros would want to compile with CQS_USE_47BIT_LIGHTUSERDATA_HACK so that 5.1 and LuaJIT can share the library....

vcunat commented 5 years ago

EDIT: wait, this is weird.

You forgot this one, apparently:

luaopen__cqueues (L=0x1cda2f8da378) at /build/source/src/cqueues.c:2924

and cond_wait() should be the same case.

vcunat commented 5 years ago

__arch64__ is a typo, most likely. EDIT: I replaced it with __aarch64__ for now, but I know little about these defines.

vcunat commented 5 years ago

With these two changes I mentioned, it loads and passes some simple tests.

daurnimator commented 5 years ago

__arch64__ is a typo, most likely. EDIT: I replaced it with __aarch64__ for now, but I know little about these defines.

__arch64__ was intentional, it should be defined on 64 bit targets.

vcunat commented 5 years ago

OK, I don't know – for now I mainly cared for the define to get triggered.

I wanted to do some more testing, but I ran into the same problem in luaossl :-/

daurnimator commented 5 years ago

@vcunat https://github.com/wahern/luaossl/pull/173