pub fn check_align(&self, ptr: Scalar, required_align: Align) -> EvalResult<'tcx> {
        // Check non-NULL/Undef, extract offset
        let (offset, alloc_align) = match ptr {
            Scalar::Ptr(ptr) => {
                let alloc = self.get(ptr.alloc_id)?;
                (ptr.offset.bytes(), alloc.align)
            }
            Scalar::Bits { bits, size } => {
                assert_eq!(size as u64, self.pointer_size().bytes());
                // FIXME: what on earth does this line do? docs or fix needed!
                let v = ((bits as u128) % (1 << self.pointer_size().bytes())) as u64;
                if v == 0 {
                    return err!(InvalidNullPointerUsage);
                }
                // the base address if the "integer allocation" is 0 and hence always aligned
                (v, required_align)
            }
        };
        // Check alignment
        if alloc_align.abi() < required_align.abi() {
            return err!(AlignmentCheckFailed {
                has: alloc_align,
                required: required_align,
            });
        }
        if offset % required_align.abi() == 0 {
            Ok(())
        } else {
            let has = offset % required_align.abi();
            err!(AlignmentCheckFailed {
                has: Align::from_bytes(has, has).unwrap(),
                required: required_align,
            })
        }
    }
/// Check that the pointer is aligned AND non-NULL.
Check that the pointer is aligned AND non-NULL.
Check that the pointer is aligned AND non - NULL .
pub fn check_align(&self, ptr: Scalar, required_align: Align) -> EvalResult<'tcx> {
        // Check non-NULL/Undef, extract offset
        let (offset, alloc_align) = match ptr {
            Scalar::Ptr(ptr) => {
                let alloc = self.get(ptr.alloc_id)?;
                (ptr.offset.bytes(), alloc.align)
            }
            Scalar::Bits { bits, size } => {
                assert_eq!(size as u64, self.pointer_size().bytes());
                // FIXME: what on earth does this line do? docs or fix needed!
                let v = ((bits as u128) % (1 << self.pointer_size().bytes())) as u64;
                if v == 0 {
                    return err!(InvalidNullPointerUsage);
                }
                // the base address if the "integer allocation" is 0 and hence always aligned
                (v, required_align)
            }
        };
        // Check alignment
        if alloc_align.abi() < required_align.abi() {
            return err!(AlignmentCheckFailed {
                has: alloc_align,
                required: required_align,
            });
        }
        if offset % required_align.abi() == 0 {
            Ok(())
        } else {
            let has = offset % required_align.abi();
            err!(AlignmentCheckFailed {
                has: Align::from_bytes(has, has).unwrap(),
                required: required_align,
            })
        }
    }
pub fn check_align ( & self , ptr : Scalar , required_align : Align ) -> EvalResult < ' tcx > { // Check non-NULL/Undef, extract offset let ( offset , alloc_align ) = match ptr { Scalar :: Ptr ( ptr ) => { let alloc = self . get ( ptr . alloc_id ) ? ; ( ptr . offset . bytes ( ) , alloc . align ) } Scalar :: Bits { bits , size } => { assert_eq ! ( size as u64 self pointer_size ( ) bytes ( ) ) ; // FIXME: what on earth does this line do? docs or fix needed! let v = ( ( bits as u128 ) % ( 1 << self . pointer_size ( ) . bytes ( ) ) ) as u64 ; if v == 0 { return err ! ( InvalidNullPointerUsage ) ; } // the base address if the "integer allocation" is 0 and hence always aligned ( v , required_align ) } } ; // Check alignment if alloc_align . abi ( ) < required_align . abi ( ) { return err ! ( AlignmentCheckFailed { has alloc_align required required_align } ) ; } if offset % required_align . abi ( ) == 0 { Ok ( ( ) ) } else { let has = offset % required_align . abi ( ) ; err ! ( AlignmentCheckFailed { has Align from_bytes ( has has ) unwrap ( ) required required_align } ) } }
Check that the pointer is aligned AND non-NULL.
Check that the pointer is aligned AND non - NULL .
&self
ptr
Scalar
required_align
Align