1da2e3ebchin/***********************************************************************
2da2e3ebchin*                                                                      *
3da2e3ebchin*               This software is part of the ast package               *
43e14f97Roger A. Faulkner*          Copyright (c) 1982-2010 AT&T Intellectual Property          *
5da2e3ebchin*                      and is licensed under the                       *
6da2e3ebchin*                  Common Public License, Version 1.0                  *
77c2fbfbApril Chin*                    by AT&T Intellectual Property                     *
8da2e3ebchin*                                                                      *
9da2e3ebchin*                A copy of the License is available at                 *
10da2e3ebchin*            http://www.opensource.org/licenses/cpl1.0.txt             *
11da2e3ebchin*         (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9)         *
12da2e3ebchin*                                                                      *
13da2e3ebchin*              Information and Software Systems Research               *
14da2e3ebchin*                            AT&T Research                             *
15da2e3ebchin*                           Florham Park NJ                            *
16da2e3ebchin*                                                                      *
17da2e3ebchin*                  David Korn <dgk@research.att.com>                   *
18da2e3ebchin*                                                                      *
19da2e3ebchin***********************************************************************/
20da2e3ebchin#pragma prototyped
21da2e3ebchin#ifndef _ULIMIT_H
22da2e3ebchin#define _ULIMIT_H 1
23da2e3ebchin/*
24da2e3ebchin * This is for the ulimit built-in command
25da2e3ebchin */
26da2e3ebchin
27da2e3ebchin#include	"FEATURE/time"
28da2e3ebchin#include	"FEATURE/rlimits"
29da2e3ebchin#if defined(_sys_resource) && defined(_lib_getrlimit)
30da2e3ebchin#   include	<sys/resource.h>
31da2e3ebchin#   if !defined(RLIMIT_FSIZE) && defined(_sys_vlimit)
32da2e3ebchin	/* This handles hp/ux problem */
33da2e3ebchin#	include	<sys/vlimit.h>
34da2e3ebchin#	define RLIMIT_FSIZE	(LIM_FSIZE-1)
35da2e3ebchin#	define RLIMIT_DATA	(LIM_DATA-1)
36da2e3ebchin#	define RLIMIT_STACK	(LIM_STACK-1)
37da2e3ebchin#	define RLIMIT_CORE	(LIM_CORE-1)
38da2e3ebchin#	define RLIMIT_CPU	(LIM_CPU-1)
39da2e3ebchin#	ifdef LIM_MAXRSS
40da2e3ebchin#		define RLIMIT_RSS       (LIM_MAXRSS-1)
41da2e3ebchin#	endif /* LIM_MAXRSS */
42da2e3ebchin#   endif
43da2e3ebchin#   undef _lib_ulimit
44da2e3ebchin#else
45da2e3ebchin#   ifdef _sys_vlimit
46da2e3ebchin#	include	<sys/vlimit.h>
47da2e3ebchin#	undef _lib_ulimit
48da2e3ebchin#	define RLIMIT_FSIZE	LIM_FSIZE
49da2e3ebchin#	define RLIMIT_DATA	LIM_DATA
50da2e3ebchin#	define RLIMIT_STACK	LIM_STACK
51da2e3ebchin#	define RLIMIT_CORE	LIM_CORE
52da2e3ebchin#	define RLIMIT_CPU	LIM_CPU
53da2e3ebchin#	ifdef LIM_MAXRSS
54da2e3ebchin#		define RLIMIT_RSS       LIM_MAXRSS
55da2e3ebchin#	endif /* LIM_MAXRSS */
56da2e3ebchin#   else
57da2e3ebchin#	ifdef _lib_ulimit
58da2e3ebchin#	    define vlimit ulimit
59da2e3ebchin#	endif /* _lib_ulimit */
60da2e3ebchin#   endif /* _lib_vlimit */
61da2e3ebchin#endif
62da2e3ebchin
63da2e3ebchin#ifdef RLIM_INFINITY
64da2e3ebchin#   define INFINITY	RLIM_INFINITY
65da2e3ebchin#else
66da2e3ebchin#   ifndef INFINITY
67da2e3ebchin#	define INFINITY	((rlim_t)-1L)
68da2e3ebchin#   endif /* INFINITY */
69da2e3ebchin#endif /* RLIM_INFINITY */
70da2e3ebchin
71da2e3ebchin#if defined(_lib_getrlimit) || defined(_lib_vlimit) || defined(_lib_ulimit)
72da2e3ebchin#   ifndef RLIMIT_CPU
73da2e3ebchin#	define RLIMIT_CPU	0
74da2e3ebchin#   endif /* !RLIMIT_CPU */
75da2e3ebchin#   ifndef RLIMIT_DATA
76da2e3ebchin#	define RLIMIT_DATA	0
77da2e3ebchin#   endif /* !RLIMIT_DATA */
78da2e3ebchin#   ifndef RLIMIT_RSS
79da2e3ebchin#	define RLIMIT_RSS	0
80da2e3ebchin#   endif /* !RLIMIT_RSS */
81da2e3ebchin#   ifndef RLIMIT_STACK
82da2e3ebchin#	define RLIMIT_STACK	0
83da2e3ebchin#   endif /* !RLIMIT_STACK */
84da2e3ebchin#   ifndef RLIMIT_CORE
85da2e3ebchin#	define RLIMIT_CORE	0
86da2e3ebchin#   endif /* !RLIMIT_CORE */
87da2e3ebchin#   ifndef RLIMIT_VMEM
88da2e3ebchin#	define RLIMIT_VMEM	0
89da2e3ebchin#   endif /* !RLIMIT_VMEM */
90da2e3ebchin#   ifndef RLIMIT_NOFILE
91da2e3ebchin#	define RLIMIT_NOFILE	0
92da2e3ebchin#   endif /* !RLIMIT_NOFILE */
93da2e3ebchin#else
94da2e3ebchin#   define _no_ulimit
95da2e3ebchin#endif
96da2e3ebchin#ifndef _typ_rlim_t
97da2e3ebchin    typedef long rlim_t;
98da2e3ebchin#endif
99da2e3ebchin
100da2e3ebchin#if !defined(RLIMIT_NOFILE) && defined(RLIMIT_OFILE)
101da2e3ebchin#define RLIMIT_NOFILE	RLIMIT_OFILE
102da2e3ebchin#endif
103da2e3ebchin
104da2e3ebchin#ifndef RLIMIT_UNKNOWN
105da2e3ebchin#define RLIMIT_UNKNOWN	(-9999)
106da2e3ebchin#endif
107da2e3ebchin#ifndef RLIMIT_AS
108da2e3ebchin#define RLIMIT_AS	RLIMIT_UNKNOWN
109da2e3ebchin#endif
110da2e3ebchin#ifndef RLIMIT_CORE
111da2e3ebchin#define RLIMIT_CORE	RLIMIT_UNKNOWN
112da2e3ebchin#endif
113da2e3ebchin#ifndef RLIMIT_CPU
114da2e3ebchin#define RLIMIT_CPU	RLIMIT_UNKNOWN
115da2e3ebchin#endif
116da2e3ebchin#ifndef RLIMIT_DATA
117da2e3ebchin#define RLIMIT_DATA	RLIMIT_UNKNOWN
118da2e3ebchin#endif
119da2e3ebchin#ifndef RLIMIT_FSIZE
120da2e3ebchin#define RLIMIT_FSIZE	RLIMIT_UNKNOWN
121da2e3ebchin#endif
122da2e3ebchin#ifndef RLIMIT_LOCKS
123da2e3ebchin#define RLIMIT_LOCKS	RLIMIT_UNKNOWN
124da2e3ebchin#endif
125da2e3ebchin#ifndef RLIMIT_MEMLOCK
126da2e3ebchin#define RLIMIT_MEMLOCK	RLIMIT_UNKNOWN
127da2e3ebchin#endif
128da2e3ebchin#ifndef RLIMIT_NOFILE
129da2e3ebchin#define RLIMIT_NOFILE	RLIMIT_UNKNOWN
130da2e3ebchin#endif
131da2e3ebchin#ifndef RLIMIT_NPROC
132da2e3ebchin#define RLIMIT_NPROC	RLIMIT_UNKNOWN
133da2e3ebchin#endif
134da2e3ebchin#ifndef RLIMIT_PIPE
135da2e3ebchin#define RLIMIT_PIPE	RLIMIT_UNKNOWN
136da2e3ebchin#endif
137da2e3ebchin#ifndef RLIMIT_RSS
138da2e3ebchin#define RLIMIT_RSS	RLIMIT_UNKNOWN
139da2e3ebchin#endif
140da2e3ebchin#ifndef RLIMIT_SBSIZE
141da2e3ebchin#define RLIMIT_SBSIZE	RLIMIT_UNKNOWN
142da2e3ebchin#endif
143da2e3ebchin#ifndef RLIMIT_STACK
144da2e3ebchin#define RLIMIT_STACK	RLIMIT_UNKNOWN
145da2e3ebchin#endif
146da2e3ebchin#ifndef RLIMIT_PTHREAD
147da2e3ebchin#define RLIMIT_PTHREAD	RLIMIT_UNKNOWN
148da2e3ebchin#endif
149da2e3ebchin#ifndef RLIMIT_VMEM
150da2e3ebchin#define RLIMIT_VMEM	RLIMIT_UNKNOWN
151da2e3ebchin#endif
152da2e3ebchin
153da2e3ebchin#define LIM_COUNT	0
154da2e3ebchin#define LIM_BLOCK	1
155da2e3ebchin#define LIM_BYTE	2
156da2e3ebchin#define LIM_KBYTE	3
157da2e3ebchin#define LIM_SECOND	4
158da2e3ebchin
159da2e3ebchintypedef struct Limit_s
160da2e3ebchin{
161da2e3ebchin	const char	name[8];
162da2e3ebchin	const char*	description;
163da2e3ebchin	int		index;
164da2e3ebchin	const char*	conf;
165da2e3ebchin	unsigned char	option;
166da2e3ebchin	unsigned char	type;
167da2e3ebchin} Limit_t;
168da2e3ebchin
169da2e3ebchinextern const Limit_t	shtab_limits[];
170da2e3ebchinextern const int	shtab_units[];
171da2e3ebchin
172da2e3ebchinextern const char	e_unlimited[];
173da2e3ebchinextern const char*	e_units[];
174da2e3ebchin
175da2e3ebchin#endif /* _ULIMIT_H */
176