resource.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /* Copyright (C) 1992-2026 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3. The GNU C Library is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU Lesser General Public
  5. License as published by the Free Software Foundation; either
  6. version 2.1 of the License, or (at your option) any later version.
  7. The GNU C Library is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public
  12. License along with the GNU C Library; if not, see
  13. <https://www.gnu.org/licenses/>. */
  14. #ifndef _SYS_RESOURCE_H
  15. #define _SYS_RESOURCE_H 1
  16. #include <features.h>
  17. /* Get the system-dependent definitions of structures and bit values. */
  18. #include <bits/resource.h>
  19. #ifndef __id_t_defined
  20. typedef __id_t id_t;
  21. # define __id_t_defined
  22. #endif
  23. __BEGIN_DECLS
  24. /* The X/Open standard defines that all the functions below must use
  25. `int' as the type for the first argument. When we are compiling with
  26. GNU extensions we change this slightly to provide better error
  27. checking. */
  28. #if defined __USE_GNU && !defined __cplusplus
  29. typedef enum __rlimit_resource __rlimit_resource_t;
  30. typedef enum __rusage_who __rusage_who_t;
  31. typedef enum __priority_which __priority_which_t;
  32. #else
  33. typedef int __rlimit_resource_t;
  34. typedef int __rusage_who_t;
  35. typedef int __priority_which_t;
  36. #endif
  37. /* Put the soft and hard limits for RESOURCE in *RLIMITS.
  38. Returns 0 if successful, -1 if not (and sets errno). */
  39. #ifndef __USE_FILE_OFFSET64
  40. extern int getrlimit (__rlimit_resource_t __resource,
  41. struct rlimit *__rlimits) __THROW __nonnull ((2));
  42. #else
  43. # ifdef __REDIRECT_NTH
  44. extern int __REDIRECT_NTH (getrlimit, (__rlimit_resource_t __resource,
  45. struct rlimit *__rlimits), getrlimit64)
  46. __nonnull ((2));
  47. # else
  48. # define getrlimit getrlimit64
  49. # endif
  50. #endif
  51. #ifdef __USE_LARGEFILE64
  52. extern int getrlimit64 (__rlimit_resource_t __resource,
  53. struct rlimit64 *__rlimits) __THROW __nonnull ((2));
  54. #endif
  55. /* Set the soft and hard limits for RESOURCE to *RLIMITS.
  56. Only the super-user can increase hard limits.
  57. Return 0 if successful, -1 if not (and sets errno). */
  58. #ifndef __USE_FILE_OFFSET64
  59. extern int setrlimit (__rlimit_resource_t __resource,
  60. const struct rlimit *__rlimits) __THROW __nonnull ((2));
  61. #else
  62. # ifdef __REDIRECT_NTH
  63. extern int __REDIRECT_NTH (setrlimit, (__rlimit_resource_t __resource,
  64. const struct rlimit *__rlimits),
  65. setrlimit64) __nonnull ((2));
  66. # else
  67. # define setrlimit setrlimit64
  68. # endif
  69. #endif
  70. #ifdef __USE_LARGEFILE64
  71. extern int setrlimit64 (__rlimit_resource_t __resource,
  72. const struct rlimit64 *__rlimits) __THROW
  73. __nonnull ((2));
  74. #endif
  75. /* Return resource usage information on process indicated by WHO
  76. and put it in *USAGE. Returns 0 for success, -1 for failure. */
  77. extern int getrusage (__rusage_who_t __who, struct rusage *__usage) __THROW;
  78. #ifdef __USE_TIME64_REDIRECTS
  79. # if defined(__REDIRECT_NTH)
  80. extern int __REDIRECT_NTH (getrusage, (__rusage_who_t __who,
  81. struct rusage *__usage),
  82. __getrusage64);
  83. # else
  84. # define getrusage __getrusage64
  85. # endif
  86. #endif
  87. /* Return the highest priority of any process specified by WHICH and WHO
  88. (see above); if WHO is zero, the current process, process group, or user
  89. (as specified by WHO) is used. A lower priority number means higher
  90. priority. Priorities range from PRIO_MIN to PRIO_MAX (above). */
  91. extern int getpriority (__priority_which_t __which, id_t __who) __THROW;
  92. /* Set the priority of all processes specified by WHICH and WHO (see above)
  93. to PRIO. Returns 0 on success, -1 on errors. */
  94. extern int setpriority (__priority_which_t __which, id_t __who, int __prio)
  95. __THROW;
  96. __END_DECLS
  97. #endif /* sys/resource.h */