Vegastrike 0.5.1 rc1  1.0
Original sources for Vegastrike Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
IceUtils.cpp
Go to the documentation of this file.
1 
8 
11 // Precompiled Header
12 #include "Stdafx.h"
13 
14 
15 using namespace Opcode;
16 
18 
24 udword Alignment(udword address)
26 {
27  // Returns 0 for null addresses
28  if(!address) return 0;
29 
30  // Test all bits
31  udword Align = 1;
32  for(udword i=1;i<32;i++)
33  {
34  // Returns as soon as the alignment is broken
35  if(address&Align) return Align;
36  Align<<=1;
37  }
38  // Here all bits are null, except the highest one (else the address would be null)
39  return Align;
40 }
41