summaryrefslogtreecommitdiff
path: root/src/lib/libast/features/tv
blob: ae15682121083fc15cbf19833fa86a558eef03ef (plain)
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
set	prototyped
set	explicit
iff	TV

cat{
	/*
	 * AT&T Research
	 *
	 * high resolution Tv_t interface definitions
	 */

	#include <ast.h>

	#define TV_NSEC_IGNORE		(1000000000L)
	#define TV_TOUCH_RETAIN		((Tv_t*)1)

	typedef struct Tv_s
	{
		uint32_t	tv_sec;
		uint32_t	tv_nsec;
	} Tv_t;
}end

if mem stat.st_mtimespec.tv_nsec sys/stat.h {
	#define ST_ATIME_NSEC_GET(st)	((st)->st_atimespec.tv_nsec)
	#define ST_CTIME_NSEC_GET(st)	((st)->st_ctimespec.tv_nsec)
	#define ST_MTIME_NSEC_GET(st)	((st)->st_mtimespec.tv_nsec)
}
elif mem stat.st_mtim.st__tim.tv_nsec sys/stat.h {
	#define ST_ATIME_NSEC_GET(st)	((st)->st_atim.st__tim.tv_nsec)
	#define ST_CTIME_NSEC_GET(st)	((st)->st_ctim.st__tim.tv_nsec)
	#define ST_MTIME_NSEC_GET(st)	((st)->st_mtim.st__tim.tv_nsec)
}
elif mem stat.st_mtim.tv_nsec sys/stat.h {
	#define ST_ATIME_NSEC_GET(st)	((st)->st_atim.tv_nsec)
	#define ST_CTIME_NSEC_GET(st)	((st)->st_ctim.tv_nsec)
	#define ST_MTIME_NSEC_GET(st)	((st)->st_mtim.tv_nsec)
}
elif mem stat.st_mtimensec sys/stat.h {
	#define ST_ATIME_NSEC_GET(st)	((st)->st_atimensec)
	#define ST_CTIME_NSEC_GET(st)	((st)->st_ctimensec)
	#define ST_MTIME_NSEC_GET(st)	((st)->st_mtimensec)
}
else pass{ no_stat_nsec=1 }end {
	#define ST_ATIME_NSEC_GET(st)	0
	#define ST_CTIME_NSEC_GET(st)	0
	#define ST_MTIME_NSEC_GET(st)	0

	#define ST_ATIME_NSEC_SET(st,n)	0
	#define ST_CTIME_NSEC_SET(st,n)	0
	#define ST_MTIME_NSEC_SET(st,n)	0
}
endif
if ( !no_stat_nsec ) {
	#define ST_ATIME_NSEC_SET(st,n)	(ST_ATIME_NSEC_GET(st)=(n))
	#define ST_CTIME_NSEC_SET(st,n)	(ST_CTIME_NSEC_GET(st)=(n))
	#define ST_MTIME_NSEC_SET(st,n)	(ST_MTIME_NSEC_GET(st)=(n))
}
endif

cat{
	#define tvgetatime(t,s)	((t)->tv_nsec=ST_ATIME_NSEC_GET(s),(t)->tv_sec=(s)->st_atime)
	#define tvgetmtime(t,s)	((t)->tv_nsec=ST_MTIME_NSEC_GET(s),(t)->tv_sec=(s)->st_mtime)
	#define tvgetctime(t,s)	((t)->tv_nsec=ST_CTIME_NSEC_GET(s),(t)->tv_sec=(s)->st_ctime)

	#define tvsetatime(t,s)	(ST_ATIME_NSEC_SET(s,(t)->tv_nsec),(s)->st_atime=(t)->tv_sec)
	#define tvsetmtime(t,s)	(ST_MTIME_NSEC_SET(s,(t)->tv_nsec),(s)->st_mtime=(t)->tv_sec)
	#define tvsetctime(t,s)	(ST_CTIME_NSEC_SET(s,(t)->tv_nsec),(s)->st_ctime=(t)->tv_sec)

	#if _BLD_ast && defined(__EXPORT__)
	#define extern		__EXPORT__
	#endif

	extern int		tvgettime(Tv_t*);
	extern int		tvsettime(const Tv_t*);
	extern int		tvcmp(const Tv_t*, const Tv_t*);
	extern int		tvtouch(const char*, const Tv_t*, const Tv_t*, const Tv_t*, int);
	extern int		tvsleep(const Tv_t*, Tv_t*);

	extern char*		fmttv(const char*, Tv_t*);
}end