Re: [PATCH] tile: rework <asm/cmpxchg.h>

From: Jan Kara
Date: Mon Sep 09 2013 - 05:36:26 EST


On Fri 06-09-13 08:56:45, Chris Metcalf wrote:
> The macrology in cmpxchg.h was designed to allow arbitrary pointer
> and integer values to be passed through the routines. To support
> cmpxchg() on 64-bit values on the 32-bit tilepro architecture, we
> used the idiom "(typeof(val))(typeof(val-val))". This way, in the
> "size 8" branch of the switch, when the underlying cmpxchg routine
> returns a 64-bit quantity, we cast it first to a typeof(val-val)
> quantity (i.e. size_t if "val" is a pointer) with no warnings about
> casting between pointers and integers of different sizes, then cast
> onwards to typeof(val), again with no warnings. If val is not a
> pointer type, the additional cast is a no-op. We can't replace the
> typeof(val-val) cast with (for example) unsigned long, since then if
> "val" is really a 64-bit type, we cast away the high bits.
Ah, I see. Thanks for explanation.

Honza
--
Jan Kara <jack@xxxxxxx>
SUSE Labs, CR
--
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/