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


Groups > comp.lang.c > #112299

Re: Type system protocols rest atop fundamental data

From David Brown <david.brown@hesbynett.no>
Newsgroups comp.lang.c
Subject Re: Type system protocols rest atop fundamental data
Date 2017-06-15 23:53 +0200
Organization A noiseless patient Spider
Message-ID <ohuve0$p7i$1@dont-email.me> (permalink)
References (10 earlier) <91aa3a76-5824-42e7-83de-ea8d70adaa5c@googlegroups.com> <1QA0B.19234$OD2.1153@fx44.iad> <1a4c81c8-9af3-4185-9bfe-864aa8590e01@googlegroups.com> <ohuq9a$5fk$1@dont-email.me> <3b604181-d513-4b04-a857-a35bf80b7fda@googlegroups.com>

Show all headers | View raw


On 15/06/17 23:23, supercat@casperkitty.com wrote:
> On Thursday, June 15, 2017 at 3:25:48 PM UTC-5, David Brown wrote:
>> On 15/06/17 22:02, supercat wrote:
>> The kindest thing that could be said about MS's decision to make long
>> 32-bit in 64-bit mode is that they thought lots of existing Windows C
>> code would make the assumption that long is always 32-bit, and so that
>> choice would cause least breakage.
> 
> C code for almost *any* microcomputer platform would have made such an
> assumption prior to C99, since "long" was the closest thing to a fixed-
> sized 32-bit type.  Many programs needed three sizes of integer, while
> C defined a total of four types.  This allowed for one of C's types to
> be regarded as implementation-dependent, and the other three to be
> regarded as fixed size *among implementations targeting microcomputers*.
> 

C99 had been around for many years before MS started on 64-bit Windows - 
though MSVC certainly didn't support it.

But you are almost right - people used "long" to mean /at least/ 32-bit. 
  It is only those who write tightly platform-specific code that assumed 
it was always /exactly/ 32-bit.


> I'm not clear why code which wants something that's 32 bits on 32-bit
> platforms and 64 bits on 64-bit platforms would want to use "long"
> rather than something like size_t or ptrdiff_t, which would seem like
> perfect types for that purpose.

Yes, often these would be a better choice of type.

> 
>> The least kind explanation is that this applied to their own code.
> 
> Their code is no worse in that regard than any other code written for
> microcomputers prior to C99.

People had been writing code that worked on 16-bit, 32-bit and 64-bit 
for a good while before that.  64-bit entered the microcomputer 
mainstream in the mid 1990's.  (Cray had 64-bit data, but not 64-bit 
addresses, in 1976, and MIPS made their first 64-bit cpu in 1991.)  In 
the *nix world, C code that is portable between 32-bit and 64-bit 
predates C99 quite significantly.

> 
>> Either way, backwards compatibility with existing Windows C (or C++)
>> code is the only sensible reason for having 32-bit longs in a 64-bit system.
> 
> Or any other C code written for microcomputers that doesn't rely upon C99
> types.
> 
>> (And Windows code that assumed a pointer could be stored in a "long"
>> still broke.)
> 
> Microsoft could have handled compatibility better there, if they'd
> remembered how things were done in 16-bit days.  Many programs use a
> small amount of RAM frequently, and a large amount infrequently.  A
> pointer with a "far" qualifier could access anything in memory, slowly,
> while one with a "near" qualifier would be limited to accessing objects
> that were within the primary 64K data segment.  A similar concept could
> have been incorporated into 64-bit Windows--not trying to use "thunking"
> in the style of segment-mode Windows (which never worked terribly well)
> but by having special functions to request low-memory allocations, and
> a means of converting 64-bit pointers to such allocations into 32-bit
> pointers suitable for use with old APIs.
> 

The last thing anyone wanted or needed would be yet another way to 
access memory in different sized chunks and with programs having 
pointers of different sizes.  I am very glad that MS stuck to a linear 
addressing.  It is fair enough to choose to use 32-bit programs on a 
64-bit cpu, or to have an intermediary size like the x32 ABI (64-bit 
integers and all the 64-bit registers, but 32-bit addresses).  But 
mixing them within the same code is a terrible idea.

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


Thread

Type system protocols rest atop fundamental data "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2017-06-14 06:14 -0700
  Re: Type system protocols rest atop fundamental data "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2017-06-14 06:18 -0700
    Re: Type system protocols rest atop fundamental data mark.bluemel@gmail.com - 2017-06-14 08:00 -0700
      Re: Type system protocols rest atop fundamental data "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2017-06-14 08:06 -0700
    Re: Type system protocols rest atop fundamental data bartc <bc@freeuk.com> - 2017-06-14 20:39 +0100
      Re: Type system protocols rest atop fundamental data Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-06-14 21:51 +0100
        Re: Type system protocols rest atop fundamental data bartc <bc@freeuk.com> - 2017-06-14 22:25 +0100
          Re: Type system protocols rest atop fundamental data Keith Thompson <kst-u@mib.org> - 2017-06-14 14:37 -0700
            Re: Type system protocols rest atop fundamental data bartc <bc@freeuk.com> - 2017-06-15 00:32 +0100
              Re: Type system protocols rest atop fundamental data Keith Thompson <kst-u@mib.org> - 2017-06-14 17:02 -0700
                Re: Type system protocols rest atop fundamental data bartc <bc@freeuk.com> - 2017-06-15 01:34 +0100
                Re: Type system protocols rest atop fundamental data Robert Wessel <robertwessel2@yahoo.com> - 2017-06-14 20:28 -0500
                Re: Type system protocols rest atop fundamental data raltbos@xs4all.nl (Richard Bos) - 2017-06-18 10:49 +0000
                Re: Type system protocols rest atop fundamental data Keith Thompson <kst-u@mib.org> - 2017-06-14 20:02 -0700
                Re: Type system protocols rest atop fundamental data David Brown <david.brown@hesbynett.no> - 2017-06-15 10:29 +0200
                Re: Type system protocols rest atop fundamental data bartc <bc@freeuk.com> - 2017-06-15 10:54 +0100
                Re: Type system protocols rest atop fundamental data David Brown <david.brown@hesbynett.no> - 2017-06-15 13:15 +0200
                Re: Type system protocols rest atop fundamental data bartc <bc@freeuk.com> - 2017-06-15 13:51 +0100
                Re: Type system protocols rest atop fundamental data David Brown <david.brown@hesbynett.no> - 2017-06-15 16:13 +0200
                Re: Type system protocols rest atop fundamental data Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-06-15 16:01 +0100
                Re: Type system protocols rest atop fundamental data Keith Thompson <kst-u@mib.org> - 2017-06-15 09:27 -0700
                Re: Type system protocols rest atop fundamental data raltbos@xs4all.nl (Richard Bos) - 2017-06-18 10:49 +0000
                Re: Type system protocols rest atop fundamental data Tim Rentsch <txr@alumni.caltech.edu> - 2017-06-16 23:35 -0700
                Re: Type system protocols rest atop fundamental data Keith Thompson <kst-u@mib.org> - 2017-06-17 16:10 -0700
                Re: Type system protocols rest atop fundamental data supercat@casperkitty.com - 2017-06-17 19:23 -0700
              Re: Type system protocols rest atop fundamental data Ian Collins <ian-news@hotmail.com> - 2017-06-16 13:13 +1200
                Re: Type system protocols rest atop fundamental data "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2017-06-15 18:44 -0700
                Re: Type system protocols rest atop fundamental data David Brown <david.brown@hesbynett.no> - 2017-06-16 13:42 +0200
                Re: Type system protocols rest atop fundamental data Gareth Owen <gwowen@gmail.com> - 2017-06-16 20:20 +0100
                Re: Type system protocols rest atop fundamental data Robert Wessel <robertwessel2@yahoo.com> - 2017-06-18 00:32 -0500
                Re: Type system protocols rest atop fundamental data raltbos@xs4all.nl (Richard Bos) - 2017-06-18 11:06 +0000
                Re: Type system protocols rest atop fundamental data David Brown <david.brown@hesbynett.no> - 2017-06-18 15:26 +0200
                Re: Type system protocols rest atop fundamental data bartc <bc@freeuk.com> - 2017-06-18 14:58 +0100
          Re: Type system protocols rest atop fundamental data Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-06-15 01:42 +0100
            Re: Type system protocols rest atop fundamental data bartc <bc@freeuk.com> - 2017-06-15 11:52 +0100
              Re: Type system protocols rest atop fundamental data Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-06-15 16:07 +0100
                Re: Type system protocols rest atop fundamental data Tim Rentsch <txr@alumni.caltech.edu> - 2017-06-16 23:37 -0700
              Re: Type system protocols rest atop fundamental data Keith Thompson <kst-u@mib.org> - 2017-06-15 09:52 -0700
                Re: Type system protocols rest atop fundamental data supercat@casperkitty.com - 2017-06-15 10:36 -0700
                Re: Type system protocols rest atop fundamental data scott@slp53.sl.home (Scott Lurndal) - 2017-06-15 17:58 +0000
                Re: Type system protocols rest atop fundamental data supercat@casperkitty.com - 2017-06-15 11:48 -0700
                Re: Type system protocols rest atop fundamental data scott@slp53.sl.home (Scott Lurndal) - 2017-06-15 19:01 +0000
                Re: Type system protocols rest atop fundamental data supercat@casperkitty.com - 2017-06-15 12:29 -0700
                Re: Type system protocols rest atop fundamental data Ian Collins <ian-news@hotmail.com> - 2017-06-16 13:47 +1200
                Re: Type system protocols rest atop fundamental data supercat@casperkitty.com - 2017-06-15 19:33 -0700
                Re: Type system protocols rest atop fundamental data supercat@casperkitty.com - 2017-06-15 13:02 -0700
                Re: Type system protocols rest atop fundamental data "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2017-06-15 13:09 -0700
                Re: Type system protocols rest atop fundamental data David Brown <david.brown@hesbynett.no> - 2017-06-15 22:25 +0200
                Re: Type system protocols rest atop fundamental data supercat@casperkitty.com - 2017-06-15 14:23 -0700
                Re: Type system protocols rest atop fundamental data David Brown <david.brown@hesbynett.no> - 2017-06-15 23:53 +0200
                Re: Type system protocols rest atop fundamental data supercat@casperkitty.com - 2017-06-15 15:39 -0700
                Re: Type system protocols rest atop fundamental data David Brown <david.brown@hesbynett.no> - 2017-06-16 13:50 +0200
                Re: Type system protocols rest atop fundamental data supercat@casperkitty.com - 2017-06-16 08:40 -0700
                Re: Type system protocols rest atop fundamental data David Brown <david.brown@hesbynett.no> - 2017-06-18 16:49 +0200
                Re: Type system protocols rest atop fundamental data supercat@casperkitty.com - 2017-06-19 10:33 -0700
                Re: Type system protocols rest atop fundamental data scott@slp53.sl.home (Scott Lurndal) - 2017-06-19 17:50 +0000
                Re: Type system protocols rest atop fundamental data supercat@casperkitty.com - 2017-06-19 12:12 -0700
                Re: Type system protocols rest atop fundamental data scott@slp53.sl.home (Scott Lurndal) - 2017-06-19 19:27 +0000
                Re: Type system protocols rest atop fundamental data Ike Naar <ike@iceland.freeshell.org> - 2017-06-20 15:18 +0000
                Re: Type system protocols rest atop fundamental data supercat@casperkitty.com - 2017-06-20 09:30 -0700
                Re: Type system protocols rest atop fundamental data David Kleinecke <dkleinecke@gmail.com> - 2017-06-16 12:05 -0700
                Re: Type system protocols rest atop fundamental data supercat@casperkitty.com - 2017-06-16 12:30 -0700
                Re: Type system protocols rest atop fundamental data David Brown <david.brown@hesbynett.no> - 2017-06-18 16:54 +0200
                Re: Type system protocols rest atop fundamental data supercat@casperkitty.com - 2017-06-19 13:25 -0700
                Re: Type system protocols rest atop fundamental data David Brown <david.brown@hesbynett.no> - 2017-06-20 09:27 +0200
                Re: Type system protocols rest atop fundamental data supercat@casperkitty.com - 2017-06-20 08:53 -0700
                Re: Type system protocols rest atop fundamental data David Brown <david.brown@hesbynett.no> - 2017-06-20 22:12 +0200
                Re: Type system protocols rest atop fundamental data "Chris M. Thomasson" <invalid@invalid.invalid> - 2017-06-20 13:14 -0700
                Re: Type system protocols rest atop fundamental data "Chris M. Thomasson" <invalid@invalid.invalid> - 2017-06-20 13:16 -0700
                Re: Type system protocols rest atop fundamental data supercat@casperkitty.com - 2017-06-20 14:04 -0700
                Re: Type system protocols rest atop fundamental data David Brown <david.brown@hesbynett.no> - 2017-06-21 15:33 +0200
                Re: Type system protocols rest atop fundamental data scott@slp53.sl.home (Scott Lurndal) - 2017-06-20 13:25 +0000
                Re: Type system protocols rest atop fundamental data scott@slp53.sl.home (Scott Lurndal) - 2017-06-16 19:42 +0000
                Re: Type system protocols rest atop fundamental data David Brown <david.brown@hesbynett.no> - 2017-06-18 16:58 +0200
                Re: Type system protocols rest atop fundamental data raltbos@xs4all.nl (Richard Bos) - 2017-06-17 19:18 +0000
                Re: Type system protocols rest atop fundamental data Robert Wessel <robertwessel2@yahoo.com> - 2017-06-15 23:40 -0500
                Re: Type system protocols rest atop fundamental data David Brown <david.brown@hesbynett.no> - 2017-06-16 13:51 +0200
                Re: Type system protocols rest atop fundamental data scott@slp53.sl.home (Scott Lurndal) - 2017-06-16 12:55 +0000
      Re: Type system protocols rest atop fundamental data "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2017-06-14 14:23 -0700
        Re: Type system protocols rest atop fundamental data Ian Collins <ian-news@hotmail.com> - 2017-06-16 13:48 +1200
          Re: Type system protocols rest atop fundamental data "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2017-06-15 19:03 -0700
            Re: Type system protocols rest atop fundamental data Ian Collins <ian-news@hotmail.com> - 2017-06-16 15:12 +1200
              Re: Type system protocols rest atop fundamental data "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2017-06-15 20:20 -0700
              Re: Type system protocols rest atop fundamental data Richard Heathfield <rjh@cpax.org.uk> - 2017-06-16 07:03 +0100
                Re: Type system protocols rest atop fundamental data Ian Collins <ian-news@hotmail.com> - 2017-06-16 20:01 +1200
                Re: Type system protocols rest atop fundamental data Richard Heathfield <rjh@cpax.org.uk> - 2017-06-16 19:21 +0100
                Re: Type system protocols rest atop fundamental data "Chris M. Thomasson" <invalid@invalid.invalid> - 2017-06-16 12:07 -0700
                Re: Type system protocols rest atop fundamental data Ian Collins <ian-news@hotmail.com> - 2017-06-17 16:18 +1200
                Re: Type system protocols rest atop fundamental data Richard Heathfield <rjh@cpax.org.uk> - 2017-06-17 07:19 +0100
                Re: Type system protocols rest atop fundamental data raltbos@xs4all.nl (Richard Bos) - 2017-06-17 19:19 +0000
                Re: Type system protocols rest atop fundamental data Ian Collins <ian-news@hotmail.com> - 2017-06-18 08:29 +1200
                Re: Type system protocols rest atop fundamental data supercat@casperkitty.com - 2017-06-17 18:49 -0700
                Re: Type system protocols rest atop fundamental data Ian Collins <ian-news@hotmail.com> - 2017-06-18 16:18 +1200
                Re: Type system protocols rest atop fundamental data Öö Tiib <ootiib@hot.ee> - 2017-06-18 06:28 -0700
                Re: Type system protocols rest atop fundamental data Keith Thompson <kst-u@mib.org> - 2017-06-16 09:11 -0700
                Re: Type system protocols rest atop fundamental data Tim Rentsch <txr@alumni.caltech.edu> - 2017-06-16 23:37 -0700
                Re: Type system protocols rest atop fundamental data David Brown <david.brown@hesbynett.no> - 2017-06-18 17:04 +0200
            Re: Type system protocols rest atop fundamental data scott@slp53.sl.home (Scott Lurndal) - 2017-06-16 12:56 +0000
              Re: Type system protocols rest atop fundamental data "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2017-06-16 07:10 -0700
              Re: Type system protocols rest atop fundamental data GOTHIER Nathan <nathan.gothier@gmail.com> - 2017-06-16 16:38 +0200
                Re: Type system protocols rest atop fundamental data scott@slp53.sl.home (Scott Lurndal) - 2017-06-16 15:02 +0000
                Re: Type system protocols rest atop fundamental data "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2017-06-16 08:11 -0700
                Re: Type system protocols rest atop fundamental data David Brown <david.brown@hesbynett.no> - 2017-06-18 17:13 +0200
      Re: Type system protocols rest atop fundamental data supercat@casperkitty.com - 2017-06-14 14:42 -0700
  Re: Type system protocols rest atop fundamental data Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-06-14 21:32 +0100
    Re: Type system protocols rest atop fundamental data "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2017-06-14 14:28 -0700

csiph-web