From owner-freebsd-arch Sun Dec 10 21:35:20 2000 From owner-freebsd-arch@FreeBSD.ORG Sun Dec 10 21:35:17 2000 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mail.rpi.edu (mail.rpi.edu [128.113.100.7]) by hub.freebsd.org (Postfix) with ESMTP id 05ECD37B401 for ; Sun, 10 Dec 2000 21:35:17 -0800 (PST) Received: from [128.113.24.47] (gilead.acs.rpi.edu [128.113.24.47]) by mail.rpi.edu (8.9.3/8.9.3) with ESMTP id AAA98792; Mon, 11 Dec 2000 00:35:07 -0500 Mime-Version: 1.0 X-Sender: drosih@mail.rpi.edu Message-Id: In-Reply-To: References: Date: Mon, 11 Dec 2000 00:35:05 -0500 To: Dag-Erling Smorgrav , arch@FreeBSD.ORG From: Garance A Drosihn Subject: Re: %a and %A formats Content-Type: text/plain; charset="us-ascii" ; format="flowed" Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG At 3:44 PM +0100 12/10/00, Dag-Erling Smorgrav wrote: >I've added %a and %A formats to the kernel printf() and replaced >most instances of inet_ntoa() in sys/netinet with %a (I'll do >netinet6 later if there's interest). The patches are up on >freefall: > > http://people.freebsd.org/~des/software/printf-20001209.diff [an aside for those who didn't look at the diff: %a is meant for ipv4 addresses, and %A is for ipv6 addresses...] I do not think we should go in this direction. The printf family of routines is something which needs to be fairly standard across OS's (compilers, etc), and it would be a bad idea for us to arbitrary add new opcodes to those routines. Most of the opcodes in printf are for basic C types, and not OS-dependent data structures. I notice you mentioned the 'kernel printf()', which implies it is separate from the userland printf(), but I'm still not comfortable with the idea of introducing opcodes to it. Besides, I can imagine this being useful to many userland programs, and if we were to add any opcode to the userland printf then it would make sense that the same code ends up in the kernel's printf(). >I'd also appreciate any information on how to teach gcc about >%a and %A (currently, it thinks %a is a floating point format >and complains about passing a pointer instead of a double) Chances are that is *because* %a and %A are already in use somewhere, which certainly implies that this is a bad idea. I don't think we need confusion over "which codes mean what" in different versions of printf's. If we were going to add some new opcodes to printf, make them something dramatically different. Go for '%|x|', where we could add a variety of our own opcodes between the '|'s. Thus, these would be '%|a|' and '%|A|' (or perhaps some other letter). Or perhaps we could define some other routine, which would know about networking data structures, and would have it's own set of opcodes. Use that to return a string (or write into a buffer), and use printf/syslog/etc to print out that string to the desired destination. I'm just trying to toss out some suggestions here, I haven't figured out which one (if any) I like... But I do expect that using %A and %a is going to get a little confusing. disclaimer: I don't work in the kernel, so my opinion probably doesn't amount to much on a topic like this... :-) -- Garance Alistair Drosehn = gad@eclipse.acs.rpi.edu Senior Systems Programmer or gad@freebsd.org Rensselaer Polytechnic Institute or drosih@rpi.edu To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message