1570af302Sopenharmony_ci#ifndef _SYS_RESOURCE_H 2570af302Sopenharmony_ci#define _SYS_RESOURCE_H 3570af302Sopenharmony_ci 4570af302Sopenharmony_ci#ifdef __cplusplus 5570af302Sopenharmony_ciextern "C" { 6570af302Sopenharmony_ci#endif 7570af302Sopenharmony_ci 8570af302Sopenharmony_ci#include <features.h> 9570af302Sopenharmony_ci#include <sys/time.h> 10570af302Sopenharmony_ci 11570af302Sopenharmony_ci#define __NEED_id_t 12570af302Sopenharmony_ci 13570af302Sopenharmony_ci#ifdef _GNU_SOURCE 14570af302Sopenharmony_ci#define __NEED_pid_t 15570af302Sopenharmony_ci#endif 16570af302Sopenharmony_ci 17570af302Sopenharmony_ci#include <bits/alltypes.h> 18570af302Sopenharmony_ci#include <bits/resource.h> 19570af302Sopenharmony_ci 20570af302Sopenharmony_citypedef unsigned long long rlim_t; 21570af302Sopenharmony_ci 22570af302Sopenharmony_cistruct rlimit { 23570af302Sopenharmony_ci rlim_t rlim_cur; 24570af302Sopenharmony_ci rlim_t rlim_max; 25570af302Sopenharmony_ci}; 26570af302Sopenharmony_ci 27570af302Sopenharmony_cistruct rusage { 28570af302Sopenharmony_ci struct timeval ru_utime; 29570af302Sopenharmony_ci struct timeval ru_stime; 30570af302Sopenharmony_ci /* linux extentions, but useful */ 31570af302Sopenharmony_ci long ru_maxrss; 32570af302Sopenharmony_ci long ru_ixrss; 33570af302Sopenharmony_ci long ru_idrss; 34570af302Sopenharmony_ci long ru_isrss; 35570af302Sopenharmony_ci long ru_minflt; 36570af302Sopenharmony_ci long ru_majflt; 37570af302Sopenharmony_ci long ru_nswap; 38570af302Sopenharmony_ci long ru_inblock; 39570af302Sopenharmony_ci long ru_oublock; 40570af302Sopenharmony_ci long ru_msgsnd; 41570af302Sopenharmony_ci long ru_msgrcv; 42570af302Sopenharmony_ci long ru_nsignals; 43570af302Sopenharmony_ci long ru_nvcsw; 44570af302Sopenharmony_ci long ru_nivcsw; 45570af302Sopenharmony_ci /* room for more... */ 46570af302Sopenharmony_ci long __reserved[16]; 47570af302Sopenharmony_ci}; 48570af302Sopenharmony_ci 49570af302Sopenharmony_ciint getrlimit (int, struct rlimit *); 50570af302Sopenharmony_ciint setrlimit (int, const struct rlimit *); 51570af302Sopenharmony_ciint getrusage (int, struct rusage *); 52570af302Sopenharmony_ci 53570af302Sopenharmony_ciint getpriority (int, id_t); 54570af302Sopenharmony_ciint setpriority (int, id_t, int); 55570af302Sopenharmony_ci 56570af302Sopenharmony_ci#ifdef _GNU_SOURCE 57570af302Sopenharmony_ciint prlimit(pid_t, int, const struct rlimit *, struct rlimit *); 58570af302Sopenharmony_ci#define prlimit64 prlimit 59570af302Sopenharmony_ci#endif 60570af302Sopenharmony_ci 61570af302Sopenharmony_ci#define PRIO_MIN (-20) 62570af302Sopenharmony_ci#define PRIO_MAX 20 63570af302Sopenharmony_ci 64570af302Sopenharmony_ci#define PRIO_PROCESS 0 65570af302Sopenharmony_ci#define PRIO_PGRP 1 66570af302Sopenharmony_ci#define PRIO_USER 2 67570af302Sopenharmony_ci 68570af302Sopenharmony_ci#define RUSAGE_SELF 0 69570af302Sopenharmony_ci#define RUSAGE_CHILDREN (-1) 70570af302Sopenharmony_ci#define RUSAGE_THREAD 1 71570af302Sopenharmony_ci 72570af302Sopenharmony_ci#define RLIM_INFINITY (~0ULL) 73570af302Sopenharmony_ci#define RLIM_SAVED_CUR RLIM_INFINITY 74570af302Sopenharmony_ci#define RLIM_SAVED_MAX RLIM_INFINITY 75570af302Sopenharmony_ci 76570af302Sopenharmony_ci#define RLIMIT_CPU 0 77570af302Sopenharmony_ci#define RLIMIT_FSIZE 1 78570af302Sopenharmony_ci#define RLIMIT_DATA 2 79570af302Sopenharmony_ci#define RLIMIT_STACK 3 80570af302Sopenharmony_ci#define RLIMIT_CORE 4 81570af302Sopenharmony_ci#ifndef RLIMIT_RSS 82570af302Sopenharmony_ci#define RLIMIT_RSS 5 83570af302Sopenharmony_ci#define RLIMIT_NPROC 6 84570af302Sopenharmony_ci#define RLIMIT_NOFILE 7 85570af302Sopenharmony_ci#define RLIMIT_MEMLOCK 8 86570af302Sopenharmony_ci#define RLIMIT_AS 9 87570af302Sopenharmony_ci#endif 88570af302Sopenharmony_ci#define RLIMIT_LOCKS 10 89570af302Sopenharmony_ci#define RLIMIT_SIGPENDING 11 90570af302Sopenharmony_ci#define RLIMIT_MSGQUEUE 12 91570af302Sopenharmony_ci#define RLIMIT_NICE 13 92570af302Sopenharmony_ci#define RLIMIT_RTPRIO 14 93570af302Sopenharmony_ci#define RLIMIT_RTTIME 15 94570af302Sopenharmony_ci#define RLIMIT_NLIMITS 16 95570af302Sopenharmony_ci 96570af302Sopenharmony_ci#define RLIM_NLIMITS RLIMIT_NLIMITS 97570af302Sopenharmony_ci 98570af302Sopenharmony_ci#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE) 99570af302Sopenharmony_ci#define RLIM64_INFINITY RLIM_INFINITY 100570af302Sopenharmony_ci#define RLIM64_SAVED_CUR RLIM_SAVED_CUR 101570af302Sopenharmony_ci#define RLIM64_SAVED_MAX RLIM_SAVED_MAX 102570af302Sopenharmony_ci#define getrlimit64 getrlimit 103570af302Sopenharmony_ci#define setrlimit64 setrlimit 104570af302Sopenharmony_ci#define rlimit64 rlimit 105570af302Sopenharmony_ci#define rlim64_t rlim_t 106570af302Sopenharmony_ci#endif 107570af302Sopenharmony_ci 108570af302Sopenharmony_ci#if _REDIR_TIME64 109570af302Sopenharmony_ci__REDIR(getrusage, __getrusage_time64); 110570af302Sopenharmony_ci#endif 111570af302Sopenharmony_ci 112570af302Sopenharmony_ci#ifdef __cplusplus 113570af302Sopenharmony_ci} 114570af302Sopenharmony_ci#endif 115570af302Sopenharmony_ci 116570af302Sopenharmony_ci#endif 117