freetype-devel
[Top][All Lists]
Advanced

[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;)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]