resource.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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 RLIM_INFINITY (~0ULL)
  59. #define RLIM_SAVED_CUR RLIM_INFINITY
  60. #define RLIM_SAVED_MAX RLIM_INFINITY
  61. #define RLIMIT_CPU 0
  62. #define RLIMIT_FSIZE 1
  63. #define RLIMIT_DATA 2
  64. #define RLIMIT_STACK 3
  65. #define RLIMIT_CORE 4
  66. #ifndef RLIMIT_RSS
  67. #define RLIMIT_RSS 5
  68. #define RLIMIT_NPROC 6
  69. #define RLIMIT_NOFILE 7
  70. #define RLIMIT_MEMLOCK 8
  71. #define RLIMIT_AS 9
  72. #endif
  73. #define RLIMIT_LOCKS 10
  74. #define RLIMIT_SIGPENDING 11
  75. #define RLIMIT_MSGQUEUE 12
  76. #define RLIMIT_NICE 13
  77. #define RLIMIT_RTPRIO 14
  78. #define RLIMIT_NLIMITS 15
  79. #define RLIM_NLIMITS RLIMIT_NLIMITS
  80. #if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
  81. #define getrlimit64 getrlimit
  82. #define setrlimit64 setrlimit
  83. #define rlimit64 rlimit
  84. #define rlim64_t rlim_t
  85. #endif
  86. #ifdef __cplusplus
  87. }
  88. #endif
  89. #endif