[cffi-devel] Providing access to errno in CFFI-SYS

Hoehle, Joerg-Cyril Joerg-Cyril.Hoehle at t-systems.com
Mon Jan 2 15:02:14 UTC 2006


James Bielman wrote:
>> See clisp/modules/bindings/glibc/linux.lisp
>I'm not an expert CLISP user---is this not built as a part of the
>standard image?
What's standard?
 ./configure --build?
 - as found on sourceforge file download?
 - as found in Debian?

I don't know the choices myself, but clearly, that file is only available on systems with glibc (I've heard mention of people trying and compiling this file on *BSD).

Furthermore, it's possibly not in the default build. For sure, it was not in the default build of old CLISP and only there with clisp --full, but it seems Sam Steingold recently changed defaults and it may be there in a default build and invocation of clisp on Linux.
So indeed, the linux package is not in every clisp.

clisp --version will list the C Modules.

My typical build contains none of them, while Ubuntu/Debian clisp-2.35 contains i18n, syscalls, regexp, linux, clx.

So for now you could perhaps try something along:
(ignore-errors
 (or
  (when (find-package "LINUX") (read-from-string "linux:errno"))
  (def-call-out errno-location (:name "__errno_location")(:return-type (c-pointer int))(:library :default)(:language :stdc))
  (def-c-var errno (:type ffi:int)(:library :default)) ; works on Linux!??!
))
...
Or just use the last one with def-c-var errno, since the rest is overengineered for the day when clisp might support threads.  Don't hold your breath.
(Actually, I'm surprised that dlsym() found "errno" on my Linux box. I'd thought __errno_location() rules in glibc/i386.  Go figure).

Regards,
	Jörg Höhle.



More information about the cffi-devel mailing list