@@ -492,114 +492,172 @@ extern "rust-intrinsic" {
492
492
pub fn roundf64 ( x : f64 ) -> f64 ;
493
493
494
494
/// Returns the number of bits set in a `u8`.
495
+ #[ cfg( stage0) ]
495
496
pub fn ctpop8 ( x : u8 ) -> u8 ;
496
497
/// Returns the number of bits set in a `u16`.
498
+ #[ cfg( stage0) ]
497
499
pub fn ctpop16 ( x : u16 ) -> u16 ;
498
500
/// Returns the number of bits set in a `u32`.
501
+ #[ cfg( stage0) ]
499
502
pub fn ctpop32 ( x : u32 ) -> u32 ;
500
503
/// Returns the number of bits set in a `u64`.
504
+ #[ cfg( stage0) ]
501
505
pub fn ctpop64 ( x : u64 ) -> u64 ;
506
+ /// Returns the number of bits set in an integer type `T`
507
+ #[ cfg( not( stage0) ) ]
508
+ pub fn ctpop < T > ( x : T ) -> T ;
502
509
503
510
/// Returns the number of leading bits unset in a `u8`.
511
+ #[ cfg( stage0) ]
504
512
pub fn ctlz8 ( x : u8 ) -> u8 ;
505
513
/// Returns the number of leading bits unset in a `u16`.
514
+ #[ cfg( stage0) ]
506
515
pub fn ctlz16 ( x : u16 ) -> u16 ;
507
516
/// Returns the number of leading bits unset in a `u32`.
517
+ #[ cfg( stage0) ]
508
518
pub fn ctlz32 ( x : u32 ) -> u32 ;
509
519
/// Returns the number of leading bits unset in a `u64`.
520
+ #[ cfg( stage0) ]
510
521
pub fn ctlz64 ( x : u64 ) -> u64 ;
522
+ /// Returns the number of leading bits unset in an integer type `T`
523
+ #[ cfg( not( stage0) ) ]
524
+ pub fn ctlz < T > ( x : T ) -> T ;
511
525
512
526
/// Returns the number of trailing bits unset in a `u8`.
527
+ #[ cfg( stage0) ]
513
528
pub fn cttz8 ( x : u8 ) -> u8 ;
514
529
/// Returns the number of trailing bits unset in a `u16`.
530
+ #[ cfg( stage0) ]
515
531
pub fn cttz16 ( x : u16 ) -> u16 ;
516
532
/// Returns the number of trailing bits unset in a `u32`.
533
+ #[ cfg( stage0) ]
517
534
pub fn cttz32 ( x : u32 ) -> u32 ;
518
535
/// Returns the number of trailing bits unset in a `u64`.
536
+ #[ cfg( stage0) ]
519
537
pub fn cttz64 ( x : u64 ) -> u64 ;
538
+ /// Returns the number of trailing bits unset in an integer type `T`
539
+ #[ cfg( not( stage0) ) ]
540
+ pub fn cttz < T > ( x : T ) -> T ;
520
541
521
542
/// Reverses the bytes in a `u16`.
543
+ #[ cfg( stage0) ]
522
544
pub fn bswap16 ( x : u16 ) -> u16 ;
523
545
/// Reverses the bytes in a `u32`.
546
+ #[ cfg( stage0) ]
524
547
pub fn bswap32 ( x : u32 ) -> u32 ;
525
548
/// Reverses the bytes in a `u64`.
549
+ #[ cfg( stage0) ]
526
550
pub fn bswap64 ( x : u64 ) -> u64 ;
551
+ /// Reverses the bytes in an integer type `T`.
552
+ #[ cfg( not( stage0) ) ]
553
+ pub fn bswap < T > ( x : T ) -> T ;
527
554
528
555
/// Performs checked `i8` addition.
556
+ #[ cfg( stage0) ]
529
557
pub fn i8_add_with_overflow ( x : i8 , y : i8 ) -> ( i8 , bool ) ;
530
558
/// Performs checked `i16` addition.
559
+ #[ cfg( stage0) ]
531
560
pub fn i16_add_with_overflow ( x : i16 , y : i16 ) -> ( i16 , bool ) ;
532
561
/// Performs checked `i32` addition.
562
+ #[ cfg( stage0) ]
533
563
pub fn i32_add_with_overflow ( x : i32 , y : i32 ) -> ( i32 , bool ) ;
534
564
/// Performs checked `i64` addition.
565
+ #[ cfg( stage0) ]
535
566
pub fn i64_add_with_overflow ( x : i64 , y : i64 ) -> ( i64 , bool ) ;
536
567
537
568
/// Performs checked `u8` addition.
569
+ #[ cfg( stage0) ]
538
570
pub fn u8_add_with_overflow ( x : u8 , y : u8 ) -> ( u8 , bool ) ;
539
571
/// Performs checked `u16` addition.
572
+ #[ cfg( stage0) ]
540
573
pub fn u16_add_with_overflow ( x : u16 , y : u16 ) -> ( u16 , bool ) ;
541
574
/// Performs checked `u32` addition.
575
+ #[ cfg( stage0) ]
542
576
pub fn u32_add_with_overflow ( x : u32 , y : u32 ) -> ( u32 , bool ) ;
543
577
/// Performs checked `u64` addition.
578
+ #[ cfg( stage0) ]
544
579
pub fn u64_add_with_overflow ( x : u64 , y : u64 ) -> ( u64 , bool ) ;
545
580
581
+ /// Performs checked integer addition.
582
+ #[ cfg( not( stage0) ) ]
583
+ pub fn add_with_overflow < T > ( x : T , y : T ) -> ( T , bool ) ;
584
+
546
585
/// Performs checked `i8` subtraction.
586
+ #[ cfg( stage0) ]
547
587
pub fn i8_sub_with_overflow ( x : i8 , y : i8 ) -> ( i8 , bool ) ;
548
588
/// Performs checked `i16` subtraction.
589
+ #[ cfg( stage0) ]
549
590
pub fn i16_sub_with_overflow ( x : i16 , y : i16 ) -> ( i16 , bool ) ;
550
591
/// Performs checked `i32` subtraction.
592
+ #[ cfg( stage0) ]
551
593
pub fn i32_sub_with_overflow ( x : i32 , y : i32 ) -> ( i32 , bool ) ;
552
594
/// Performs checked `i64` subtraction.
595
+ #[ cfg( stage0) ]
553
596
pub fn i64_sub_with_overflow ( x : i64 , y : i64 ) -> ( i64 , bool ) ;
554
597
555
598
/// Performs checked `u8` subtraction.
599
+ #[ cfg( stage0) ]
556
600
pub fn u8_sub_with_overflow ( x : u8 , y : u8 ) -> ( u8 , bool ) ;
557
601
/// Performs checked `u16` subtraction.
602
+ #[ cfg( stage0) ]
558
603
pub fn u16_sub_with_overflow ( x : u16 , y : u16 ) -> ( u16 , bool ) ;
559
604
/// Performs checked `u32` subtraction.
605
+ #[ cfg( stage0) ]
560
606
pub fn u32_sub_with_overflow ( x : u32 , y : u32 ) -> ( u32 , bool ) ;
561
607
/// Performs checked `u64` subtraction.
608
+ #[ cfg( stage0) ]
562
609
pub fn u64_sub_with_overflow ( x : u64 , y : u64 ) -> ( u64 , bool ) ;
563
610
611
+ /// Performs checked integer subtraction
612
+ #[ cfg( not( stage0) ) ]
613
+ pub fn sub_with_overflow < T > ( x : T , y : T ) -> ( T , bool ) ;
614
+
564
615
/// Performs checked `i8` multiplication.
616
+ #[ cfg( stage0) ]
565
617
pub fn i8_mul_with_overflow ( x : i8 , y : i8 ) -> ( i8 , bool ) ;
566
618
/// Performs checked `i16` multiplication.
619
+ #[ cfg( stage0) ]
567
620
pub fn i16_mul_with_overflow ( x : i16 , y : i16 ) -> ( i16 , bool ) ;
568
621
/// Performs checked `i32` multiplication.
622
+ #[ cfg( stage0) ]
569
623
pub fn i32_mul_with_overflow ( x : i32 , y : i32 ) -> ( i32 , bool ) ;
570
624
/// Performs checked `i64` multiplication.
625
+ #[ cfg( stage0) ]
571
626
pub fn i64_mul_with_overflow ( x : i64 , y : i64 ) -> ( i64 , bool ) ;
572
627
573
628
/// Performs checked `u8` multiplication.
629
+ #[ cfg( stage0) ]
574
630
pub fn u8_mul_with_overflow ( x : u8 , y : u8 ) -> ( u8 , bool ) ;
575
631
/// Performs checked `u16` multiplication.
632
+ #[ cfg( stage0) ]
576
633
pub fn u16_mul_with_overflow ( x : u16 , y : u16 ) -> ( u16 , bool ) ;
577
634
/// Performs checked `u32` multiplication.
635
+ #[ cfg( stage0) ]
578
636
pub fn u32_mul_with_overflow ( x : u32 , y : u32 ) -> ( u32 , bool ) ;
579
637
/// Performs checked `u64` multiplication.
638
+ #[ cfg( stage0) ]
580
639
pub fn u64_mul_with_overflow ( x : u64 , y : u64 ) -> ( u64 , bool ) ;
581
640
582
- /// Returns (a + b) mod 2^N, where N is the width of N in bits.
641
+ /// Performs checked integer multiplication
642
+ #[ cfg( not( stage0) ) ]
643
+ pub fn mul_with_overflow < T > ( x : T , y : T ) -> ( T , bool ) ;
644
+
645
+ /// Performs an unchecked division, resulting in undefined behavior
646
+ /// where y = 0 or x = `T::min_value()` and y = -1
647
+ #[ cfg( not( stage0) ) ]
648
+ pub fn unchecked_div < T > ( x : T , y : T ) -> T ;
649
+ /// Returns the remainder of an unchecked division, resulting in
650
+ /// undefined behavior where y = 0 or x = `T::min_value()` and y = -1
651
+ #[ cfg( not( stage0) ) ]
652
+ pub fn unchecked_rem < T > ( x : T , y : T ) -> T ;
653
+
654
+ /// Returns (a + b) mod 2^N, where N is the width of T in bits.
583
655
pub fn overflowing_add < T > ( a : T , b : T ) -> T ;
584
- /// Returns (a - b) mod 2^N, where N is the width of N in bits.
656
+ /// Returns (a - b) mod 2^N, where N is the width of T in bits.
585
657
pub fn overflowing_sub < T > ( a : T , b : T ) -> T ;
586
- /// Returns (a * b) mod 2^N, where N is the width of N in bits.
658
+ /// Returns (a * b) mod 2^N, where N is the width of T in bits.
587
659
pub fn overflowing_mul < T > ( a : T , b : T ) -> T ;
588
660
589
- /// Performs an unchecked signed division, which results in undefined behavior,
590
- /// in cases where y == 0, or x == isize::MIN and y == -1
591
- pub fn unchecked_sdiv < T > ( x : T , y : T ) -> T ;
592
- /// Performs an unchecked unsigned division, which results in undefined behavior,
593
- /// in cases where y == 0
594
- pub fn unchecked_udiv < T > ( x : T , y : T ) -> T ;
595
-
596
- /// Returns the remainder of an unchecked signed division, which results in
597
- /// undefined behavior, in cases where y == 0, or x == isize::MIN and y == -1
598
- pub fn unchecked_srem < T > ( x : T , y : T ) -> T ;
599
- /// Returns the remainder of an unchecked unsigned division, which results in
600
- /// undefined behavior, in cases where y == 0
601
- pub fn unchecked_urem < T > ( x : T , y : T ) -> T ;
602
-
603
661
/// Returns the value of the discriminant for the variant in 'v',
604
662
/// cast to a `u64`; if `T` has no discriminant, returns 0.
605
663
pub fn discriminant_value < T > ( v : & T ) -> u64 ;
0 commit comments