Skip to contentSkip to conversation

type safe lists (was Re: PATCH: type safe(r) list_entry repacement: generic_out_cast)

DISCUSSION Andi Kleen 3 participants 3 messages Jul 24, 2002 2 messages not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

Andi Kleen

author
#2 lore raw
Quoted 4 lines

As long as your pointers are 32bit this seems to be ok. But on 64bit implementations pointers are not (unsigned long) so this cast seems to be wrong.

A pointer fits into unsigned long on all 64bit linux ports. The kernel very heavily relies on that.

You are probably thinking of Win64, but this is not Windows.

-Andi

#3 lore raw
Quoted 7 lines · Andi Kleen
Quoted 4 lines

As long as your pointers are 32bit this seems to be ok. But on 64bit implementations pointers are not (unsigned long) so this cast seems to be wrong.

A pointer fits into unsigned long on all 64bit linux ports. The kernel very heavily relies on that.

Not just the kernel, afaik. I think it's rather tightly integrated into gcc internals too (ie pointers are eventually just converted to SI inside the compiler, and making a non-SI pointer would be hard).

Linus

#4 lore raw
Quoted 10 lines · Linus Torvalds
Quoted 6 lines
Quoted 3 lines

As long as your pointers are 32bit this seems to be ok. But on 64bit implementations pointers are not (unsigned long) so this cast seems to be wrong.

A pointer fits into unsigned long on all 64bit linux ports. The kernel very heavily relies on that.

Not just the kernel, afaik. I think it's rather tightly integrated into gcc internals too (ie pointers are eventually just converted to SI inside the compiler, and making a non-SI pointer would be hard).

That can't be the case, as how would GCC represent 64-bit pointers on platforms like the Alpha, which support 64-bit, 32-bit, 16-bit and 8-bit types? 64-bits must be DImode simply because QImode is the smallest mode, and required for the 8-bit type.

-- Jamie