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