Subject: Re: sysctl variadicity [was Re: packet capturing]
To: Jonathan Stone <jonathan@DSG.Stanford.EDU>
From: Andrew Brown <atatat@atatdot.net>
List: tech-kern
Date: 01/21/2004 21:52:33
>Thanks, I didn't know c99 had standardized that.
>
>However.. I'm still skeptical whether a macro can figure out how deep
>the variadic call should be for a given point in the mib.
>
>If a macro can do that, then we shouldn't need to expose the variadic
>functions as part of the API. The API could instead wrap the variadic
>functions with suitable fixed-length versions for node/int/struct, a
>la FreeBSD's SYSCTL_{NODE,INT,STRUCT} macros.
>
>That's my real gripe. Maybe Andrew can clarify why the API has to be
>variadic.

the *only* variadic portion of the api is the in-kernel-only
"simpler-to-use" create interface.  it's "simpler" in that it will
cons up the struct, find the appropriate parent, call create at it,
and cover up for duplication (eg, when seventeen callers all say they
want to put stuff under "net" but there's no rule about who actually
has to create it since there's really no ordering to the callers).

think of it like how execl(3) compares to execve(2).  sure, you know
when you write the code how many arguments there are to exec, but who
feels like wasting the time to stuff all that into a char*[] and call
execve(2)?   execl(3) is there for convenience.

the exposed user-land interface still takes the regular six, and
majority of the other in-kernel interfaces take nine (the extra three
are another int*, a node*, and an lwp* -- there's a sysctl(9) man page
now, too).

[okay, there's the variadic destroy interface, too, but no one's using
that yet except me, and only in the code i haven't committed yet.]

-- 
|-----< "CODE WARRIOR" >-----|
codewarrior@daemon.org             * "ah!  i see you have the internet
twofsonet@graffiti.com (Andrew Brown)                that goes *ping*!"
werdna@squooshy.com       * "information is power -- share the wealth."