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