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. 317fbd6150SJohn-Mark Gurney.\" 327f3dea24SPeter Wemm.\" $FreeBSD$ 337fbd6150SJohn-Mark Gurney.\" 340786f79cSPoul-Henning Kamp.Dd December 13, 1995 350786f79cSPoul-Henning Kamp.Dt INTRO 9 363d45e180SRuslan Ermilov.Os 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.Sh PROTOTYPES ANSI-C AND ALL THAT 440786f79cSPoul-Henning KampYes please. 45aab5e1b6SMike Pritchard.Pp 460786f79cSPoul-Henning KampWe would like all code to be fully prototyped. 47aab5e1b6SMike Pritchard.Pp 480786f79cSPoul-Henning KampIf your code compiles cleanly with 490786f79cSPoul-Henning Kamp.Nm cc 500786f79cSPoul-Henning Kamp.Ar -Wall 510786f79cSPoul-Henning Kampwe would feel happy about it. 520786f79cSPoul-Henning KampIt is important to understand that this isn't a question of just shutting up 530786f79cSPoul-Henning Kamp.Nm cc , 540786f79cSPoul-Henning Kampit is a question about avoiding the things it complains about. 550786f79cSPoul-Henning KampTo put it bluntly, don't hide the problem by casting and other 560786f79cSPoul-Henning Kampobfuscating practices, solve the problem. 570786f79cSPoul-Henning Kamp.Sh INDENTATION AND STYLE 5818809773SMike PritchardBelieve it or not, there actually exists a guide for indentation and style. 590786f79cSPoul-Henning KampIt isn't generally applied though. 60aab5e1b6SMike Pritchard.Pp 610786f79cSPoul-Henning KampWe would appreciate if people would pay attention to it, and at least not 620786f79cSPoul-Henning Kampviolate it blatantly. 63aab5e1b6SMike Pritchard.Pp 640786f79cSPoul-Henning KampWe don't mind it too badly if you have your own style, but please make 650786f79cSPoul-Henning Kampsure we can read it too. 66aab5e1b6SMike Pritchard.Pp 67b030a305SPoul-Henning KampPlease take time to read 68b030a305SPoul-Henning Kamp.Xr style 9 69b030a305SPoul-Henning Kampfor more information. 700786f79cSPoul-Henning Kamp.Sh NAMING THINGS 710786f79cSPoul-Henning KampSome general rules exist: 720786f79cSPoul-Henning Kamp.Bl -enum 730786f79cSPoul-Henning Kamp.It 740786f79cSPoul-Henning KampIf a function is meant as a debugging aid in DDB, it should be enclosed 750786f79cSPoul-Henning Kampin 760786f79cSPoul-Henning Kamp.Bd -literal -offset indent 770786f79cSPoul-Henning Kamp#ifdef DDB 780786f79cSPoul-Henning Kamp 790786f79cSPoul-Henning Kamp#endif /* DDB */ 800786f79cSPoul-Henning Kamp.Ed 813136363fSRuslan Ermilov.Pp 824a8d0283SMike PritchardAnd the name of the procedure should start with the prefix 830786f79cSPoul-Henning Kamp.Li DDB_ 840786f79cSPoul-Henning Kampto clearly identify the procedure as a debugger routine. 850786f79cSPoul-Henning Kamp.El 860786f79cSPoul-Henning Kamp.Sh SCOPE OF SYMBOLS 870786f79cSPoul-Henning KampIt is important to carefully consider the scope of symbols in the kernel. 880786f79cSPoul-Henning KampThe default is to make everything static, unless some reason requires 890786f79cSPoul-Henning Kampthe opposite. 90aab5e1b6SMike Pritchard.Pp 910786f79cSPoul-Henning KampThere are several reasons for this policy, 920786f79cSPoul-Henning Kampthe main one is that the kernel is one monolithic name-space, 934a8d0283SMike Pritchardand pollution is not a good idea here either. 94aab5e1b6SMike Pritchard.Pp 950786f79cSPoul-Henning KampFor device drivers and other modules that don't add new internal interfaces 96476702b3SMichael Haroto the kernel, the entire source should be in one file if possible. 970786f79cSPoul-Henning KampThat way all symbols can be made static. 98aab5e1b6SMike Pritchard.Pp 990786f79cSPoul-Henning KampIf for some reason a module is split over multiple source files, then try 1000786f79cSPoul-Henning Kampto split the module along some major fault-line and consider using the 1010786f79cSPoul-Henning Kampnumber of global symbols as your guide. 1020786f79cSPoul-Henning KampThe fewer the better. 103e69bcfc3SAlexander Langer.Sh SEE ALSO 104e69bcfc3SAlexander Langer.Xr style 9 1050786f79cSPoul-Henning Kamp.Sh HISTORY 1060786f79cSPoul-Henning KampThe 1074b66483fSRuslan Ermilov.Nm 108fe6869c2SMike Pritchardsection manual page appeared in 109fe6869c2SMike Pritchard.Fx 2.2 . 110