xref: /titanic_50/usr/src/lib/libast/common/features/tvlib (revision c84b7bbef5ecc2a27799422588073deefd9db715)
1hdr	time
2lib	clock_settime,gettimeofday,settimeofday,stime,utimes
3lib	nanosleep,usleep
4lib	utimensat -D_ATFILE_SOURCE sys/stat.h note{ complete utimensat implementation }end link{
5	#include <fcntl.h>
6	static struct timespec	ts[2];
7	int
8	main()
9	{
10		ts[0].tv_nsec = UTIME_NOW;
11		ts[1].tv_nsec = UTIME_OMIT;
12		return utimensat(AT_FDCWD, ".", ts, AT_SYMLINK_NOFOLLOW) != 0;
13	}
14}end
15
16if ! mem timeval.tv_sec sys/time.h {
17	struct timeval
18	{
19		time_t	tv_sec;
20		time_t	tv_usec;
21	};
22}
23endif
24
25lib	clock_gettime execute{
26	#include <time.h>
27	int
28	main()
29	{
30		struct timespec	tv;
31		return clock_gettime(CLOCK_REALTIME, &tv) != 0;
32	}
33}end
34
35lib	utimets link{
36	#include <time.h>
37	#include <sys/time.h>
38	static struct timespec	tv;
39	int
40	main()
41	{
42		return utimets(".", &tv) != 0;
43	}
44}end
45
46tst	- -DN=1 - -DN=2 - -DN=3 - -DN=4 output{
47	#include <sys/types.h>
48	#include <sys/time.h>
49	int
50	main()
51	{
52		struct timeval	tv;
53#if N == 1
54		struct timezone	tz;
55		if (gettimeofday(&tv, (struct timezone*)0) < 0)
56			return 1;
57		printf("#define tmgettimeofday(p)	gettimeofday(p,(struct timezone*)0)\n");
58#if _lib_settimeofday
59		printf("#define tmsettimeofday(p)	settimeofday(p,(struct timezone*)0)\n");
60#endif
61#endif
62#if N == 2
63		if (gettimeofday(&tv, (void*)0) < 0)
64			return 1;
65		printf("#define tmgettimeofday(p)	gettimeofday(p,(void*)0)\n");
66#if _lib_settimeofday
67		printf("#define tmsettimeofday(p)	gettimeofday(p,(void*)0)\n");
68#endif
69#endif
70#if N == 3
71		if (gettimeofday(&tv) < 0)
72			return 1;
73		printf("#define tmgettimeofday(p)	gettimeofday(p)\n");
74#if _lib_settimeofday
75		printf("#define tmsettimeofday(p)	settimeofday(p)\n");
76#endif
77#endif
78		return 0;
79	}
80}end
81