xref: /titanic_51/usr/src/lib/libshell/common/include/ulimit.h (revision 19d61fc7991644175873937566d932d8cf52912a)
1 /***********************************************************************
2 *                                                                      *
3 *               This software is part of the ast package               *
4 *           Copyright (c) 1982-2007 AT&T Knowledge Ventures            *
5 *                      and is licensed under the                       *
6 *                  Common Public License, Version 1.0                  *
7 *                      by AT&T Knowledge Ventures                      *
8 *                                                                      *
9 *                A copy of the License is available at                 *
10 *            http://www.opensource.org/licenses/cpl1.0.txt             *
11 *         (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9)         *
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_CPU
73 #	define RLIMIT_CPU	0
74 #   endif /* !RLIMIT_CPU */
75 #   ifndef RLIMIT_DATA
76 #	define RLIMIT_DATA	0
77 #   endif /* !RLIMIT_DATA */
78 #   ifndef RLIMIT_RSS
79 #	define RLIMIT_RSS	0
80 #   endif /* !RLIMIT_RSS */
81 #   ifndef RLIMIT_STACK
82 #	define RLIMIT_STACK	0
83 #   endif /* !RLIMIT_STACK */
84 #   ifndef RLIMIT_CORE
85 #	define RLIMIT_CORE	0
86 #   endif /* !RLIMIT_CORE */
87 #   ifndef RLIMIT_VMEM
88 #	define RLIMIT_VMEM	0
89 #   endif /* !RLIMIT_VMEM */
90 #   ifndef RLIMIT_NOFILE
91 #	define RLIMIT_NOFILE	0
92 #   endif /* !RLIMIT_NOFILE */
93 #else
94 #   define _no_ulimit
95 #endif
96 #ifndef _typ_rlim_t
97     typedef long rlim_t;
98 #endif
99 
100 #if !defined(RLIMIT_NOFILE) && defined(RLIMIT_OFILE)
101 #define RLIMIT_NOFILE	RLIMIT_OFILE
102 #endif
103 
104 #ifndef RLIMIT_UNKNOWN
105 #define RLIMIT_UNKNOWN	(-9999)
106 #endif
107 #ifndef RLIMIT_AS
108 #define RLIMIT_AS	RLIMIT_UNKNOWN
109 #endif
110 #ifndef RLIMIT_CORE
111 #define RLIMIT_CORE	RLIMIT_UNKNOWN
112 #endif
113 #ifndef RLIMIT_CPU
114 #define RLIMIT_CPU	RLIMIT_UNKNOWN
115 #endif
116 #ifndef RLIMIT_DATA
117 #define RLIMIT_DATA	RLIMIT_UNKNOWN
118 #endif
119 #ifndef RLIMIT_FSIZE
120 #define RLIMIT_FSIZE	RLIMIT_UNKNOWN
121 #endif
122 #ifndef RLIMIT_LOCKS
123 #define RLIMIT_LOCKS	RLIMIT_UNKNOWN
124 #endif
125 #ifndef RLIMIT_MEMLOCK
126 #define RLIMIT_MEMLOCK	RLIMIT_UNKNOWN
127 #endif
128 #ifndef RLIMIT_NOFILE
129 #define RLIMIT_NOFILE	RLIMIT_UNKNOWN
130 #endif
131 #ifndef RLIMIT_NPROC
132 #define RLIMIT_NPROC	RLIMIT_UNKNOWN
133 #endif
134 #ifndef RLIMIT_PIPE
135 #define RLIMIT_PIPE	RLIMIT_UNKNOWN
136 #endif
137 #ifndef RLIMIT_RSS
138 #define RLIMIT_RSS	RLIMIT_UNKNOWN
139 #endif
140 #ifndef RLIMIT_SBSIZE
141 #define RLIMIT_SBSIZE	RLIMIT_UNKNOWN
142 #endif
143 #ifndef RLIMIT_STACK
144 #define RLIMIT_STACK	RLIMIT_UNKNOWN
145 #endif
146 #ifndef RLIMIT_PTHREAD
147 #define RLIMIT_PTHREAD	RLIMIT_UNKNOWN
148 #endif
149 #ifndef RLIMIT_VMEM
150 #define RLIMIT_VMEM	RLIMIT_UNKNOWN
151 #endif
152 
153 #define LIM_COUNT	0
154 #define LIM_BLOCK	1
155 #define LIM_BYTE	2
156 #define LIM_KBYTE	3
157 #define LIM_SECOND	4
158 
159 typedef struct Limit_s
160 {
161 	const char	name[8];
162 	const char*	description;
163 	int		index;
164 	const char*	conf;
165 	unsigned char	option;
166 	unsigned char	type;
167 } Limit_t;
168 
169 extern const Limit_t	shtab_limits[];
170 extern const int	shtab_units[];
171 
172 extern const char	e_unlimited[];
173 extern const char*	e_units[];
174 
175 #endif /* _ULIMIT_H */
176