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