/* $Header: resource.h,v 1.18.106.4 98/02/19 11:13:41 dianes Exp $ * $Locker: $ */ /* * @(#) resource.h $Date: 1998/06/22 11:47:27 $Revision: r11ros/4 PATCH_11.00 (PHKL_15705) */ #ifndef _SYS_RESOURCE_INCLUDED #define _SYS_RESOURCE_INCLUDED #ifdef _KERNEL_BUILD #define ATT_BYTESPERBLOCK 512 #define LOG_ATT_BYTESPERBLOCK 9 #include "../h/stdsyms.h" #else /* ! _KERNEL_BUILD */ #include #endif /* _KERNEL_BUILD */ #ifdef _INCLUDE_XOPEN_SOURCE_EXTENDED #ifdef _KERNEL_BUILD #include "../h/types.h" #include "../h/time.h" #else /* ! _KERNEL_BUILD */ #include #include #endif /* _KERNEL_BUILD */ /* * Resource limits */ #if !defined(_KERNEL) # define __rlimit rlimit # define _T_RLIM_T rlim_t #ifdef _KERNEL_BUILD # include "../h/_rlimit_body.h" #else /* ! _KERNEL_BUILD */ # include #endif /* _KERNEL_BUILD */ # undef _T_RLIM_T # undef __rlimit # if defined(_LARGEFILE64_SOURCE) # define __rlimit rlimit64 # define _T_RLIM_T rlim64_t #ifdef _KERNEL_BUILD # include "../h/_rlimit_body.h" #else /* ! _KERNEL_BUILD */ # include #endif /* _KERNEL_BUILD */ # undef _T_RLIM_T # undef __rlimit # endif /* _LARGEFILE64_SOURCE */ #else /* _KERNEL */ # define __rlimit rlimit # define _T_RLIM_T rlim_t # include "_rlimit_body.h" # undef _T_RLIM_T # undef __rlimit # define k_rlimit rlimit #endif /* ! _KERNEL */ /* * Process priority specifications to get/setpriority. */ #define PRIO_MIN -20 #define PRIO_MAX 20 #define PRIO_PROCESS 0 #define PRIO_PGRP 1 #define PRIO_USER 2 /* * Resource utilization information. */ #define RUSAGE_SELF 0 #define RUSAGE_CHILDREN -1 struct rusage { struct timeval ru_utime; /* user time used */ struct timeval ru_stime; /* system time used */ /* actual values kept in proc struct */ long ru_maxrss; #define ru_first ru_ixrss long ru_ixrss; /* integral shared memory size */ long ru_idrss; /* integral unshared data " */ long ru_isrss; /* integral unshared stack " */ long ru_minflt; /* page reclaims */ long ru_majflt; /* page faults */ long ru_nswap; /* swaps */ long ru_inblock; /* block input operations */ long ru_oublock; /* block output operations */ long ru_ioch; /* # of characters read/written */ long ru_msgsnd; /* messages sent */ long ru_msgrcv; /* messages received */ long ru_nsignals; /* signals received */ long ru_nvcsw; /* voluntary context switches */ long ru_nivcsw; /* involuntary " */ #define ru_last ru_nivcsw }; /* * Within the kernel, time information is stored as ticks rather than as * seconds plus microseconds. This makes normal updates more efficient * and eliminates race conditions while updating. The seconds field is * used to store ticks and the microseconds field is unused. */ /* * The information is converted to seconds plus microseconds when given * to the user via the getrusage and wait3 system calls. */ /* Function prototypes */ #ifndef _KERNEL #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ extern int getpriority __((int, id_t)); extern int getrusage __((int, struct rusage *)); extern int setpriority __((int, id_t, int)); _LF_EXTERN_OR_STATIC_OR_INLINE int getrlimit __((int, struct rlimit *)); _LF_EXTERN_OR_STATIC_OR_INLINE int setrlimit __((int, const struct rlimit *)); # if defined(_LARGEFILE64_SOURCE) # ifdef __LP64__ # define getrlimit64 getrlimit # define setrlimit64 setrlimit # else /* __LP64__ */ extern int getrlimit64 __((int, struct rlimit64 *)); extern int setrlimit64 __((int, const struct rlimit64 *)); # endif /* __LP64__ */ # endif /* _LARGEFILE64_SOURCE */ #ifdef _APP32_64BIT_OFF_T extern int __getrlimit64 __((int, struct rlimit *)); extern int __setrlimit64 __((int, const struct rlimit *)); # ifdef _PROTOTYPES _LF_STATIC_OR_INLINE int getrlimit(int a, struct rlimit *b) { return __getrlimit64(a,b); } _LF_STATIC_OR_INLINE int setrlimit(int a, const struct rlimit *b) { return __setrlimit64(a,b); } # else /* _PROTOTYPES */ static int getrlimit(a,b) int a; struct rlimit *b; { return __getrlimit64(a,b); } # ifdef __STDC_EXT__ static int setrlimit(a,b) int a; const struct rlimit *b; { return __setrlimit64(a,b); } # else static int setrlimit(a,b) int a; struct rlimit *b; { return __setrlimit64(a,b); } # endif /* __STDC_EXT__ */ # endif /* _PROTOTYPES */ #endif /* _APP32_64BIT_OFF_T */ #ifdef __cplusplus } #endif /* __cplusplus */ #endif /* not _KERNEL */ /* * Resource limits */ #if defined(_KERNEL) || defined(_LARGEFILE64_SOURCE) # if defined(__L64_MODE__) # define RLIM64_INFINITY 0x7fffffffffffffffL # else /* __L64_MODE__ */ # if defined(__LL_MODE__) # define RLIM64_INFINITY 0x7fffffffffffffffLL # endif /* __LL_MODE__ */ # endif /* __L64_MODE__ */ # define RLIM32_INFINITY 0x7fffffff #endif /* _KERNEL || _LARGEFILE64_SOURCE */ #if defined(_KERNEL) # define RLIM_INFINITY RLIM64_INFINITY # define K_RLIM_INFINITY RLIM_INFINITY # define ATT_BYTESPERBLOCK 512 # define LOG_ATT_BYTESPERBLOCK 9 /* bytes to 1/2k blocks and 1/2k blocks to bytes conversion macro. */ # define bt2bk(x) (((unsigned long) (x)) >> (LOG_ATT_BYTESPERBLOCK)) # define bk2bt(x) (((unsigned long) (x)) << (LOG_ATT_BYTESPERBLOCK)) # define ULIMIT_MAX bt2bk(0x7fffffff) # if defined(__L64_MODE__) # define ULIMIT64_MAX bt2bk(0x7fffffffffffffffL) # endif /* __L64_MODE__ */ # define ULIMIT32_MAX bt2bk(0x7fffffff) #else # if defined(__L64_MODE__) # define RLIM_INFINITY 0x7fffffffffffffffL # else /* __L64_MODE__ */ # if defined(__64BIT_OFF_T) # if defined(__LL_MODE__) # define RLIM_INFINITY 0x7fffffffffffffffLL # else /* __LL_MODE__ */ # define RLIM_INFINITY 0x7fffffff # endif /* __LL_MODE__ */ # else /* __64BIT_OFF_T */ # define RLIM_INFINITY 0x7fffffff # endif /* __64BIT_OFF_T */ # endif /* __L64_MODE__ */ #endif /* _KERNEL */ #define RLIMIT_CPU 0 /* cpu time in milliseconds */ #define RLIMIT_DATA 2 /* data size */ #define RLIMIT_STACK 3 /* stack size */ #define RLIMIT_RSS 5 /* resident set size */ #define RLIMIT_FSIZE 1 /* maximum file size */ #define RLIMIT_CORE 4 /* core file size */ #define RLIMIT_NOFILE 6 /* maximum number of open files */ #define RLIMIT_OPEN_MAX RLIMIT_NOFILE /* maximum number of open files */ #define RLIMIT_AS 7 /* maximum number of open files */ #define RLIMIT_TCACHE 8 /* maximum number of cached threads */ #define RLIMIT_AIO_OPS 9 /* maximum number of POSIX AIO ops */ #define RLIMIT_AIO_MEM 10 /* maximum bytes locked for POSIX AIO */ #define RLIM_NLIMITS 11 /* number of resource limits */ #endif /* _INCLUDE_XOPEN_SOURCE_EXTENDED */ #endif /* _SYS_RESOURCE_INCLUDED */