10786f79cSPoul-Henning Kamp.\" Copyright (c) 1983, 1991, 1993 20786f79cSPoul-Henning Kamp.\" The Regents of the University of California. All rights reserved. 30786f79cSPoul-Henning Kamp.\" 40786f79cSPoul-Henning Kamp.\" Redistribution and use in source and binary forms, with or without 50786f79cSPoul-Henning Kamp.\" modification, are permitted provided that the following conditions 60786f79cSPoul-Henning Kamp.\" are met: 70786f79cSPoul-Henning Kamp.\" 1. Redistributions of source code must retain the above copyright 80786f79cSPoul-Henning Kamp.\" notice, this list of conditions and the following disclaimer. 90786f79cSPoul-Henning Kamp.\" 2. Redistributions in binary form must reproduce the above copyright 100786f79cSPoul-Henning Kamp.\" notice, this list of conditions and the following disclaimer in the 110786f79cSPoul-Henning Kamp.\" documentation and/or other materials provided with the distribution. 120786f79cSPoul-Henning Kamp.\" 3. All advertising materials mentioning features or use of this software 130786f79cSPoul-Henning Kamp.\" must display the following acknowledgement: 140786f79cSPoul-Henning Kamp.\" This product includes software developed by the University of 150786f79cSPoul-Henning Kamp.\" California, Berkeley and its contributors. 160786f79cSPoul-Henning Kamp.\" 4. Neither the name of the University nor the names of its contributors 170786f79cSPoul-Henning Kamp.\" may be used to endorse or promote products derived from this software 180786f79cSPoul-Henning Kamp.\" without specific prior written permission. 190786f79cSPoul-Henning Kamp.\" 200786f79cSPoul-Henning Kamp.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 210786f79cSPoul-Henning Kamp.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 220786f79cSPoul-Henning Kamp.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 230786f79cSPoul-Henning Kamp.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 240786f79cSPoul-Henning Kamp.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 250786f79cSPoul-Henning Kamp.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 260786f79cSPoul-Henning Kamp.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 270786f79cSPoul-Henning Kamp.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 280786f79cSPoul-Henning Kamp.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 290786f79cSPoul-Henning Kamp.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 300786f79cSPoul-Henning Kamp.\" SUCH DAMAGE. 310786f79cSPoul-Henning Kamp.\" 320786f79cSPoul-Henning Kamp.\" @(#)intro.8 8.2 (Berkeley) 12/11/93 330786f79cSPoul-Henning Kamp.\" 340786f79cSPoul-Henning Kamp.Dd December 13, 1995 350786f79cSPoul-Henning Kamp.Dt INTRO 9 360786f79cSPoul-Henning Kamp.Os FreeBSD 2.2 370786f79cSPoul-Henning Kamp.Sh NAME 380786f79cSPoul-Henning Kamp.Nm intro 390786f79cSPoul-Henning Kamp.Nd "introduction to system kernel interfaces" 400786f79cSPoul-Henning Kamp.Sh DESCRIPTION 410786f79cSPoul-Henning KampThis section contains information about the interfaces and 420786f79cSPoul-Henning Kampsubroutines in the kernel. 430786f79cSPoul-Henning Kamp 440786f79cSPoul-Henning Kamp.Sh PROTOTYPES ANSI-C AND ALL THAT 450786f79cSPoul-Henning KampYes please. 460786f79cSPoul-Henning Kamp 470786f79cSPoul-Henning KampWe would like all code to be fully prototyped. 480786f79cSPoul-Henning Kamp 490786f79cSPoul-Henning KampIf your code compiles cleanly with 500786f79cSPoul-Henning Kamp.Nm cc 510786f79cSPoul-Henning Kamp.Ar -Wall 520786f79cSPoul-Henning Kampwe would feel happy about it. 530786f79cSPoul-Henning KampIt is important to understand that this isn't a question of just shutting up 540786f79cSPoul-Henning Kamp.Nm cc , 550786f79cSPoul-Henning Kampit is a question about avoiding the things it complains about. 560786f79cSPoul-Henning KampTo put it bluntly, don't hide the problem by casting and other 570786f79cSPoul-Henning Kampobfuscating practices, solve the problem. 580786f79cSPoul-Henning Kamp 590786f79cSPoul-Henning Kamp.Sh INDENTATION AND STYLE 600786f79cSPoul-Henning KampBelive it or not, there actually exists a guide for indentation and style. 610786f79cSPoul-Henning KampIt isn't generally applied though. 620786f79cSPoul-Henning Kamp 630786f79cSPoul-Henning KampWe would appreciate if people would pay attention to it, and at least not 640786f79cSPoul-Henning Kampviolate it blatantly. 650786f79cSPoul-Henning Kamp 660786f79cSPoul-Henning KampWe don't mind it too badly if you have your own style, but please make 670786f79cSPoul-Henning Kampsure we can read it too. 680786f79cSPoul-Henning Kamp 690786f79cSPoul-Henning KampIn particular there are some iron-clad requirements: 700786f79cSPoul-Henning Kamp.Bl -enum -compact 710786f79cSPoul-Henning Kamp.It 720786f79cSPoul-Henning KampTAB stops is 8. 730786f79cSPoul-Henning Kamp.It 740786f79cSPoul-Henning KampAll funtion names start in col 1. 750786f79cSPoul-Henning Kamp.El 760786f79cSPoul-Henning Kamp 770786f79cSPoul-Henning Kamp.Sh NAMING THINGS 780786f79cSPoul-Henning KampSome general rules exist: 790786f79cSPoul-Henning Kamp.Bl -enum 800786f79cSPoul-Henning Kamp.It 810786f79cSPoul-Henning KampIf a function is meant as a debugging aid in DDB, it should be enclosed 820786f79cSPoul-Henning Kampin 830786f79cSPoul-Henning Kamp.Bd -literal -offset indent 840786f79cSPoul-Henning Kamp#ifdef DDB 850786f79cSPoul-Henning Kamp 860786f79cSPoul-Henning Kamp#endif /* DDB */ 870786f79cSPoul-Henning Kamp.Ed 880786f79cSPoul-Henning Kamp 890786f79cSPoul-Henning KampAnd the name of the procedure shoule start with the prefix 900786f79cSPoul-Henning Kamp.Li DDB_ 910786f79cSPoul-Henning Kampto clearly identify the procedure as a debugger routine. 920786f79cSPoul-Henning Kamp.El 930786f79cSPoul-Henning Kamp 940786f79cSPoul-Henning Kamp 950786f79cSPoul-Henning Kamp.Sh SCOPE OF SYMBOLS 960786f79cSPoul-Henning KampIt is important to carefully consider the scope of symbols in the kernel. 970786f79cSPoul-Henning KampThe default is to make everything static, unless some reason requires 980786f79cSPoul-Henning Kampthe opposite. 990786f79cSPoul-Henning Kamp 1000786f79cSPoul-Henning KampThere are several reasons for this policy, 1010786f79cSPoul-Henning Kampthe main one is that the kernel is one monolithic name-space, 1020786f79cSPoul-Henning Kampand polution is not a good idea here either. 1030786f79cSPoul-Henning Kamp 1040786f79cSPoul-Henning KampFor device drivers and other modules that don't add new internal interfaces 1050786f79cSPoul-Henning Kampto the kernel, the entire source should be in one file it possible. 1060786f79cSPoul-Henning KampThat way all symbols can be made static. 1070786f79cSPoul-Henning Kamp 1080786f79cSPoul-Henning KampIf for some reason a module is split over multiple source files, then try 1090786f79cSPoul-Henning Kampto split the module along some major fault-line and consider using the 1100786f79cSPoul-Henning Kampnumber of global symbols as your guide. 1110786f79cSPoul-Henning KampThe fewer the better. 1120786f79cSPoul-Henning Kamp 1130786f79cSPoul-Henning Kamp.Sh HISTORY 1140786f79cSPoul-Henning KampThe 1150786f79cSPoul-Henning Kamp.Nm intro 1160786f79cSPoul-Henning Kampsection manual page appeared in FreeBSD 2.2 117