home *** CD-ROM | disk | FTP | other *** search
/ RISCWORLD 7 / RISCWORLD_VOL7.iso / Software / Issue6 / SDL.ZIP / !gcc / include / unixlib / sys / h / resource < prev    next >
Encoding:
C/C++ Source or Header  |  2006-09-17  |  5.0 KB  |  167 lines

  1. /****************************************************************************
  2.  *
  3.  * $Source: /usr/local/cvsroot/gccsdk/unixlib/source/clib/sys/resource.h,v $
  4.  * $Date: 2005/04/13 19:20:06 $
  5.  * $Revision: 1.8 $
  6.  * $State: Exp $
  7.  * $Author: nick $
  8.  *
  9.  ***************************************************************************/
  10.  
  11. #ifndef    __SYS_RESOURCE_H
  12.  
  13. #if !defined __need_rusage
  14. #define __SYS_RESOURCE_H
  15. #endif
  16.  
  17. #ifndef __UNIXLIB_TYPES_H
  18. #include <unixlib/types.h>
  19. #endif
  20.  
  21. #define __need_timeval
  22. #include <sys/time.h>
  23.  
  24. #if !defined __rusage_defined && (defined __SYS_RESOURCE_H || defined __need_rusage)
  25. #define __rusage_defined
  26. /* Structure which says how much of each resource has been used.  */
  27. struct rusage
  28.   {
  29.     /* Total amount of user time used.  */
  30.     struct timeval ru_utime;
  31.     /* Total amount of system time used.  */
  32.     struct timeval ru_stime;
  33.     /* Maximum resident set size (in kilobytes).  */
  34.     int ru_maxrss;
  35.     /* Amount of sharing of text segment memory
  36.        with other processes (kilobyte-seconds).  */
  37.     int ru_ixrss;
  38.     /* Amount of data segment memory used (kilobyte-seconds).  */
  39.     int ru_idrss;
  40.     /* Amount of stack memory used (kilobyte-seconds).  */
  41.     int ru_isrss;
  42.     /* Number of soft page faults (i.e. those serviced by reclaiming
  43.        a page from the list of pages awaiting reallocation.  */
  44.     int ru_minflt;
  45.     /* Number of hard page faults (i.e. those that required I/O).  */
  46.     int ru_majflt;
  47.     /* Number of times a process was swapped out of physical memory.  */
  48.     int ru_nswap;
  49.     /* Number of input operations via the file system.  Note: This
  50.        and `ru_oublock' do not include operations with the cache.  */
  51.     int ru_inblock;
  52.     /* Number of output operations via the file system.  */
  53.     int ru_oublock;
  54.     /* Number of IPC messages sent.  */
  55.     int ru_msgsnd;
  56.     /* Number of IPC messages received.  */
  57.     int ru_msgrcv;
  58.     /* Number of signals delivered.  */
  59.     int ru_nsignals;
  60.     /* Number of voluntary context switches, i.e. because the process
  61.        gave up the process before it had to (usually to wait for some
  62.        resource to be available).  */
  63.     int ru_nvcsw;
  64.     /* Number of involuntary context switches, i.e. a higher priority process
  65.        became runnable or the current process used up its time slice.  */
  66.     int ru_nivcsw;
  67.   };
  68. #endif
  69. #undef __need_rusage
  70.  
  71. #ifdef __SYS_RESOURCE_H
  72.  
  73. #ifndef __UNIXLIB_FEATURES_h
  74. #include <features.h>
  75. #endif
  76.  
  77. __BEGIN_DECLS
  78.  
  79. typedef __rlim_t rlim_t;
  80.  
  81. enum __rlimit_resource
  82.   {
  83.     RLIMIT_CPU,
  84. #define RLIMIT_CPU RLIMIT_CPU
  85.     RLIMIT_FSIZE,
  86. #define RLIMIT_FSIZE RLIMIT_FSIZE
  87.     RLIMIT_CORE,
  88. #define RLIMIT_CORE RLIMIT_CORE
  89.     RLIMIT_DATA,
  90. #define RLIMIT_DATA RLIMIT_DATA
  91.     RLIMIT_STACK,
  92. #define RLIMIT_STACK RLIMIT_STACK
  93.     RLIMIT_RSS,
  94. #define RLIMIT_RSS RLIMIT_RSS
  95.     RLIMIT_MEMLOCK,
  96. #define RLIMIT_MEMLOCK RLIMIT_MEMLOCK
  97.     RLIMIT_NPROC,
  98. #define RLIMIT_NPROC RLIMIT_NPROC
  99.     RLIMIT_NOFILE,
  100.     RLIMIT_OFILE = RLIMIT_NOFILE,
  101. #define RLIMIT_NOFILE RLIMIT_NOFILE
  102. #define RLIMIT_OFILE RLIMIT_OFILE
  103.     RLIMIT_NLIMITS
  104. #define RLIMIT_NLIMITS RLIMIT_NLIMITS
  105.   };
  106.  
  107. struct rlimit
  108.   {
  109.     /* The current (soft) limit.  */
  110.     int rlim_cur;
  111.     /* The hard limit.  */
  112.     int rlim_max;
  113.   };
  114.  
  115. /* Value used to indicate that there is no limit.  */
  116. #define RLIM_INFINITY 0x7fffffff
  117.  
  118. /* Put the soft and hard limits for RESOURCE in *RLIMITS.
  119.    Returns 0 if successful, -1 if not (and sets errno).  */
  120. extern int getrlimit (enum __rlimit_resource, struct rlimit *) __THROW;
  121.  
  122. /* Set the soft and hard limits for RESOURCE to *RLIMITS.
  123.    Only the super-user can increase hard limits.
  124.    Return 0 if successful, -1 if not (and sets errno).  */
  125. extern int setrlimit (enum __rlimit_resource, const struct rlimit *) __THROW;
  126.  
  127. /* Whose usage statistics do you want?  */
  128. enum __rusage_who
  129. /* The macro definitions are necessary because some programs want
  130.    to test for operating system features with #ifdef RUSAGE_SELF.
  131.    In ANSI C the reflexive definition is a no-op.  */
  132.   {
  133.     /* The calling process.  */
  134.     RUSAGE_SELF = 0,
  135. #define    RUSAGE_SELF    RUSAGE_SELF
  136.     /* All of its terminated child processes.  */
  137.     RUSAGE_CHILDREN = -1
  138. #define    RUSAGE_CHILDREN    RUSAGE_CHILDREN
  139.   };
  140.  
  141. /* Return resource usage information on a process.  */
  142. extern int getrusage (enum __rusage_who, struct rusage *) __THROW;
  143.  
  144. /* Priority limits.  */
  145. #define    PRIO_MIN    -20    /* Minimum priority a process can have.  */
  146. #define    PRIO_MAX    20    /* Maximum priority a process can have.  */
  147.  
  148. /* The type of the 'which' argument to `getpriority' and `setpriority',
  149.    indicating what flavor of entity the WHO argument specifies.  */
  150. enum __priority_which
  151.   {
  152.     PRIO_PROCESS = 0,        /* WHO is a process ID.  */
  153.     PRIO_PGRP = 1,        /* WHO is a process group ID.  */
  154.     PRIO_USER = 2        /* WHO is a user ID.  */
  155.   };
  156.  
  157. /* Return the highest priority of any process.  */
  158. extern int getpriority (enum __priority_which, __id_t __who) __THROW;
  159.  
  160. /* Set the priority of all processes.  */
  161. extern int setpriority (enum __priority_which, __id_t __who, int __value) __THROW;
  162.  
  163. __END_DECLS
  164.  
  165. #endif /* resource.h  */
  166. #endif /* ! __SYS_RESOURCE_H */
  167.