comp.lang.ada
 help / color / mirror / Atom feed
From: Simon Wright <simon@pushface.org>
Subject: Re: What is a byte?
Date: Tue, 29 Jul 2014 19:40:56 +0100
Date: 2014-07-29T19:40:56+01:00	[thread overview]
Message-ID: <lyd2coqa87.fsf@pushface.org> (raw)
In-Reply-To: af2a7f35-2149-444e-b2d0-8333841b1b13@googlegroups.com

"Dan'l Miller" <optikos@verizon.net> writes:

> Victor, if you transliterate your specification to say "octet"
> wherever it says "byte" (following ITU's convention to end this
> perennial/chronic silly debate over how big a byte is in C), then the
> answer to your question becomes quite clear: use integer of range {0,
> ..., 255} or {-128, ..., 128} and mask off the upper powers of 2 if
> any, because unsigned char will always be at least 8 bits on modern
> processors, which means that on some processors byte might be 16- or
> 32-bit, but those extra powers of 2 to the left are simply ignored,
> just as they are in the underlying protocol.  (No specification of any
> modern interoperable protocol uses the 2^8 and higher bits in a byte
> if they exist on some arcade hardware.)  Likewise for signed char,
> respecting twos-complement's bias of sign-extension versus
> sign-magnitude's sign bit.

I don't think this is right (not in terms of how the ABI expects a char
to be passed to a function, but in terms of what Victor ought to do).

If the C function takes a char, you should specify
Interfaces.C.char. It's up to the compiler to decide whether that gets
passed in 8 bits, 32 bits, or come to that 9/36 bits on hardware that no
one is remotely likely to encounter (even in an arcade).

  reply	other threads:[~2014-07-29 18:40 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-28 19:09 What is a byte? Victor Porton
2014-07-28 19:48 ` Dan'l Miller
2014-07-28 20:05   ` Dan'l Miller
2014-07-28 22:38   ` Randy Brukardt
2014-07-28 21:15 ` Simon Wright
2014-07-29 10:53 ` Jeffrey Carter
2014-07-29 12:26   ` Dan'l Miller
2014-07-29 18:40     ` Simon Wright [this message]
2014-07-29 21:15       ` Dan'l Miller
2014-07-29 23:08         ` Simon Clubley
2014-07-30  4:11       ` Dan'l Miller
2014-07-30  7:47       ` Simon Wright
2014-08-02 21:01   ` Keith Thompson
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox