justincormack / ljsyscall

LuaJIT Unix syscall FFI
http://www.myriabit.com/ljsyscall/
Other
441 stars 54 forks source link

fail to load on OSX #129

Closed lipp closed 10 years ago

lipp commented 10 years ago
luajit
LuaJIT 2.0.2 -- Copyright (C) 2005-2013 Mike Pall. http://luajit.org/
JIT: ON CMOV SSE2 SSE3 SSE4.1 fold cse dce fwd dse narrow loop abc sink fuse
> require'syscall'
./syscall/helpers.lua:77: undeclared or implicit tag 'flock'
stack traceback:
    [C]: in function 'metatype'
    ./syscall/helpers.lua:77: in function 'addtype'
    ./syscall/osx/types.lua:163: in function <./syscall/osx/types.lua:10>
    ./syscall/types.lua:611: in function 'init'
    ./syscall.lua:33: in main chunk
    [C]: in function 'require'
    stdin:1: in main chunk
    [C]: at 0x0100001590
lipp commented 10 years ago

with PR #130 this gets the problem:

luajit -lsyscall
luajit: ./syscall/bsd/types.lua:88: bad argument #1 to 'pairs' (table expected, got nil)
stack traceback:
    [C]: in function 'pairs'
    ./syscall/bsd/types.lua:88: in function <./syscall/bsd/types.lua:10>
    ./syscall/types.lua:612: in function 'init'
    ./syscall.lua:33: in main chunk
    [C]: at 0x01000280a0
    [C]: at 0x0100001590
justincormack commented 10 years ago

Yes sorry, I merged in FreeBSD support just recently, which disrupted things a bit. It should make things easier though, as most of the missing OSX stuff can probably just be copied directly from FreeBSD as they are largly the same, with just a few tweaks...

justincormack commented 10 years ago

I have pushed a lot of fixes, not quite there yet but the tests run...

justincormack commented 10 years ago

OK, more fixes pushed. The largest issue now is that 'ls' is not working as getdirentries is broken. There are some warnings in the man page about this so I need to check the correct fix.

lipp commented 10 years ago

Now I get this:

git log -n 1
commit 04e0cc5e94c29336aa17650322c128d51679c1b8
Author: Justin Cormack <justin@specialbusservice.com>
Date:   Thu Dec 26 19:06:01 2013 +0000

    cast last ioctl argument to void always
bunsen:ljsyscall preuss$ luajit -e "require'syscall'.socket('inet','stream,nonblock')"
luajit: ./syscall/syscalls.lua:169: bad argument #2 to 'socket' (cannot convert 'nil' to 'int')
stack traceback:
    [C]: in function 'socket'
    ./syscall/syscalls.lua:169: in function 'socket'
    (command line):1: in main chunk
    [C]: at 0x0100001590
justincormack commented 10 years ago

I changed the tests to not have that in. OSX does not have a nonblock flags for sockets, so you can't use 'stream,nonblock' just stream and set the socket to nonblock after...

justincormack commented 10 years ago

Fixed all except one of the tests - just some issues with the pty calls to fix now.

lipp commented 10 years ago

thanks for pointing osx nonblock issue out.

lipp commented 10 years ago

We are getting closer :) Now I get this:

luajit: /usr/local/share/lua/5.1/syscall/syscalls.lua:216: attempt to index field 'SO' (a nil value)
stack traceback:
    /usr/local/share/lua/5.1/syscall/syscalls.lua:216: in function 'setsockopt'
justincormack commented 10 years ago

OK, added the SO constants and some tests for setsockopt and getsockopt...

lipp commented 10 years ago

:+1: I am trying to do node like implementation of sockets etc. Currently I am evaluating using your great ljsyscall. Target is an embedded powerpc system. I am developing under OSX though.

https://github.com/lipp/nodish/tree/use-ljsyscall

lipp commented 10 years ago

BTW: I looked for TCP_NODELAY option and cannot grep it. Do you have a hint?

I tried the obvious:

sock:setsockopt('socket','nodelay',true)
justincormack commented 10 years ago

Have added those as #134 - had missed them...

justincormack commented 10 years ago

I guess you will be wanting kqueue on OSX? Had been meaning to sort that out - its there for NetBSD so means moving it to the generic BSD section instead and filling in the structs that should be similar...

lipp commented 10 years ago

I don't think so (yet). So far I am happy with lua-ev as event loop.

In the future it might be nice to have ALL the stuff (poll,etc) just by using ljsyscall and luajit.

justincormack commented 10 years ago

Well I added it anyway as I had been meaning to, and fixed the other issue, so all tests passing.