Generate /usr/libexec/getconf files when cross-compiling
Roland McGrath
roland@hack.frob.com
Thu Nov 15 23:15:00 GMT 2012
> Here is a refactoring of the existing confstr / sysconf code along
> those lines, with a structure and using macros designed to be suitable
> for the build-time use as well (which is not included in this patch).
This looks generally good, though I'd like to see the follow-on patch
implementing the build-time use before we conclude that this patch is
right.
> - case _CS_V7_WIDTH_RESTRICTED_ENVS:
> - /* We have to return a newline-separated list of named of
> + /* For _CS_V7_WIDTH_RESTRICTED_ENVS, _CS_V6_WIDTH_RESTRICTED_ENVS
> + and _CS_V5_WIDTH_RESTRICTED_ENVS:
> +
> + We have to return a newline-separated list of named of
Not your typo, but since you're touching the line: s/named/names/
> +
> +#define START_ENV_GROUP(VERSION) \
> + case _CS_##VERSION##_WIDTH_RESTRICTED_ENVS: \
> string_len = 0;
> +
> +#define END_ENV_GROUP(VERSION) \
> + restenvs[string_len++] = '\0'; \
> + string = restenvs; \
> break;
>
> +#define KNOWN_ABSENT_ENVIRONMENT(SC_PREFIX, ENV_PREFIX, SUFFIX)
It's conventional practice to use a comment in the rhs of a macro intended
to expand to empty.
> +#define KNOWN_PRESENT_ENV_STRING(STR) \
> + if (string_len) \
Don't use implicit boolean coercion: if (string_len > 0).
> +#define UNKNOWN_ENVIRONMENT(SC_PREFIX, ENV_PREFIX, SUFFIX) \
> + if (__sysconf (_SC_##SC_PREFIX##_##SUFFIX) > 0) \
> + { \
> + KNOWN_PRESENT_ENVIRONMENT (SC_PREFIX, ENV_PREFIX, SUFFIX) \
> }
If a macro will be used this way, then make it have a statement-like form
(i.e. wrap in do { ... } while (0)) so it can appear here without braces
and with a semicolon.
> +#include "posix-envs.c"
It's conventional in cases like this to #undef the macros after the
#include, even if there isn't a second #include. Also, a file like
this is called foo.def rather than foo.c or foo.h.
Thanks,
Roland
More information about the Libc-alpha
mailing list