Back to index

glibc  2.9
resource.h
Go to the documentation of this file.
00001 /* Copyright (C) 1992,94,1996-2000,2002,2004 Free Software Foundation, Inc.
00002    This file is part of the GNU C Library.
00003 
00004    The GNU C Library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Lesser General Public
00006    License as published by the Free Software Foundation; either
00007    version 2.1 of the License, or (at your option) any later version.
00008 
00009    The GNU C Library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Lesser General Public License for more details.
00013 
00014    You should have received a copy of the GNU Lesser General Public
00015    License along with the GNU C Library; if not, write to the Free
00016    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00017    02111-1307 USA.  */
00018 
00019 #ifndef       _SYS_RESOURCE_H
00020 #define       _SYS_RESOURCE_H      1
00021 
00022 #include <features.h>
00023 
00024 /* Get the system-dependent definitions of structures and bit values.  */
00025 #include <bits/resource.h>
00026 
00027 #ifndef __id_t_defined
00028 typedef __id_t id_t;
00029 # define __id_t_defined
00030 #endif
00031 
00032 __BEGIN_DECLS
00033 
00034 /* The X/Open standard defines that all the functions below must use
00035    `int' as the type for the first argument.  When we are compiling with
00036    GNU extensions we change this slightly to provide better error
00037    checking.  */
00038 #if defined __USE_GNU && !defined __cplusplus
00039 typedef enum __rlimit_resource __rlimit_resource_t;
00040 typedef enum __rusage_who __rusage_who_t;
00041 typedef enum __priority_which __priority_which_t;
00042 #else
00043 typedef int __rlimit_resource_t;
00044 typedef int __rusage_who_t;
00045 typedef int __priority_which_t;
00046 #endif
00047 
00048 /* Put the soft and hard limits for RESOURCE in *RLIMITS.
00049    Returns 0 if successful, -1 if not (and sets errno).  */
00050 #ifndef __USE_FILE_OFFSET64
00051 extern int getrlimit (__rlimit_resource_t __resource,
00052                     struct rlimit *__rlimits) __THROW;
00053 #else
00054 # ifdef __REDIRECT_NTH
00055 extern int __REDIRECT_NTH (getrlimit, (__rlimit_resource_t __resource,
00056                                    struct rlimit *__rlimits), getrlimit64);
00057 # else
00058 #  define getrlimit getrlimit64
00059 # endif
00060 #endif
00061 #ifdef __USE_LARGEFILE64
00062 extern int getrlimit64 (__rlimit_resource_t __resource,
00063                      struct rlimit64 *__rlimits) __THROW;
00064 #endif
00065 
00066 /* Set the soft and hard limits for RESOURCE to *RLIMITS.
00067    Only the super-user can increase hard limits.
00068    Return 0 if successful, -1 if not (and sets errno).  */
00069 #ifndef __USE_FILE_OFFSET64
00070 extern int setrlimit (__rlimit_resource_t __resource,
00071                     __const struct rlimit *__rlimits) __THROW;
00072 #else
00073 # ifdef __REDIRECT_NTH
00074 extern int __REDIRECT_NTH (setrlimit, (__rlimit_resource_t __resource,
00075                                    __const struct rlimit *__rlimits),
00076                         setrlimit64);
00077 # else
00078 #  define setrlimit setrlimit64
00079 # endif
00080 #endif
00081 #ifdef __USE_LARGEFILE64
00082 extern int setrlimit64 (__rlimit_resource_t __resource,
00083                      __const struct rlimit64 *__rlimits) __THROW;
00084 #endif
00085 
00086 /* Return resource usage information on process indicated by WHO
00087    and put it in *USAGE.  Returns 0 for success, -1 for failure.  */
00088 extern int getrusage (__rusage_who_t __who, struct rusage *__usage) __THROW;
00089 
00090 /* Return the highest priority of any process specified by WHICH and WHO
00091    (see above); if WHO is zero, the current process, process group, or user
00092    (as specified by WHO) is used.  A lower priority number means higher
00093    priority.  Priorities range from PRIO_MIN to PRIO_MAX (above).  */
00094 extern int getpriority (__priority_which_t __which, id_t __who) __THROW;
00095 
00096 /* Set the priority of all processes specified by WHICH and WHO (see above)
00097    to PRIO.  Returns 0 on success, -1 on errors.  */
00098 extern int setpriority (__priority_which_t __which, id_t __who, int __prio)
00099      __THROW;
00100 
00101 __END_DECLS
00102 
00103 #endif /* sys/resource.h  */