Skip to content

Commit 36d698d

Browse files
committed
bigint: cfg(target_arch = ...) => cfg(target_word_size = ...)
1 parent 6a649e6 commit 36d698d

File tree

1 file changed

+11
-25
lines changed

1 file changed

+11
-25
lines changed

src/libextra/num/bigint.rs

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -32,30 +32,26 @@ A BigDigit is a BigUint's composing element.
3232
3333
A BigDigit is half the size of machine word size.
3434
*/
35-
#[cfg(target_arch = "x86")]
36-
#[cfg(target_arch = "arm")]
37-
#[cfg(target_arch = "mips")]
35+
#[cfg(target_word_size = "32")]
3836
pub type BigDigit = u16;
3937

4038
/**
4139
A BigDigit is a BigUint's composing element.
4240
4341
A BigDigit is half the size of machine word size.
4442
*/
45-
#[cfg(target_arch = "x86_64")]
43+
#[cfg(target_word_size = "64")]
4644
pub type BigDigit = u32;
4745

4846
pub static ZERO_BIG_DIGIT: BigDigit = 0;
4947

5048
pub mod BigDigit {
5149
use bigint::BigDigit;
5250

53-
#[cfg(target_arch = "x86")]
54-
#[cfg(target_arch = "arm")]
55-
#[cfg(target_arch = "mips")]
51+
#[cfg(target_word_size = "32")]
5652
pub static bits: uint = 16;
5753

58-
#[cfg(target_arch = "x86_64")]
54+
#[cfg(target_word_size = "64")]
5955
pub static bits: uint = 32;
6056

6157
pub static base: uint = 1 << bits;
@@ -659,8 +655,7 @@ impl BigUint {
659655
}
660656
}
661657

662-
#[cfg(target_arch = "x86_64")]
663-
658+
#[cfg(target_word_size = "64")]
664659
fn get_radix_base(radix: uint) -> (uint, uint) {
665660
assert!(1 < radix && radix <= 16);
666661
match radix {
@@ -683,10 +678,7 @@ fn get_radix_base(radix: uint) -> (uint, uint) {
683678
}
684679
}
685680

686-
#[cfg(target_arch = "arm")]
687-
#[cfg(target_arch = "x86")]
688-
#[cfg(target_arch = "mips")]
689-
681+
#[cfg(target_word_size = "32")]
690682
fn get_radix_base(radix: uint) -> (uint, uint) {
691683
assert!(1 < radix && radix <= 16);
692684
match radix {
@@ -1233,7 +1225,7 @@ mod biguint_tests {
12331225
12341226
test_shl_bits();
12351227
1236-
#[cfg(target_arch = "x86_64")]
1228+
#[cfg(target_word_size = "64")]
12371229
fn test_shl_bits() {
12381230
check(~[0x7654_3210, 0xfedc_ba98,
12391231
0x7654_3210, 0xfedc_ba98], 4,
@@ -1245,9 +1237,7 @@ mod biguint_tests {
12451237
0x5555_4444, 0x7777_6666, 0x8888]);
12461238
}
12471239

1248-
#[cfg(target_arch = "arm")]
1249-
#[cfg(target_arch = "x86")]
1250-
#[cfg(target_arch = "mips")]
1240+
#[cfg(target_word_size = "32")]
12511241
fn test_shl_bits() {
12521242
check(~[0x3210, 0x7654, 0xba98, 0xfedc,
12531243
0x3210, 0x7654, 0xba98, 0xfedc], 4,
@@ -1262,9 +1252,7 @@ mod biguint_tests {
12621252
}
12631253

12641254
#[test]
1265-
#[ignore(cfg(target_arch = "x86"))]
1266-
#[ignore(cfg(target_arch = "arm"))]
1267-
#[ignore(cfg(target_arch = "mips"))]
1255+
#[ignore(cfg(target_word_size = "32"))]
12681256
fn test_shr() {
12691257
fn check(v: ~[BigDigit], shift: uint, ans: ~[BigDigit]) {
12701258
assert_eq!(BigUint::new(v) >> shift, BigUint::new(ans));
@@ -1279,7 +1267,7 @@ mod biguint_tests {
12791267
check(~[0, 1], 1, ~[0x80000000]);
12801268
test_shr_bits();
12811269

1282-
#[cfg(target_arch = "x86_64")]
1270+
#[cfg(target_word_size = "64")]
12831271
fn test_shr_bits() {
12841272
check(~[0x6543_2100, 0xedcb_a987,
12851273
0x6543_210f, 0xedcb_a987, 0xf], 4,
@@ -1291,9 +1279,7 @@ mod biguint_tests {
12911279
0x6666_5555, 0x8888_7777]);
12921280
}
12931281

1294-
#[cfg(target_arch = "arm")]
1295-
#[cfg(target_arch = "x86")]
1296-
#[cfg(target_arch = "mips")]
1282+
#[cfg(target_word_size = "32")]
12971283
fn test_shr_bits() {
12981284
check(~[0x2100, 0x6543, 0xa987, 0xedcb,
12991285
0x210f, 0x6543, 0xa987, 0xedcb, 0xf], 4,

0 commit comments

Comments
 (0)