From e01682bb682cd99da2f2daf742291878a2609b4a Mon Sep 17 00:00:00 2001 From: David Schultz Date: Sun, 13 Jun 2004 22:07:58 +0000 Subject: [PATCH] Make this header a little bit more XSI-compliant: - Define type rlim_t and struct timeval. This makes autoconf happier. (PR: 62388) - Add RLIMIT_AS, which is an alias for our RLIMIT_VMEM. - structs orlimit and loadavg, as well as macros CP*, should only appear if __BSD_VISIBLE. - Use underscored versions of int32_t and fixpt_t in case is not included. - Document areas of non-conformance. --- sys/sys/resource.h | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/sys/sys/resource.h b/sys/sys/resource.h index 778d781549d5..6b905f4482d8 100644 --- a/sys/sys/resource.h +++ b/sys/sys/resource.h @@ -33,6 +33,10 @@ #ifndef _SYS_RESOURCE_H_ #define _SYS_RESOURCE_H_ +#include +#include +#include + /* * Process priority specifications to get/setpriority. */ @@ -85,10 +89,12 @@ struct rusage { #define RLIMIT_NOFILE 8 /* number of open files */ #define RLIMIT_SBSIZE 9 /* maximum size of all socket buffers */ #define RLIMIT_VMEM 10 /* virtual process size (inclusive of mmap) */ +#define RLIMIT_AS RLIMIT_VMEM /* standard name for RLIMIT_VMEM */ #define RLIM_NLIMITS 11 /* number of resource limits */ #define RLIM_INFINITY ((rlim_t)(((u_quad_t)1 << 63) - 1)) +/* XXX Missing: RLIM_SAVED_MAX, RLIM_SAVED_CUR */ /* @@ -111,20 +117,26 @@ static char *rlimit_ident[] = { }; #endif -struct orlimit { - int32_t rlim_cur; /* current (soft) limit */ - int32_t rlim_max; /* maximum value for rlim_cur */ -}; +#ifndef _RLIM_T_DECLARED +typedef __rlim_t rlim_t; +#define _RLIM_T_DECLARED +#endif struct rlimit { rlim_t rlim_cur; /* current (soft) limit */ rlim_t rlim_max; /* maximum value for rlim_cur */ }; -/* Load average structure. */ +#if __BSD_VISIBLE + +struct orlimit { + __int32_t rlim_cur; /* current (soft) limit */ + __int32_t rlim_max; /* maximum value for rlim_cur */ +}; + struct loadavg { - fixpt_t ldavg[3]; - long fscale; + __fixpt_t ldavg[3]; + long fscale; }; #define CP_USER 0 @@ -134,6 +146,8 @@ struct loadavg { #define CP_IDLE 4 #define CPUSTATES 5 +#endif /* __BSD_VISIBLE */ + #ifdef _KERNEL extern struct loadavg averunnable; extern long cp_time[CPUSTATES]; @@ -141,9 +155,9 @@ extern long cp_time[CPUSTATES]; int kern_setrlimit(struct thread *, u_int, struct rlimit *); #else -#include __BEGIN_DECLS +/* XXX 2nd arg to [gs]etpriority() should be an id_t */ int getpriority(int, int); int getrlimit(int, struct rlimit *); int getrusage(int, struct rusage *);