@@ -596,17 +596,34 @@ pub fn C_u64(ccx: &CrateContext, i: u64) -> ValueRef {
596
596
}
597
597
598
598
pub fn C_int < I : AsI64 > ( ccx : & CrateContext , i : I ) -> ValueRef {
599
- C_integral ( ccx. int_type ( ) , i. as_i64 ( ) as u64 , true )
599
+ let v = i. as_i64 ( ) ;
600
+
601
+ match machine:: llbitsize_of_real ( ccx. int_type ( ) ) {
602
+ 32 => assert ! ( v < ( 1 <<31 ) && v >= -( 1 <<31 ) ) ,
603
+ 64 => { } ,
604
+ n => fail ! ( "unsupported target size: {}" , n)
605
+ }
606
+
607
+ C_integral ( ccx. int_type ( ) , v as u64 , true )
600
608
}
601
609
602
610
pub fn C_uint < I : AsU64 > ( ccx : & CrateContext , i : I ) -> ValueRef {
603
- C_integral ( ccx. int_type ( ) , i. as_u64 ( ) , false )
611
+ let v = i. as_u64 ( ) ;
612
+
613
+ match machine:: llbitsize_of_real ( ccx. int_type ( ) ) {
614
+ 32 => assert ! ( v < ( 1 <<32 ) ) ,
615
+ 64 => { } ,
616
+ n => fail ! ( "unsupported target size: {}" , n)
617
+ }
618
+
619
+ C_integral ( ccx. int_type ( ) , v, false )
604
620
}
605
621
606
622
pub trait AsI64 { fn as_i64 ( self ) -> i64 ; }
607
623
pub trait AsU64 { fn as_u64 ( self ) -> u64 ; }
608
624
609
- // FIXME: remove the intptr conversions
625
+ // FIXME: remove the intptr conversions, because they
626
+ // are host-architecture-dependent
610
627
impl AsI64 for i64 { fn as_i64 ( self ) -> i64 { self as i64 } }
611
628
impl AsI64 for i32 { fn as_i64 ( self ) -> i64 { self as i64 } }
612
629
impl AsI64 for int { fn as_i64 ( self ) -> i64 { self as i64 } }
0 commit comments