diff options
Diffstat (limited to 'gdb/common/common-utils.c')
-rw-r--r-- | gdb/common/common-utils.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/gdb/common/common-utils.c b/gdb/common/common-utils.c index 80de826..8d839d1 100644 --- a/gdb/common/common-utils.c +++ b/gdb/common/common-utils.c @@ -440,3 +440,23 @@ is_regular_file (const char *name, int *errno_ptr) *errno_ptr = EINVAL; return false; } + +/* See common/common-utils.h. */ + +ULONGEST +align_up (ULONGEST v, int n) +{ + /* Check that N is really a power of two. */ + gdb_assert (n && (n & (n-1)) == 0); + return (v + n - 1) & -n; +} + +/* See common/common-utils.h. */ + +ULONGEST +align_down (ULONGEST v, int n) +{ + /* Check that N is really a power of two. */ + gdb_assert (n && (n & (n-1)) == 0); + return (v & -n); +} |