modernc.org/cc@v1.0.1/v2/headers/linux_386/usr/include/i386-linux-gnu/sys/time.h (about)

     1  /* Copyright (C) 1991-2018 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, see
    16     <http://www.gnu.org/licenses/>.  */
    17  
    18  #ifndef _SYS_TIME_H
    19  #define _SYS_TIME_H	1
    20  
    21  #include <features.h>
    22  
    23  #include <bits/types.h>
    24  #include <bits/types/time_t.h>
    25  #include <bits/types/struct_timeval.h>
    26  
    27  #ifndef __suseconds_t_defined
    28  typedef __suseconds_t suseconds_t;
    29  # define __suseconds_t_defined
    30  #endif
    31  
    32  #include <sys/select.h>
    33  
    34  __BEGIN_DECLS
    35  #ifdef __USE_GNU
    36  /* Macros for converting between `struct timeval' and `struct timespec'.  */
    37  # define TIMEVAL_TO_TIMESPEC(tv, ts) {                                   \
    38  	(ts)->tv_sec = (tv)->tv_sec;                                    \
    39  	(ts)->tv_nsec = (tv)->tv_usec * 1000;                           \
    40  }
    41  # define TIMESPEC_TO_TIMEVAL(tv, ts) {                                   \
    42  	(tv)->tv_sec = (ts)->tv_sec;                                    \
    43  	(tv)->tv_usec = (ts)->tv_nsec / 1000;                           \
    44  }
    45  #endif
    46  #ifdef __USE_MISC
    47  /* Structure crudely representing a timezone.
    48     This is obsolete and should never be used.  */
    49      struct timezone {
    50  	int tz_minuteswest;	/* Minutes west of GMT.  */
    51  	int tz_dsttime;		/* Nonzero if DST is ever in effect.  */
    52  };
    53  
    54  typedef struct timezone *__restrict __timezone_ptr_t;
    55  #else
    56  typedef void *__restrict __timezone_ptr_t;
    57  #endif
    58  
    59  /* Get the current time of day and timezone information,
    60     putting it into *TV and *TZ.  If TZ is NULL, *TZ is not filled.
    61     Returns 0 on success, -1 on errors.
    62     NOTE: This form of timezone information is obsolete.
    63     Use the functions and variables declared in <time.h> instead.  */
    64  extern int gettimeofday(struct timeval *__restrict __tv, __timezone_ptr_t __tz)
    65  __THROW __nonnull((1));
    66  
    67  #ifdef __USE_MISC
    68  /* Set the current time of day and timezone information.
    69     This call is restricted to the super-user.  */
    70  extern int settimeofday(const struct timeval *__tv, const struct timezone *__tz) __THROW;
    71  
    72  /* Adjust the current time of day by the amount in DELTA.
    73     If OLDDELTA is not NULL, it is filled in with the amount
    74     of time adjustment remaining to be done from the last `adjtime' call.
    75     This call is restricted to the super-user.  */
    76  extern int adjtime(const struct timeval *__delta, struct timeval *__olddelta) __THROW;
    77  #endif
    78  
    79  /* Values for the first argument to `getitimer' and `setitimer'.  */
    80  enum __itimer_which {
    81  	/* Timers run in real time.  */
    82  	ITIMER_REAL = 0,
    83  #define ITIMER_REAL ITIMER_REAL
    84  	/* Timers run only when the process is executing.  */
    85  	ITIMER_VIRTUAL = 1,
    86  #define ITIMER_VIRTUAL ITIMER_VIRTUAL
    87  	/* Timers run when the process is executing and when
    88  	   the system is executing on behalf of the process.  */
    89  	ITIMER_PROF = 2
    90  #define ITIMER_PROF ITIMER_PROF
    91  };
    92  
    93  /* Type of the second argument to `getitimer' and
    94     the second and third arguments `setitimer'.  */
    95  struct itimerval {
    96  	/* Value to put into `it_value' when the timer expires.  */
    97  	struct timeval it_interval;
    98  	/* Time to the next timer expiration.  */
    99  	struct timeval it_value;
   100  };
   101  
   102  #if defined __USE_GNU && !defined __cplusplus
   103  /* Use the nicer parameter type only in GNU mode and not for C++ since the
   104     strict C++ rules prevent the automatic promotion.  */
   105  typedef enum __itimer_which __itimer_which_t;
   106  #else
   107  typedef int __itimer_which_t;
   108  #endif
   109  
   110  /* Set *VALUE to the current setting of timer WHICH.
   111     Return 0 on success, -1 on errors.  */
   112  extern int getitimer(__itimer_which_t __which, struct itimerval *__value) __THROW;
   113  
   114  /* Set the timer WHICH to *NEW.  If OLD is not NULL,
   115     set *OLD to the old value of timer WHICH.
   116     Returns 0 on success, -1 on errors.  */
   117  extern int setitimer(__itimer_which_t __which, const struct itimerval *__restrict __new, struct itimerval *__restrict __old) __THROW;
   118  
   119  /* Change the access time of FILE to TVP[0] and the modification time of
   120     FILE to TVP[1].  If TVP is a null pointer, use the current time instead.
   121     Returns 0 on success, -1 on errors.  */
   122  extern int utimes(const char *__file, const struct timeval __tvp[2])
   123  __THROW __nonnull((1));
   124  
   125  #ifdef __USE_MISC
   126  /* Same as `utimes', but does not follow symbolic links.  */
   127  extern int lutimes(const char *__file, const struct timeval __tvp[2])
   128  __THROW __nonnull((1));
   129  
   130  /* Same as `utimes', but takes an open file descriptor instead of a name.  */
   131  extern int futimes(int __fd, const struct timeval __tvp[2]) __THROW;
   132  #endif
   133  
   134  #ifdef __USE_GNU
   135  /* Change the access time of FILE relative to FD to TVP[0] and the
   136     modification time of FILE to TVP[1].  If TVP is a null pointer, use
   137     the current time instead.  Returns 0 on success, -1 on errors.  */
   138  extern int futimesat(int __fd, const char *__file, const struct timeval __tvp[2]) __THROW;
   139  #endif
   140  
   141  #ifdef __USE_MISC
   142  /* Convenience macros for operations on timevals.
   143     NOTE: `timercmp' does not work for >= or <=.  */
   144  # define timerisset(tvp)	((tvp)->tv_sec || (tvp)->tv_usec)
   145  # define timerclear(tvp)	((tvp)->tv_sec = (tvp)->tv_usec = 0)
   146  # define timercmp(a, b, CMP) 						      \
   147    (((a)->tv_sec == (b)->tv_sec) ? 					      \
   148     ((a)->tv_usec CMP (b)->tv_usec) : 					      \
   149     ((a)->tv_sec CMP (b)->tv_sec))
   150  # define timeradd(a, b, result)						      \
   151    do {									      \
   152      (result)->tv_sec = (a)->tv_sec + (b)->tv_sec;			      \
   153      (result)->tv_usec = (a)->tv_usec + (b)->tv_usec;			      \
   154      if ((result)->tv_usec >= 1000000)					      \
   155        {									      \
   156  	++(result)->tv_sec;						      \
   157  	(result)->tv_usec -= 1000000;					      \
   158        }									      \
   159    } while (0)
   160  # define timersub(a, b, result)						      \
   161    do {									      \
   162      (result)->tv_sec = (a)->tv_sec - (b)->tv_sec;			      \
   163      (result)->tv_usec = (a)->tv_usec - (b)->tv_usec;			      \
   164      if ((result)->tv_usec < 0) {					      \
   165        --(result)->tv_sec;						      \
   166        (result)->tv_usec += 1000000;					      \
   167      }									      \
   168    } while (0)
   169  #endif				/* Misc.  */
   170  
   171  __END_DECLS
   172  #endif				/* sys/time.h */