RE: funniness with pointers

  • From: William Adams <william_a_adams@xxxxxxx>
  • To: "luajit@xxxxxxxxxxxxx" <luajit@xxxxxxxxxxxxx>
  • Date: Thu, 14 May 2015 02:20:26 +0000

out of the ground.

Date: Wed, 13 May 2015 18:05:06 +0200
From: mike-1505@xxxxxxxxxx
To: luajit@xxxxxxxxxxxxx
Subject: Re: funniness with pointers

William Adams wrote:
myobj.A = ffi.new("epoll_event")

You've probably gotten the declaration of epoll_event wrong. For
multi-arch compatibility, it's a packed structure on Linux/x64
(but not on other platforms!). Then it's 12 bytes long and not 16,
which matters most when you pass it to epoll().

ffi.cdef([[
struct epoll_event {
int32_t events;
epoll_data_t;
}]]..(ffi.arch == "x64" and [[__attribute__((__packed__));]] or [[;]]))


--Mike


That makes sense. I'll admit to using the poor man's declaration, and I am
in fact on Linux/x64.

It would also explain why the data structure seemingly gets overwritten with
random
stuff.



At the end of the day, I think I'll just have to incorporate ljsyscall to get
all the Linux
specifics correct.

Thanks for the quick evaluation.

===============
Finally got to try this. That was the issue.

onward!

-- William


Other related posts: