Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

It is easier to change the specification to fit the program than vice versa.


devel / comp.lang.c / Examples of implementations with unusual uintptr_t?

SubjectAuthor
* Examples of implementations with unusual uintptr_t?Anthony Cuozzo
+- Re: Examples of implementations with unusual uintptr_t?Scott Lurndal
`- Re: Examples of implementations with unusual uintptr_t?Keith Thompson

1
Examples of implementations with unusual uintptr_t?

<liAqN.244457$Wp_8.208846@fx17.iad>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=31268&group=comp.lang.c#31268

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!peer02.ams1!peer.ams1.xlned.com!news.xlned.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx17.iad.POSTED!not-for-mail
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Newsgroups: comp.lang.c
Content-Language: en-US
From: anth...@cuozzo.us (Anthony Cuozzo)
Subject: Examples of implementations with unusual uintptr_t?
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 10
Message-ID: <liAqN.244457$Wp_8.208846@fx17.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Fri, 19 Jan 2024 19:44:17 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Fri, 19 Jan 2024 14:44:17 -0500
X-Received-Bytes: 1028
 by: Anthony Cuozzo - Fri, 19 Jan 2024 19:44 UTC

Does anyone know of any examples of compilers for flat memory
architectures in which uintptr_t is defined, but the underlying values
aren't just the memory addresses you'd use in the machine code for the
architecture?

fabricated e.g., "The cccccc compiler for the DMR-VI machine has
uintptr_t with all bits reversed!"

Thanks,
--Anthony

Re: Examples of implementations with unusual uintptr_t?

<7NAqN.362496$83n7.133281@fx18.iad>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=31271&group=comp.lang.c#31271

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!peer03.ams1!peer.ams1.xlned.com!news.xlned.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx18.iad.POSTED!not-for-mail
X-newsreader: xrn 9.03-beta-14-64bit
Sender: scott@dragon.sl.home (Scott Lurndal)
From: sco...@slp53.sl.home (Scott Lurndal)
Reply-To: slp53@pacbell.net
Subject: Re: Examples of implementations with unusual uintptr_t?
Newsgroups: comp.lang.c
References: <liAqN.244457$Wp_8.208846@fx17.iad>
Lines: 7
Message-ID: <7NAqN.362496$83n7.133281@fx18.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Fri, 19 Jan 2024 20:17:07 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Fri, 19 Jan 2024 20:17:07 GMT
X-Received-Bytes: 1006
 by: Scott Lurndal - Fri, 19 Jan 2024 20:17 UTC

Anthony Cuozzo <anthony@cuozzo.us> writes:
>Does anyone know of any examples of compilers for flat memory
>architectures in which uintptr_t is defined, but the underlying values
>aren't just the memory addresses you'd use in the machine code for the
>architecture?

https://www.cl.cam.ac.uk/research/security/ctsrd/cheri/

Re: Examples of implementations with unusual uintptr_t?

<87bk9hc8ya.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=31277&group=comp.lang.c#31277

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!news.chmurka.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c
Subject: Re: Examples of implementations with unusual uintptr_t?
Date: Fri, 19 Jan 2024 13:25:01 -0800
Organization: None to speak of
Lines: 46
Message-ID: <87bk9hc8ya.fsf@nosuchdomain.example.com>
References: <liAqN.244457$Wp_8.208846@fx17.iad>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="557d127e5a9de6fbe9a4acea8ddca985";
logging-data="3487940"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19BFBlX56XzQit5Cd2ytLkZ"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:j8KWyGqPppc9GyYFw70dx6yTYfs=
sha1:Iyspb0JctSC0iyxQRf5UPKQvsk4=
 by: Keith Thompson - Fri, 19 Jan 2024 21:25 UTC

Anthony Cuozzo <anthony@cuozzo.us> writes:
> Does anyone know of any examples of compilers for flat memory
> architectures in which uintptr_t is defined, but the underlying values
> aren't just the memory addresses you'd use in the machine code for the
> architecture?
>
> fabricated e.g., "The cccccc compiler for the DMR-VI machine has
> uintptr_t with all bits reversed!"

No, but I have an interesting counterexample.

Cray vector machines (T90, SV1, etc.) have 64-bit words, and
machine-level addresses are 64-bit words that can only address a full
word. There is no hardware support for addressing octets. The C
implementation has CHAR_BIT==8, so byte addresses are constructed in
compiler-generated code by storing a 3-bit byte offset in the high-order
3 bits of a pointer value. The maximum address space is far smaller
than 64 bits, so it's not necessary to make char* and void* bigger than
int*; those bits would always have been zero. One consequence of this
is that string-handling code is relatively slow. These machines are
heavily optimized for floating-point computations.

Casting between a pointer and a 64-bit integer, for example uintptr_t,
just copies the bits of the representation.

I once fixed some code that was trying to do pointer arithmetic by
converting to an integer and doing arithmetic on the result, which would
give garbage results if the 3-bit offset is non-zero, and results off by
a factor of 8 even if the offset is zero. The fix was simply to do
pointer arithmetic, which the compiler takes care of getting right.

(The compiler *could* have implemented pointer-to-integer conversion by
constructing a byte address, but there would be no great advantage in
that other than catering to non-portable code -- and providing a
positive answer to your question.)

And to be clear, the issue is not how uintptr_t is represented.
uintptr_t itself is just an alias for an existing unsigned integer type
(possibly an extended integer type, but very probably just one of the
predefined ones). The issue is whether a conversion from a pointer to a
same-sized integer does something more than blindly copying the bits.

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Medtronic
void Void(void) { Void(); } /* The recursive call of the void */

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor