00001 00002 00008 00009 00011 // Precompiled Header 00012 #include "Stdafx.h" 00013 00014 using namespace IceCore; 00015 00017 00023 00024 udword IceCore::Alignment(udword address) 00025 { 00026 // Returns 0 for null addresses 00027 if(!address) return 0; 00028 00029 // Test all bits 00030 udword Align = 1; 00031 for(udword i=1;i<32;i++) 00032 { 00033 // Returns as soon as the alignment is broken 00034 if(address&Align) return Align; 00035 Align<<=1; 00036 } 00037 // Here all bits are null, except the highest one (else the address would be null) 00038 return Align; 00039 }