Getting raw address of lisp object and binding object back from pointer (stored by os kernel)

Horia Mihai David <[email protected]>
Newsgroups gmane.lisp.steel-bank.general
Message-ID <[email protected]>
Hi all,

I came across a use-case I am implementing and I can find very little
documentation around how to do it.

I am writing a network server for Linux based on epoll().
I have for each active connection an instance of a struct.

The Linux Kernel can store for my program a 64 bit word associated with
a file descriptor I am interested in receiving events about. When an
event occurs, the kernel notifies my program and returns the stored
word.

I'd like to store the raw address of the connection instance, and when
the kernel gives that address back to my program I'd like to bind a
variable to that object instance so I can continue using it.

I managed to get the raw address using sb-kernel:get-lisp-obj-address
See:
https://stackoverflow.com/questions/50612953/object-address-in-memory-common-lisp

How stable is this? How can I bind a variable to an object given a raw
address?

In the mean time I store a hash and retrieve the object from a hash
table, but it would be more efficient in this critical path to store a
raw pointer to the context/connection, like it is usually done in C
programs that use this epoll() interface.

I understand that this is not portable across CL implementations.

Tank you in advance. Have a nice day.

~ Horia Mihai David
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.