Skip to contentSkip to conversation

Differences in bitops argument types

DISCUSSION Jan Kara 2 participants 2 messages Nov 1, 2007 – Nov 2, 2007

lore
Share & tools
lore

Jan Kara

author
#0 lore raw

Hello,

I've just found out that operations like constant_test_bit() take pointer
of different types on different architectures. In particular, x86_64, blackfin and frv take void * while i386, s390 and m68k take unsigned long *. Is this intended difference? Wouldn't using void * everywhere be more appropriate? Thanks for answer in advance.

Honza

#1 lore raw
Quoted 5 lines · Jan Kara

I've just found out that operations like constant_test_bit() take pointer
of different types on different architectures. In particular, x86_64, blackfin and frv take void * while i386, s390 and m68k take unsigned long *. Is this intended difference? Wouldn't using void * everywhere be more appropriate? Thanks for answer in advance.

A bitmap is defined to be an array of unsigned longs. Using an array of a smaller or longer type will give different results on big-endian architectures. Therefore using unsigned long * is better, because it finds errors where callers are using an array of some other type.

Paul.