man adjtime:
代码: 全选
EINVAL The adjustment in delta is outside the permitted range.
不知道去找系统调用实现代码是否是个合适的方法
或者有其它文档描述了这个"range"?
代码: 全选
EINVAL The adjustment in delta is outside the permitted range.
见 man adjtime "NOTES" 一节末尾科学之子 写了:主要是想知道"range"是什么
网搜可得印证man adjtime 写了:NOTES
The adjustment that adjtime() makes to the clock is carried out in such a manner that the clock is always monotonically increasing. Using adjtime() to adjust the time prevents the problems that can be caused for certain applications (e.g., make(1)) by abrupt positive or negative jumps in the system time.
adjtime() is intended to be used to make small adjustments to the system time. Most systems impose a limit on the adjustment that can be specified in delta. In the glibc implementation, delta must be less than or equal to (INT_MAX / 1000000 - 2) and greater than or equal to (INT_MIN / 1000000 + 2) (respectively 2145 and -2145 seconds on i386).
对于 glibc,见 https://www.gnu.org/software/libc/download.html科学之子 写了:adjtime之类的系统调用的实现代码从哪里找?不知道去找系统调用实现代码是否是个合适的方法
代码: 全选
#define MAX_SEC (INT_MAX / 1000000L - 2)
#define MIN_SEC (INT_MIN / 1000000L + 2)
vickycq 写了:见 man adjtime "NOTES" 一节末尾科学之子 写了:主要是想知道"range"是什么网搜可得印证man adjtime 写了:NOTES
The adjustment that adjtime() makes to the clock is carried out in such a manner that the clock is always monotonically increasing. Using adjtime() to adjust the time prevents the problems that can be caused for certain applications (e.g., make(1)) by abrupt positive or negative jumps in the system time.
adjtime() is intended to be used to make small adjustments to the system time. Most systems impose a limit on the adjustment that can be specified in delta. In the glibc implementation, delta must be less than or equal to (INT_MAX / 1000000 - 2) and greater than or equal to (INT_MIN / 1000000 + 2) (respectively 2145 and -2145 seconds on i386).
http://lists.ntp.org/pipermail/question ... 08671.html
https://bugs.debian.org/cgi-bin/bugrepo ... bug=697643
对于 glibc,见 https://www.gnu.org/software/libc/download.html科学之子 写了:adjtime之类的系统调用的实现代码从哪里找?不知道去找系统调用实现代码是否是个合适的方法
sysdeps/unix/sysv/linux/adjtime.c代码: 全选
#define MAX_SEC (INT_MAX / 1000000L - 2) #define MIN_SEC (INT_MIN / 1000000L + 2)
代码: 全选
./ports/sysdeps/unix/sysv/linux/alpha/adjtime.c
./sysdeps/mach/adjtime.c
./sysdeps/mach/hurd/adjtime.c
./sysdeps/unix/sysv/linux/adjtime.c
./time/adjtime.c
代码: 全选
$ grep INT_MAX $(grep -l 1000000 $(grep -l -r adjtime) |grep \\\.c$)
sysdeps/unix/sysv/linux/adjtime.c:#define MAX_SEC (INT_MAX / 1000000L - 2)
这样搜不是事后诸葛亮么,一开始咱是不知道这些关键词的科学之子 写了:$ grep INT_MAX $(grep -l 1000000 $(grep -l -r adjtime) |grep \\\.c$)
sysdeps/unix/sysv/linux/adjtime.c:#define MAX_SEC (INT_MAX / 1000000L - 2)
vickycq 写了:这样搜不是事后诸葛亮么,一开始咱是不知道这些关键词的科学之子 写了:$ grep INT_MAX $(grep -l 1000000 $(grep -l -r adjtime) |grep \\\.c$)
sysdeps/unix/sysv/linux/adjtime.c:#define MAX_SEC (INT_MAX / 1000000L - 2)
下载源代码后:
grep -Ri 'einval' ./
发现很多,
grep -Ri 'einval' ./ | grep adjtime
./sysdeps/unix/sysv/linux/adjtime.c: return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
打开 ./sysdeps/unix/sysv/linux/adjtime.c,在 EINVAL 的前一行发现 MIN_SEC, MAX_SEC
再找 MIN_SEC, MAX_SEC 定义即可(实际上不需要,打开文件第一眼就看到了)
搜索时使用 viewtopic.php?f=165&t=480008 是更好的办法
代码: 全选
grep -Ri 'einval' ./ | grep adjtime
./sysdeps/unix/sysv/linux/adjtime.c: return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
代码: 全选
$ grep -Ri 'einval' ./ | grep adjtime
./sysdeps/unix/sysv/linux/adjtime.c: __set_errno (EINVAL);
./sysdeps/unix/sysv/linux/adjtime.c: if (itv && errno == EINVAL && tntx.modes == ADJ_OFFSET_SS_READ)
感觉不完全是事后诸葛亮,man中可以观察到"1000000",INT_MAX,同时猜测实现中应该还包含"adjtime"这样搜不是事后诸葛亮么,一开始咱是不知道这些关键词的
可能原因 您下载的是 jessie 自带的 glibc 2.19,我是从官网下载的 glibc 2.24。科学之子 写了: 奇怪,我这里的执行结果是:
./sysdeps/unix/sysv/linux/adjtime.c: __set_errno (EINVAL);
./sysdeps/unix/sysv/linux/adjtime.c: if (itv && errno == EINVAL && tntx.modes == ADJ_OFFSET_SS_READ)