[klibc] syconf(_SC_PAGESIZE) versus getpagesize()

H. Peter Anvin hpa at zytor.com
Tue Jul 29 14:47:18 PDT 2008


maximilian attems wrote:
> hello karel,
> 
> thanks a lot for the klibc portability merges.
> 
> current HEAD klibc failure:
> mkswap.c: In function ‘init_signature_page’:
> mkswap.c:148: error: ‘_SC_PAGESIZE’ undeclared (first use in this function)
> 
> although POSIX encourages sysconf() could util-linux use getpagesize() ?
> 

I should motivate this.

sysconf() is a multiplex API which invokes a large number of unrelated 
data items.  To support it in klibc, I would have to pull *all* the 
sysconf items to support any single one, which would lead me with a 
couple of choices:

1. Support a subset of sysconf() entries only, like _SC_PAGESIZE,
    and perhaps a few which can be derived from static code.
2. Support as many sysconf() entries as possible, which would bloat
    static binaries.
3. Implement sysconf() as a hideously ugly must_inline thing trying
    to disambiguate the individual items, at least in the common case
    of passing in a constant.
4. Implement sysconf() taking a function pointer, instead of int.

I'm not ruling this out, however, to the best of my knowledge 
getpagesize() is more portable than sysconf() to anything Linux; I don't 
know about non-Linux systems or if we care.

	-hpa



More information about the klibc mailing list