Path: utzoo!mnetor!uunet!mcvax!philmds!philtis!chang From: chang@philtis.UUCP (Marc R.S. Chang Sing Pang) Newsgroups: comp.lang.c Subject: Re: But what about kernel printfs? Message-ID: <471@philtis.UUCP> Date: 5 May 88 08:00:52 GMT References: <12360@tut.cis.ohio-state.edu> Organization: Philips, Corp. CAD Centre, Eindhoven, The Netherlands Lines: 44 Keywords: printf,UNIX,kernel Summary: Use #defines to replace printfs with kprintfs In article <12360@tut.cis.ohio-state.edu> lvc@tut.cis.ohio-state.edu (Lawrence V. Cipriani) writes: >The discussion about compilers replacing function >calls with something supposedly equivalent (and better) >got me to wonder about all those UNIX kernel printfs. >I guess the most portable thing to do would be to replace >all the printfs (and other routines in the UNIX kernel) >that clash with the C library with kprintf kexit etc. > >Even if one argues that an implementation of the UNIX >kernel is not portable to other machines it should be >at least portable to other compilers for the same cpu. > >Is there a better solution? > >-- >Larry Cipriani, AT&T Network Systems and Ohio State University >Domain: lvc@tut.cis.ohio-state.edu >Path: ...!cbosgd!osu-cis!tut.cis.ohio-state.edu!lvc (weird but right) You don't have to replace all those kernel printfs that clash with the C library with kprintf, kexit etc. in the source. You can let the preprocessor do the work for you. e.g. Put in a .h file which is included in all the kernel source files the following lines: #define printf kprintf /* Use kernel printf for output */ #define exit kexit /* Use kernel exit, not library exit */ etc. etc. etc... This way the compiler will never see a printf statement, only kprintfs. --- Marc Chang Sing Pang Philips, Corporate Cad Centre, Eindhoven, The Netherlands uucp: {philabs!prlb2,mcvax}!philmds!philtis!chang or: {philabs!prlb2}!prlb!chang-cadctr-decnet Mail: Nederlandse Philips Bedrijven B.V. Corp. ISA/CAD Centre Building SAQ-p794 P.O.Box 218 5600 MD Eindhoven