[MLton] additional sysconf variables

Matthew Fluet matthew.fluet at gmail.com
Tue Jul 12 13:56:22 PDT 2011


For the most part, we've been following the Single Unix Specification
for the POSIX functionality.  The currently supported sysconf
variables correspond to those that are required by the specification
(http://pubs.opengroup.org/onlinepubs/009695399/functions/sysconf.html).
 I'm not sure the best way of handling variables above and beyond the
required set.  Adding them piecemeal like this seems to be an onerous
process.  SML/NJ tries to mine <unistd.h> for _SC* names and generates
a table specific to the target platform.

On Sun, Jul 10, 2011 at 8:16 PM, Christopher Cramer
<tsuyoshi at yumegakanau.org> wrote:
> Hi
>
> Below is a patch that adds support for querying these variables with
> Posix.ProcEnv.sysconf:
>
>        AVPHYS_PAGES
>        NPROCESSORS_CONF
>        NPROCESSORS_ONLN
>        PHYS_PAGES
>
> Index: runtime/basis/Posix/ProcEnv/sysconf-consts.c
> ===================================================================
> --- runtime/basis/Posix/ProcEnv/sysconf-consts.c        (revision 7550)
> +++ runtime/basis/Posix/ProcEnv/sysconf-consts.c        (working copy)
> @@ -100,6 +100,10 @@
>  #define _SC_ADVISORY_INFO -1
>  #endif
>  const C_Int_t Posix_ProcEnv_SC_ADVISORY_INFO = _SC_ADVISORY_INFO;
> +#ifndef _SC_AVPHYS_PAGES
> +#define _SC_AVPHYS_PAGES -1
> +#endif
> +const C_Int_t Posix_ProcEnv_SC_AVPHYS_PAGES = _SC_AVPHYS_PAGES;
>  #ifndef _SC_BARRIERS
>  #define _SC_BARRIERS -1
>  #endif
> @@ -152,6 +156,18 @@
>  #define _SC_MONOTONIC_CLOCK -1
>  #endif
>  const C_Int_t Posix_ProcEnv_SC_MONOTONIC_CLOCK = _SC_MONOTONIC_CLOCK;
> +#ifndef _SC_NPROCESSORS_CONF
> +#define _SC_NPROCESSORS_CONF -1
> +#endif
> +const C_Int_t Posix_ProcEnv_SC_NPROCESSORS_CONF = _SC_NPROCESSORS_CONF;
> +#ifndef _SC_NPROCESSORS_ONLN
> +#define _SC_NPROCESSORS_ONLN -1
> +#endif
> +const C_Int_t Posix_ProcEnv_SC_NPROCESSORS_ONLN = _SC_NPROCESSORS_ONLN;
> +#ifndef _SC_PHYS_PAGES
> +#define _SC_PHYS_PAGES -1
> +#endif
> +const C_Int_t Posix_ProcEnv_SC_PHYS_PAGES = _SC_PHYS_PAGES;
>  #ifndef _SC_PRIORITIZED_IO
>  #define _SC_PRIORITIZED_IO -1
>  #endif
> Index: runtime/gen/basis-ffi.def
> ===================================================================
> --- runtime/gen/basis-ffi.def   (revision 7550)
> +++ runtime/gen/basis-ffi.def   (working copy)
> @@ -411,6 +411,7 @@
>  Posix.ProcEnv.SC_ARG_MAX = _const : C_Int.t
>  Posix.ProcEnv.SC_ASYNCHRONOUS_IO = _const : C_Int.t
>  Posix.ProcEnv.SC_ATEXIT_MAX = _const : C_Int.t
> +Posix.ProcEnv.SC_AVPHYS_PAGES = _const : C_Int.t
>  Posix.ProcEnv.SC_BARRIERS = _const : C_Int.t
>  Posix.ProcEnv.SC_BC_BASE_MAX = _const : C_Int.t
>  Posix.ProcEnv.SC_BC_DIM_MAX = _const : C_Int.t
> @@ -441,9 +442,12 @@
>  Posix.ProcEnv.SC_MQ_OPEN_MAX = _const : C_Int.t
>  Posix.ProcEnv.SC_MQ_PRIO_MAX = _const : C_Int.t
>  Posix.ProcEnv.SC_NGROUPS_MAX = _const : C_Int.t
> +Posix.ProcEnv.SC_NPROCESSORS_CONF = _const : C_Int.t
> +Posix.ProcEnv.SC_NPROCESSORS_ONLN = _const : C_Int.t
>  Posix.ProcEnv.SC_OPEN_MAX = _const : C_Int.t
>  Posix.ProcEnv.SC_PAGESIZE = _const : C_Int.t
>  Posix.ProcEnv.SC_PAGE_SIZE = _const : C_Int.t
> +Posix.ProcEnv.SC_PHYS_PAGES = _const : C_Int.t
>  Posix.ProcEnv.SC_PRIORITIZED_IO = _const : C_Int.t
>  Posix.ProcEnv.SC_PRIORITY_SCHEDULING = _const : C_Int.t
>  Posix.ProcEnv.SC_RAW_SOCKETS = _const : C_Int.t
> Index: basis-library/posix/proc-env.sml
> ===================================================================
> --- basis-library/posix/proc-env.sml    (revision 7550)
> +++ basis-library/posix/proc-env.sml    (working copy)
> @@ -121,6 +121,7 @@
>                (Prim.SC_ARG_MAX,"ARG_MAX") ::?
>                (Prim.SC_ASYNCHRONOUS_IO,"ASYNCHRONOUS_IO") ::?
>                (Prim.SC_ATEXIT_MAX,"ATEXIT_MAX") ::?
> +              (Prim.SC_AVPHYS_PAGES,"AVPHYS_PAGES") ::?
>                (Prim.SC_BARRIERS,"BARRIERS") ::?
>                (Prim.SC_BC_BASE_MAX,"BC_BASE_MAX") ::?
>                (Prim.SC_BC_DIM_MAX,"BC_DIM_MAX") ::?
> @@ -151,9 +152,12 @@
>                (Prim.SC_MQ_OPEN_MAX,"MQ_OPEN_MAX") ::?
>                (Prim.SC_MQ_PRIO_MAX,"MQ_PRIO_MAX") ::?
>                (Prim.SC_NGROUPS_MAX,"NGROUPS_MAX") ::?
> +              (Prim.SC_NPROCESSORS_CONF,"NPROCESSORS_CONF") ::?
> +              (Prim.SC_NPROCESSORS_ONLN,"NPROCESSORS_ONLN") ::?
>                (Prim.SC_OPEN_MAX,"OPEN_MAX") ::?
>                (Prim.SC_PAGESIZE,"PAGESIZE") ::?
>                (Prim.SC_PAGE_SIZE,"PAGE_SIZE") ::?
> +              (Prim.SC_PHYS_PAGES,"PHYS_PAGES") ::?
>                (Prim.SC_PRIORITIZED_IO,"PRIORITIZED_IO") ::?
>                (Prim.SC_PRIORITY_SCHEDULING,"PRIORITY_SCHEDULING") ::?
>                (Prim.SC_RAW_SOCKETS,"RAW_SOCKETS") ::?
> Index: basis-library/primitive/basis-ffi.sml
> ===================================================================
> --- basis-library/primitive/basis-ffi.sml       (revision 7550)
> +++ basis-library/primitive/basis-ffi.sml       (working copy)
> @@ -540,6 +540,7 @@
>  val SC_ARG_MAX = _const "Posix_ProcEnv_SC_ARG_MAX" : C_Int.t;
>  val SC_ASYNCHRONOUS_IO = _const "Posix_ProcEnv_SC_ASYNCHRONOUS_IO" : C_Int.t;
>  val SC_ATEXIT_MAX = _const "Posix_ProcEnv_SC_ATEXIT_MAX" : C_Int.t;
> +val SC_AVPHYS_PAGES = _const "Posix_ProcEnv_SC_AVPHYS_PAGES" : C_Int.t;
>  val SC_BARRIERS = _const "Posix_ProcEnv_SC_BARRIERS" : C_Int.t;
>  val SC_BC_BASE_MAX = _const "Posix_ProcEnv_SC_BC_BASE_MAX" : C_Int.t;
>  val SC_BC_DIM_MAX = _const "Posix_ProcEnv_SC_BC_DIM_MAX" : C_Int.t;
> @@ -570,9 +571,12 @@
>  val SC_MQ_OPEN_MAX = _const "Posix_ProcEnv_SC_MQ_OPEN_MAX" : C_Int.t;
>  val SC_MQ_PRIO_MAX = _const "Posix_ProcEnv_SC_MQ_PRIO_MAX" : C_Int.t;
>  val SC_NGROUPS_MAX = _const "Posix_ProcEnv_SC_NGROUPS_MAX" : C_Int.t;
> +val SC_NPROCESSORS_CONF = _const "Posix_ProcEnv_SC_NPROCESSORS_CONF" : C_Int.t;
> +val SC_NPROCESSORS_ONLN = _const "Posix_ProcEnv_SC_NPROCESSORS_ONLN" : C_Int.t;
>  val SC_OPEN_MAX = _const "Posix_ProcEnv_SC_OPEN_MAX" : C_Int.t;
>  val SC_PAGE_SIZE = _const "Posix_ProcEnv_SC_PAGE_SIZE" : C_Int.t;
>  val SC_PAGESIZE = _const "Posix_ProcEnv_SC_PAGESIZE" : C_Int.t;
> +val SC_PHYS_PAGES = _const "Posix_ProcEnv_SC_PHYS_PAGES" : C_Int.t;
>  val SC_PRIORITIZED_IO = _const "Posix_ProcEnv_SC_PRIORITIZED_IO" : C_Int.t;
>  val SC_PRIORITY_SCHEDULING = _const "Posix_ProcEnv_SC_PRIORITY_SCHEDULING" : C_Int.t;
>  val SC_RAW_SOCKETS = _const "Posix_ProcEnv_SC_RAW_SOCKETS" : C_Int.t;
>
> _______________________________________________
> MLton mailing list
> MLton at mlton.org
> http://mlton.org/mailman/listinfo/mlton
>



More information about the MLton mailing list