Skip to content

Commit 54587ec

Browse files
committed
Remove broken newlib support
Nix has never supported a newlib target, but there were a few cfg checks for it in our codebase. Some of them were misspelled (newlibc vs newlib), and some of the checks were wrong. Removing them makes the code much more readable.
1 parent c5db0ea commit 54587ec

File tree

1 file changed

+35
-56
lines changed

1 file changed

+35
-56
lines changed

src/time.rs

Lines changed: 35 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,8 @@ impl ClockId {
5151
#[cfg(not(any(
5252
target_os = "macos",
5353
target_os = "ios",
54-
all(
55-
not(any(target_env = "uclibc", target_env = "newlibc")),
56-
any(target_os = "redox", target_os = "hermit",),
57-
),
54+
target_os = "redox",
55+
target_os = "hermit",
5856
)))]
5957
pub fn set_time(self, timespec: TimeSpec) -> Result<()> {
6058
clock_settime(self, timespec)
@@ -66,72 +64,65 @@ impl ClockId {
6664
}
6765

6866
#[cfg(any(
67+
target_os = "android",
68+
target_os = "emscripten",
6969
target_os = "fuchsia",
70-
all(
71-
not(any(target_env = "uclibc", target_env = "newlib")),
72-
any(target_os = "linux", target_os = "android", target_os = "emscripten"),
73-
)
70+
target_os = "linux"
7471
))]
7572
pub const CLOCK_BOOTTIME: ClockId = ClockId(libc::CLOCK_BOOTTIME);
7673
#[cfg(any(
74+
target_os = "android",
75+
target_os = "emscripten",
7776
target_os = "fuchsia",
78-
all(
79-
not(any(target_env = "uclibc", target_env = "newlib")),
80-
any(target_os = "linux", target_os = "android", target_os = "emscripten")
81-
)
77+
target_os = "linux"
8278
))]
8379
pub const CLOCK_BOOTTIME_ALARM: ClockId = ClockId(libc::CLOCK_BOOTTIME_ALARM);
8480
pub const CLOCK_MONOTONIC: ClockId = ClockId(libc::CLOCK_MONOTONIC);
8581
#[cfg(any(
82+
target_os = "android",
83+
target_os = "emscripten",
8684
target_os = "fuchsia",
87-
all(
88-
not(any(target_env = "uclibc", target_env = "newlib")),
89-
any(target_os = "linux", target_os = "android", target_os = "emscripten")
90-
)
85+
target_os = "linux"
9186
))]
9287
pub const CLOCK_MONOTONIC_COARSE: ClockId = ClockId(libc::CLOCK_MONOTONIC_COARSE);
9388
#[cfg(any(target_os = "freebsd", target_os = "dragonfly"))]
9489
pub const CLOCK_MONOTONIC_FAST: ClockId = ClockId(libc::CLOCK_MONOTONIC_FAST);
9590
#[cfg(any(target_os = "freebsd", target_os = "dragonfly"))]
9691
pub const CLOCK_MONOTONIC_PRECISE: ClockId = ClockId(libc::CLOCK_MONOTONIC_PRECISE);
9792
#[cfg(any(
93+
target_os = "android",
94+
target_os = "emscripten",
9895
target_os = "fuchsia",
99-
all(
100-
not(any(target_env = "uclibc", target_env = "newlib")),
101-
any(target_os = "linux", target_os = "android", target_os = "emscripten")
102-
)
96+
target_os = "linux"
10397
))]
10498
pub const CLOCK_MONOTONIC_RAW: ClockId = ClockId(libc::CLOCK_MONOTONIC_RAW);
10599
#[cfg(any(
100+
target_os = "android",
101+
target_os = "emscripten",
106102
target_os = "fuchsia",
107-
target_env = "uclibc",
108103
target_os = "macos",
109104
target_os = "ios",
110105
target_os = "freebsd",
111106
target_os = "dragonfly",
112-
all(
113-
not(target_env = "newlib"),
114-
any(target_os = "linux", target_os = "android", target_os = "emscripten")
115-
)
107+
target_os = "redox",
108+
target_os = "linux"
116109
))]
117110
pub const CLOCK_PROCESS_CPUTIME_ID: ClockId = ClockId(libc::CLOCK_PROCESS_CPUTIME_ID);
118111
#[cfg(any(target_os = "freebsd", target_os = "dragonfly"))]
119112
pub const CLOCK_PROF: ClockId = ClockId(libc::CLOCK_PROF);
120113
pub const CLOCK_REALTIME: ClockId = ClockId(libc::CLOCK_REALTIME);
121114
#[cfg(any(
115+
target_os = "android",
116+
target_os = "emscripten",
122117
target_os = "fuchsia",
123-
all(
124-
not(any(target_env = "uclibc", target_env = "newlib")),
125-
any(target_os = "linux", target_os = "android", target_os = "emscripten")
126-
)
118+
target_os = "linux"
127119
))]
128120
pub const CLOCK_REALTIME_ALARM: ClockId = ClockId(libc::CLOCK_REALTIME_ALARM);
129121
#[cfg(any(
122+
target_os = "android",
123+
target_os = "emscripten",
130124
target_os = "fuchsia",
131-
all(
132-
not(any(target_env = "uclibc", target_env = "newlib")),
133-
any(target_os = "linux", target_os = "android", target_os = "emscripten")
134-
)
125+
target_os = "linux"
135126
))]
136127
pub const CLOCK_REALTIME_COARSE: ClockId = ClockId(libc::CLOCK_REALTIME_COARSE);
137128
#[cfg(any(target_os = "freebsd", target_os = "dragonfly"))]
@@ -141,38 +132,27 @@ impl ClockId {
141132
#[cfg(any(target_os = "freebsd", target_os = "dragonfly"))]
142133
pub const CLOCK_SECOND: ClockId = ClockId(libc::CLOCK_SECOND);
143134
#[cfg(any(
135+
target_os = "emscripten",
144136
target_os = "fuchsia",
145-
all(
146-
not(any(target_env = "uclibc", target_env = "newlib")),
147-
any(
148-
target_os = "emscripten",
149-
all(target_os = "linux", target_env = "musl")
150-
)
151-
)
137+
all(target_os = "linux", target_env = "musl")
152138
))]
153139
pub const CLOCK_SGI_CYCLE: ClockId = ClockId(libc::CLOCK_SGI_CYCLE);
154140
#[cfg(any(
141+
target_os = "android",
142+
target_os = "emscripten",
155143
target_os = "fuchsia",
156-
all(
157-
not(any(target_env = "uclibc", target_env = "newlib")),
158-
any(
159-
target_os = "emscripten",
160-
all(target_os = "linux", target_env = "musl")
161-
)
162-
)
144+
target_os = "linux"
163145
))]
164146
pub const CLOCK_TAI: ClockId = ClockId(libc::CLOCK_TAI);
165147
#[cfg(any(
166-
target_env = "uclibc",
148+
target_os = "android",
149+
target_os = "emscripten",
167150
target_os = "fuchsia",
168151
target_os = "ios",
169152
target_os = "macos",
170153
target_os = "freebsd",
171154
target_os = "dragonfly",
172-
all(
173-
not(target_env = "newlib"),
174-
any(target_os = "linux", target_os = "android", target_os = "emscripten",),
175-
),
155+
target_os = "linux"
176156
))]
177157
pub const CLOCK_THREAD_CPUTIME_ID: ClockId = ClockId(libc::CLOCK_THREAD_CPUTIME_ID);
178158
#[cfg(any(target_os = "freebsd", target_os = "dragonfly"))]
@@ -229,10 +209,9 @@ pub fn clock_gettime(clock_id: ClockId) -> Result<TimeSpec> {
229209
#[cfg(not(any(
230210
target_os = "macos",
231211
target_os = "ios",
232-
all(
233-
not(any(target_env = "uclibc", target_env = "newlibc")),
234-
any(target_os = "redox", target_os = "hermit",),
235-
),
212+
target_env = "uclibc",
213+
target_os = "redox",
214+
target_os = "hermit",
236215
)))]
237216
pub fn clock_settime(clock_id: ClockId, timespec: TimeSpec) -> Result<()> {
238217
let ret = unsafe { libc::clock_settime(clock_id.as_raw(), timespec.as_ref()) };

0 commit comments

Comments
 (0)