diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2013-05-12 21:14:40 -0400 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2013-05-24 15:31:34 -0500 |
| commit | ec8fb884e94975ed6d82a4cc0ea0a064a4b7155f (patch) | |
| tree | da60056094a97e33f736fb620a09bd12e361dcd3 /src/libstd/num/i8.rs | |
| parent | b5ab1012f1f5786f550e511ba1302a22c85fcd71 (diff) | |
| download | rust-ec8fb884e94975ed6d82a4cc0ea0a064a4b7155f.tar.gz rust-ec8fb884e94975ed6d82a4cc0ea0a064a4b7155f.zip | |
Remove usage of the #[merge] hack with int modules
Diffstat (limited to 'src/libstd/num/i8.rs')
| -rw-r--r-- | src/libstd/num/i8.rs | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/libstd/num/i8.rs b/src/libstd/num/i8.rs new file mode 100644 index 00000000000..939965b9691 --- /dev/null +++ b/src/libstd/num/i8.rs @@ -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) } } +} |
