45
45
46
46
#![ allow( unsigned_negate) ]
47
47
48
- use libc:: c_ulonglong;
49
48
use std:: collections:: Map ;
50
49
use std:: num:: Int ;
51
50
use std:: rc:: Rc ;
@@ -132,7 +131,7 @@ pub struct Struct {
132
131
// If the struct is DST, then the size and alignment do not take into
133
132
// account the unsized fields of the struct.
134
133
pub size : u64 ,
135
- pub align : u64 ,
134
+ pub align : u32 ,
136
135
pub sized : bool ,
137
136
pub packed : bool ,
138
137
pub fields : Vec < ty:: t >
@@ -652,9 +651,7 @@ fn load_discr(bcx: Block, ity: IntType, ptr: ValueRef, min: Disr, max: Disr)
652
651
} else {
653
652
// llvm::ConstantRange can deal with ranges that wrap around,
654
653
// so an overflow on (max + 1) is fine.
655
- LoadRangeAssert ( bcx, ptr, min as c_ulonglong ,
656
- ( max + 1 ) as c_ulonglong ,
657
- /* signed: */ True )
654
+ LoadRangeAssert ( bcx, ptr, min, ( max+1 ) , /* signed: */ True )
658
655
}
659
656
}
660
657
@@ -973,11 +970,11 @@ fn compute_struct_field_offsets(ccx: &CrateContext, st: &Struct) -> Vec<u64> {
973
970
for & ty in st. fields . iter ( ) {
974
971
let llty = type_of:: sizing_type_of ( ccx, ty) ;
975
972
if !st. packed {
976
- let type_align = type_of:: align_of ( ccx, ty) as u64 ;
973
+ let type_align = type_of:: align_of ( ccx, ty) ;
977
974
offset = roundup ( offset, type_align) ;
978
975
}
979
976
offsets. push ( offset) ;
980
- offset += machine:: llsize_of_alloc ( ccx, llty) as u64 ;
977
+ offset += machine:: llsize_of_alloc ( ccx, llty) ;
981
978
}
982
979
assert_eq ! ( st. fields. len( ) , offsets. len( ) ) ;
983
980
offsets
@@ -1004,8 +1001,7 @@ fn build_const_struct(ccx: &CrateContext, st: &Struct, vals: &[ValueRef])
1004
1001
let mut cfields = Vec :: new ( ) ;
1005
1002
for ( & val, & target_offset) in vals. iter ( ) . zip ( target_offsets. iter ( ) ) {
1006
1003
if !st. packed {
1007
- let val_align = machine:: llalign_of_min ( ccx, val_ty ( val) )
1008
- /*bad*/ as u64 ;
1004
+ let val_align = machine:: llalign_of_min ( ccx, val_ty ( val) ) ;
1009
1005
offset = roundup ( offset, val_align) ;
1010
1006
}
1011
1007
if offset != target_offset {
@@ -1014,7 +1010,7 @@ fn build_const_struct(ccx: &CrateContext, st: &Struct, vals: &[ValueRef])
1014
1010
}
1015
1011
assert ! ( !is_undef( val) ) ;
1016
1012
cfields. push ( val) ;
1017
- offset += machine:: llsize_of_alloc ( ccx, val_ty ( val) ) as u64 ;
1013
+ offset += machine:: llsize_of_alloc ( ccx, val_ty ( val) ) ;
1018
1014
}
1019
1015
1020
1016
assert ! ( st. sized && offset <= st. size) ;
@@ -1031,7 +1027,7 @@ fn padding(ccx: &CrateContext, size: u64) -> ValueRef {
1031
1027
1032
1028
// FIXME this utility routine should be somewhere more general
1033
1029
#[ inline]
1034
- fn roundup ( x : u64 , a : u64 ) -> u64 { ( ( x + ( a - 1 ) ) / a) * a }
1030
+ fn roundup ( x : u64 , a : u32 ) -> u64 { let a = a as u64 ; ( ( x + ( a - 1 ) ) / a) * a }
1035
1031
1036
1032
/// Get the discriminant of a constant value. (Not currently used.)
1037
1033
pub fn const_get_discrim ( ccx : & CrateContext , r : & Repr , val : ValueRef )
0 commit comments