[Openmcl-devel] ioctl

Gary Byers gb at clozure.com
Wed Nov 10 13:26:34 PST 2010



On Wed, 10 Nov 2010, Didier Verna wrote:

>
>  Hello,
>
> I'm trying to perform an ioctl call from CCL, but I'm stuck on something
> I don't understand. I got as far as this:
>
>  (rlet ((winsize :winsize))
>    (#_ioctl stream           ;; or should I use ccl::stream-device ?
>             #$TIOCGWINSZ
> 	     winsize)
>    (pref winsize :winsize.ws_col))

You should use CCL:STREAM-DEVICE; you want to pass a file descriptor
to #_ioctl, not a lisp STREAM object.

>
>
> But this barfs with the following error:
>
>> Error: Remaining arguments should be keyword/value pairs: (WINSIZE)
>> While executing: CCL::%EXTERNAL-CALL-EXPANDER, in process listener(1).

ioctl's prototype in C is something like:

int
ioctl(int fd, unsigned request, ...)

e.g., it takes 2 or more arguments where the number and types of any
non-fixed arguments depend on the value of the fixed arguments (generally
the request.)

#_ knows that ioctl's first arg is of foreign type :int and the second
is :unsigned, but needs to be told the foreign types of any additional
arguments as well as their values.  (In other words, any non-fixed arguments
in the call to #_ioctl have to be keyword/value pairs.)

(#_ioctl (ccl:stream-device stream :whatever-direction)
          #$TIOCGWINSZ
          :address winsize)

or, if you prefer:

(#_ioctl (ccl:stream-device stream :whatever-direction)
          #$TIOCGWINSZ
          (:* (:struct :winsize))  winsize)

There's an example of this in the description of #_ in section 12.12 of
the manual, where the (non-required) argument to #_printf needs to have
its type explicitly specified.

I suppose that the error message could be clearer: what's really required
at the point of complaint is a sequence of "foreign-type-specifier/value"
pairs.


>
> So it seems that #_ioctl expects something else than just winsize. I
> thought maybe :* winsize was needed, but this is not the case either.
>
> What am I doing wrong ?
>
> Thank you !
>
> -- 
> Resistance is futile. You will be jazzimilated.
>
> Scientific site:   http://www.lrde.epita.fr/~didier
> Music (Jazz) site: http://www.didierverna.com
> _______________________________________________
> Openmcl-devel mailing list
> Openmcl-devel at clozure.com
> http://clozure.com/mailman/listinfo/openmcl-devel
>
>



More information about the Openmcl-devel mailing list