Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] Annotation of /sml/trunk/src/runtime/c-libs/posix-procenv/sysconf.c
ViewVC logotype

Annotation of /sml/trunk/src/runtime/c-libs/posix-procenv/sysconf.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 651 - (view) (download) (as text)

1 : monnier 249 /* sysconf.c
2 :     *
3 :     * COPYRIGHT (c) 1995 by AT&T Bell Laboratories.
4 :     */
5 :    
6 :     #include "ml-unixdep.h"
7 :     #include <unistd.h>
8 :     #include <errno.h>
9 :     #include "ml-base.h"
10 :     #include "ml-values.h"
11 :     #include "ml-objects.h"
12 :     #include "ml-c.h"
13 :     #include "cfun-proto-list.h"
14 :     #include "../posix-error/posix-name-val.h"
15 :    
16 :     /* The following table is generated from all _SC_ values
17 :     * in unistd.h. For most systems, this will include
18 :     * _SC_ARG_MAX
19 :     * _SC_CHILD_MAX
20 :     * _SC_CLK_TCK
21 :     * _SC_JOB_CONTROL
22 :     * _SC_NGROUPS_MAX
23 :     * _SC_OPEN_MAX
24 :     * _SC_SAVED_IDS
25 :     * _SC_STREAM_MAX
26 :     * _SC_TZNAME_MAX
27 :     * _SC_VERSION
28 :     *
29 :     * The full POSIX list is given in section 4.8.1 of Std 1003.1b-1993.
30 :     *
31 :     * The SML string used to look up these values has the same
32 :     * form but without the prefix, e.g., to lookup _SC_ARG_MAX,
33 :     * use sysconf "ARG_MAX"
34 :     */
35 :     static name_val_t values[] = {
36 :     #include "ml_sysconf.h"
37 :     };
38 :    
39 :     #define NUMELMS ((sizeof values)/(sizeof (name_val_t)))
40 :    
41 :     /* _ml_P_ProcEnv_sysconf : string -> word
42 :     *
43 :     *
44 :     * Get configurable system variables
45 :     */
46 :     ml_val_t _ml_P_ProcEnv_sysconf (ml_state_t *msp, ml_val_t arg)
47 :     {
48 :     long val;
49 :     name_val_t *attr;
50 :     ml_val_t p;
51 :    
52 :     attr = _ml_posix_nv_lookup (STR_MLtoC(arg), values, NUMELMS);
53 :     if (!attr) {
54 :     errno = EINVAL;
55 :     return RAISE_SYSERR(msp, -1);
56 :     }
57 :    
58 :     errno = 0;
59 :     while (((val = sysconf(attr->val)) == -1) && (errno == EINTR)) {
60 :     errno = 0;
61 :     continue;
62 :     }
63 :    
64 :     if (val >= 0) {
65 :     WORD_ALLOC (msp, p, val);
66 :     return p;
67 :     }
68 :     else if (errno == 0)
69 :     return RAISE_ERROR(msp, "unsupported POSIX feature");
70 :     else
71 :     return RAISE_SYSERR(msp, -1);
72 :    
73 :     } /* end of _ml_P_ProcEnv_sysconf */

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0