resource.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. #ifndef _SYS_RESOURCE_H
  2. #define _SYS_RESOURCE_H
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. #include <features.h>
  7. #include <sys/time.h>
  8. #define __NEED_id_t
  9. #ifdef _GNU_SOURCE
  10. #define __NEED_pid_t
  11. #endif
  12. #include <bits/alltypes.h>
  13. #include <bits/resource.h>
  14. typedef unsigned long long rlim_t;
  15. struct rlimit {
  16. rlim_t rlim_cur;
  17. rlim_t rlim_max;
  18. };
  19. struct rusage {
  20. struct timeval ru_utime;
  21. struct timeval ru_stime;
  22. /* linux extentions, but useful */
  23. long ru_maxrss;
  24. long ru_ixrss;
  25. long ru_idrss;
  26. long ru_isrss;
  27. long ru_minflt;
  28. long ru_majflt;
  29. long ru_nswap;
  30. long ru_inblock;
  31. long ru_oublock;
  32. long ru_msgsnd;
  33. long ru_msgrcv;
  34. long ru_nsignals;
  35. long ru_nvcsw;
  36. long ru_nivcsw;
  37. /* room for more... */
  38. long __reserved[16];
  39. };
  40. int getrlimit (int, struct rlimit *);
  41. int setrlimit (int, const struct rlimit *);
  42. int getrusage (int, struct rusage *);
  43. int getpriority (int, id_t);
  44. int setpriority (int, id_t, int);
  45. #ifdef _GNU_SOURCE
  46. int prlimit(pid_t, int, const struct rlimit *, struct rlimit *);
  47. #define prlimit64 prlimit
  48. #endif
  49. #define PRIO_MIN (-20)
  50. #define PRIO_MAX 20
  51. #define PRIO_PROCESS 0
  52. #define PRIO_PGRP 1
  53. #define PRIO_USER 2
  54. #define RUSAGE_SELF 0
  55. #define RUSAGE_CHILDREN (-1)
  56. #define RUSAGE_THREAD 1
  57. #define RLIM_INFINITY (~0ULL)
  58. #define RLIM_SAVED_CUR RLIM_INFINITY
  59. #define RLIM_SAVED_MAX RLIM_INFINITY
  60. #define RLIMIT_CPU 0
  61. #define RLIMIT_FSIZE 1
  62. #define RLIMIT_DATA 2
  63. #define RLIMIT_STACK 3
  64. #define RLIMIT_CORE 4
  65. #ifndef RLIMIT_RSS
  66. #define RLIMIT_RSS 5
  67. #define RLIMIT_NPROC 6
  68. #define RLIMIT_NOFILE 7
  69. #define RLIMIT_MEMLOCK 8
  70. #define RLIMIT_AS 9
  71. #endif
  72. #define RLIMIT_LOCKS 10
  73. #define RLIMIT_SIGPENDING 11
  74. #define RLIMIT_MSGQUEUE 12
  75. #define RLIMIT_NICE 13
  76. #define RLIMIT_RTPRIO 14
  77. #define RLIMIT_NLIMITS 15
  78. #define RLIM_NLIMITS RLIMIT_NLIMITS
  79. #if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
  80. #define RLIM64_INFINITY RLIM_INFINITY
  81. #define RLIM64_SAVED_CUR RLIM_SAVED_CUR
  82. #define RLIM64_SAVED_MAX RLIM_SAVED_MAX
  83. #define getrlimit64 getrlimit
  84. #define setrlimit64 setrlimit
  85. #define rlimit64 rlimit
  86. #define rlim64_t rlim_t
  87. #endif
  88. #ifdef __cplusplus
  89. }
  90. #endif
  91. #endif