Subject: Re: multiple inclusion protection for kernel files
To: Christos Zoulas <firstname.lastname@example.org>
From: Rui Paulo <email@example.com>
Date: 12/03/2005 22:42:16
Content-Type: text/plain; charset=us-ascii
On 2005.12.03 16:59:35 -0500, Christos Zoulas wrote:
| I just made a short pass in sys/fs and sys/sys to fix multiple inclusion
| issues. Where many files followed the current standard, there were quite
| a few that did not.
| My understanding of the current rules for include files [kernel] are:
| 1. For files that get installed in /usr/include:
| All the code in the include file is bracketed by:
| #ifndef _[<DIR>_...]<FILENAME>_H_
| #define _[<DIR>_...]<FILENAME>_H_
| .... code ....
| #endif /* _[<DIR>_...]<FILENAME>_H_ */
| The DIR portion is the dirname portion of the path capitalized, and wi=
| `/' substituted by `_'. The path is the install path of the file not t=
| source path. For example:
| src/sys/fs/cd9660/iso.h gets installed in /usr/include/isofs/cd9660/is=
| so the file should be protected by:
| #ifndef _ISOFS_CD9660_ISO_H_
| #define _ISOFS_CD9660_ISO_H_
| #endif /* _ISOFS_CD9660_ISO_H_ */
| Files that should not be protected against multiple inclusion should m=
| this prominently as a comment immediately after the copyright notice.
Yes, I think this truly correct.
| 2. Header files that are not installed are not protected for multiple inc=
| but they are protected against use in the userland by:
| #ifndef _KERNEL
| #error not supposed to be exposed to userland.
| #endif /* _KERNEL */
| The rationale is that we don't want to include these files multiple ti=
| accidentally, and we also don't want userland applications to include =
| Most of the kernel files do not follow this standard right now. I.e. t=
| are files that are used by userland programs and not being installed, =
| most files don't have the #error protection.
We can work together on fixing this.
-- Rui Paulo
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (NetBSD)
-----END PGP SIGNATURE-----