forked from mosa/MOSA-Project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAlignment.cs
37 lines (31 loc) · 995 Bytes
/
Alignment.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Copyright (c) MOSA Project. Licensed under the New BSD License.
namespace Mosa.Compiler.Common
{
public static class Alignment
{
public static uint AlignUp(uint position, uint alignment)
{
return position + ((alignment - (position % alignment)) % alignment);
}
public static int AlignUp(int position, int alignment)
{
return position + ((alignment - (position % alignment)) % alignment);
}
public static ulong AlignUp(ulong position, uint alignment)
{
return position + ((alignment - (position % alignment)) % alignment);
}
public static uint AlignDown(uint position, uint alignment)
{
return position - ((alignment - (position % alignment)) % alignment);
}
public static int AlignDown(int position, int alignment)
{
return position - ((alignment - (position % alignment)) % alignment);
}
public static ulong AlignDown(ulong position, uint alignment)
{
return position - ((alignment - (position % alignment)) % alignment);
}
}
}