Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 29 Jul 1999 11:18:21 -0400 (EDT)
From:      Garrett Wollman <wollman@khavrinen.lcs.mit.edu>
To:        "Brian F. Feldman" <green@FreeBSD.org>
Cc:        chat@FreeBSD.org
Subject:   Re: cvs commit: src/sys/netinet ip_fw.c
Message-ID:  <199907291518.LAA13592@khavrinen.lcs.mit.edu>
In-Reply-To: <Pine.BSF.4.10.9907291037360.13541-100000@janus.syracuse.net>
References:  <199907291156.NAA06494@labinfo.iet.unipi.it> <Pine.BSF.4.10.9907291037360.13541-100000@janus.syracuse.net>

next in thread | previous in thread | raw e-mail | index | archive | help
<<On Thu, 29 Jul 1999 10:39:16 -0400 (EDT), "Brian F. Feldman" <green@FreeBSD.org> said:

> Hehe. The point is that '8' does not specifically make apparent that we
> want the 'Number of Bits per BYtes'. Your examples of ZERO and ONE do
> not make anything more clear, whereas NBBY does.

To be fair, what's usually needed in C programs is not Number of Bits
per BYte (NBBY), but rather CHARacter's count of BITs (CHAR_BIT).
To some extent, this is a result of a significant historical shift in
meaning:

Originally, a ``byte'' was simply a contiguous string of bits, with no
universally-accepted length.  Different machines had different byte
sizes, and some were only word-addressable to begin with so packing
and unpacking had to be done in software.  Most famously, in PDP-10
terminology, a byte could be any chunk of the 36-bit word, and there
were machine instructions to extract such chunks.

Of course, we all know what happened: IBM took over the world, and DEC
abandoned the PDP-10 in favor of the VAX.  IBM decided to make an
eight-bit character set (EBCDIC), and since their machines had 32-bit
words it was natural to fix their byte size at eight.

Eight-bit-long characters became standard rather before the eight-bit
bytes did; this is why network protocols often speak of ``octets''
rather than ``bytes'' -- at the time protocolspeak was being
developed, there was no unambiguous term for ``eight-bit byte'', so
``octet'' was borrowed from the French.

36-bit machines like the PDP-10 persisted for quite a while.
Depending on the application and character set, character sizes of
seven, eight, nine, and twelve bits were used.  (This is the reason
the `TYPE L' command in FTP takes the byte size as an argument.)  They
persisted through the era of C standardization, and the fine folks on
X3J11, recognizing the need to for C to be portable, eschewed any
notion of ``bytes'' or other explicit bit-lengths and defined
everything in terms of characters.  Hence, the smallest object in C as
defined by X3.159-1989 is a character, and the sizeof operator is
defined to give values in character-lengths.  It was obviously
necessary for programmers to know how big these characters were, so
the committee invented the macro CHAR_BIT which provides the answer.

-GAWollman

--
Garrett A. Wollman   | O Siem / We are all family / O Siem / We're all the same
wollman@lcs.mit.edu  | O Siem / The fires of freedom 
Opinions not those of| Dance in the burning flame
MIT, LCS, CRS, or NSA|                     - Susan Aglukark and Chad Irschick


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-chat" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199907291518.LAA13592>