gcl-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Gcl-devel] Storing C structure pointers in lisp


From: Camm Maguire
Subject: Re: [Gcl-devel] Storing C structure pointers in lisp
Date: 12 Aug 2004 16:30:14 -0400
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2

Greetings!  We've setup a gcl-users list, but haven't yet gotten it
going.  Not sure if this is because there are problems at savannah.
Am cross posting this to check.  In any case, at present gcl-devel
might be your best bet with these questions.  Perhaps you might also
cross post to attempt a jump start of gcl-users.

Take care,

David Kirkman <address@hidden> writes:

> Hi Camm,
> 
> Thanks for following up on my question about C structures.  Is there a
> user-level (instead of a developer) list for gcl?  I have some silly
> questions about what happens to object pointers you've got in C code when
> garbage collection occurs, but I don't want to annoy the developers with
> somebody who is inexperienced in both C and Lisp. (Actually, I've been
> using both for over a decade, but coding only a few days a year does
> not build much competence).  Is there a more appropriate forum for such
> things?
> 
> Also, I noticed in the gcl-devel archives that you maintain lapack and
> blas on Debian.  I'd like to thank you for that too -- I use both debian
> and lapack extensively (and effortlessly).  
> 
> Cheers, 
> 
> -david k.
> 
> On 6 Aug 2004, Camm Maguire wrote:
> 
> > Greetings!  What you want to do is quite possible with a little work. 
> > 
> > Take a look at GCL's 'structure' structure:
> > 
> > struct structure {          /*  structure header  */
> >             FIRSTWORD;
> >     object  str_def;        /*  structure definition (a structure)  */
> >     object  *str_self;      /*  structure self  */
> > };
> > 
> > struct s_data {object name;
> >            int length;
> >            object raw;
> >            object included;
> >            object includes;
> >            object staticp;
> >            object print_function;
> >            object slot_descriptions;
> >            object slot_position;
> >            int    size;
> >            object has_holes;
> >          };
> > 
> > #define USHORT_GCL(x,i) (((unsigned short *)(x)->ust.ust_self)[i])
> > 
> > #define S_DATA(x) ((struct s_data *)((x)->str.str_self))
> > #define SLOT_TYPE(def,i) (((S_DATA(def))->raw->ust.ust_self[i]))
> > #define SLOT_POS(def,i) USHORT_GCL(S_DATA(def)->slot_position,i)
> > #define STREF(type,x,i) (*((type *)(((char *)((x)->str.str_self))+(i))))
> > 
> > 
> > Your data goes in raw, and the offsets in slot_position.  Also check
> > the supplied functions for making/accessing structures at the end of
> > structure.c.  The can be called from C via the names supplied as the
> > second argument to make_function.
> > 
> > Please keep us posted,
> > 
> > David Kirkman <address@hidden> writes:
> > 
> > > Hi All,
> > > 
> > >    I'm interfacing gcl with some old C code of mine.  I have a lot of
> > > functions which take structure pointers as parameters.  The structures
> > > are created, manipulated, and freed entirely in C, but it would be
> > > mighty convenient to be able to hold onto them in lisp.
> > > 
> > >    Is there a standard (or easy) way to do this in gcl?
> > > 
> > >    For the moment, I'm casting the pointer to an int and sending the
> > > int back to gcl.  I'm doing the interface with (defentry) and some
> > > scaffolding (clines) to do the back and forth casting.  I've looked at
> > > the lispunion types in h/object.h, but I don't see anything that looks
> > > like it is meant to hold onto a C side pointer.  Am I missing something?
> > > 
> > > Thanks,
> > > 
> > > -david k.
> > > 
> > > 
> > > 
> > > _______________________________________________
> > > Gcl-devel mailing list
> > > address@hidden
> > > http://lists.gnu.org/mailman/listinfo/gcl-devel
> > > 
> > > 
> > > 
> > 
> > -- 
> > Camm Maguire                                                address@hidden
> > ==========================================================================
> > "The earth is but one country, and mankind its citizens."  --  Baha'u'llah
> > 
> 
> 
> 
> 

-- 
Camm Maguire                                            address@hidden
==========================================================================
"The earth is but one country, and mankind its citizens."  --  Baha'u'llah




reply via email to

[Prev in Thread] Current Thread [Next in Thread]