Message ID | 20170620134418.31324-1-ricaljasan@pacific.net |
---|---|
State | New |
Headers | show |
On 06/20/2017 03:44 PM, Rical Jasan wrote: > @@ -628,11 +628,10 @@ There is no operator in the C language that can give you the number of > bits in an integer data type. But you can compute it from the macro > @code{CHAR_BIT}, defined in the header file @file{limits.h}. Sorry for scope creep, but the paragraph is inaccurate: We now have *_WIDTH macros, and you actually cannot easily compute the number of usable bits in a portable manner. Rest of the patch looks fine to me. Thanks, Florian
On 06/22/2017 06:23 AM, Florian Weimer wrote: > On 06/20/2017 03:44 PM, Rical Jasan wrote: >> @@ -628,11 +628,10 @@ There is no operator in the C language that can give you the number of >> bits in an integer data type. But you can compute it from the macro >> @code{CHAR_BIT}, defined in the header file @file{limits.h}. > > Sorry for scope creep, but the paragraph is inaccurate: We now have > *_WIDTH macros, and you actually cannot easily compute the number of > usable bits in a portable manner. > > Rest of the patch looks fine to me. > > Thanks, > Florian Can I commit the refactoring [1] and prepare a follow-up patch? The issues you point out in the diff context go even further in this section. The issues I see are: * The name of the section itself is "Computing the Width of an Integer Data Type", which is probably better named "Width of an Integer Type" now (and would be consistent with the following section "Range of an Integer Type"). * The bit vector example could use LONG_WIDTH. * If the computation of the number of bits in any given data type isn't possible using CHAR_BIT, that example needs to be either removed or given a @strong{Portability Note:} (and updated with a better example, if possible). * Simply removing the inaccurate paragraph doesn't improve the section; it should still say something to introduce CHAR_BIT, which provided the practical example of computing LONGBITS for the bit vector example that introduced the section. Basically, it just needs to be rewritten... Rical [1] https://sourceware.org/ml/libc-alpha/2017-06/msg00915.html
On 07/27/2017 01:28 PM, Rical Jasan wrote: > On 06/22/2017 06:23 AM, Florian Weimer wrote: >> On 06/20/2017 03:44 PM, Rical Jasan wrote: >>> @@ -628,11 +628,10 @@ There is no operator in the C language that can give you the number of >>> bits in an integer data type. But you can compute it from the macro >>> @code{CHAR_BIT}, defined in the header file @file{limits.h}. >> >> Sorry for scope creep, but the paragraph is inaccurate: We now have >> *_WIDTH macros, and you actually cannot easily compute the number of >> usable bits in a portable manner. >> >> Rest of the patch looks fine to me. >> >> Thanks, >> Florian > > Can I commit the refactoring [1] and prepare a follow-up patch? The > issues you point out in the diff context go even further in this > section. Sure, please go ahead. Note that the hard freeze is starting really soon now. Thanks, Florian
On 07/27/2017 04:31 AM, Florian Weimer wrote: > On 07/27/2017 01:28 PM, Rical Jasan wrote: >> Can I commit the refactoring [1] and prepare a follow-up patch? The >> issues you point out in the diff context go even further in this >> section. > Sure, please go ahead. Note that the hard freeze is starting really > soon now. Committed as d3675d95. I've submitted a proposal for the larger documentation changes. Thank you, Rical
diff --git a/manual/lang.texi b/manual/lang.texi index c4b641d4e1..75af677dc9 100644 --- a/manual/lang.texi +++ b/manual/lang.texi @@ -628,11 +628,10 @@ There is no operator in the C language that can give you the number of bits in an integer data type. But you can compute it from the macro @code{CHAR_BIT}, defined in the header file @file{limits.h}. -@table @code -@item CHAR_BIT -@standards{ISO, limits.h} -This is the number of bits in a @code{char}---eight, on most systems. -The value has type @code{int}. +@deftypevr Macro int CHAR_BIT +@standards{C90, limits.h} +This is the number of bits in a @code{char}. POSIX.1-2001 requires +this to be 8. You can compute the number of bits in any data type @var{type} like this: @@ -640,7 +639,7 @@ this: @smallexample sizeof (@var{type}) * CHAR_BIT @end smallexample -@end table +@end deftypevr That expression includes padding bits as well as value and sign bits. On all systems supported by @theglibc{}, standard integer types other