#ifndef _SYS_RESOURCE_H
#define _SYS_RESOURCE_H
#include <sys/feature_tests.h>
#include <sys/types.h>
#include <sys/time.h>
#ifdef __cplusplus
extern "C" {
#endif
#define PRIO_PROCESS 0
#define PRIO_PGRP 1
#define PRIO_USER 2
#define PRIO_GROUP 3
#define PRIO_SESSION 4
#define PRIO_LWP 5
#define PRIO_TASK 6
#define PRIO_PROJECT 7
#define PRIO_ZONE 8
#define PRIO_CONTRACT 9
#define RLIMIT_CPU 0
#define RLIMIT_FSIZE 1
#define RLIMIT_DATA 2
#define RLIMIT_STACK 3
#define RLIMIT_CORE 4
#define RLIMIT_NOFILE 5
#define RLIMIT_VMEM 6
#define RLIMIT_AS RLIMIT_VMEM
#define RLIM_NLIMITS 7
#if defined(_LP64)
typedef unsigned long rlim_t;
#define RLIM_INFINITY ((rlim_t)-3)
#define RLIM_SAVED_MAX ((rlim_t)-2)
#define RLIM_SAVED_CUR ((rlim_t)-1)
#else
#if _FILE_OFFSET_BITS == 32
typedef unsigned long rlim_t;
#define RLIM_INFINITY 0x7fffffff
#define RLIM_SAVED_MAX 0x7ffffffe
#define RLIM_SAVED_CUR 0x7ffffffd
#else
typedef u_longlong_t rlim_t;
#define RLIM_INFINITY ((rlim_t)-3)
#define RLIM_SAVED_MAX ((rlim_t)-2)
#define RLIM_SAVED_CUR ((rlim_t)-1)
#endif
#endif
#if defined(_SYSCALL32)
typedef uint32_t rlim32_t;
#define RLIM32_INFINITY 0x7fffffff
#define RLIM32_SAVED_MAX 0x7ffffffe
#define RLIM32_SAVED_CUR 0x7ffffffd
struct rlimit32 {
rlim32_t rlim_cur;
rlim32_t rlim_max;
};
#endif
struct rlimit {
rlim_t rlim_cur;
rlim_t rlim_max;
};
#ifdef _LARGEFILE64_SOURCE
typedef u_longlong_t rlim64_t;
#define RLIM64_INFINITY ((rlim64_t)-3)
#define RLIM64_SAVED_MAX ((rlim64_t)-2)
#define RLIM64_SAVED_CUR ((rlim64_t)-1)
struct rlimit64 {
rlim64_t rlim_cur;
rlim64_t rlim_max;
};
#endif
#if defined(_LP64)
#define RLIM_SAVED(x) (1)
#define RLIM_NSAVED RLIM_NLIMITS
#else
#define RLIM_SAVED(x) (x <= RLIMIT_FSIZE)
#define RLIM_NSAVED (RLIMIT_FSIZE + 1)
#endif
struct rusage {
struct timeval ru_utime;
struct timeval ru_stime;
long ru_maxrss;
long ru_ixrss;
long ru_idrss;
long ru_isrss;
long ru_minflt;
long ru_majflt;
long ru_nswap;
long ru_inblock;
long ru_oublock;
long ru_msgsnd;
long ru_msgrcv;
long ru_nsignals;
long ru_nvcsw;
long ru_nivcsw;
};
#define _RUSAGESYS_GETRUSAGE 0
#define _RUSAGESYS_GETRUSAGE_CHLD 1
#define _RUSAGESYS_GETRUSAGE_LWP 2
#define _RUSAGESYS_GETVMUSAGE 3
#if defined(_SYSCALL32)
struct rusage32 {
struct timeval32 ru_utime;
struct timeval32 ru_stime;
int ru_maxrss;
int ru_ixrss;
int ru_idrss;
int ru_isrss;
int ru_minflt;
int ru_majflt;
int ru_nswap;
int ru_inblock;
int ru_oublock;
int ru_msgsnd;
int ru_msgrcv;
int ru_nsignals;
int ru_nvcsw;
int ru_nivcsw;
};
#endif
#ifdef _KERNEL
#include <sys/model.h>
struct proc;
#else
#define RUSAGE_SELF 0
#define RUSAGE_LWP 1
#define RUSAGE_CHILDREN -1
#if !defined(_LP64) && _FILE_OFFSET_BITS == 64
#ifdef __PRAGMA_REDEFINE_EXTNAME
#pragma redefine_extname setrlimit setrlimit64
#pragma redefine_extname getrlimit getrlimit64
#else
#define setrlimit setrlimit64
#define getrlimit getrlimit64
#define rlimit rlimit64
#endif
#endif
#if defined(_LP64) && defined(_LARGEFILE64_SOURCE)
#ifdef __PRAGMA_REDEFINE_EXTNAME
#pragma redefine_extname setrlimit64 setrlimit
#pragma redefine_extname getrlimit64 getrlimit
#else
#define setrlimit64 setrlimit
#define getrlimit64 getrlimit
#define rlimit64 rlimit
#endif
#endif
extern int setrlimit(int, const struct rlimit *);
extern int getrlimit(int, struct rlimit *);
#if defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \
!defined(__PRAGMA_REDEFINE_EXTNAME))
extern int setrlimit64(int, const struct rlimit64 *);
extern int getrlimit64(int, struct rlimit64 *);
#endif
extern int getpriority(int, id_t);
extern int setpriority(int, id_t, int);
extern int getrusage(int, struct rusage *);
#endif
#ifdef __cplusplus
}
#endif
#endif