Re: [PATCH] remove abs64()

From: Oleg Nesterov
Date: Wed Apr 13 2011 - 10:27:43 EST


On 04/13, Alexey Dobriyan wrote:
>
> +#define abs(x) \
> +({ \
> + typeof(x) _x = (x); \
> + \
> + __builtin_choose_expr( \
> + __builtin_types_compatible_p(typeof(_x), signed char), \
> + (unsigned char)({ _x < 0 ? -_x : _x; }), \
> + __builtin_choose_expr( \
> + __builtin_types_compatible_p(typeof(_x), short), \
> + (unsigned short)({ _x < 0 ? -_x : _x; }), \
> + __builtin_choose_expr( \
> + __builtin_types_compatible_p(typeof(_x), int), \
> + (unsigned int)({ _x < 0 ? -_x : _x; }), \
> + __builtin_choose_expr( \
> + __builtin_types_compatible_p(typeof(_x), long), \
> + (unsigned long)({ _x < 0 ? -_x : _x; }), \
> + __builtin_choose_expr( \
> + __builtin_types_compatible_p(typeof(_x), long long), \
> + (unsigned long long)({ _x < 0 ? -_x : _x; }), \
> + _x))))); \
> +})

Personally I agree.

But, we have some stupid users which do something like abs(u32_value)
and expecting that abs() should treat this value as "signed".

Oleg.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/