resource.h 2.1 KB

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