23
23
#include "kernel-posix-cpu-timers.h"
24
24
#include <sysdep-vdso.h>
25
25
#include <shlib-compat.h>
26
+ #include <syscall-template.h>
26
27
27
28
/* Get current value of CLOCK and store it in TP. */
29
+
30
+ // Now after clang compile it will call gettime64 first(but in real case we have only 32 bit)
31
+ // In this case, we need “#if __TIMESIZE != 64” and this is always true. And always call __clock_gettime at last.
32
+
28
33
int
29
34
__clock_gettime64 (clockid_t clock_id , struct __timespec64 * tp )
30
35
{
31
- int r ;
32
-
33
- #ifndef __NR_clock_gettime64
34
- # define __NR_clock_gettime64 __NR_clock_gettime
35
- #endif
36
-
37
- #ifdef HAVE_CLOCK_GETTIME64_VSYSCALL
38
- int (* vdso_time64 ) (clockid_t clock_id , struct __timespec64 * tp )
39
- = GLRO (dl_vdso_clock_gettime64 );
40
- if (vdso_time64 != NULL )
41
- {
42
- r = INTERNAL_VSYSCALL_CALL (vdso_time64 , 2 , clock_id , tp );
43
- if (r == 0 )
44
- return 0 ;
45
- return INLINE_SYSCALL_ERROR_RETURN_VALUE (- r );
46
- }
47
- #endif
48
-
49
- #ifdef HAVE_CLOCK_GETTIME_VSYSCALL
50
- int (* vdso_time ) (clockid_t clock_id , struct timespec * tp )
51
- = GLRO (dl_vdso_clock_gettime );
52
- if (vdso_time != NULL )
53
- {
54
- struct timespec tp32 ;
55
- r = INTERNAL_VSYSCALL_CALL (vdso_time , 2 , clock_id , & tp32 );
56
- if (r == 0 && tp32 .tv_sec >= 0 )
57
- {
58
- * tp = valid_timespec_to_timespec64 (tp32 );
59
- return 0 ;
60
- }
61
- else if (r != 0 )
62
- return INLINE_SYSCALL_ERROR_RETURN_VALUE (- r );
63
-
64
- /* Fallback to syscall if the 32-bit time_t vDSO returns overflows. */
65
- }
66
- #endif
67
-
68
- r = INTERNAL_SYSCALL_CALL (clock_gettime64 , clock_id , tp );
69
- if (r == 0 )
70
- return 0 ;
71
- if (r != - ENOSYS )
72
- return INLINE_SYSCALL_ERROR_RETURN_VALUE (- r );
73
-
74
- #ifndef __ASSUME_TIME64_SYSCALLS
75
- /* Fallback code that uses 32-bit support. */
76
- struct timespec tp32 ;
77
- r = INTERNAL_SYSCALL_CALL (clock_gettime , clock_id , & tp32 );
78
- if (r == 0 )
79
- {
80
- * tp = valid_timespec_to_timespec64 (tp32 );
81
- return 0 ;
82
- }
83
- #endif
84
-
85
- return INLINE_SYSCALL_ERROR_RETURN_VALUE (- r );
36
+ return MAKE_SYSCALL (191 , "syscall|clock_gettime" , (uint64_t ) clock_id , (uint64_t ) tp , NOTUSED , NOTUSED , NOTUSED , NOTUSED );
86
37
}
87
38
88
39
#if __TIMESIZE != 64
@@ -91,26 +42,11 @@ libc_hidden_def (__clock_gettime64)
91
42
int
92
43
__clock_gettime (clockid_t clock_id , struct timespec * tp )
93
44
{
94
- int ret ;
95
- struct __timespec64 tp64 ;
96
-
97
- ret = __clock_gettime64 (clock_id , & tp64 );
98
-
99
- if (ret == 0 )
100
- {
101
- if (! in_time_t_range (tp64 .tv_sec ))
102
- {
103
- __set_errno (EOVERFLOW );
104
- return -1 ;
105
- }
106
-
107
- * tp = valid_timespec64_to_timespec (tp64 );
108
- }
109
-
110
- return ret ;
45
+ return MAKE_SYSCALL (191 , "syscall|clock_gettime" , (uint64_t ) clock_id , (uint64_t ) tp , NOTUSED , NOTUSED , NOTUSED , NOTUSED );
111
46
}
47
+
112
48
#endif
113
- libc_hidden_def (__clock_gettime )
49
+ libc_hidden_def (__clock_gettime );
114
50
115
51
versioned_symbol (libc , __clock_gettime , clock_gettime , GLIBC_2_17 );
116
52
/* clock_gettime moved to libc in version 2.17;
0 commit comments