modernc.org/cc@v1.0.1/v2/headers/linux_arm/usr/include/arm-linux-gnueabihf/sys/time.h (about)

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