diff options
| author | bors <bors@rust-lang.org> | 2016-06-03 22:32:15 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2016-06-03 22:32:15 -0700 |
| commit | 7738479d72418ddc08febee0fa7097df334d357e (patch) | |
| tree | 02db04b160da2230fa0097d6fea5331237945e29 /src/libcore/num | |
| parent | c81c75076c05990af6f71e56ccc12d7b196ee25c (diff) | |
| parent | bc7595c8abbf4e3b737e926d61814686e0ebda77 (diff) | |
| download | rust-7738479d72418ddc08febee0fa7097df334d357e.tar.gz rust-7738479d72418ddc08febee0fa7097df334d357e.zip | |
Auto merge of #33460 - shepmaster:16-bit-pointers, r=Aatch
Support 16-bit pointers as well as i/usize I'm opening this pull request to get some feedback from the community. Although Rust doesn't support any platforms with a native 16-bit pointer at the moment, the [AVR-Rust][ar] fork is working towards that goal. Keeping this forked logic up-to-date with the changes in master has been onerous so I'd like to merge these changes so that they get carried along when refactoring happens. I do not believe this should increase the maintenance burden. This is based on the original work of Dylan McKay (@dylanmckay). [ar]: https://github.com/avr-rust/rust
Diffstat (limited to 'src/libcore/num')
| -rw-r--r-- | src/libcore/num/isize.rs | 2 | ||||
| -rw-r--r-- | src/libcore/num/mod.rs | 21 | ||||
| -rw-r--r-- | src/libcore/num/usize.rs | 2 | ||||
| -rw-r--r-- | src/libcore/num/wrapping.rs | 6 |
4 files changed, 31 insertions, 0 deletions
diff --git a/src/libcore/num/isize.rs b/src/libcore/num/isize.rs index de5b1777f93..86bcef4011d 100644 --- a/src/libcore/num/isize.rs +++ b/src/libcore/num/isize.rs @@ -14,6 +14,8 @@ #![stable(feature = "rust1", since = "1.0.0")] +#[cfg(target_pointer_width = "16")] +int_module! { isize, 16 } #[cfg(target_pointer_width = "32")] int_module! { isize, 32 } #[cfg(target_pointer_width = "64")] diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs index 9b6f6698def..5988a6375d4 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -1176,6 +1176,15 @@ impl i64 { intrinsics::mul_with_overflow } } +#[cfg(target_pointer_width = "16")] +#[lang = "isize"] +impl isize { + int_impl! { i16, u16, 16, + intrinsics::add_with_overflow, + intrinsics::sub_with_overflow, + intrinsics::mul_with_overflow } +} + #[cfg(target_pointer_width = "32")] #[lang = "isize"] impl isize { @@ -2188,6 +2197,18 @@ impl u64 { intrinsics::mul_with_overflow } } +#[cfg(target_pointer_width = "16")] +#[lang = "usize"] +impl usize { + uint_impl! { u16, 16, + intrinsics::ctpop, + intrinsics::ctlz, + intrinsics::cttz, + intrinsics::bswap, + intrinsics::add_with_overflow, + intrinsics::sub_with_overflow, + intrinsics::mul_with_overflow } +} #[cfg(target_pointer_width = "32")] #[lang = "usize"] impl usize { diff --git a/src/libcore/num/usize.rs b/src/libcore/num/usize.rs index 0c7d16a41bc..685c52e271e 100644 --- a/src/libcore/num/usize.rs +++ b/src/libcore/num/usize.rs @@ -14,6 +14,8 @@ #![stable(feature = "rust1", since = "1.0.0")] +#[cfg(target_pointer_width = "16")] +uint_module! { usize, 16 } #[cfg(target_pointer_width = "32")] uint_module! { usize, 32 } #[cfg(target_pointer_width = "64")] diff --git a/src/libcore/num/wrapping.rs b/src/libcore/num/wrapping.rs index 04e8bc4913b..4857817e84e 100644 --- a/src/libcore/num/wrapping.rs +++ b/src/libcore/num/wrapping.rs @@ -292,6 +292,12 @@ wrapping_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 } mod shift_max { #![allow(non_upper_case_globals)] + #[cfg(target_pointer_width = "16")] + mod platform { + pub const usize: u32 = super::u16; + pub const isize: u32 = super::i16; + } + #[cfg(target_pointer_width = "32")] mod platform { pub const usize: u32 = super::u32; |
