From: Sam S. <sd...@gn...> - 2003-03-30 21:02:24
|
> * In message <200...@th...> > * On the subject of "[clisp-list] exporting reader functions for slots?" > * Sent on Sun, 30 Mar 2003 14:13:57 +0200 (CEST) > * Honorable Pascal Bourguignon <pj...@in...> writes: > > Shouldn't the reader functions for slots of def-c-struct be exported > from LINUX? would you be happy with the appended patch? actually, I am somewhat uneasy with this. def-c-struct defines both a C struct and a LISP structure type. how is this passed into the FFI? i.e., suppose I create a passwd with linux:MAKE-passwd. can I pass it to linux:putpwent? I cannot check that because even=20 (linux::putpwent (linux:getpwent) linux:stdout) crashes: (gdb) where #0 0x080b1283 in nls_asciiext_wcstombs (encoding=3D{one_o =3D 539610993}, = stream=3D {one_o =3D 0}, srcp=3D0xbfff8de8, srcend=3D0x203dc16c, destp=3D0xbfff= 8de0,=20 destend=3D0x404 <Address 0x404 out of bounds>) at encoding.d:1616 #1 0x081879a9 in convert_to_foreign (fvd=3D{one_o =3D 136519537}, obj=3D {one_o =3D 540918101}, data=3D0xbfff8fa0) at foreign.d:1848 #2 0x08187d45 in convert_to_foreign (fvd=3D{one_o =3D 540726929}, obj=3D {one_o =3D 540918233}, data=3D0xbfff8fa0) at foreign.d:1904 #3 0x08188e71 in convert_to_foreign_nomalloc (fvd=3D{one_o =3D 540726929},= obj=3D {one_o =3D 540918233}, data=3D0xbfff8fa0) at foreign.d:2174 #4 0x0818cf5b in C_foreign_call_out (argcount=3D2, rest_args_pointer=3D0x4= 01dc088) at foreign.d:3251 #5 0x0809d4eb in funcall_subr (fun=3D{one_o =3D 136474578}, args_on_stack= =3D2) at eval.d:5229 #6 0x0809c94b in funcall (fun=3D{one_o =3D 136474578}, args_on_stack=3D3) at eval.d:4831 #7 0x0809a272 in eval_ffunction (ffun=3D{one_o =3D 540727585}) at eval.d:3= 900 #8 0x08097090 in eval1 (form=3D{one_o =3D 1745141891}) at eval.d:2978 #9 0x08096b90 in eval (form=3D{one_o =3D 1745141891}) at eval.d:2834 #10 0x0813adf7 in C_read_eval_print () at debug.d:309 #11 0x0809d599 in funcall_subr (fun=3D{one_o =3D 136456434}, args_on_stack= =3D2) at eval.d:5232 #12 0x0809c9be in funcall (fun=3D{one_o =3D 136480085}, args_on_stack=3D2) at eval.d:4838 #13 0x080a0b8b in interpret_bytecode_ (closure=3D{one_o =3D 540264193},=20 codeptr=3D0x2033c6d0,=20 byteptr_in=3D0x2033c6e2 "=C5P\030.\001\024.\002\024.\003\024s\003\023.\= 004\0240\005\037\002.\006Q\031\001\031\001") at eval.d:6883 #14 0x0809e410 in funcall_closure (closure=3D{one_o =3D 540264193},=20 args_on_stack=3D0) at eval.d:5678 #15 0x0809c976 in funcall (fun=3D{one_o =3D 540264193}, args_on_stack=3D0) at eval.d:4833 #16 0x080ac32b in C_driver () at control.d:1903 #17 0x080a0cbe in interpret_bytecode_ (closure=3D{one_o =3D 540264237},=20 codeptr=3D0x2033c688, byteptr_in=3D0x2033c69a "=C5\017\001=DC1U=A0=C63 = \021\v") at eval.d:6889 #18 0x0809e410 in funcall_closure (closure=3D{one_o =3D 540264237},=20 args_on_stack=3D0) at eval.d:5678 #19 0x0809c976 in funcall (fun=3D{one_o =3D 540264237}, args_on_stack=3D0) at eval.d:4833 #20 0x080a1684 in interpret_bytecode_ (closure=3D{one_o =3D 540875949},=20 codeptr=3D0x202cfcc8, byteptr_in=3D0x202cfcda "") at eval.d:6939 #21 0x0809e410 in funcall_closure (closure=3D{one_o =3D 540875949},=20 args_on_stack=3D0) at eval.d:5678 #22 0x0809c976 in funcall (fun=3D{one_o =3D 540875949}, args_on_stack=3D0) at eval.d:4833 #23 0x0813b166 in driver () at debug.d:375 #24 0x0808df36 in main (argc=3D11, argv=3D0xbfffe174) at spvw.d:2963 #25 0x420154a0 in __libc_start_main () from /lib/tls/libc.so.6 (gdb)=20 Joerg, what's up?! --=20 Sam Steingold (http://www.podval.org/~sds) running RedHat8 GNU/Linux <http://www.camera.org> <http://www.iris.org.il> <http://www.memri.org/> <http://www.mideasttruth.com/> <http://www.palestine-central.com/links.html> If Perl is the solution, you're solving the wrong problem. - Erik Naggum --- linux.lisp.~1.19.~ 2003-03-29 10:02:55.000000000 -0500 +++ linux.lisp 2003-03-30 15:43:39.000000000 -0500 @@ -105,11 +105,30 @@ `(progn (defmacro ,new-macro-name (name &rest more) `(progn - (export ',(if (consp name) (car name) name)) + (export ',name) (,',original-macro-name ,name ,@(sublis substitut= ion more)) ) ) ) ) ) + (exporting-slots (defining-macro-name) + (let ((original-macro-name (intern (string-upcase defining-= macro-name) "FFI")) + (new-macro-name (intern defining-macro-name "LINUX"))) + `(defmacro ,new-macro-name (name &rest more) + (let ((sname (if (consp name) (car name) name))) + `(progn + (export '(,sname + ,@(let ((cname (sys::string-concat + (symbol-name sname) "-"= ))) + (list* + (sys::concat-pnames "COPY-" cname) + (sys::concat-pnames "MAKE-" cname) + (sys::concat-pnames cname "-P") + (mapcar (lambda (slot) + (sys::concat-pnames + cname (car slot))) + more))))) + (,',original-macro-name + ,name ,@(sublis substitution more))))))) (normal (defining-macro-name) (let ((original-macro-name (intern (string-upcase defining-= macro-name) "FFI")) (new-macro-name (intern defining-macro-name "LINUX"))) @@ -125,7 +144,7 @@ (exporting "define-symbol-macro") (exporting "def-c-type") (exporting "def-c-enum") - (exporting "def-c-struct") + (exporting-slots "def-c-struct") (exporting "def-c-var") (exporting "def-call-out") (normal "c-lines") |