Re: [PATCH] ARM: type casts update_sched_clock cyc_to_sched_clock cyc_to_fixed_sched_clock

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Apr 05, 2011 at 09:43:21AM +0200, Jan Weitzel wrote:
> parameter "u32 mask" type cast befor inversion

Nak.  I want a 32-bit all ones quantity.

unsigned long long vali = (unsigned short)~0;
unsigned long long vall = ~(unsigned short)0;

compiles to:

vali:
        .word   65535
        .word   0

vall:
        .word   -1
        .word   -1

So moving the ~ to be evaluated after the cast has the effect of making
the cast pointless, and produces wrong values.  (u32)~0 does the 32-bit
cast _after_ the inversion which ensures that its always truncated to
a 32-bit value.

As the function is declared as taking a u32, the cast isn't needed.  If
the function gets changed to take a u64, the casts will need to be
re-added.  So, (u32)~0 makes the fact that we want a 32-bit all-ones
mask explicit.
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Arm (vger)]     [ARM Kernel]     [ARM MSM]     [Linux Tegra]     [Linux WPAN Networking]     [Linux Wireless Networking]     [Maemo Users]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux