diff options
Diffstat (limited to 'meta/recipes-core/busybox/busybox/0001-Remove-syscall-wrappers-around-clock_gettime-closes-.patch')
-rw-r--r-- | meta/recipes-core/busybox/busybox/0001-Remove-syscall-wrappers-around-clock_gettime-closes-.patch | 120 |
1 files changed, 120 insertions, 0 deletions
diff --git a/meta/recipes-core/busybox/busybox/0001-Remove-syscall-wrappers-around-clock_gettime-closes-.patch b/meta/recipes-core/busybox/busybox/0001-Remove-syscall-wrappers-around-clock_gettime-closes-.patch new file mode 100644 index 0000000000..0c7f9b8132 --- /dev/null +++ b/meta/recipes-core/busybox/busybox/0001-Remove-syscall-wrappers-around-clock_gettime-closes-.patch | |||
@@ -0,0 +1,120 @@ | |||
1 | From be5a505d771a77c640acc35ceaa470c80e62f954 Mon Sep 17 00:00:00 2001 | ||
2 | From: Denys Vlasenko <vda.linux@googlemail.com> | ||
3 | Date: Thu, 24 Oct 2019 16:26:55 +0200 | ||
4 | Subject: [PATCH] Remove syscall wrappers around clock_gettime, closes 12091 | ||
5 | |||
6 | 12091 "Direct use of __NR_clock_gettime is not time64-safe". | ||
7 | |||
8 | function old new delta | ||
9 | runsv_main 1698 1712 +14 | ||
10 | startservice 378 383 +5 | ||
11 | get_mono 31 25 -6 | ||
12 | date_main 932 926 -6 | ||
13 | gettimeofday_ns 17 - -17 | ||
14 | ------------------------------------------------------------------------------ | ||
15 | (add/remove: 0/1 grow/shrink: 2/2 up/down: 19/-29) Total: -10 bytes | ||
16 | |||
17 | Upstream-Status: Backport [https://git.busybox.net/busybox/commit/?id=be5a505d771a77c640acc35ceaa470c80e62f954] | ||
18 | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com> | ||
19 | --- | ||
20 | Makefile.flags | 6 ++++-- | ||
21 | coreutils/date.c | 16 +++------------- | ||
22 | libbb/time.c | 11 +---------- | ||
23 | runit/runsv.c | 11 +---------- | ||
24 | 4 files changed, 9 insertions(+), 35 deletions(-) | ||
25 | |||
26 | --- a/Makefile.flags | ||
27 | +++ b/Makefile.flags | ||
28 | @@ -129,10 +129,12 @@ endif | ||
29 | # fall back to using a temp file: | ||
30 | CRYPT_AVAILABLE := $(shell echo 'int main(void){return 0;}' >crypttest.c; $(CC) $(CFLAGS) -lcrypt -o /dev/null crypttest.c >/dev/null 2>&1 && echo "y"; rm crypttest.c) | ||
31 | ifeq ($(CRYPT_AVAILABLE),y) | ||
32 | -LDLIBS += m crypt | ||
33 | +LDLIBS += m rt crypt | ||
34 | else | ||
35 | -LDLIBS += m | ||
36 | +LDLIBS += m rt | ||
37 | endif | ||
38 | +# libm may be needed for dc, awk, ntpd | ||
39 | +# librt may be needed for clock_gettime() | ||
40 | |||
41 | # libpam may use libpthread, libdl and/or libaudit. | ||
42 | # On some platforms that requires an explicit -lpthread, -ldl, -laudit. | ||
43 | --- a/coreutils/date.c | ||
44 | +++ b/coreutils/date.c | ||
45 | @@ -33,10 +33,9 @@ | ||
46 | //config: Enable option (-I) to output an ISO-8601 compliant | ||
47 | //config: date/time string. | ||
48 | //config: | ||
49 | -//config:# defaults to "no": stat's nanosecond field is a bit non-portable | ||
50 | //config:config FEATURE_DATE_NANO | ||
51 | //config: bool "Support %[num]N nanosecond format specifier" | ||
52 | -//config: default n # syscall(__NR_clock_gettime) or syscall(__NR_clock_gettime64) | ||
53 | +//config: default n # stat's nanosecond field is a bit non-portable | ||
54 | //config: depends on DATE | ||
55 | //config: select PLATFORM_LINUX | ||
56 | //config: help | ||
57 | @@ -271,17 +270,8 @@ int date_main(int argc UNUSED_PARAM, cha | ||
58 | */ | ||
59 | #endif | ||
60 | } else { | ||
61 | -#if ENABLE_FEATURE_DATE_NANO && defined(__NR_clock_gettime) | ||
62 | - /* libc has incredibly messy way of doing this, | ||
63 | - * typically requiring -lrt. We just skip all this mess */ | ||
64 | - syscall(__NR_clock_gettime, CLOCK_REALTIME, &ts); | ||
65 | -#elif ENABLE_FEATURE_DATE_NANO && __TIMESIZE == 64 | ||
66 | - /* Let's only support the 64 suffix syscalls for 64-bit time_t. | ||
67 | - * This simplifies the code for us as we don't need to convert | ||
68 | - * between 64-bit and 32-bit. We also don't have a way to | ||
69 | - * report overflow errors here. | ||
70 | - */ | ||
71 | - syscall(__NR_clock_gettime64, CLOCK_REALTIME, &ts); | ||
72 | +#if ENABLE_FEATURE_DATE_NANO | ||
73 | + clock_gettime(CLOCK_REALTIME, &ts); | ||
74 | #else | ||
75 | time(&ts.tv_sec); | ||
76 | #endif | ||
77 | --- a/libbb/time.c | ||
78 | +++ b/libbb/time.c | ||
79 | @@ -253,18 +253,9 @@ char* FAST_FUNC strftime_YYYYMMDDHHMMSS( | ||
80 | #define CLOCK_MONOTONIC 1 | ||
81 | #endif | ||
82 | |||
83 | -/* libc has incredibly messy way of doing this, | ||
84 | - * typically requiring -lrt. We just skip all this mess */ | ||
85 | static void get_mono(struct timespec *ts) | ||
86 | { | ||
87 | -#if defined(__NR_clock_gettime) | ||
88 | - if (syscall(__NR_clock_gettime, CLOCK_MONOTONIC, ts)) | ||
89 | -#elif __TIMESIZE == 64 | ||
90 | - if (syscall(__NR_clock_gettime64, CLOCK_MONOTONIC, ts)) | ||
91 | -#else | ||
92 | -# error "We currently don't support architectures without " \ | ||
93 | - "the __NR_clock_gettime syscall and 32-bit time_t" | ||
94 | -#endif | ||
95 | + if (clock_gettime(CLOCK_MONOTONIC, ts)) | ||
96 | bb_error_msg_and_die("clock_gettime(MONOTONIC) failed"); | ||
97 | } | ||
98 | unsigned long long FAST_FUNC monotonic_ns(void) | ||
99 | --- a/runit/runsv.c | ||
100 | +++ b/runit/runsv.c | ||
101 | @@ -51,18 +51,9 @@ ADVISED OF THE POSSIBILITY OF SUCH DAMAG | ||
102 | #if ENABLE_MONOTONIC_SYSCALL | ||
103 | #include <sys/syscall.h> | ||
104 | |||
105 | -/* libc has incredibly messy way of doing this, | ||
106 | - * typically requiring -lrt. We just skip all this mess */ | ||
107 | static void gettimeofday_ns(struct timespec *ts) | ||
108 | { | ||
109 | -#if defined(__NR_clock_gettime) | ||
110 | - syscall(__NR_clock_gettime, CLOCK_REALTIME, ts); | ||
111 | -#elif __TIMESIZE == 64 | ||
112 | - syscall(__NR_clock_gettime64, CLOCK_REALTIME, ts); | ||
113 | -#else | ||
114 | -# error "We currently don't support architectures without " \ | ||
115 | - "the __NR_clock_gettime syscall and 32-bit time_t" | ||
116 | -#endif | ||
117 | + clock_gettime(CLOCK_REALTIME, ts); | ||
118 | } | ||
119 | #else | ||
120 | static void gettimeofday_ns(struct timespec *ts) | ||