From owner-freebsd-chat Thu Jul 29 8:19: 4 1999 Delivered-To: freebsd-chat@freebsd.org Received: from khavrinen.lcs.mit.edu (khavrinen.lcs.mit.edu [18.24.4.193]) by hub.freebsd.org (Postfix) with ESMTP id 224E214C8F; Thu, 29 Jul 1999 08:18:59 -0700 (PDT) (envelope-from wollman@khavrinen.lcs.mit.edu) Received: (from wollman@localhost) by khavrinen.lcs.mit.edu (8.9.1/8.9.1) id LAA13592; Thu, 29 Jul 1999 11:18:21 -0400 (EDT) (envelope-from wollman) Date: Thu, 29 Jul 1999 11:18:21 -0400 (EDT) From: Garrett Wollman Message-Id: <199907291518.LAA13592@khavrinen.lcs.mit.edu> To: "Brian F. Feldman" Cc: chat@FreeBSD.org Subject: Re: cvs commit: src/sys/netinet ip_fw.c In-Reply-To: References: <199907291156.NAA06494@labinfo.iet.unipi.it> Sender: owner-freebsd-chat@FreeBSD.ORG Precedence: bulk X-Loop: 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