From mboxrd@z Thu Jan 1 00:00:00 1970 MIME-Version: 1.0 In-Reply-To: <8a7bc276ced4ae75de62a296b99c1efb@hamnavoe.com> References: <8a7bc276ced4ae75de62a296b99c1efb@hamnavoe.com> Date: Thu, 22 Nov 2012 11:32:34 +0000 Message-ID: From: Charles Forsyth To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Content-Type: text/plain; charset=UTF-8 Subject: Re: [9fans] go forth and ulong no more! Topicbox-Message-UUID: defbef1e-ead7-11e9-9d60-3106f5b1d025 To try to clarify: most existing Plan 9 code doesn't worry about the actual type of sizeof or pointer differences. They assume int/long or uint/ulong. It's obvious from this discussion that hardly anyone noticed usize. Since its introduction years ago, grep shows that only kernel code has used usize. size_t is more popular in ANSI C code, but I suspect even there neither size_t nor ptrdiff_t are used everywhere they ought to be. An arbitrary sample (my src directory on Linux) shows 4995 uses of size_t, and only 54 of ptrdiff_t, but perhaps pointer subtraction just isn't that common. That's why I say that it would be better to make int and uint the same size as uintptr, although it's a bit of a waste, since existing code that needs bigger int values will use another type, but after the change it's easy to have code casually assume 64 bits. One reason 6c doesn't make int and long 64 bits is that it's quite hard to find code (automatically) that assumes they are 32 bits. Hence the drive to use explicit types when it matters. Again, I'll note that erik's manual page doesn't propose or introduce anything new: even allowing for the ill-chosen "typically" and "usually" it is still a fair reflection of the current state, or aims to be. Perhaps the unfortunate qualifications should be in BUGS. On 22 November 2012 11:10, Richard Miller <9fans@hamnavoe.com> wrote: >> usize is indeed the same size as uintptr. >> Instead of either for purely integer values, it would be better to >> make all integers 64 bit > > I hope that was intended as a joke. It's not that long ago I was > writing C for a 16-bit processor (in a smart card). I would hate to > lose the meaning of "int" as "whatever fits in a CPU register". > >