From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: What is a byte? Date: Tue, 29 Jul 2014 19:40:56 +0100 Organization: A noiseless patient Spider Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx05.eternal-september.org; posting-host="f008dfb2a20cab2735f9b6a28e892fd7"; logging-data="29348"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+XJTJeBMhCXiuorDCVl3busPTXIH2M/Uo=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (darwin) Cancel-Lock: sha1:qbzUPFLd3mGlyQwxY5SDRko0lwI= sha1:W6MNrEvd/JjkPvpa3fslZh9IqMw= Xref: news.eternal-september.org comp.lang.ada:21339 Date: 2014-07-29T19:40:56+01:00 List-Id: "Dan'l Miller" 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).