Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 11 Dec 2000 00:35:05 -0500
From:      Garance A Drosihn <drosih@rpi.edu>
To:        Dag-Erling Smorgrav <des@ofug.org>, arch@FreeBSD.ORG
Subject:   Re: %a and %A formats
Message-ID:  <p04330100b65a10758f0c@[128.113.24.47]>
In-Reply-To: <xzppuj0s5da.fsf@flood.ping.uio.no>
References:  <xzppuj0s5da.fsf@flood.ping.uio.no>

next in thread | previous in thread | raw e-mail | index | archive | help
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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?p04330100b65a10758f0c>