Skip to content

Commit

Permalink
auto merge of #6722 : alexcrichton/rust/issue-4219-no-merge-hack, r=b…
Browse files Browse the repository at this point in the history
…rson

Changes the int/uint modules to all use macros instead of using the `merge` attribute. It would be nice to have #4375 resolved as well for this, but that can probably come at a later date.

Closes #4219.
  • Loading branch information
bors committed May 25, 2013
2 parents 2706271 + 03ae629 commit e2f8b51
Show file tree
Hide file tree
Showing 24 changed files with 909 additions and 1,201 deletions.
46 changes: 18 additions & 28 deletions src/libstd/core.rc
Original file line number Diff line number Diff line change
Expand Up @@ -88,34 +88,24 @@ pub mod prelude;

/* Primitive types */

#[path = "num/int-template.rs"] #[merge = "num/int-template/int.rs"]
pub mod int;
#[path = "num/int-template.rs"] #[merge = "num/int-template/i8.rs"]
pub mod i8;
#[path = "num/int-template.rs"] #[merge = "num/int-template/i16.rs"]
pub mod i16;
#[path = "num/int-template.rs"] #[merge = "num/int-template/i32.rs"]
pub mod i32;
#[path = "num/int-template.rs"] #[merge = "num/int-template/i64.rs"]
pub mod i64;
#[path = "num/uint-template.rs"] #[merge = "num/uint-template/uint.rs"]
pub mod uint;

#[path = "num/uint-template.rs"] #[merge = "num/uint-template/u8.rs"]
pub mod u8;
#[path = "num/uint-template.rs"] #[merge = "num/uint-template/u16.rs"]
pub mod u16;
#[path = "num/uint-template.rs"] #[merge = "num/uint-template/u32.rs"]
pub mod u32;
#[path = "num/uint-template.rs"] #[merge = "num/uint-template/u64.rs"]
pub mod u64;

#[path = "num/float.rs"]
pub mod float;
#[path = "num/f32.rs"]
pub mod f32;
#[path = "num/f64.rs"]
pub mod f64;
#[path = "num/int_macros.rs"] mod int_macros;
#[path = "num/uint_macros.rs"] mod uint_macros;

#[path = "num/int.rs"] pub mod int;
#[path = "num/i8.rs"] pub mod i8;
#[path = "num/i16.rs"] pub mod i16;
#[path = "num/i32.rs"] pub mod i32;
#[path = "num/i64.rs"] pub mod i64;

#[path = "num/uint.rs"] pub mod uint;
#[path = "num/u8.rs"] pub mod u8;
#[path = "num/u16.rs"] pub mod u16;
#[path = "num/u32.rs"] pub mod u32;
#[path = "num/u64.rs"] pub mod u64;

#[path = "num/float.rs"] pub mod float;
#[path = "num/f32.rs"] pub mod f32;
#[path = "num/f64.rs"] pub mod f64;

pub mod nil;
pub mod bool;
Expand Down
32 changes: 32 additions & 0 deletions src/libstd/num/i16.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

//! Operations and constants for `i16`
use num::BitCount;
use unstable::intrinsics;

pub use self::generated::*;

int_module!(i16, 16)

impl BitCount for i16 {
/// Counts the number of bits set. Wraps LLVM's `ctpop` intrinsic.
#[inline(always)]
fn population_count(&self) -> i16 { unsafe { intrinsics::ctpop16(*self) } }

/// Counts the number of leading zeros. Wraps LLVM's `ctlz` intrinsic.
#[inline(always)]
fn leading_zeros(&self) -> i16 { unsafe { intrinsics::ctlz16(*self) } }

/// Counts the number of trailing zeros. Wraps LLVM's `cttz` intrinsic.
#[inline(always)]
fn trailing_zeros(&self) -> i16 { unsafe { intrinsics::cttz16(*self) } }
}
32 changes: 32 additions & 0 deletions src/libstd/num/i32.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

//! Operations and constants for `i32`
use num::BitCount;
use unstable::intrinsics;

pub use self::generated::*;

int_module!(i32, 32)

impl BitCount for i32 {
/// Counts the number of bits set. Wraps LLVM's `ctpop` intrinsic.
#[inline(always)]
fn population_count(&self) -> i32 { unsafe { intrinsics::ctpop32(*self) } }

/// Counts the number of leading zeros. Wraps LLVM's `ctlz` intrinsic.
#[inline(always)]
fn leading_zeros(&self) -> i32 { unsafe { intrinsics::ctlz32(*self) } }

/// Counts the number of trailing zeros. Wraps LLVM's `cttz` intrinsic.
#[inline(always)]
fn trailing_zeros(&self) -> i32 { unsafe { intrinsics::cttz32(*self) } }
}
32 changes: 32 additions & 0 deletions src/libstd/num/i64.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

//! Operations and constants for `i64`
use num::BitCount;
use unstable::intrinsics;

pub use self::generated::*;

int_module!(i64, 64)

impl BitCount for i64 {
/// Counts the number of bits set. Wraps LLVM's `ctpop` intrinsic.
#[inline(always)]
fn population_count(&self) -> i64 { unsafe { intrinsics::ctpop64(*self) } }

/// Counts the number of leading zeros. Wraps LLVM's `ctlz` intrinsic.
#[inline(always)]
fn leading_zeros(&self) -> i64 { unsafe { intrinsics::ctlz64(*self) } }

/// Counts the number of trailing zeros. Wraps LLVM's `cttz` intrinsic.
#[inline(always)]
fn trailing_zeros(&self) -> i64 { unsafe { intrinsics::cttz64(*self) } }
}
32 changes: 32 additions & 0 deletions src/libstd/num/i8.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

//! Operations and constants for `i8`
use num::BitCount;
use unstable::intrinsics;

pub use self::generated::*;

int_module!(i8, 8)

impl BitCount for i8 {
/// Counts the number of bits set. Wraps LLVM's `ctpop` intrinsic.
#[inline(always)]
fn population_count(&self) -> i8 { unsafe { intrinsics::ctpop8(*self) } }

/// Counts the number of leading zeros. Wraps LLVM's `ctlz` intrinsic.
#[inline(always)]
fn leading_zeros(&self) -> i8 { unsafe { intrinsics::ctlz8(*self) } }

/// Counts the number of trailing zeros. Wraps LLVM's `cttz` intrinsic.
#[inline(always)]
fn trailing_zeros(&self) -> i8 { unsafe { intrinsics::cttz8(*self) } }
}
41 changes: 0 additions & 41 deletions src/libstd/num/int-template/i16.rs

This file was deleted.

41 changes: 0 additions & 41 deletions src/libstd/num/int-template/i32.rs

This file was deleted.

41 changes: 0 additions & 41 deletions src/libstd/num/int-template/i64.rs

This file was deleted.

41 changes: 0 additions & 41 deletions src/libstd/num/int-template/i8.rs

This file was deleted.

Loading

0 comments on commit e2f8b51

Please sign in to comment.