Skip to content

Commit f96fb72

Browse files
committed
---
yaml --- r: 149040 b: refs/heads/try2 c: 073b655 h: refs/heads/master v: v3
1 parent f5bda0d commit f96fb72

File tree

9 files changed

+44
-42
lines changed

9 files changed

+44
-42
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: c7710cdf4563533b211a16cb02a9b4cb70ed3ca9
8+
refs/heads/try2: 073b655187916e9155d285efc496cfd89104796c
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/libnative/io/net.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ use std::libc;
1515
use std::mem;
1616
use std::rt::rtio;
1717
use std::sync::arc::UnsafeArc;
18-
use std::unstable::intrinsics;
1918

2019
use super::{IoResult, retry};
2120
use super::file::keep_going;
@@ -28,10 +27,10 @@ use super::file::keep_going;
2827
#[cfg(unix)] pub type sock_t = super::file::fd_t;
2928

3029
pub fn htons(u: u16) -> u16 {
31-
intrinsics::to_be16(u as i16) as u16
30+
mem::to_be16(u as i16) as u16
3231
}
3332
pub fn ntohs(u: u16) -> u16 {
34-
intrinsics::from_be16(u as i16) as u16
33+
mem::from_be16(u as i16) as u16
3534
}
3635

3736
enum InAddr {

branches/try2/src/librustc/util/sha2.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use extra::hex::ToHex;
2222
/// format.
2323
fn write_u32_be(dst: &mut[u8], input: u32) {
2424
use std::cast::transmute;
25-
use std::unstable::intrinsics::to_be32;
25+
use std::mem::to_be32;
2626
assert!(dst.len() == 4);
2727
unsafe {
2828
let x: *mut i32 = transmute(dst.unsafe_mut_ref(0));
@@ -33,7 +33,7 @@ fn write_u32_be(dst: &mut[u8], input: u32) {
3333
/// Read a vector of bytes into a vector of u32s. The values are read in big-endian format.
3434
fn read_u32v_be(dst: &mut[u32], input: &[u8]) {
3535
use std::cast::transmute;
36-
use std::unstable::intrinsics::to_be32;
36+
use std::mem::to_be32;
3737
assert!(dst.len() * 4 == input.len());
3838
unsafe {
3939
let mut x: *mut i32 = transmute(dst.unsafe_mut_ref(0));

branches/try2/src/librustuv/net.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ use std::mem;
1717
use std::ptr;
1818
use std::rt::rtio;
1919
use std::rt::task::BlockedTask;
20-
use std::unstable::intrinsics;
2120

2221
use access::Access;
2322
use homing::{HomingIO, HomeHandle};
@@ -33,8 +32,8 @@ use uvll;
3332
/// Generic functions related to dealing with sockaddr things
3433
////////////////////////////////////////////////////////////////////////////////
3534

36-
pub fn htons(u: u16) -> u16 { intrinsics::to_be16(u as i16) as u16 }
37-
pub fn ntohs(u: u16) -> u16 { intrinsics::from_be16(u as i16) as u16 }
35+
pub fn htons(u: u16) -> u16 { mem::to_be16(u as i16) as u16 }
36+
pub fn ntohs(u: u16) -> u16 { mem::from_be16(u as i16) as u16 }
3837

3938
pub fn sockaddr_to_addr(storage: &libc::sockaddr_storage,
4039
len: uint) -> ip::SocketAddr {

branches/try2/src/libserialize/ebml.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ pub mod reader {
132132

133133
pub fn vuint_at(data: &[u8], start: uint) -> Res {
134134
use std::ptr::offset;
135-
use std::unstable::intrinsics::from_be32;
135+
use std::mem::from_be32;
136136

137137
if data.len() - start < 4 {
138138
return vuint_at_slow(data, start);

branches/try2/src/libstd/io/extensions.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ impl<'r, R: Reader> Iterator<u8> for Bytes<'r, R> {
5151
}
5252

5353
pub fn u64_to_le_bytes<T>(n: u64, size: uint, f: |v: &[u8]| -> T) -> T {
54-
use unstable::intrinsics::{to_le16, to_le32, to_le64};
54+
use mem::{to_le16, to_le32, to_le64};
5555
use cast::transmute;
5656

5757
// LLVM fails to properly optimize this when using shifts instead of the to_le* intrinsics
@@ -77,7 +77,7 @@ pub fn u64_to_le_bytes<T>(n: u64, size: uint, f: |v: &[u8]| -> T) -> T {
7777
}
7878

7979
pub fn u64_to_be_bytes<T>(n: u64, size: uint, f: |v: &[u8]| -> T) -> T {
80-
use unstable::intrinsics::{to_be16, to_be32, to_be64};
80+
use mem::{to_be16, to_be32, to_be64};
8181
use cast::transmute;
8282

8383
// LLVM fails to properly optimize this when using shifts instead of the to_be* intrinsics
@@ -105,7 +105,7 @@ pub fn u64_from_be_bytes(data: &[u8],
105105
size: uint)
106106
-> u64 {
107107
use ptr::{copy_nonoverlapping_memory, offset, mut_offset};
108-
use unstable::intrinsics::from_be64;
108+
use mem::from_be64;
109109
use vec::MutableVector;
110110

111111
assert!(size <= 8u);

branches/try2/src/libstd/mem.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@
1010

1111
//! Functions relating to memory layout
1212
13+
#[allow(missing_doc)]; // FIXME
14+
1315
use unstable::intrinsics;
16+
use unstable::intrinsics::{bswap16, bswap32, bswap64};
1417

1518
/// Returns the size of a type
1619
#[inline]
@@ -91,6 +94,34 @@ pub unsafe fn move_val_init<T>(dst: &mut T, src: T) {
9194
intrinsics::move_val_init(dst, src)
9295
}
9396

97+
#[cfg(target_endian = "little")] #[inline] pub fn to_le16(x: i16) -> i16 { x }
98+
#[cfg(target_endian = "big")] #[inline] pub fn to_le16(x: i16) -> i16 { unsafe { bswap16(x) } }
99+
#[cfg(target_endian = "little")] #[inline] pub fn to_le32(x: i32) -> i32 { x }
100+
#[cfg(target_endian = "big")] #[inline] pub fn to_le32(x: i32) -> i32 { unsafe { bswap32(x) } }
101+
#[cfg(target_endian = "little")] #[inline] pub fn to_le64(x: i64) -> i64 { x }
102+
#[cfg(target_endian = "big")] #[inline] pub fn to_le64(x: i64) -> i64 { unsafe { bswap64(x) } }
103+
104+
#[cfg(target_endian = "little")] #[inline] pub fn to_be16(x: i16) -> i16 { unsafe { bswap16(x) } }
105+
#[cfg(target_endian = "big")] #[inline] pub fn to_be16(x: i16) -> i16 { x }
106+
#[cfg(target_endian = "little")] #[inline] pub fn to_be32(x: i32) -> i32 { unsafe { bswap32(x) } }
107+
#[cfg(target_endian = "big")] #[inline] pub fn to_be32(x: i32) -> i32 { x }
108+
#[cfg(target_endian = "little")] #[inline] pub fn to_be64(x: i64) -> i64 { unsafe { bswap64(x) } }
109+
#[cfg(target_endian = "big")] #[inline] pub fn to_be64(x: i64) -> i64 { x }
110+
111+
#[cfg(target_endian = "little")] #[inline] pub fn from_le16(x: i16) -> i16 { x }
112+
#[cfg(target_endian = "big")] #[inline] pub fn from_le16(x: i16) -> i16 { unsafe { bswap16(x) } }
113+
#[cfg(target_endian = "little")] #[inline] pub fn from_le32(x: i32) -> i32 { x }
114+
#[cfg(target_endian = "big")] #[inline] pub fn from_le32(x: i32) -> i32 { unsafe { bswap32(x) } }
115+
#[cfg(target_endian = "little")] #[inline] pub fn from_le64(x: i64) -> i64 { x }
116+
#[cfg(target_endian = "big")] #[inline] pub fn from_le64(x: i64) -> i64 { unsafe { bswap64(x) } }
117+
118+
#[cfg(target_endian = "little")] #[inline] pub fn from_be16(x: i16) -> i16 { unsafe { bswap16(x) } }
119+
#[cfg(target_endian = "big")] #[inline] pub fn from_be16(x: i16) -> i16 { x }
120+
#[cfg(target_endian = "little")] #[inline] pub fn from_be32(x: i32) -> i32 { unsafe { bswap32(x) } }
121+
#[cfg(target_endian = "big")] #[inline] pub fn from_be32(x: i32) -> i32 { x }
122+
#[cfg(target_endian = "little")] #[inline] pub fn from_be64(x: i64) -> i64 { unsafe { bswap64(x) } }
123+
#[cfg(target_endian = "big")] #[inline] pub fn from_be64(x: i64) -> i64 { x }
124+
94125

95126
#[cfg(test)]
96127
mod tests {

branches/try2/src/libstd/unstable/intrinsics.rs

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -439,33 +439,6 @@ extern "rust-intrinsic" {
439439
pub fn u64_mul_with_overflow(x: u64, y: u64) -> (u64, bool);
440440
}
441441

442-
#[cfg(target_endian = "little")] #[inline] pub fn to_le16(x: i16) -> i16 { x }
443-
#[cfg(target_endian = "big")] #[inline] pub fn to_le16(x: i16) -> i16 { unsafe { bswap16(x) } }
444-
#[cfg(target_endian = "little")] #[inline] pub fn to_le32(x: i32) -> i32 { x }
445-
#[cfg(target_endian = "big")] #[inline] pub fn to_le32(x: i32) -> i32 { unsafe { bswap32(x) } }
446-
#[cfg(target_endian = "little")] #[inline] pub fn to_le64(x: i64) -> i64 { x }
447-
#[cfg(target_endian = "big")] #[inline] pub fn to_le64(x: i64) -> i64 { unsafe { bswap64(x) } }
448-
449-
#[cfg(target_endian = "little")] #[inline] pub fn to_be16(x: i16) -> i16 { unsafe { bswap16(x) } }
450-
#[cfg(target_endian = "big")] #[inline] pub fn to_be16(x: i16) -> i16 { x }
451-
#[cfg(target_endian = "little")] #[inline] pub fn to_be32(x: i32) -> i32 { unsafe { bswap32(x) } }
452-
#[cfg(target_endian = "big")] #[inline] pub fn to_be32(x: i32) -> i32 { x }
453-
#[cfg(target_endian = "little")] #[inline] pub fn to_be64(x: i64) -> i64 { unsafe { bswap64(x) } }
454-
#[cfg(target_endian = "big")] #[inline] pub fn to_be64(x: i64) -> i64 { x }
455-
456-
#[cfg(target_endian = "little")] #[inline] pub fn from_le16(x: i16) -> i16 { x }
457-
#[cfg(target_endian = "big")] #[inline] pub fn from_le16(x: i16) -> i16 { unsafe { bswap16(x) } }
458-
#[cfg(target_endian = "little")] #[inline] pub fn from_le32(x: i32) -> i32 { x }
459-
#[cfg(target_endian = "big")] #[inline] pub fn from_le32(x: i32) -> i32 { unsafe { bswap32(x) } }
460-
#[cfg(target_endian = "little")] #[inline] pub fn from_le64(x: i64) -> i64 { x }
461-
#[cfg(target_endian = "big")] #[inline] pub fn from_le64(x: i64) -> i64 { unsafe { bswap64(x) } }
462-
463-
#[cfg(target_endian = "little")] #[inline] pub fn from_be16(x: i16) -> i16 { unsafe { bswap16(x) } }
464-
#[cfg(target_endian = "big")] #[inline] pub fn from_be16(x: i16) -> i16 { x }
465-
#[cfg(target_endian = "little")] #[inline] pub fn from_be32(x: i32) -> i32 { unsafe { bswap32(x) } }
466-
#[cfg(target_endian = "big")] #[inline] pub fn from_be32(x: i32) -> i32 { x }
467-
#[cfg(target_endian = "little")] #[inline] pub fn from_be64(x: i64) -> i64 { unsafe { bswap64(x) } }
468-
#[cfg(target_endian = "big")] #[inline] pub fn from_be64(x: i64) -> i64 { x }
469442

470443
/// `TypeId` represents a globally unique identifier for a type
471444
#[lang="type_id"] // This needs to be kept in lockstep with the code in trans/intrinsic.rs and

branches/try2/src/libuuid/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ impl Uuid {
203203
/// * `d3` A 16-bit word
204204
/// * `d4` Array of 8 octets
205205
pub fn from_fields(d1: u32, d2: u16, d3: u16, d4: &[u8]) -> Uuid {
206-
use std::unstable::intrinsics::{to_be16, to_be32};
206+
use std::mem::{to_be16, to_be32};
207207

208208
// First construct a temporary field-based struct
209209
let mut fields = UuidFields {
@@ -329,7 +329,7 @@ impl Uuid {
329329
///
330330
/// Example: `550e8400-e29b-41d4-a716-446655440000`
331331
pub fn to_hyphenated_str(&self) -> ~str {
332-
use std::unstable::intrinsics::{to_be16, to_be32};
332+
use std::mem::{to_be16, to_be32};
333333
// Convert to field-based struct as it matches groups in output.
334334
// Ensure fields are in network byte order, as per RFC.
335335
let mut uf: UuidFields;

0 commit comments

Comments
 (0)