diff options
| author | bors <bors@rust-lang.org> | 2016-04-28 10:17:44 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2016-04-28 10:17:44 -0700 |
| commit | 02acf0917f88cf7896d663d3b2b16ade7fa0e64f (patch) | |
| tree | bbddc22dc4bbe765dd42c70207a5dd443d985eba /src/libstd/num | |
| parent | ea6b3ddee9663e27221f366671261b21618394a0 (diff) | |
| parent | c31e2e77ed955faafffe7b22859f045cc1e5deec (diff) | |
| download | rust-02acf0917f88cf7896d663d3b2b16ade7fa0e64f.tar.gz rust-02acf0917f88cf7896d663d3b2b16ade7fa0e64f.zip | |
Auto merge of #33211 - alexcrichton:android-back-in-time, r=nagisa
std: Add compatibility with android-9 The Gecko folks currently use Android API level 9 for their builds, so they're requesting that we move back our minimum supported API level from 18 to 9. Turns out, ABI-wise at least, there's not that many changes we need to take care of. The `ftruncate64` API appeared in android-12 and the `log2` and `log2f` APIs appeared in android-18. We can have a simple shim for `ftruncate64` which falls back on `ftruncate` and the `log2` function can be approximated with just `ln(f) / ln(2)`. This should at least get the standard library building on API level 9, although the tests aren't quite happening there just yet. As we seem to be growing a number of Android compatibility shims, they're now centralized in a common `sys::android` module.
Diffstat (limited to 'src/libstd/num')
| -rw-r--r-- | src/libstd/num/f32.rs | 5 | ||||
| -rw-r--r-- | src/libstd/num/f64.rs | 7 |
2 files changed, 10 insertions, 2 deletions
diff --git a/src/libstd/num/f32.rs b/src/libstd/num/f32.rs index 624748f352e..94aa3d6b513 100644 --- a/src/libstd/num/f32.rs +++ b/src/libstd/num/f32.rs @@ -646,7 +646,10 @@ impl f32 { #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn log2(self) -> f32 { - unsafe { intrinsics::log2f32(self) } + #[cfg(target_os = "android")] + return ::sys::android::log2f32(self); + #[cfg(not(target_os = "android"))] + return unsafe { intrinsics::log2f32(self) }; } /// Returns the base 10 logarithm of the number. diff --git a/src/libstd/num/f64.rs b/src/libstd/num/f64.rs index 6515301aefd..2beffb64d3d 100644 --- a/src/libstd/num/f64.rs +++ b/src/libstd/num/f64.rs @@ -546,7 +546,12 @@ impl f64 { #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn log2(self) -> f64 { - self.log_wrapper(|n| { unsafe { intrinsics::log2f64(n) } }) + self.log_wrapper(|n| { + #[cfg(target_os = "android")] + return ::sys::android::log2f64(n); + #[cfg(not(target_os = "android"))] + return unsafe { intrinsics::log2f64(n) }; + }) } /// Returns the base 10 logarithm of the number. |
