Ядро Linux в комментариях

       

Include/linux/time.h


18330 #ifndef _LINUX_TIME_H 18331 #define _LINUX_TIME_H 18332 18333 #include <asm/param.h> 18334 #include <linux/types.h> 18335 18336 #ifndef _STRUCT_TIMESPEC 18337 #define _STRUCT_TIMESPEC 18338 struct timespec { 18339 time_t tv_sec; /* seconds */ 18340 long tv_nsec; /* nanoseconds */ 18341 }; 18342 #endif /* _STRUCT_TIMESPEC */ 18343 18344 /* Change timeval to jiffies, trying to avoid the most 18345 * obvious overflows.. 18346 * 18347 * And some not so obvious. 18348 * 18349 * Note that we don't want to return MAX_LONG, because 18350 * for various timeout reasons we often end up having to 18351 * wait "jiffies+1" in order to guarantee that we wait at 18352 * _least_ "jiffies" - so "jiffies+1" had better still be 18353 * positive. */ 18354 #define MAX_JIFFY_OFFSET ((~0UL >> 1)-1) 18355 18356 static __inline__ unsigned long 18357 timespec_to_jiffies(struct timespec *value) 18358 { 18359 unsigned long sec = value->tv_sec; 18360 long nsec = value->tv_nsec; 18361 18362 if (sec >= (MAX_JIFFY_OFFSET / HZ)) 18363 return MAX_JIFFY_OFFSET; 18364 nsec += 1000000000L / HZ - 1; 18365 nsec /= 1000000000L / HZ; 18366 return HZ * sec + nsec; 18367 } 18368 18369 static __inline__ void 18370 jiffies_to_timespec(unsigned long jiffies, 18371 struct timespec *value) 18372 { 18373 value->tv_nsec = (jiffies % HZ) * (1000000000L / HZ); 18374 value->tv_sec = jiffies / HZ; 18375 } 18376 18377 struct timeval { 18378 time_t tv_sec; /* seconds */ 18379 suseconds_t tv_usec; /* microseconds */ 18380 }; 18381 18382 struct timezone { 18383 int tz_minuteswest; /* minutes west of Greenwich */ 18384 int tz_dsttime; /* type of dst correction */ 18385 }; 18386 18387 #define NFDBITS __NFDBITS 18388 18389 #ifdef __KERNEL__ 18390 extern void do_gettimeofday(struct timeval *tv); 18391 extern void do_settimeofday(struct timeval *tv); 18392 extern void get_fast_time(struct timeval *tv); 18393 extern void (*do_get_fast_time)(struct timeval *); 18394 #endif 18395 18396 #define FD_SETSIZE __FD_SETSIZE 18397 #define FD_SET(fd,fdsetp) __FD_SET(fd,fdsetp) 18398 #define FD_CLR(fd,fdsetp) __FD_CLR(fd,fdsetp) 18399 #define FD_ISSET(fd,fdsetp) __FD_ISSET(fd,fdsetp) 18400 #define FD_ZERO(fdsetp) __FD_ZERO(fdsetp) 18401 18402 /* Names of the interval timers, and structure defining a 18403 * timer setting. */ 18404 #define ITIMER_REAL 0 18405 #define ITIMER_VIRTUAL 1 18406 #define ITIMER_PROF 2 18407 18408 struct itimerspec { 18409 struct timespec it_interval; /* timer period */ 18410 struct timespec it_value; /* timer expiration */ 18411 }; 18412 18413 struct itimerval { 18414 struct timeval it_interval; /* timer interval */ 18415 struct timeval it_value; /* current value */ 18416 }; 18417 18418 #endif



Содержание раздела