[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [ft-devel] LLP64 model outside Win64
From: |
Roland Mainz |
Subject: |
Re: [ft-devel] LLP64 model outside Win64 |
Date: |
Sun, 11 Feb 2018 20:19:38 +0100 |
On Sun, Feb 11, 2018 at 7:30 PM, Werner LEMBERG <address@hidden> wrote:
>
>>> (void*)(size_t)(x) should be safe, c90, and warning-less.
>>
>> You assume that all machines have a flat, linear memory model.... ;-(
>>
>> The "safe", portable way is to use
>>
>> (void *)(((char *)0) + (x))
>>
>> to cast an integer to a void pointer, and use
>>
>> (ptrdiff_t)((char *)(x)) - ((char *)0)
>>
>> to cast a pointer to an integer.
>
> Interesting. Can you name an example of a machine with a non-linear
> memory model?
24bit/32bit embedded CPU designs, typically designs predating the
widespread adoption of 64bit address space&&pointers. For example i960
can implement one-address-space-per-object-type - for those who
remember C64's "banking": Sort of One-bank-per-object-type. In such a
scenario a pointer is only valid for the type it was used for since
the same "integer" value can refer to a completely different chunk of
memory for another object type.
A more classical scenario is data&&code separation as in the
https://en.wikipedia.org/wiki/Harvard_architecture
That's why the wording in the ISO >= C89 standard has a bit more
complex wording about pointer differences, but I can't quote them
since my book
(https://www.amazon.de/Annotated-ANSI-Standard-Programming-Languages-C/dp/0078819520/ref=sr_1_1)
is a few 100km away right now...
----
Bye,
Roland
--
__ . . __
(o.\ \/ /.o) address@hidden
\__\/\/__/ MPEG specialist, C&&JAVA&&Sun&&Unix programmer
/O /==\ O\ TEL +49 641 3992797
(;O/ \/ \O;)
- [ft-devel] LLP64 model outside Win64, Ruslan Nikolaev, 2018/02/08
- Re: [ft-devel] LLP64 model outside Win64, Alexei Podtelezhnikov, 2018/02/09
- Re: [ft-devel] LLP64 model outside Win64, Werner LEMBERG, 2018/02/09
- Re: [ft-devel] LLP64 model outside Win64, Alexei Podtelezhnikov, 2018/02/11
- Re: [ft-devel] LLP64 model outside Win64, Roland Mainz, 2018/02/11
- Re: [ft-devel] LLP64 model outside Win64, Werner LEMBERG, 2018/02/11
- Re: [ft-devel] LLP64 model outside Win64,
Roland Mainz <=
- Re: [ft-devel] LLP64 model outside Win64, Alexei Podtelezhnikov, 2018/02/11
- Re: [ft-devel] LLP64 model outside Win64, Behdad Esfahbod, 2018/02/11
- Re: [ft-devel] LLP64 model outside Win64, Alexei Podtelezhnikov, 2018/02/11
- Re: [ft-devel] LLP64 model outside Win64, Behdad Esfahbod, 2018/02/11
- Re: [ft-devel] LLP64 model outside Win64, Werner LEMBERG, 2018/02/12
- Re: [ft-devel] LLP64 model outside Win64, Alexei Podtelezhnikov, 2018/02/12
- Re: [ft-devel] LLP64 model outside Win64, Werner LEMBERG, 2018/02/12
- Re: [ft-devel] LLP64 model outside Win64, Alexei Podtelezhnikov, 2018/02/19
- Re: [ft-devel] LLP64 model outside Win64, Werner LEMBERG, 2018/02/25
- Re: [ft-devel] LLP64 model outside Win64, Alexei Podtelezhnikov, 2018/02/25