DragonFly BSD
DragonFly kernel List (threaded) for 2003-09
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

Re: computing userland pointers


From: "David P. Reese, Jr." <daver@xxxxxxxxxxxx>
Date: Fri, 12 Sep 2003 18:55:23 -0700

On Fri, Sep 12, 2003 at 09:31:33PM -0400, drhodus@xxxxxxxxx wrote:
> Quoting "David P. Reese, Jr." <daver@xxxxxxxxxxxx>:
> 
> > In separating recvmsg() I want to be able to copyout to a single member of
> > a struct msghdr that lives in userland.  I'm currently using code like
> > 
> >    ucontrollenp = (socklen_t *)((caddr_t)uap->msg + offsetof(struct 
> msghdr,
> >        msg_controllen));
> > 
> > I'm curious if anything like this already exists as a macro.  If it such
> > a macro doesn't exist, would there be any argument against adding one?
> > 
> > #define UADDRESS(cast, type, addr, member) \
> > 	(cast)((caddr_t)addr + offsetof(type, member))
> > 
> > I think it could be placed in sys/systm.h.
> 
> What is the approximate calculation of the use frequency if this
> macro if implemented ? 

A quick browse through sys/sysproto.h leads me to believe that it would
only be handy in a very small number of cases including recvmsg().  I
guess I'll forget about the macro.

-- 
   David P. Reese, Jr.                                     daver@xxxxxxxxxxxx
                                               http://www.gomerbud.com/daver/



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