Initial import of the CDE 2.1.30 sources from the Open Group.
This commit is contained in:
159
cde/programs/dtksh/ksh93/src/lib/libast/comp/sysconf.c
Normal file
159
cde/programs/dtksh/ksh93/src/lib/libast/comp/sysconf.c
Normal file
@@ -0,0 +1,159 @@
|
||||
/* $XConsortium: sysconf.c /main/3 1995/11/01 17:20:18 rswiston $ */
|
||||
/***************************************************************
|
||||
* *
|
||||
* AT&T - PROPRIETARY *
|
||||
* *
|
||||
* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF *
|
||||
* AT&T BELL LABORATORIES *
|
||||
* AND IS NOT TO BE DISCLOSED OR USED EXCEPT IN *
|
||||
* ACCORDANCE WITH APPLICABLE AGREEMENTS *
|
||||
* *
|
||||
* Copyright (c) 1994 AT&T Bell Laboratories *
|
||||
* Unpublished & Not for Publication *
|
||||
* All Rights Reserved *
|
||||
* *
|
||||
* The copyright notice above does not evidence any *
|
||||
* actual or intended publication of such source code *
|
||||
* *
|
||||
* This software was created by the *
|
||||
* Software Engineering Research Department *
|
||||
* AT&T Bell Laboratories *
|
||||
* *
|
||||
* For further information contact *
|
||||
* advsoft@research.att.com *
|
||||
* Randy Hackbarth 908-582-5245 *
|
||||
* Dave Belanger 908-582-7427 *
|
||||
* *
|
||||
***************************************************************/
|
||||
|
||||
/* : : generated by proto : : */
|
||||
|
||||
#line 1
|
||||
|
||||
#if !defined(__PROTO__)
|
||||
#if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
|
||||
#if defined(__cplusplus)
|
||||
#define __MANGLE__ "C"
|
||||
#else
|
||||
#define __MANGLE__
|
||||
#endif
|
||||
#define __STDARG__
|
||||
#define __PROTO__(x) x
|
||||
#define __OTORP__(x)
|
||||
#define __PARAM__(n,o) n
|
||||
#if !defined(__STDC__) && !defined(__cplusplus)
|
||||
#if !defined(c_plusplus)
|
||||
#define const
|
||||
#endif
|
||||
#define signed
|
||||
#define void int
|
||||
#define volatile
|
||||
#define __V_ char
|
||||
#else
|
||||
#define __V_ void
|
||||
#endif
|
||||
#else
|
||||
#define __PROTO__(x) ()
|
||||
#define __OTORP__(x) x
|
||||
#define __PARAM__(n,o) o
|
||||
#define __MANGLE__
|
||||
#define __V_ char
|
||||
#define const
|
||||
#define signed
|
||||
#define void int
|
||||
#define volatile
|
||||
#endif
|
||||
#if defined(__cplusplus) || defined(c_plusplus)
|
||||
#define __VARARG__ ...
|
||||
#else
|
||||
#define __VARARG__
|
||||
#endif
|
||||
#if defined(__STDARG__)
|
||||
#define __VA_START__(p,a) va_start(p,a)
|
||||
#else
|
||||
#define __VA_START__(p,a) va_start(p)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#line 3
|
||||
#include <ast.h>
|
||||
|
||||
#ifdef _lib_sysconf
|
||||
|
||||
NoN(sysconf)
|
||||
|
||||
#else
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#ifndef errno
|
||||
extern __MANGLE__ int errno;
|
||||
#endif
|
||||
|
||||
#if _lib_getdtablesize
|
||||
extern __MANGLE__ int getdtablesize __PROTO__((void));
|
||||
#else
|
||||
#if _lib_getrlimit && _sys_resource
|
||||
#include <sys/time.h>
|
||||
#include <sys/resource.h>
|
||||
extern __MANGLE__ int getrlimit __PROTO__((int, struct rlimit*));
|
||||
#endif
|
||||
#endif
|
||||
|
||||
long
|
||||
sysconf __PARAM__((int op), (op)) __OTORP__(int op;)
|
||||
#line 29
|
||||
{
|
||||
int n;
|
||||
|
||||
switch (op)
|
||||
{
|
||||
case _SC_ARG_MAX:
|
||||
return(ARG_MAX);
|
||||
case _SC_CHILD_MAX:
|
||||
return(CHILD_MAX);
|
||||
case _SC_CLK_TCK:
|
||||
return(_AST_CLK_TCK);
|
||||
case _SC_NGROUPS_MAX:
|
||||
if ((n = getgroups(0, (gid_t*)&n)) <= 0) n = NGROUPS_MAX;
|
||||
return(n);
|
||||
case _SC_OPEN_MAX:
|
||||
#if _lib_getdtablesize
|
||||
return(getdtablesize());
|
||||
#else
|
||||
#ifdef RLIMIT_NOFILE
|
||||
{
|
||||
struct rlimit rlim;
|
||||
|
||||
return(getrlimit(RLIMIT_NOFILE, &rlim) ? OPEN_MAX_CEIL : rlim.rlim_cur);
|
||||
}
|
||||
#else
|
||||
return(OPEN_MAX_CEIL);
|
||||
#endif
|
||||
#endif
|
||||
case _SC_JOB_CONTROL:
|
||||
#ifdef _POSIX_JOB_CONTROL
|
||||
return(_POSIX_JOB_CONTROL);
|
||||
#else
|
||||
return(-1);
|
||||
#endif
|
||||
case _SC_SAVED_IDS:
|
||||
#ifdef _POSIX_SAVED_IDS
|
||||
return(_POSIX_SAVED_IDS);
|
||||
#else
|
||||
return(-1);
|
||||
#endif
|
||||
case _SC_TZNAME_MAX:
|
||||
return(3);
|
||||
case _SC_VERSION:
|
||||
#ifdef _POSIX_VERSION
|
||||
return(_POSIX_VERSION);
|
||||
#else
|
||||
return(-1);
|
||||
#endif
|
||||
}
|
||||
errno = EINVAL;
|
||||
return(-1);
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user