phunix/lib/libc/gen/minix/sysconf.c
Ben Gras 2fe8fb192f Full switch to clang/ELF. Drop ack. Simplify.
There is important information about booting non-ack images in
docs/UPDATING. ack/aout-format images can't be built any more, and
booting clang/ELF-format ones is a little different. Updating to the
new boot monitor is recommended.

Changes in this commit:

	. drop boot monitor -> allowing dropping ack support
	. facility to copy ELF boot files to /boot so that old boot monitor
	  can still boot fairly easily, see UPDATING
	. no more ack-format libraries -> single-case libraries
	. some cleanup of OBJECT_FMT, COMPILER_TYPE, etc cases
	. drop several ack toolchain commands, but not all support
	  commands (e.g. aal is gone but acksize is not yet).
	. a few libc files moved to netbsd libc dir
	. new /bin/date as minix date used code in libc/
	. test compile fix
	. harmonize includes
	. /usr/lib is no longer special: without ack, /usr/lib plays no
	  kind of special bootstrapping role any more and bootstrapping
	  is done exclusively through packages, so releases depend even
	  less on the state of the machine making them now.
	. rename nbsd_lib* to lib*
	. reduce mtree
2012-02-14 14:52:02 +01:00

83 lines
1.4 KiB
C

/* sysconf.c POSIX 4.8.1
* long int sysconf(int name);
*
* POSIX allows some of the values in <limits.h> to be increased at
* run time. The sysconf() function allows such values to be checked
* at run time. MINIX does not use this facility - the run time
* limits are those given in <limits.h>.
*/
#include <sys/cdefs.h>
#include "namespace.h"
#include <lib.h>
#include <unistd.h>
#include <time.h>
#include <stdio.h>
#include <paths.h>
#ifdef __weak_alias
__weak_alias(sysconf, __sysconf)
#endif
PRIVATE u32_t get_hz(void)
{
FILE *fp;
u32_t hz;
int r;
if ((fp = fopen(_PATH_PROC "hz", "r")) != NULL)
{
r = fscanf(fp, "%u", &hz);
fclose(fp);
if (r == 1)
return hz;
}
return DEFAULT_HZ;
}
PUBLIC long int sysconf(name)
int name; /* property being inspected */
{
switch(name) {
case _SC_ARG_MAX:
return (long) ARG_MAX;
case _SC_CHILD_MAX:
return (long) CHILD_MAX;
case _SC_CLK_TCK:
return (long) get_hz();
case _SC_NGROUPS_MAX:
return (long) NGROUPS_MAX;
case _SC_OPEN_MAX:
return (long) OPEN_MAX;
case _SC_JOB_CONTROL:
return -1L; /* no job control */
case _SC_SAVED_IDS:
return -1L; /* no saved uid/gid */
case _SC_VERSION:
return (long) _POSIX_VERSION;
case _SC_STREAM_MAX:
return (long) STREAM_MAX;
case _SC_TZNAME_MAX:
return (long) TZNAME_MAX;
case _SC_PAGESIZE:
return getpagesize();
default:
errno = EINVAL;
return -1L;
}
}