Re: raw1394_request user/kernel space size differences
Brought to you by:
aeb,
bencollins
From: Andreas B. <and...@mu...> - 2000-06-01 23:19:35
|
On Mon, May 29, 2000 at 05:45:35PM -0400, Ben Collins wrote: > > Ok, I tested this and it worked. So I took it one step further. Attached > > are two patches. One for linux1394 CVS which defines a kptr_t just like > > you did for libraw1394. The other is for libraw1394 to sync the raw1394.h > > from the kernel source. > > Guess attaching the patches would actually help. > >-- [...] > struct raw1394_request { > - int type; > - int error; > - int misc; > - > - unsigned int generation; > - octlet_t address; > - > - unsigned long tag; > - > - size_t length; > - quadlet_t *sendb; > - quadlet_t *recvb; > + __s32 type; > + __s32 error; > + __s32 misc; > + > + __u32 generation; > + __u64 address; > + > + __u64 tag; > + > + __u32 length; > +#ifdef __KERNEL__ > + raw1394_kptr_t sendb; > + raw1394_kptr_t recvb; > +#else > +/* We use this to make it easy to pass pointers to the kernel, > + * even in mixed 32/64 bit environments */ > +#define SET_CAST_PTR(x,p) \ > +if (sizeof(void *) == sizeof(__u32)) { \ > + x.large = 0; \ > + x.small[1] = (__u32)p; \ > +} else { \ > + x.large = (__u64)p; \ > +} > + > + union { > + __u32 small[2]; > + __u64 large; > + } sendb; > + union { > + __u32 small[2]; > + __u64 large; > + } recvb; > +#endif > }; Using explicit width types for everything seems like a good idea. But we can also just forget the environment and always use __u64 types for the pointer fields. Writing a 64 bit field in a 32 bit environment will clear the upper 32 and write the lower 32 bits, just like your SET_CAST_PTR macro --- just cleaner and without endianness problems (looking at your macro I can see Sparc is run big endian). If we'd be really tightassed, we could make autoconf efforts to make those types 32 bit on fully 32 bit platforms like x86, but zeroing a few bytes really shouldn't be a performance problem. I'll try that tomorrow. -- Andreas E. Bombe <and...@mu...> DSA key 0x04880A44 http://home.pages.de/~andreas.bombe/ http://linux1394.sourceforge.net/ |