@@ -32,30 +32,26 @@ A BigDigit is a BigUint's composing element.
32
32
33
33
A BigDigit is half the size of machine word size.
34
34
*/
35
- #[ cfg( target_arch = "x86" ) ]
36
- #[ cfg( target_arch = "arm" ) ]
37
- #[ cfg( target_arch = "mips" ) ]
35
+ #[ cfg( target_word_size = "32" ) ]
38
36
pub type BigDigit = u16 ;
39
37
40
38
/**
41
39
A BigDigit is a BigUint's composing element.
42
40
43
41
A BigDigit is half the size of machine word size.
44
42
*/
45
- #[ cfg( target_arch = "x86_64 " ) ]
43
+ #[ cfg( target_word_size = "64 " ) ]
46
44
pub type BigDigit = u32 ;
47
45
48
46
pub static ZERO_BIG_DIGIT : BigDigit = 0 ;
49
47
50
48
pub mod BigDigit {
51
49
use bigint:: BigDigit ;
52
50
53
- #[ cfg( target_arch = "x86" ) ]
54
- #[ cfg( target_arch = "arm" ) ]
55
- #[ cfg( target_arch = "mips" ) ]
51
+ #[ cfg( target_word_size = "32" ) ]
56
52
pub static bits: uint = 16 ;
57
53
58
- #[ cfg( target_arch = "x86_64 " ) ]
54
+ #[ cfg( target_word_size = "64 " ) ]
59
55
pub static bits: uint = 32 ;
60
56
61
57
pub static base: uint = 1 << bits;
@@ -659,8 +655,7 @@ impl BigUint {
659
655
}
660
656
}
661
657
662
- #[ cfg( target_arch = "x86_64" ) ]
663
-
658
+ #[ cfg( target_word_size = "64" ) ]
664
659
fn get_radix_base ( radix : uint ) -> ( uint , uint ) {
665
660
assert ! ( 1 < radix && radix <= 16 ) ;
666
661
match radix {
@@ -683,10 +678,7 @@ fn get_radix_base(radix: uint) -> (uint, uint) {
683
678
}
684
679
}
685
680
686
- #[ cfg( target_arch = "arm" ) ]
687
- #[ cfg( target_arch = "x86" ) ]
688
- #[ cfg( target_arch = "mips" ) ]
689
-
681
+ #[ cfg( target_word_size = "32" ) ]
690
682
fn get_radix_base ( radix : uint ) -> ( uint , uint ) {
691
683
assert ! ( 1 < radix && radix <= 16 ) ;
692
684
match radix {
@@ -1233,7 +1225,7 @@ mod biguint_tests {
1233
1225
1234
1226
test_shl_bits();
1235
1227
1236
- #[cfg(target_arch = " x86_64 ") ]
1228
+ #[cfg(target_word_size = " 64 ") ]
1237
1229
fn test_shl_bits( ) {
1238
1230
check ( ~[ 0x7654_3210 , 0xfedc_ba98 ,
1239
1231
0x7654_3210 , 0xfedc_ba98 ] , 4 ,
@@ -1245,9 +1237,7 @@ mod biguint_tests {
1245
1237
0x5555_4444 , 0x7777_6666 , 0x8888 ] ) ;
1246
1238
}
1247
1239
1248
- #[ cfg( target_arch = "arm" ) ]
1249
- #[ cfg( target_arch = "x86" ) ]
1250
- #[ cfg( target_arch = "mips" ) ]
1240
+ #[ cfg( target_word_size = "32" ) ]
1251
1241
fn test_shl_bits ( ) {
1252
1242
check ( ~[ 0x3210 , 0x7654 , 0xba98 , 0xfedc ,
1253
1243
0x3210 , 0x7654 , 0xba98 , 0xfedc ] , 4 ,
@@ -1262,9 +1252,7 @@ mod biguint_tests {
1262
1252
}
1263
1253
1264
1254
#[ 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" ) ) ]
1268
1256
fn test_shr ( ) {
1269
1257
fn check ( v : ~[ BigDigit ] , shift : uint , ans : ~[ BigDigit ] ) {
1270
1258
assert_eq ! ( BigUint :: new( v) >> shift, BigUint :: new( ans) ) ;
@@ -1279,7 +1267,7 @@ mod biguint_tests {
1279
1267
check ( ~[ 0 , 1 ] , 1 , ~[ 0x80000000 ] ) ;
1280
1268
test_shr_bits ( ) ;
1281
1269
1282
- #[ cfg( target_arch = "x86_64 " ) ]
1270
+ #[ cfg( target_word_size = "64 " ) ]
1283
1271
fn test_shr_bits ( ) {
1284
1272
check ( ~[ 0x6543_2100 , 0xedcb_a987 ,
1285
1273
0x6543_210f , 0xedcb_a987 , 0xf ] , 4 ,
@@ -1291,9 +1279,7 @@ mod biguint_tests {
1291
1279
0x6666_5555 , 0x8888_7777 ] ) ;
1292
1280
}
1293
1281
1294
- #[ cfg( target_arch = "arm" ) ]
1295
- #[ cfg( target_arch = "x86" ) ]
1296
- #[ cfg( target_arch = "mips" ) ]
1282
+ #[ cfg( target_word_size = "32" ) ]
1297
1283
fn test_shr_bits ( ) {
1298
1284
check ( ~[ 0x2100 , 0x6543 , 0xa987 , 0xedcb ,
1299
1285
0x210f , 0x6543 , 0xa987 , 0xedcb , 0xf ] , 4 ,
0 commit comments