On 02/12/2013 09:00 AM, Linus Torvalds wrote: > On Tue, Feb 12, 2013 at 8:38 AM, H.J. Lu <hjl.tools@xxxxxxxxx> wrote: >> >> Can you do something similar to what we did in glibc: > > No. Because we use macros to be type-independent (i e"get_user()" > works *regardless* of type), so casting to "uintptr_t" doesn't work. > It throws away the type information, and truncates 64-bit values on > 32-bit architectures. > > The whole point of the bitmask thing is that it doesn't have that > issue, and gets the size correct automatically. It's not pretty, but > it allows the rest of the sources to be readable. > No, I think what he is talking about it this bit: /* 1 if 'type' is a pointer type, 0 otherwise. */ # define __pointer_type(type) (__builtin_classify_type ((type) 0) == 5) /* __intptr_t if P is true, or T if P is false. */ # define __integer_if_pointer_type_sub(T, P) \ __typeof__ (*(0 ? (__typeof__ (0 ? (T *) 0 : (void *) (P))) 0 \ : (__typeof__ (0 ? (__intptr_t *) 0 : (void *)(!(P)))) 0)) /* __intptr_t if EXPR has a pointer type, or the type of EXPR otherwise. */ # define __integer_if_pointer_type(expr) \ __integer_if_pointer_type_sub(__typeof__ ((__typeof__ (expr)) 0), \ __pointer_type (__typeof__ (expr))) /* Cast an integer or a pointer VAL to integer with proper type. */ # define cast_to_integer(val) ((__integer_if_pointer_type (val)) (val)) Good grief, this makes the bitfield look like Mona Lisa. On the other hand, it relies on the *entirely* undocumented __builtin_classify_type() -- there appears to be absolutely no reference to it in gcc documentation. H.J., do you know what the bounds on the __builtin_classify_type() are (gcc versions available and so on)? Sadly I don't think one can use __builtin_types_compatible_p() instead. -hpa -- To unsubscribe from this list: send the line "unsubscribe linux-tip-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html