Date: Sun, 23 Apr 2000 19:22:35 -0400 (EDT) From: Brian Fundakowski Feldman <green@freebsd.org> To: arch@freebsd.org Subject: limits.h and styles; ANSIfication Message-ID: <Pine.BSF.4.21.0004231855310.46547-100000@green.dyndns.org>
next in thread | raw e-mail | index | archive | help
I've noticed that machdep headers tend to diverge quite a bit from the i386 and alpha trees, and it seems like this is a good thing. It's a good thing because old headers are being cleaned up and made much more readable. The first case I'd like to take care of is limits.h. If you look at the i386 tree's limits.h, you have things like this, a prime example: #define INT_MIN (-2147483647-1) /* min value for an int */ Now, if you look at the alpha header, limits.h looks much cleaner: #define INT_MIN (-0x7fffffff-1) /* min value for an int */ Okay, that's nicer, but it's not as clean as the now-common: #define INT_MIN -0x80000000 /* min value for an int */ There are many cases of this. In each case, the "compiler bugs" that caused the very strange declarations are no longer around, and likely haven't been around for a very long time. I'd like to bring these files' styles in line with eachother. Here are the (fully-tested on i386) diffs which bring the styles closer, standardizing on hexadecimal constants rather than weird-looking decimal ones. The advantage is, of course, that it's easy to count the bits in a hexadecimal constant, so the header is much more human-readable. Consulting the C9X draft, January 18, 1999 (WG14/N869), pg. 492 (Annex E: Implementation limits), the new style is perfectly acceptable: [#1] The contents of the header <limits.h> are given below, in alphabetical order. The minimum magnitudes shown shall be replaced by implementation-defined magnitudes with the same sign. The values shall all be constant expressions suitable for use in #if preprocessing directives. The components are described further in 5.2.4.2.1. Therefore, I'd like to submit the patches for this cleanup for review. After this, I'd like to begin work on making our system's headers more C9X-compliant, including getting <stdint.h>, <stdbool.h>, and <inttypes.h>, and <stddef.h> knocked off first. <stddef.h> is the home of things such as ptrdiff_t, size_t, wchar_t, NULL, and offsetof(). <stdint.h> is the home of u?int(|_least|_fast)[[:digit:]]*_t, u?intptr_t, and u?intmax_t. There are of course some issues with getting the proper ifdefs in, but it's not bad. Of course, these will also require work on <limits.h>, but hopefully <machine/limits.h> will not have to be modified for anything but the "maximal" int types. Sorry for turning this into two different subjects, but it's inevitable. I'd appreciate reviews on limits.h, and of course discussion for the implementation of C9X in FreeBSD. -- Brian Fundakowski Feldman \ FreeBSD: The Power to Serve! / green@FreeBSD.org `------------------------------' To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.21.0004231855310.46547-100000>