Re: [Sbcl-devel] Re: sb-grovel and string structure members

Andreas Fuchs <asf@...> writes:
> On 2003-08-17, Andreas Fuchs <asf@...> wrote:
>> to make readdir usable, the attached patch rearranges things in
>> foreign-glue.lisp so that accessing string members of structures can
>> easily be accessed and setfed.
>
> Christophe asked me why I wasn't using sb-kernel:%naturalize-c-string,
> and I found out why: it doesn't do bounds checking, which would be a
> good thing to have. I've rewritten the getter/setter functions to be
> more like %n-c-s, especially to use copy-{from,to}-system-area. tested
> and working with a recent sbcl CVS build.
Thanks. I've merged something not totally dissimilar into
sbcl-0.8.2.44.
The sb-posix constants.lisp entry for struct dirent currently looks
like
(:structure dirent
("struct dirent"
(:c-string name "char *" "d_name"
:distrust-length #+solaris t #-solaris nil)))
and the interface.lisp definitions
(define-call "opendir" (* t) null-alien (pathname filename))
(define-call "readdir" (* t)
;; readdir() has the worst error convention in the world. It's just
;; too painful to support. (return is NULL _and_ errno "unchanged"
;; is not an error, it's EOF).
not
(dir (* t)))
(define-call "closedir" int minusp (dir (* t)))
This is close enough that I thought it worth including, because at
least the programmer interface now works. Behind the scenes, though,
it would be good to do the work so that readdir could be declared to
return a (* dirent), not just a (* t); this would mean including some
alien awareness into SB-GROVEL:DEFINE-C-STRUCT.
Anyway, that's for the future; for now, thank you very much again.
Cheers,
Christophe
--
http://www-jcsu.jesus.cam.ac.uk/~csr21/ +44 1223 510 299/+44 7729 383 757
(set-pprint-dispatch 'number (lambda (s o) (declare (special b)) (format s b)))
(defvar b "~&Just another Lisp hacker~%") (pprint #36rJesusCollegeCambridge)

Andreas Fuchs <asf@...> writes:
> On 2003-08-17, Andreas Fuchs <asf@...> wrote:
>> to make readdir usable, the attached patch rearranges things in
>> foreign-glue.lisp so that accessing string members of structures can
>> easily be accessed and setfed.
>
> Christophe asked me why I wasn't using sb-kernel:%naturalize-c-string,
> and I found out why: it doesn't do bounds checking, which would be a
> good thing to have. I've rewritten the getter/setter functions to be
> more like %n-c-s, especially to use copy-{from,to}-system-area. tested
> and working with a recent sbcl CVS build.
Thanks. I've merged something not totally dissimilar into
sbcl-0.8.2.44.
The sb-posix constants.lisp entry for struct dirent currently looks
like
(:structure dirent
("struct dirent"
(:c-string name "char *" "d_name"
:distrust-length #+solaris t #-solaris nil)))
and the interface.lisp definitions
(define-call "opendir" (* t) null-alien (pathname filename))
(define-call "readdir" (* t)
;; readdir() has the worst error convention in the world. It's just
;; too painful to support. (return is NULL _and_ errno "unchanged"
;; is not an error, it's EOF).
not
(dir (* t)))
(define-call "closedir" int minusp (dir (* t)))
This is close enough that I thought it worth including, because at
least the programmer interface now works. Behind the scenes, though,
it would be good to do the work so that readdir could be declared to
return a (* dirent), not just a (* t); this would mean including some
alien awareness into SB-GROVEL:DEFINE-C-STRUCT.
Anyway, that's for the future; for now, thank you very much again.
Cheers,
Christophe
--
http://www-jcsu.jesus.cam.ac.uk/~csr21/ +44 1223 510 299/+44 7729 383 757
(set-pprint-dispatch 'number (lambda (s o) (declare (special b)) (format s b)))
(defvar b "~&Just another Lisp hacker~%") (pprint #36rJesusCollegeCambridge)

Hi,
On Wed, Sep 24, 2003 at 12:48:29PM +0200, Vincent Arkesteijn wrote:
> See attached patch.
And this brought to light another issue. The foo.c generated by
sb-grovel outputs (in-package :SB-POSIX) and later
(sb-grovel::define-c-accessor DIRENT-NAME DIRENT C-STRING 10 nil)
Because sb-posix doesn't :use the common-lisp package, this
doesn't work. Again, see attached patch.
Sorry for testing only after mailing the first patch. This time,
I did it the other way around, and sb-posix::dirent-name works
as expected.
Vincent.

Vincent Arkesteijn <vincent@...> writes:
> On Wed, Sep 24, 2003 at 12:48:29PM +0200, Vincent Arkesteijn wrote:
>> See attached patch.
>
> And this brought to light another issue. The foo.c generated by
> sb-grovel outputs (in-package :SB-POSIX) and later
> (sb-grovel::define-c-accessor DIRENT-NAME DIRENT C-STRING 10 nil)
> Because sb-posix doesn't :use the common-lisp package, this
> doesn't work. Again, see attached patch.
Thank you very much. I've merged your various contrib/ fixes for SunOS
into sbcl-0.8.3.92.
> Sorry for testing only after mailing the first patch. This time,
> I did it the other way around, and sb-posix::dirent-name works
> as expected.
At some point we will need some regression tests for sb-posix; in an
extreme-programming world, of course, it would already have them, but
for now thinking about them (and the somewhat related matter of
package exports) will have to do.
Thanks again,
Cheers,
Christophe
--
http://www-jcsu.jesus.cam.ac.uk/~csr21/ +44 1223 510 299/+44 7729 383 757
(set-pprint-dispatch 'number (lambda (s o) (declare (special b)) (format s b)))
(defvar b "~&Just another Lisp hacker~%") (pprint #36rJesusCollegeCambridge)