Dr Andrew Scott G7VAV

My photo
 
April 2024
Mo Tu We Th Fr Sa Su
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 1 2 3 4 5
6 7 8 9 10 11 12


time.h
001: /* Copyright (C) 1991-1994,1996-2003,2005,2006,2009
002:         Free Software Foundation, Inc.
003:    This file is part of the GNU C Library.
004: 
005:    The GNU C Library is free software; you can redistribute it and/or
006:    modify it under the terms of the GNU Lesser General Public
007:    License as published by the Free Software Foundation; either
008:    version 2.1 of the License, or (at your option) any later version.
009: 
010:    The GNU C Library is distributed in the hope that it will be useful,
011:    but WITHOUT ANY WARRANTY; without even the implied warranty of
012:    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
013:    Lesser General Public License for more details.
014: 
015:    You should have received a copy of the GNU Lesser General Public
016:    License along with the GNU C Library; if not, write to the Free
017:    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
018:    02111-1307 USA.  */
019: 
020: #ifndef _SYS_TIME_H
021: #define _SYS_TIME_H     1
022: 
023: #include <features.h>
024: 
025: #include <bits/types.h>
026: #define __need_time_t
027: #include <time.h>
028: #define __need_timeval
029: #include <bits/time.h>
030: 
031: #include <sys/select.h>
032: 
033: #ifndef __suseconds_t_defined
034: typedef __suseconds_t suseconds_t;
035: # define __suseconds_t_defined
036: #endif
037: 
038: 
039: __BEGIN_DECLS
040: 
041: #ifdef __USE_GNU
042: /* Macros for converting between `struct timeval' and `struct timespec'.  */
043: # define TIMEVAL_TO_TIMESPEC(tv, ts) {                                   \
044:         (ts)->tv_sec = (tv)->tv_sec;                                    \
045:         (ts)->tv_nsec = (tv)->tv_usec * 1000;                           \
046: }
047: # define TIMESPEC_TO_TIMEVAL(tv, ts) {                                   \
048:         (tv)->tv_sec = (ts)->tv_sec;                                    \
049:         (tv)->tv_usec = (ts)->tv_nsec / 1000;                           \
050: }
051: #endif
052: 
053: 
054: #ifdef __USE_BSD
055: /* Structure crudely representing a timezone.
056:    This is obsolete and should never be used.  */
057: struct timezone
058:   {
059:     int tz_minuteswest;         /* Minutes west of GMT.  */
060:     int tz_dsttime;             /* Nonzero if DST is ever in effect.  */
061:   };
062: 
063: typedef struct timezone *__restrict __timezone_ptr_t;
064: #else
065: typedef void *__restrict __timezone_ptr_t;
066: #endif
067: 
068: /* Get the current time of day and timezone information,
069:    putting it into *TV and *TZ.  If TZ is NULL, *TZ is not filled.
070:    Returns 0 on success, -1 on errors.
071:    NOTE: This form of timezone information is obsolete.
072:    Use the functions and variables declared in <time.h> instead.  */
073: extern int gettimeofday (struct timeval *__restrict __tv,
074:                          __timezone_ptr_t __tz) __THROW __nonnull ((1));
075: 
076: #ifdef __USE_BSD
077: /* Set the current time of day and timezone information.
078:    This call is restricted to the super-user.  */
079: extern int settimeofday (__const struct timeval *__tv,
080:                          __const struct timezone *__tz)
081:      __THROW __nonnull ((1));
082: 
083: /* Adjust the current time of day by the amount in DELTA.
084:    If OLDDELTA is not NULL, it is filled in with the amount
085:    of time adjustment remaining to be done from the last `adjtime' call.
086:    This call is restricted to the super-user.  */
087: extern int adjtime (__const struct timeval *__delta,
088:                     struct timeval *__olddelta) __THROW;
089: #endif
090: 
091: 
092: /* Values for the first argument to `getitimer' and `setitimer'.  */
093: enum __itimer_which
094:   {
095:     /* Timers run in real time.  */
096:     ITIMER_REAL = 0,
097: #define ITIMER_REAL ITIMER_REAL
098:     /* Timers run only when the process is executing.  */
099:     ITIMER_VIRTUAL = 1,
100: #define ITIMER_VIRTUAL ITIMER_VIRTUAL
101:     /* Timers run when the process is executing and when
102:        the system is executing on behalf of the process.  */
103:     ITIMER_PROF = 2
104: #define ITIMER_PROF ITIMER_PROF
105:   };
106: 
107: /* Type of the second argument to `getitimer' and
108:    the second and third arguments `setitimer'.  */
109: struct itimerval
110:   {
111:     /* Value to put into `it_value' when the timer expires.  */
112:     struct timeval it_interval;
113:     /* Time to the next timer expiration.  */
114:     struct timeval it_value;
115:   };
116: 
117: #if defined __USE_GNU && !defined __cplusplus
118: /* Use the nicer parameter type only in GNU mode and not for C++ since the
119:    strict C++ rules prevent the automatic promotion.  */
120: typedef enum __itimer_which __itimer_which_t;
121: #else
122: typedef int __itimer_which_t;
123: #endif
124: 
125: /* Set *VALUE to the current setting of timer WHICH.
126:    Return 0 on success, -1 on errors.  */
127: extern int getitimer (__itimer_which_t __which,
128:                       struct itimerval *__value) __THROW;
129: 
130: /* Set the timer WHICH to *NEW.  If OLD is not NULL,
131:    set *OLD to the old value of timer WHICH.
132:    Returns 0 on success, -1 on errors.  */
133: extern int setitimer (__itimer_which_t __which,
134:                       __const struct itimerval *__restrict __new,
135:                       struct itimerval *__restrict __old) __THROW;
136: 
137: /* Change the access time of FILE to TVP[0] and the modification time of
138:    FILE to TVP[1].  If TVP is a null pointer, use the current time instead.
139:    Returns 0 on success, -1 on errors.  */
140: extern int utimes (__const char *__file, __const struct timeval __tvp[2])
141:      __THROW __nonnull ((1));
142: 
143: #ifdef __USE_BSD
144: /* Same as `utimes', but does not follow symbolic links.  */
145: extern int lutimes (__const char *__file, __const struct timeval __tvp[2])
146:      __THROW __nonnull ((1));
147: 
148: /* Same as `utimes', but takes an open file descriptor instead of a name.  */
149: extern int futimes (int __fd, __const struct timeval __tvp[2]) __THROW;
150: #endif
151: 
152: #ifdef __USE_GNU
153: /* Change the access time of FILE relative to FD to TVP[0] and the
154:    modification time of FILE to TVP[1].  If TVP is a null pointer, use
155:    the current time instead.  Returns 0 on success, -1 on errors.  */
156: extern int futimesat (int __fd, __const char *__file,
157:                       __const struct timeval __tvp[2]) __THROW;
158: #endif
159: 
160: 
161: #ifdef __USE_BSD
162: /* Convenience macros for operations on timevals.
163:    NOTE: `timercmp' does not work for >= or <=.  */
164: # define timerisset(tvp)        ((tvp)->tv_sec || (tvp)->tv_usec)
165: # define timerclear(tvp)        ((tvp)->tv_sec = (tvp)->tv_usec = 0)
166: # define timercmp(a, b, CMP)                                                  \
167:   (((a)->tv_sec == (b)->tv_sec) ?                                             \
168:    ((a)->tv_usec CMP (b)->tv_usec) :                                          \
169:    ((a)->tv_sec CMP (b)->tv_sec))
170: # define timeradd(a, b, result)                                               \
171:   do {                                                                        \
172:     (result)->tv_sec = (a)->tv_sec + (b)->tv_sec;                             \
173:     (result)->tv_usec = (a)->tv_usec + (b)->tv_usec;                          \
174:     if ((result)->tv_usec >= 1000000)                                         \
175:       {                                                                       \
176:         ++(result)->tv_sec;                                                   \
177:         (result)->tv_usec -= 1000000;                                         \
178:       }                                                                       \
179:   } while (0)
180: # define timersub(a, b, result)                                               \
181:   do {                                                                        \
182:     (result)->tv_sec = (a)->tv_sec - (b)->tv_sec;                             \
183:     (result)->tv_usec = (a)->tv_usec - (b)->tv_usec;                          \
184:     if ((result)->tv_usec < 0) {                                              \
185:       --(result)->tv_sec;                                                     \
186:       (result)->tv_usec += 1000000;                                           \
187:     }                                                                         \
188:   } while (0)
189: #endif  /* BSD */
190: 
191: __END_DECLS
192: 
193: #endif /* sys/time.h */
194: 


for client 3.19.211.134
© Andrew Scott 2006 - 2024,
All Rights Reserved
http://www.andrew-scott.uk/
Andrew Scott
http://www.andrew-scott.co.uk/