public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc/zack/no-nested-includes] sys/timex.h: don’t include sys/time.h
@ 2019-05-31 14:42 Zack Weinberg
0 siblings, 0 replies; 2+ messages in thread
From: Zack Weinberg @ 2019-05-31 14:42 UTC (permalink / raw)
To: glibc-cvs
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="us-ascii", Size: 6413 bytes --]
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=be0889c408d4f96c154f0e36d27b3ff9173893d6
commit be0889c408d4f96c154f0e36d27b3ff9173893d6
Author: Zack Weinberg <zackw@panix.com>
Date: Fri May 31 10:30:38 2019 -0400
sys/timex.h: donât include sys/time.h
The interfaces defined in sys/timex.h only need struct timeval, not
any of the other things defined in sys/time.h.
While I was at it I moved stuff around so that sysdeps/â¦/linux/bits/timex.h
defines everything that linux/timex.h defines (as of version 5.0;
alas, we still cannot use uapi linux/timex.h directly) plus the
MOD_CLKA and MOD_CLKB constants. In particular, the TIME_* constants
are relevant to users of clock_adjtime as well as adjtimex (I presumeâ
clock_adjtime is not very well documented) so they should be visible
from time.h as well as sys/timex.h. Conversely, as far as I can tell,
struct ntptimeval was never a kernel interface on Linux, and MAXTC is
not part of the exposed API and also has the wrong value for current
kernels. Also I removed a thoroughly obsolete bug workaround from
ntp_gettime.c and ntp_gettimex.c.
* sysdeps/unix/sysv/linux/sys/timex.h: Donât include sys/time.h.
Update commentary. Donât define MAXTC. Move definition of
NTP_API and the TIME_* constants...
* sysdeps/unix/sysv/linux/bits/timex.h: ...here.
Allow inclusion only by sys/timex.h and bits/time.h.
Update commentary.
* sysdeps/unix/sysv/linux/ntp_gettime.c
* sysdeps/unix/sysv/linux/ntp_gettimex.c: Remove obsolete
check for MOD_OFFSET not being defined.
* scripts/check-obsolete-constructs.py (HEADER_ALLOWED_INCLUDES):
Update.
Diff:
---
scripts/check-obsolete-constructs.py | 1 -
sysdeps/unix/sysv/linux/bits/timex.h | 20 ++++++++++++++++++--
sysdeps/unix/sysv/linux/ntp_gettime.c | 4 ----
sysdeps/unix/sysv/linux/ntp_gettimex.c | 4 ----
sysdeps/unix/sysv/linux/sys/timex.h | 18 ++----------------
5 files changed, 20 insertions(+), 27 deletions(-)
diff --git a/scripts/check-obsolete-constructs.py b/scripts/check-obsolete-constructs.py
index 7f410c2..f7db88d 100755
--- a/scripts/check-obsolete-constructs.py
+++ b/scripts/check-obsolete-constructs.py
@@ -586,7 +586,6 @@ HEADER_ALLOWED_INCLUDES = {
"sys/raw.h": [ "sys/ioctl.h" ],
"sys/socketvar.h": [ "sys/socket.h" ],
"sys/timerfd.h": [ "time.h" ],
- "sys/timex.h": [ "sys/time.h" ],
"sys/ttychars.h": [ "sys/ttydefaults.h" ],
"sys/ucontext.h": [ "sys/procfs.h" ],
"sys/vfs.h": [ "sys/statfs.h" ],
diff --git a/sysdeps/unix/sysv/linux/bits/timex.h b/sysdeps/unix/sysv/linux/bits/timex.h
index bb272e8..db36759 100644
--- a/sysdeps/unix/sysv/linux/bits/timex.h
+++ b/sysdeps/unix/sysv/linux/bits/timex.h
@@ -18,10 +18,16 @@
#ifndef _BITS_TIMEX_H
#define _BITS_TIMEX_H 1
+#if !defined _SYS_TIMEX_H && !defined _BITS_TIME_H
+# error "Never include <bits/timex.h> directly; use <sys/timex.h> instead."
+#endif
+
#include <bits/types.h>
#include <bits/types/struct_timeval.h>
-/* These definitions from linux/timex.h as of 3.18. */
+/* These definitions match linux/timex.h as of 5.0. */
+
+#define NTP_API 4 /* NTP API version */
struct timex
{
@@ -47,7 +53,7 @@ struct timex
int tai; /* TAI offset (ro) */
- /* ??? */
+ /* room for future expansion */
int :32; int :32; int :32; int :32;
int :32; int :32; int :32; int :32;
int :32; int :32; int :32;
@@ -65,6 +71,7 @@ struct timex
#define ADJ_MICRO 0x1000 /* select microsecond resolution */
#define ADJ_NANO 0x2000 /* select nanosecond resolution */
#define ADJ_TICK 0x4000 /* tick value */
+
#define ADJ_OFFSET_SINGLESHOT 0x8001 /* old-fashioned adjtime */
#define ADJ_OFFSET_SS_READ 0xa001 /* read-only adjtime */
@@ -107,4 +114,13 @@ struct timex
#define STA_RONLY (STA_PPSSIGNAL | STA_PPSJITTER | STA_PPSWANDER \
| STA_PPSERROR | STA_CLOCKERR | STA_NANO | STA_MODE | STA_CLK)
+/* Clock states (codes returned by adjtimex) */
+#define TIME_OK 0 /* clock synchronized, no leap second */
+#define TIME_INS 1 /* insert leap second */
+#define TIME_DEL 2 /* delete leap second */
+#define TIME_OOP 3 /* leap second in progress */
+#define TIME_WAIT 4 /* leap second has occurred */
+#define TIME_ERROR 5 /* clock not synchronized */
+#define TIME_BAD TIME_ERROR /* bw compat */
+
#endif /* bits/timex.h */
diff --git a/sysdeps/unix/sysv/linux/ntp_gettime.c b/sysdeps/unix/sysv/linux/ntp_gettime.c
index cff9b60..571339f 100644
--- a/sysdeps/unix/sysv/linux/ntp_gettime.c
+++ b/sysdeps/unix/sysv/linux/ntp_gettime.c
@@ -21,10 +21,6 @@
#undef ntp_gettime
-#ifndef MOD_OFFSET
-# define modes mode
-#endif
-
int
ntp_gettime (struct ntptimeval *ntv)
diff --git a/sysdeps/unix/sysv/linux/ntp_gettimex.c b/sysdeps/unix/sysv/linux/ntp_gettimex.c
index 044122b..c83aa1e 100644
--- a/sysdeps/unix/sysv/linux/ntp_gettimex.c
+++ b/sysdeps/unix/sysv/linux/ntp_gettimex.c
@@ -17,10 +17,6 @@
#include <sys/timex.h>
-#ifndef MOD_OFFSET
-# define modes mode
-#endif
-
int
ntp_gettimex (struct ntptimeval *ntv)
diff --git a/sysdeps/unix/sysv/linux/sys/timex.h b/sysdeps/unix/sysv/linux/sys/timex.h
index c71ace1..ee57946 100644
--- a/sysdeps/unix/sysv/linux/sys/timex.h
+++ b/sysdeps/unix/sysv/linux/sys/timex.h
@@ -19,14 +19,11 @@
#define _SYS_TIMEX_H 1
#include <features.h>
-#include <sys/time.h>
-
-/* These definitions from linux/timex.h as of 2.6.30. */
+/* Get struct timex and related constants. */
#include <bits/timex.h>
-#define NTP_API 4 /* NTP API version */
-
+/* Parameter structure used by ntp_gettime(x). */
struct ntptimeval
{
struct timeval time; /* current time (ro) */
@@ -40,17 +37,6 @@ struct ntptimeval
long int __glibc_reserved4;
};
-/* Clock states (time_state) */
-#define TIME_OK 0 /* clock synchronized, no leap second */
-#define TIME_INS 1 /* insert leap second */
-#define TIME_DEL 2 /* delete leap second */
-#define TIME_OOP 3 /* leap second in progress */
-#define TIME_WAIT 4 /* leap second has occurred */
-#define TIME_ERROR 5 /* clock not synchronized */
-#define TIME_BAD TIME_ERROR /* bw compat */
-
-/* Maximum time constant of the PLL. */
-#define MAXTC 6
__BEGIN_DECLS
^ permalink raw reply [flat|nested] 2+ messages in thread
* [glibc/zack/no-nested-includes] sys/timex.h: don’t include sys/time.h
@ 2019-06-18 15:36 Zack Weinberg
0 siblings, 0 replies; 2+ messages in thread
From: Zack Weinberg @ 2019-06-18 15:36 UTC (permalink / raw)
To: glibc-cvs
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="us-ascii", Size: 6413 bytes --]
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=cac916ad1186265356ce9890ab0ae6c54f15e945
commit cac916ad1186265356ce9890ab0ae6c54f15e945
Author: Zack Weinberg <zackw@panix.com>
Date: Fri May 31 10:30:38 2019 -0400
sys/timex.h: donât include sys/time.h
The interfaces defined in sys/timex.h only need struct timeval, not
any of the other things defined in sys/time.h.
While I was at it I moved stuff around so that sysdeps/â¦/linux/bits/timex.h
defines everything that linux/timex.h defines (as of version 5.0;
alas, we still cannot use uapi linux/timex.h directly) plus the
MOD_CLKA and MOD_CLKB constants. In particular, the TIME_* constants
are relevant to users of clock_adjtime as well as adjtimex (I presumeâ
clock_adjtime is not very well documented) so they should be visible
from time.h as well as sys/timex.h. Conversely, as far as I can tell,
struct ntptimeval was never a kernel interface on Linux, and MAXTC is
not part of the exposed API and also has the wrong value for current
kernels. Also I removed a thoroughly obsolete bug workaround from
ntp_gettime.c and ntp_gettimex.c.
* sysdeps/unix/sysv/linux/sys/timex.h: Donât include sys/time.h.
Update commentary. Donât define MAXTC. Move definition of
NTP_API and the TIME_* constants...
* sysdeps/unix/sysv/linux/bits/timex.h: ...here.
Allow inclusion only by sys/timex.h and bits/time.h.
Update commentary.
* sysdeps/unix/sysv/linux/ntp_gettime.c
* sysdeps/unix/sysv/linux/ntp_gettimex.c: Remove obsolete
check for MOD_OFFSET not being defined.
* scripts/check-obsolete-constructs.py (HEADER_ALLOWED_INCLUDES):
Update.
Diff:
---
scripts/check-obsolete-constructs.py | 1 -
sysdeps/unix/sysv/linux/bits/timex.h | 20 ++++++++++++++++++--
sysdeps/unix/sysv/linux/ntp_gettime.c | 4 ----
sysdeps/unix/sysv/linux/ntp_gettimex.c | 4 ----
sysdeps/unix/sysv/linux/sys/timex.h | 18 ++----------------
5 files changed, 20 insertions(+), 27 deletions(-)
diff --git a/scripts/check-obsolete-constructs.py b/scripts/check-obsolete-constructs.py
index 7f410c2..f7db88d 100755
--- a/scripts/check-obsolete-constructs.py
+++ b/scripts/check-obsolete-constructs.py
@@ -586,7 +586,6 @@ HEADER_ALLOWED_INCLUDES = {
"sys/raw.h": [ "sys/ioctl.h" ],
"sys/socketvar.h": [ "sys/socket.h" ],
"sys/timerfd.h": [ "time.h" ],
- "sys/timex.h": [ "sys/time.h" ],
"sys/ttychars.h": [ "sys/ttydefaults.h" ],
"sys/ucontext.h": [ "sys/procfs.h" ],
"sys/vfs.h": [ "sys/statfs.h" ],
diff --git a/sysdeps/unix/sysv/linux/bits/timex.h b/sysdeps/unix/sysv/linux/bits/timex.h
index bb272e8..db36759 100644
--- a/sysdeps/unix/sysv/linux/bits/timex.h
+++ b/sysdeps/unix/sysv/linux/bits/timex.h
@@ -18,10 +18,16 @@
#ifndef _BITS_TIMEX_H
#define _BITS_TIMEX_H 1
+#if !defined _SYS_TIMEX_H && !defined _BITS_TIME_H
+# error "Never include <bits/timex.h> directly; use <sys/timex.h> instead."
+#endif
+
#include <bits/types.h>
#include <bits/types/struct_timeval.h>
-/* These definitions from linux/timex.h as of 3.18. */
+/* These definitions match linux/timex.h as of 5.0. */
+
+#define NTP_API 4 /* NTP API version */
struct timex
{
@@ -47,7 +53,7 @@ struct timex
int tai; /* TAI offset (ro) */
- /* ??? */
+ /* room for future expansion */
int :32; int :32; int :32; int :32;
int :32; int :32; int :32; int :32;
int :32; int :32; int :32;
@@ -65,6 +71,7 @@ struct timex
#define ADJ_MICRO 0x1000 /* select microsecond resolution */
#define ADJ_NANO 0x2000 /* select nanosecond resolution */
#define ADJ_TICK 0x4000 /* tick value */
+
#define ADJ_OFFSET_SINGLESHOT 0x8001 /* old-fashioned adjtime */
#define ADJ_OFFSET_SS_READ 0xa001 /* read-only adjtime */
@@ -107,4 +114,13 @@ struct timex
#define STA_RONLY (STA_PPSSIGNAL | STA_PPSJITTER | STA_PPSWANDER \
| STA_PPSERROR | STA_CLOCKERR | STA_NANO | STA_MODE | STA_CLK)
+/* Clock states (codes returned by adjtimex) */
+#define TIME_OK 0 /* clock synchronized, no leap second */
+#define TIME_INS 1 /* insert leap second */
+#define TIME_DEL 2 /* delete leap second */
+#define TIME_OOP 3 /* leap second in progress */
+#define TIME_WAIT 4 /* leap second has occurred */
+#define TIME_ERROR 5 /* clock not synchronized */
+#define TIME_BAD TIME_ERROR /* bw compat */
+
#endif /* bits/timex.h */
diff --git a/sysdeps/unix/sysv/linux/ntp_gettime.c b/sysdeps/unix/sysv/linux/ntp_gettime.c
index cff9b60..571339f 100644
--- a/sysdeps/unix/sysv/linux/ntp_gettime.c
+++ b/sysdeps/unix/sysv/linux/ntp_gettime.c
@@ -21,10 +21,6 @@
#undef ntp_gettime
-#ifndef MOD_OFFSET
-# define modes mode
-#endif
-
int
ntp_gettime (struct ntptimeval *ntv)
diff --git a/sysdeps/unix/sysv/linux/ntp_gettimex.c b/sysdeps/unix/sysv/linux/ntp_gettimex.c
index 044122b..c83aa1e 100644
--- a/sysdeps/unix/sysv/linux/ntp_gettimex.c
+++ b/sysdeps/unix/sysv/linux/ntp_gettimex.c
@@ -17,10 +17,6 @@
#include <sys/timex.h>
-#ifndef MOD_OFFSET
-# define modes mode
-#endif
-
int
ntp_gettimex (struct ntptimeval *ntv)
diff --git a/sysdeps/unix/sysv/linux/sys/timex.h b/sysdeps/unix/sysv/linux/sys/timex.h
index c71ace1..ee57946 100644
--- a/sysdeps/unix/sysv/linux/sys/timex.h
+++ b/sysdeps/unix/sysv/linux/sys/timex.h
@@ -19,14 +19,11 @@
#define _SYS_TIMEX_H 1
#include <features.h>
-#include <sys/time.h>
-
-/* These definitions from linux/timex.h as of 2.6.30. */
+/* Get struct timex and related constants. */
#include <bits/timex.h>
-#define NTP_API 4 /* NTP API version */
-
+/* Parameter structure used by ntp_gettime(x). */
struct ntptimeval
{
struct timeval time; /* current time (ro) */
@@ -40,17 +37,6 @@ struct ntptimeval
long int __glibc_reserved4;
};
-/* Clock states (time_state) */
-#define TIME_OK 0 /* clock synchronized, no leap second */
-#define TIME_INS 1 /* insert leap second */
-#define TIME_DEL 2 /* delete leap second */
-#define TIME_OOP 3 /* leap second in progress */
-#define TIME_WAIT 4 /* leap second has occurred */
-#define TIME_ERROR 5 /* clock not synchronized */
-#define TIME_BAD TIME_ERROR /* bw compat */
-
-/* Maximum time constant of the PLL. */
-#define MAXTC 6
__BEGIN_DECLS
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-06-18 15:36 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-31 14:42 [glibc/zack/no-nested-includes] sys/timex.h: don’t include sys/time.h Zack Weinberg
2019-06-18 15:36 Zack Weinberg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).