Thanks, I have it now, but now my question is: would they not be better off
replacing
#define get_user(x,ptr) \
({ int __ret_gu,__val_gu; \
switch(sizeof (*(ptr))) { \
case 1: __get_user_x(1,__ret_gu,__val_gu,ptr); break; \
case 2: __get_user_x(2,__ret_gu,__val_gu,ptr); break; \
case 4: __get_user_x(4,__ret_gu,__val_gu,ptr); break; \
default: __get_user_x(X,__ret_gu,__val_gu,ptr); break; \
} \
(x) = (__typeof__(*(ptr)))__val_gu; \
__ret_gu; \
})
with
#define get_user(x,ptr) \
({ int __ret_gu,__val_gu; \
__get_user_x(sizeof (*(ptr)),__ret_gu,__val_gu,ptr); \
(x) = (__typeof__(*(ptr)))__val_gu; \
__ret_gu; \
})
Benefits:
- gcc doesn't have to optimise away the other __put_users because
they are never there in the first place.
- calling put_user with a pointer to something of the wrong size still
breaks just as badly as it used to, except you now have a hint to what
broke it because insmod will complain about __put_user_8 not existing
- if other sizes become legal you don't have make any changes to this
header file
- less code
Or am I missing something?
Fergal
On Sun, Apr 22, 2001 at 03:59:22PM +0100, Mark McLoughlin wrote:
> On Sat, 21 Apr 2001, Fergal Daly wrote:
>> > The bit that's still really confusing me is where is gcc getting the capital
> > X from, I have grepped all the .h and .c files of 2.2.17 and 2.2.19 and
> > there is no mention of put_user_X, only put_user_x. Any idea what that's
> > about?
>> I think the whole point is there is no put_user_X. So if you try and
> do a put_user with something that's more the 4 bytes, it won't link.
> If you look at the cpp output, it's the default branch
>> default: __asm__ __volatile__("call __put_user_" "X"
>> This doesn't work without optimising (-fthread-jumps, I think) turned
> on because with this turned on all defunct branches of the switch get
> optimised away so there are references to put_user_{1,2,4,X}. If you
> do have it turned on, you're left with only a reference to the
> put_user you need, and if that's put_user_X you're screwed....
>> Good Luck,
> Mark.
>>> --
> Irish Linux Users' Group: ilug at linux.ie>http://www.linux.ie/mailman/listinfo/ilug for (un)subscription information.
> List maintainer: listmaster at linux.ie
--
Maintained by the ILUG website team. The aim of Linux.ie is to
support and help commercial and private users of Linux in Ireland. You can
display ILUG news in your own webpages, read backend
information to find out how. Networking services kindly provided by HEAnet, server kindly donated by
Dell. Linux is a trademark of Linus Torvalds,
used with permission. No penguins were harmed in the production or maintenance
of this highly praised website. Looking for the
Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!