bitfields in structs

rif <[email protected]> Tue, 4 May 2004 17:24:30 -0400
Newsgroups gmane.lisp.uffi.general
Message-ID <[email protected]>
I'm trying to wrap R.  One of the things it has is a struct consisting
of a bunch of bitfields:

struct sxpinfo_struct {
    SEXPTYPE type      :  5;/* ==> (FUNSXP == 99) %% 2^5 == 3 == CLOSXP
                             * -> warning: `type' is narrower than values
                             *              of its type
                             * when SEXPTYPE was an enum */
    unsigned int obj   :  1;
    unsigned int named :  2;
    unsigned int gp    : 16;
    unsigned int mark  :  1;
    unsigned int debug :  1;
    unsigned int trace :  1;
    unsigned int fin   :  1;  /* has finalizer installed */
    unsigned int gcgen :  1;  /* old generation number */
    unsigned int gccls :  3;  /* node class */
}; /*               Tot: 32 */

I assume there's no direct way to wrap this in UFFI?  In fact, can
this even be done on top of most UFFI's?  Fortunately, I don't *think*
I need to actually access any of the fields in this thing --- I think
I can get by with just having the sxpinfo_struct contained an
:unsigned-int, and I guess if I need bit access I could write
accessors in C or something?

rif