Browse Source

Merge pull request #30 from kentaromiura/compile_again

Make ctru-rs compile again
pull/10/head
Ronald Kinard 8 years ago committed by GitHub
parent
commit
9749018832
  1. 16
      ctr-std/src/collections/hash/table.rs
  2. 34
      ctr-std/src/f32.rs
  3. 30
      ctr-std/src/f64.rs
  4. 3
      ctr-std/src/lib.rs
  5. 4
      ctr-std/src/num.rs
  6. 2
      ctru-rs/Xargo.toml

16
ctr-std/src/collections/hash/table.rs

@ -672,13 +672,13 @@ impl<K, V> RawTable<K, V> { @@ -672,13 +672,13 @@ impl<K, V> RawTable<K, V> {
let hashes_size = self.capacity * size_of::<HashUint>();
let pairs_size = self.capacity * size_of::<(K, V)>();
let buffer = *self.hashes as *mut u8;
let buffer = self.hashes.as_ptr();
let (pairs_offset, _, oflo) =
calculate_offsets(hashes_size, pairs_size, align_of::<(K, V)>());
debug_assert!(!oflo, "capacity overflow");
unsafe {
RawBucket {
hash: *self.hashes,
hash: self.hashes.as_ptr(),
pair: buffer.offset(pairs_offset as isize) as *const _,
_marker: marker::PhantomData,
}
@ -690,7 +690,7 @@ impl<K, V> RawTable<K, V> { @@ -690,7 +690,7 @@ impl<K, V> RawTable<K, V> {
pub fn new(capacity: usize) -> RawTable<K, V> {
unsafe {
let ret = RawTable::new_uninitialized(capacity);
ptr::write_bytes(*ret.hashes, 0, capacity);
ptr::write_bytes(ret.hashes.as_ptr(), 0, capacity);
ret
}
}
@ -709,7 +709,7 @@ impl<K, V> RawTable<K, V> { @@ -709,7 +709,7 @@ impl<K, V> RawTable<K, V> {
fn raw_buckets(&self) -> RawBuckets<K, V> {
RawBuckets {
raw: self.first_bucket_raw(),
hashes_end: unsafe { self.hashes.offset(self.capacity as isize) },
hashes_end: unsafe { self.hashes.as_ptr().offset(self.capacity as isize) },
marker: marker::PhantomData,
}
}
@ -975,7 +975,7 @@ impl<'a, K, V> Iterator for Drain<'a, K, V> { @@ -975,7 +975,7 @@ impl<'a, K, V> Iterator for Drain<'a, K, V> {
fn next(&mut self) -> Option<(SafeHash, K, V)> {
self.iter.next().map(|bucket| {
unsafe {
(**self.table).size -= 1;
(*self.table.as_mut_ptr()).size -= 1;
let (k, v) = ptr::read(bucket.pair);
(SafeHash { hash: ptr::replace(bucket.hash, EMPTY_BUCKET) }, k, v)
}
@ -983,13 +983,13 @@ impl<'a, K, V> Iterator for Drain<'a, K, V> { @@ -983,13 +983,13 @@ impl<'a, K, V> Iterator for Drain<'a, K, V> {
}
fn size_hint(&self) -> (usize, Option<usize>) {
let size = unsafe { (**self.table).size() };
let size = unsafe { (*self.table.as_mut_ptr()).size() };
(size, Some(size))
}
}
impl<'a, K, V> ExactSizeIterator for Drain<'a, K, V> {
fn len(&self) -> usize {
unsafe { (**self.table).size() }
unsafe { (*self.table.as_mut_ptr()).size() }
}
}
@ -1063,7 +1063,7 @@ impl<K, V> Drop for RawTable<K, V> { @@ -1063,7 +1063,7 @@ impl<K, V> Drop for RawTable<K, V> {
debug_assert!(!oflo, "should be impossible");
unsafe {
deallocate(*self.hashes as *mut u8, size, align);
deallocate(self.hashes.as_ptr() as *mut u8, size, align);
// Remember how everything was allocated out of one buffer
// during initialization? We only need one call to free here.
}

34
ctr-std/src/f32.rs

@ -242,40 +242,6 @@ impl f32 { @@ -242,40 +242,6 @@ impl f32 {
#[inline]
pub fn classify(self) -> FpCategory { num::Float::classify(self) }
/// Returns the mantissa, base 2 exponent, and sign as integers, respectively.
/// The original number can be recovered by `sign * mantissa * 2 ^ exponent`.
/// The floating point encoding is documented in the [Reference][floating-point].
///
/// ```
/// #![feature(float_extras)]
///
/// use std::f32;
///
/// let num = 2.0f32;
///
/// // (8388608, -22, 1)
/// let (mantissa, exponent, sign) = num.integer_decode();
/// let sign_f = sign as f32;
/// let mantissa_f = mantissa as f32;
/// let exponent_f = num.powf(exponent as f32);
///
/// // 1 * 8388608 * 2^(-22) == 2
/// let abs_difference = (sign_f * mantissa_f * exponent_f - num).abs();
///
/// assert!(abs_difference <= f32::EPSILON);
/// ```
/// [floating-point]: ../reference.html#machine-types
#[unstable(feature = "float_extras", reason = "signature is undecided",
issue = "27752")]
#[rustc_deprecated(since = "1.11.0",
reason = "never really came to fruition and easily \
implementable outside the standard library")]
#[inline]
#[allow(deprecated)]
pub fn integer_decode(self) -> (u64, i16, i8) {
num::Float::integer_decode(self)
}
/// Returns the largest integer less than or equal to a number.
///
/// ```

30
ctr-std/src/f64.rs

@ -186,36 +186,6 @@ impl f64 { @@ -186,36 +186,6 @@ impl f64 {
#[inline]
pub fn classify(self) -> FpCategory { num::Float::classify(self) }
/// Returns the mantissa, base 2 exponent, and sign as integers, respectively.
/// The original number can be recovered by `sign * mantissa * 2 ^ exponent`.
/// The floating point encoding is documented in the [Reference][floating-point].
///
/// ```
/// #![feature(float_extras)]
///
/// let num = 2.0f64;
///
/// // (8388608, -22, 1)
/// let (mantissa, exponent, sign) = num.integer_decode();
/// let sign_f = sign as f64;
/// let mantissa_f = mantissa as f64;
/// let exponent_f = num.powf(exponent as f64);
///
/// // 1 * 8388608 * 2^(-22) == 2
/// let abs_difference = (sign_f * mantissa_f * exponent_f - num).abs();
///
/// assert!(abs_difference < 1e-10);
/// ```
/// [floating-point]: ../reference.html#machine-types
#[unstable(feature = "float_extras", reason = "signature is undecided",
issue = "27752")]
#[rustc_deprecated(since = "1.11.0",
reason = "never really came to fruition and easily \
implementable outside the standard library")]
#[inline]
#[allow(deprecated)]
pub fn integer_decode(self) -> (u64, i16, i8) { num::Float::integer_decode(self) }
/// Returns the largest integer less than or equal to a number.
///
/// ```

3
ctr-std/src/lib.rs

@ -4,8 +4,8 @@ @@ -4,8 +4,8 @@
#![feature(cfg_target_has_atomic)]
#![feature(cfg_target_thread_local)]
#![feature(collections)]
#![feature(collections_bound)]
#![feature(collections_range)]
#![feature(core_float)]
#![feature(const_fn)]
#![feature(compiler_builtins_lib)]
#![feature(core_intrinsics)]
@ -44,6 +44,7 @@ @@ -44,6 +44,7 @@
#![allow(non_camel_case_types, dead_code, unused_features)]
#![no_std]
#![stable(feature = "rust1", since = "1.0.0")]
#[prelude_import]

4
ctr-std/src/num.rs

@ -16,11 +16,9 @@ @@ -16,11 +16,9 @@
#![stable(feature = "rust1", since = "1.0.0")]
#![allow(missing_docs)]
#[stable(feature = "rust1", since = "1.0.0")]
#[allow(deprecated)]
pub use core::num::{Zero, One};
#[stable(feature = "rust1", since = "1.0.0")]
pub use core::num::{FpCategory, ParseIntError, ParseFloatError, TryFromIntError};
#[stable(feature = "rust1", since = "1.0.0")]
pub use core::num::Wrapping;

2
ctru-rs/Xargo.toml

@ -1,5 +1,7 @@ @@ -1,5 +1,7 @@
[dependencies.collections]
[dependencies.rand]
[dependencies.ctr-libc]
path = "../ctr-libc"
stage = 1

Loading…
Cancel
Save