tech-userlevel archive

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

Re: fun (not so much) with funopen

>>> If you're going to break something, then go whole hog and fix it so
>>> you won't have to break the API ever again. :)
>> How does an ops struct do that?  You still have an API flag day
> API flag *YEARS*.  That's my point.  It isn't a day.  It is years.

I thought "flag day" was better understood than that.  A flag day has
no duration; it is an event - a point in time, if you will. explains.

> A struct does it by using an initializer that stamps it with the
> initializer version.

You can get basically the same effect with a funopen-style interface

#define funopen(k,r,w,s,c) funopen_intf(FUNOPEN_VERSION,(k),(r),(w),(s),(c))
extern FILE *funopen_intf(int, ...);

-> change ->

#define funopen(what,ever,v2,uses) 
extern FILE *funopen_intf(int, ...);

If you want prototype argument type checking, you can get that with

#define funopen(k,r,w,s,c) funopen_intf(FUNOPEN_VERSION,\
        __funopen_arg_cookie((k)),                      \
        __funopen_arg_rfn((r)),                         \
        __funopen_arg_wfn((w)),                         \
        __funopen_arg_sfn((s)),                         \
        __funopen_arg_cfn((c)) )
extern FILE *funopen_intf(int, ...);
extern __inline__ void *__funopen_arg_cookie(void *x)
        __attribute__((__always_inline__)) { return(x); }
extern __inline__ int (*__funopen_arg_rfn(ssize_t (*x)(void *, void *, 
size_t))(void *, void *, size_t)
        __attribute__((__always_inline__)) { return(x); }

/~\ The ASCII                             Mouse
\ / Ribbon Campaign
 X  Against HTML      
/ \ Email!           7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B

Home | Main Index | Thread Index | Old Index