resource.h 4.5 KB

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