xref: /illumos-gate/usr/src/contrib/ast/src/lib/libast/features/tv (revision 2b9481465d6ee67ac62c160dbf79c3ec3348c611)
1set	prototyped
2set	explicit
3iff	TV
4
5cat{
6	/*
7	 * AT&T Research
8	 *
9	 * high resolution Tv_t interface definitions
10	 */
11
12	#include <ast.h>
13
14	#define TV_NSEC_IGNORE		(1000000000L)
15	#define TV_TOUCH_RETAIN		((Tv_t*)1)
16
17	typedef struct Tv_s
18	{
19		uint32_t	tv_sec;
20		uint32_t	tv_nsec;
21	} Tv_t;
22}end
23
24if mem stat.st_mtimespec.tv_nsec sys/stat.h {
25	#define ST_ATIME_NSEC_GET(st)	((st)->st_atimespec.tv_nsec)
26	#define ST_CTIME_NSEC_GET(st)	((st)->st_ctimespec.tv_nsec)
27	#define ST_MTIME_NSEC_GET(st)	((st)->st_mtimespec.tv_nsec)
28}
29elif mem stat.st_mtim.st__tim.tv_nsec sys/stat.h {
30	#define ST_ATIME_NSEC_GET(st)	((st)->st_atim.st__tim.tv_nsec)
31	#define ST_CTIME_NSEC_GET(st)	((st)->st_ctim.st__tim.tv_nsec)
32	#define ST_MTIME_NSEC_GET(st)	((st)->st_mtim.st__tim.tv_nsec)
33}
34elif mem stat.st_mtim.tv_nsec sys/stat.h {
35	#define ST_ATIME_NSEC_GET(st)	((st)->st_atim.tv_nsec)
36	#define ST_CTIME_NSEC_GET(st)	((st)->st_ctim.tv_nsec)
37	#define ST_MTIME_NSEC_GET(st)	((st)->st_mtim.tv_nsec)
38}
39elif mem stat.st_mtimensec sys/stat.h {
40	#define ST_ATIME_NSEC_GET(st)	((st)->st_atimensec)
41	#define ST_CTIME_NSEC_GET(st)	((st)->st_ctimensec)
42	#define ST_MTIME_NSEC_GET(st)	((st)->st_mtimensec)
43}
44else pass{ no_stat_nsec=1 }end {
45	#define ST_ATIME_NSEC_GET(st)	0
46	#define ST_CTIME_NSEC_GET(st)	0
47	#define ST_MTIME_NSEC_GET(st)	0
48
49	#define ST_ATIME_NSEC_SET(st,n)	0
50	#define ST_CTIME_NSEC_SET(st,n)	0
51	#define ST_MTIME_NSEC_SET(st,n)	0
52}
53endif
54if ( !no_stat_nsec ) {
55	#define ST_ATIME_NSEC_SET(st,n)	(ST_ATIME_NSEC_GET(st)=(n))
56	#define ST_CTIME_NSEC_SET(st,n)	(ST_CTIME_NSEC_GET(st)=(n))
57	#define ST_MTIME_NSEC_SET(st,n)	(ST_MTIME_NSEC_GET(st)=(n))
58}
59endif
60
61cat{
62	#define tvgetatime(t,s)	((t)->tv_nsec=ST_ATIME_NSEC_GET(s),(t)->tv_sec=(s)->st_atime)
63	#define tvgetmtime(t,s)	((t)->tv_nsec=ST_MTIME_NSEC_GET(s),(t)->tv_sec=(s)->st_mtime)
64	#define tvgetctime(t,s)	((t)->tv_nsec=ST_CTIME_NSEC_GET(s),(t)->tv_sec=(s)->st_ctime)
65
66	#define tvsetatime(t,s)	(ST_ATIME_NSEC_SET(s,(t)->tv_nsec),(s)->st_atime=(t)->tv_sec)
67	#define tvsetmtime(t,s)	(ST_MTIME_NSEC_SET(s,(t)->tv_nsec),(s)->st_mtime=(t)->tv_sec)
68	#define tvsetctime(t,s)	(ST_CTIME_NSEC_SET(s,(t)->tv_nsec),(s)->st_ctime=(t)->tv_sec)
69
70	#if _BLD_ast && defined(__EXPORT__)
71	#define extern		__EXPORT__
72	#endif
73
74	extern int		tvgettime(Tv_t*);
75	extern int		tvsettime(const Tv_t*);
76	extern int		tvcmp(const Tv_t*, const Tv_t*);
77	extern int		tvtouch(const char*, const Tv_t*, const Tv_t*, const Tv_t*, int);
78	extern int		tvsleep(const Tv_t*, Tv_t*);
79
80	extern char*		fmttv(const char*, Tv_t*);
81}end
82