Unverified Commit df2737fd authored by A. Wilcox's avatar A. Wilcox 🦊
Browse files

getconf: Add POSIX2_LINE_MAX and INT_MAX variables

parent 1b77f8f4
......@@ -24,6 +24,9 @@ typedef struct variable_mapping
/* For variables that are valid, but undefined in this implementation */
#define _UNDEFINED_VARIABLE_ 0x7FEEDFEE
#define SHIMMY_POSIX2_LINE_MAX 0x7FEEDFED
#define SHIMMY_INT_MAX 0x7FEEDFEC
const var_map_t sysconf_vars[] = {
/* max */
{ "AIO_LISTIO_MAX", _SC_AIO_LISTIO_MAX },
......@@ -315,10 +318,13 @@ const var_map_t sysconf_vars[] = {
{ "_XOPEN_UUCP", _UNDEFINED_VARIABLE_ },
#endif
#if defined(_SC_XOPEN_VERSION)
{ "_XOPEN_VERSION", _SC_XOPEN_VERSION }
{ "_XOPEN_VERSION", _SC_XOPEN_VERSION },
#else /* NetBSD */
{ "_XOPEN_VERSION", _UNDEFINED_VARIABLE_ }
{ "_XOPEN_VERSION", _UNDEFINED_VARIABLE_ },
#endif
{ "POSIX2_LINE_MAX", SHIMMY_POSIX2_LINE_MAX },
{ "INT_MAX", SHIMMY_INT_MAX }
};
......@@ -410,11 +416,20 @@ int do_system_var(char *environment, char *system_var)
return 0;
}
errno = 0;
val = sysconf(sysconf_vars[var].value);
if(errno != 0)
switch(sysconf_vars[var].value)
{
case SHIMMY_POSIX2_LINE_MAX:
val = LINE_MAX;
break;
case SHIMMY_INT_MAX:
val = INT_MAX;
break;
default:
errno = 0;
val = sysconf(sysconf_vars[var].value);
if(errno != 0)
{
/* We know that this is a valid symbol, so don't break
* expectations (see _POSIX_TRACE_LOG in FreeBSD).
*
......@@ -425,8 +440,9 @@ int do_system_var(char *environment, char *system_var)
* a result in getconf. So, I feel this is the
* strictest way to conform.
*/
printf("undefined\n");
return 0;
printf("undefined\n");
return 0;
}
}
printf("%ld\n", val);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment