[Ecls-list] Does ECL support SERVE-EVENT?

Brad Beveridge brad.beveridge at gmail.com
Wed Sep 6 23:25:32 UTC 2006

On 06/09/06, Dave Roberts <dave at vyatta.com> wrote:
> Brad Beveridge wrote:
> > I'll prototype this out in SBCL first to see if that handling system
> > does what I want.  I've just been reading a little bit about Posix
> > select - it looks to me as if some critical aspects of select are
> > platform specific - ie fd_set, and the macros
> >  FD_SET(fd, &fdset);
> >  FD_CLR(fd, &fdset);
> >  FD_ISSET(fd, &fdset);
> > FD_COPY(&fdset_orig, &fdset_copy);
> > FD_ZERO(&fdset);
> > This feels like a bit of a problem to me, as how can CFFI access these
> > macros and types port ably?  It looks to me as if the most portable
> > way to do this is to write a small amount of C that provides a few
> > functions
> >  void add_fd(int fd)
> >  void remove_fd (int fd)
> >  int fd_needs_attention (int fd)
> > int my_select (...)
> I don't believe ECL supports CFFI anyway. The ECL FFI is pretty nice,
> however, as it allows you to include arbitrary C code mixed in with your
> Lisp. The whole shooting match is compiled to C and then run through GCC
> to produce FASLs. Thus, you should be able to create wrapper functions
> in the Lisp world for each of those C macros. The Lisp wrappers just
> include the C macros in the text and set/return values. You can take a
> look at the ECL contrib sockets code for some good ideas of what can be
> done. It took me a while to get used to it, but once I did I really
> started to like it.
> Note that ECL also supports a UFFI-style FFI which is build on top of
> the raw native FFI. I found that the UFFI code was way too verbose and a
> PITA with respect to macros and such. The ECL native FFI was easier to
> work in. If you can keep the amount of FFI code small and generally do
> most of the work on the Lisp side, it would be relatively easy to swap
> in other FFIs for the few functions that cross the boundary.
> > Then the Lisp code would need to call my_select, and test each fd to
> > see if it requires action.
> > How does this sound?
> That sounds reasonable.

I messed up the reply-to-list, and I think that Dave replied to me
intending to hit the whole list.
ECL is coloured green in the CFFI support matrix
(http://common-lisp.net/project/cffi/), so unless things have changed
CFFI is ok to work with.
I think that ECL is one of the few Lisps that can actually interact
with C at such a level where C macros actually work - which is pretty
cool.  But in this case I suspect the amount of CFFI contortions would
be less if I just write some small functions in C.


More information about the ecl-devel mailing list