diff options
author | Jeremie Koenig <jk@jk.fr.eu.org> | 2010-08-22 20:17:54 +0000 |
---|---|---|
committer | Jeremie Koenig <jk@jk.fr.eu.org> | 2010-08-30 14:29:51 +0200 |
commit | b3427143ae8dc628cb3748da7618700c6bd7ac9e (patch) | |
tree | ec004ed9e346a6feb8edb3b3cb50f7eb03572851 /main.c | |
parent | f9ddb679942b6f4309d05b5462fe5cbb3d0a2beb (diff) | |
download | hurd-b3427143ae8dc628cb3748da7618700c6bd7ac9e.tar.gz hurd-b3427143ae8dc628cb3748da7618700c6bd7ac9e.tar.bz2 hurd-b3427143ae8dc628cb3748da7618700c6bd7ac9e.zip |
Add --clk-tck to set the clock unit
* main.c (argp_parser, main): Add and parse the --clk-tck option.
* main.h: Publish opt_clk_tck.
* process.c (sc_tc): Use the user-provided clock frequency.
* rootdir.c (rootdir_gc_stat): Likewise.
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 40 |
1 files changed, 39 insertions, 1 deletions
@@ -1,5 +1,6 @@ #include <mach.h> #include <hurd.h> +#include <unistd.h> #include <error.h> #include <argp.h> #include <hurd/netfs.h> @@ -7,6 +8,42 @@ #include "proclist.h" #include "rootdir.h" #include "dircat.h" +#include "main.h" + +/* Command-line options */ +int opt_clk_tck; + +static error_t +argp_parser (int key, char *arg, struct argp_state *state) +{ + char *endp; + + switch (key) + { + case 'h': + opt_clk_tck = strtol (arg, &endp, 0); + if (*endp || ! *arg || opt_clk_tck <= 0) + error (1, 0, "--clk-tck: HZ should be a positive integer"); + break; + } + + return 0; +} + +struct argp argp = { + .options = (struct argp_option []) { + { "clk-tck", 'h', "HZ", 0, + "Unit used for the values expressed in system clock ticks " + "(default: sysconf(_SC_CLK_TCK))" }, + {} + }, + .parser = argp_parser, + .doc = "A virtual filesystem emulating the Linux procfs.", + .children = (struct argp_child []) { + { &netfs_std_startup_argp, }, + {} + }, +}; error_t root_make_node (struct node **np) @@ -43,7 +80,8 @@ int main (int argc, char **argv) { mach_port_t bootstrap; - argp_parse (&netfs_std_startup_argp, argc, argv, 0, 0, 0); + opt_clk_tck = sysconf(_SC_CLK_TCK); + argp_parse (&argp, argc, argv, 0, 0, 0); task_get_bootstrap_port (mach_task_self (), &bootstrap); if (bootstrap == MACH_PORT_NULL) |