Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #164639

Re: Here come the 128-bit pointers

From David Brown <david.brown@hesbynett.no>
Newsgroups comp.lang.c
Subject Re: Here come the 128-bit pointers
Date 2022-01-26 09:36 +0100
Organization A noiseless patient Spider
Message-ID <ssr173$ljo$1@dont-email.me> (permalink)
References <RZBHJ.39378$gX.11188@fx40.iad> <sso8kg$82t$1@dont-email.me> <ssochk$t26$1@dont-email.me> <a6bbc001-438a-4298-b096-29ed8505fb2bn@googlegroups.com> <sspdgi$3sj$1@dont-email.me>

Show all headers | View raw


On 25/01/2022 18:54, BGB wrote:
> On 1/25/2022 4:04 AM, Öö Tiib wrote:
>> On Tuesday, 25 January 2022 at 10:32:01 UTC+2, BGB wrote:

>>> Unlikely to be widely adopted, as using it would adversely impact
>>> existing C codebases (which tend to assume pointers are either 32 or 64
>>> bits, and the ability to freely cast to and from integer types and
>>> manipulate them at the bit level, ...).
>>
>> That is unlikely a problem. Very few actual products convert to integers
>> and crunch pointers at bit level. The one's that do are highly platform
>> specific and so don't care about Morellos elsewhere in universe.
>> The portable code bases however support both 32 and 64 bit pointers
>> without problems already now as rule. Adding 128 is just extending
>> what is already there.
>>
> 
> My experience differs some.
> 
> It was sort of a pain porting a lot of 32-bit era code to 64-bit
> targets, mostly because of these sorts of issues. Porting 16-bit era
> code borders on rewriting much of it (such as to eliminate all the
> wrangling with "far pointers"; or to deal with things like 'int' and
> 'long' now being different sizes; ...).
> 
> A lot of this sort of code often still ends up with ifdefs to try to
> detect things like target and pointer size.
> 
> A few times, one has also gotten bitten by code which assumes things
> like whether 'char' is signed or unsigned by default, etc.
> 
> 
> 
> My prediction is that porting such code to also be able to deal with
> 128-bit pointers would be yet another layer of hassle.
> 

I think this is going to vary depending on the ancestory of the code.
In DOS and 16-bit Windows programming, you had a mess of "far" and
"near" pointers, and different sizes.  There were many tricks/hacks used
for re-using high bits of pointers, xor'ing pointers so you get
double-linked lists with just one pointer, and so on.  Some of this code
and attitude was moved directly over to 32-bit Windows.  Programmers
viewed everything as a fixed ABI - you /knew/ "long int" was 32-bit and
big enough for a pointer.  There was no C99 in MS' world at the time,
nor any attempt at standardisation or portability - you didn't use
"uintptr_t" for an integer matching a pointer, you used "unsigned long",
"DWORD", or other such "wintypes.h" name.

The move to 64-bit Windows involved a great deal of work here for a lot
of code.  In particular, programmers had made two assumptions about
"long int" - that they were always 32-bit, and that they could always
hold a pointer.  One of these had to break (MS choose the later), and
with it broke a lot of code.  30 years after the Alpha brought 64-bit to
the workstation, most of the programs run on Windows systems are still
32-bit.

However, for those that made the fixes and change of styles to get
64-bit to work, I don't /think/ supporting 128-bit pointers will cause
nearly as much of an issue.


For code and programmers from the *nix world, mixing 32-bit and 64-bit
targets has been the norm for decades.  Programmers usually make far
fewer assumptions about sizes, endianness, and other portability issues.
 It is common that the same source can be compiled for different 32-bit
or 64-bit targets without much trouble.  (Yes, there are ifdef's and the
like - but those are mostly in standard headers and library headers, not
application code.)  So again, moving to 128-bit pointers will not be as
hard as one might think.


Where I see the problem, however, is the challenge of introducing
128-bit integers to C.  (It might be rare to need to convert a pointer
to an integer, but people do it sometimes.)  If you want to have a
128-bit "uintptr_t", it means you also need a 128-bit "intmax_t".  Are
you going to make size_t 128-bit, or keep it at 64-bit?  Should you now
have a 128-bit "long long int"?  Should your fundamental 128-bit be an
extended integer type "__int128_t"?  "Long long long int" ?  Should you
give up on uintptr_t entirely, and say that anyone who wants to
manipulate the bits of a pointer should use memcpy and unsigned char*
pointers?

It will be interesting to see how this all plays out.

Back to comp.lang.c | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Here come the 128-bit pointers scott@slp53.sl.home (Scott Lurndal) - 2022-01-24 18:12 +0000
  Re: Here come the 128-bit pointers Dan Purgert <dan@djph.net> - 2022-01-24 18:31 +0000
  Re: Here come the 128-bit pointers BGB <cr88192@gmail.com> - 2022-01-24 15:41 -0600
  Re: Here come the 128-bit pointers Bonita Montero <Bonita.Montero@gmail.com> - 2022-01-25 08:25 +0100
    Re: Here come the 128-bit pointers BGB <cr88192@gmail.com> - 2022-01-25 02:31 -0600
      Re: Here come the 128-bit pointers Öö Tiib <ootiib@hot.ee> - 2022-01-25 02:04 -0800
        Re: Here come the 128-bit pointers scott@slp53.sl.home (Scott Lurndal) - 2022-01-25 14:48 +0000
        Re: Here come the 128-bit pointers BGB <cr88192@gmail.com> - 2022-01-25 11:54 -0600
          Re: Here come the 128-bit pointers scott@slp53.sl.home (Scott Lurndal) - 2022-01-25 18:23 +0000
            Re: Here come the 128-bit pointers BGB <cr88192@gmail.com> - 2022-01-25 14:17 -0600
          Re: Here come the 128-bit pointers David Brown <david.brown@hesbynett.no> - 2022-01-26 09:36 +0100
            Re: Here come the 128-bit pointers Theo <theom+news@chiark.greenend.org.uk> - 2022-01-28 22:12 +0000
      Re: Here come the 128-bit pointers Bonita Montero <Bonita.Montero@gmail.com> - 2022-01-25 19:49 +0100
        Re: Here come the 128-bit pointers BGB <cr88192@gmail.com> - 2022-01-25 15:59 -0600
          Re: Here come the 128-bit pointers scott@slp53.sl.home (Scott Lurndal) - 2022-01-25 22:25 +0000
          Re: Here come the 128-bit pointers Bonita Montero <Bonita.Montero@gmail.com> - 2022-01-26 09:43 +0100
            Re: Here come the 128-bit pointers scott@slp53.sl.home (Scott Lurndal) - 2022-01-26 15:53 +0000
              Re: Here come the 128-bit pointers Bonita Montero <Bonita.Montero@gmail.com> - 2022-01-26 17:25 +0100
            Re: Here come the 128-bit pointers Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2022-01-26 08:34 -0800
              Re: Here come the 128-bit pointers Bonita Montero <Bonita.Montero@gmail.com> - 2022-01-26 17:57 +0100
              Re: Here come the 128-bit pointers Bart <bc@freeuk.com> - 2022-01-26 17:10 +0000
                Re: Here come the 128-bit pointers scott@slp53.sl.home (Scott Lurndal) - 2022-01-26 17:27 +0000
                Re: Here come the 128-bit pointers Bart <bc@freeuk.com> - 2022-01-26 17:41 +0000
                Re: Here come the 128-bit pointers scott@slp53.sl.home (Scott Lurndal) - 2022-01-26 18:05 +0000
                Re: Here come the 128-bit pointers Bart <bc@freeuk.com> - 2022-01-26 18:23 +0000
                Re: Here come the 128-bit pointers BGB <cr88192@gmail.com> - 2022-01-26 14:42 -0600
                Re: Here come the 128-bit pointers BGB <cr88192@gmail.com> - 2022-01-26 14:30 -0600
              Re: Here come the 128-bit pointers Mateusz Viste <mateusz@xyz.invalid> - 2022-01-26 19:36 +0100
                Re: Here come the 128-bit pointers scott@slp53.sl.home (Scott Lurndal) - 2022-01-26 18:52 +0000
            Re: Here come the 128-bit pointers tth <tth@none.invalid> - 2022-01-26 21:01 +0100
            Re: Here come the 128-bit pointers Bart <bc@freeuk.com> - 2022-01-26 20:18 +0000
              Re: Here come the 128-bit pointers BGB <cr88192@gmail.com> - 2022-01-26 15:35 -0600
                Re: Here come the 128-bit pointers scott@slp53.sl.home (Scott Lurndal) - 2022-01-26 21:50 +0000
                Re: Here come the 128-bit pointers BGB <cr88192@gmail.com> - 2022-01-26 20:34 -0600
                Re: Here come the 128-bit pointers Bart <bc@freeuk.com> - 2022-01-27 12:11 +0000
                Re: Here come the 128-bit pointers BGB <cr88192@gmail.com> - 2022-01-27 13:40 -0600
        Re: Here come the 128-bit pointers William Ahern <william@25thandClement.com> - 2022-01-27 13:28 -0800
  Re: Here come the 128-bit pointers Theo Markettos <theom+news@chiark.greenend.org.uk> - 2022-01-28 23:18 +0000

csiph-web