����14-32 linux/include/sys/time.h
1 #ifndef _SYS_TIME_H
2 #define _SYS_TIME_H
3
4 /* gettimofday returns this */ // gettimeofday()�������ظ�ʱ��ṹ��
5 struct timeval {
6 long tv_sec; /* seconds */ // �롣
7 long tv_usec; /* microseconds */ // �롣
8 };
9
// ʱ�����ṹ��tzΪʱ����Time Zone������д��DST��Daylight Saving Time��������ʱ����д��
10 struct timezone {
11 int tz_minuteswest; /* minutes west of Greenwich */ // ����������������ʱ�䡣
12 int tz_dsttime; /* type of dst correction */ // ����ʱ������ʱ�䡣
13 };
14
15 #define DST_NONE 0 /* not on dst */ // ������ʱ��
16 #define DST_USA 1 /* USA style dst */ // USA��ʽ������ʱ��
17 #define DST_AUST 2 /* Australian style dst */ // ������ʽ������ʱ��
18 #define DST_WET 3 /* Western European dst */
19 #define DST_MET 4 /* Middle European dst */
20 #define DST_EET 5 /* Eastern European dst */
21 #define DST_CAN 6 /* Canada */
22 #define DST_GB 7 /* Great Britain and Eire */
23 #define DST_RUM 8 /* Rumania */
24 #define DST_TUR 9 /* Turkey */
25 #define DST_AUSTALT 10 /* Australian style with shift in 1986 */
26
// �ļ��������������ú꣬����select()������
27 #define FD_SET(fd,fdsetp) (*(fdsetp) |= (1 << (fd)))
28 #define FD_CLR(fd,fdsetp) (*(fdsetp) &= ~(1 << (fd)))
29 #define FD_ISSET(fd,fdsetp) ((*(fdsetp) >> fd) & 1)
30 #define FD_ZERO(fdsetp) (*(fdsetp) = 0)
31
32 /*
33 * Operations on timevals.
34 *
35 * NB: timercmp does not work for >= or <=.
36 */
// timevalʱ��ṹ�IJ���������
37 #define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec)
38 #define timercmp(tvp, uvp, cmp) \
39 ((tvp)->tv_sec cmp (uvp)->tv_sec || \
40 (tvp)->tv_sec == (uvp)->tv_sec && (tvp)->tv_usec cmp (uvp)->tv_usec)
41 #define timerclear(tvp) ((tvp)->tv_sec = (tvp)->tv_usec = 0)
42
43 /*
44 * Names of the interval timers, and structure
45 * defining a timer setting.
46 */
/* �ڲ���ʱ�����ƺͽṹ�����ڶ��嶨ʱ�����á� */
47 #define ITIMER_REAL 0 // ��ʵ��ʱ��ݼ���
48 #define ITIMER_VIRTUAL 1 // �Խ�������ʱ��ݼ���
49 #define ITIMER_PROF 2 // �Խ�������ʱ����ߵ�ϵͳ����ʱ�Խ���ʱ��ݼ���
50
// �ڲ�ʱ��ṹ������it��Internal Timer�����ڲ���ʱ������д��
51 struct itimerval {
52 struct timeval it_interval; /* timer interval */
53 struct timeval it_value; /* current value */
54 };
55
56 #include <time.h>
57 #include <sys/types.h>
58
59 int gettimeofday(struct timeval * tp, struct timezone * tz);
60 int select(int width, fd_set * readfds, fd_set * writefds,
61 fd_set * exceptfds, struct timeval * timeout);
62
63 #endif /*_SYS_TIME_H*/
64