[OpenAFS-devel] Re: osi_Panic on AIX and IRIX

Tom Keiser tkeiser@sinenomine.net
Tue, 9 Feb 2010 23:50:25 -0500


On Tue, Feb 9, 2010 at 10:50 PM, Derrick Brashear <shadow@dementia.org> wrote:
>
>
>
> On Feb 9, 2010, at 9:30 PM, "Chas Williams (CONTRACTOR)"
> <chas@cmf.nrl.navy.mil> wrote:
>
>> In message <20100209142550.350695c6.adeason@sinenomine.net>,Andrew Deason
>> writes:
>>>
>>> On those platforms, it looks like osi_Panic should be decl'd
>>> 'osi_Panic(char *msg, void *a1, void *a2, void *a3)', and should be
>>> defined to effectively printf(msg, a1, a2, a3). There should be no
>>> vprintf in osi_Panic, and I can't see how it could get in there,
>>> assuming AFS_AIX_ENV and AFS_SGI_ENV are the right symbols.
>>

AFAIK, all the relevant param files define those macros.  I don't see
how vprintf symbol refs are leaking in either...


>> do we have kernels (or userspaces) that do not support stdargs/varargs
>> in some fashion?
>>
>
> that'd be aix and irix...
>

To be 100% clear, the AIX kernel has stdarg.  That being said, there
are (iirc) only three printf-like interfaces in-kernel: printf,
sprintf, uprintf.  As far as doing variadic arg processing on these
two kernels, I'll make two proposals:

1) A very easy (and admittedly very ugly) solution is to make
osi_Panic a variadic macro on AIX.  [I don't remember whether the
MIPSpro preprocessor supports C99 variadic macros, so no clue whether
it would solve there as well].  That would let us use the generic
kernel printf() interface as follows:

#ifdef AFS_AIX_ENV
#define osi_Panic(buf, ...) \
    do { \
        printf(buf, __VA_ARGS__); \
        panic(buf); \
    } while (0)
#endif

Or I suppose we could even allocate a static buffer and use sprintf so
the panic message is more useful.  The one disadvantage of (1) is,
iirc, C99 variadic macros MUST have at least one argument after buf,
and thus all format strings must contain at least one parameter.


2) Taking Chas' line of thought to its logical completion, we could
pull in suitably-licensed implementations of v*printf.

Thoughts?

-Tom