Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mariadb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
630a1fc0
Commit
630a1fc0
authored
Mar 05, 2008
by
marko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
branches/zip: Implement ut_calc_align() and ut_calc_align_down() as
type-independent macros.
parent
9be9363c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
60 deletions
+7
-60
include/ut0byte.h
include/ut0byte.h
+0
-22
include/ut0byte.ic
include/ut0byte.ic
+0
-36
include/ut0ut.h
include/ut0ut.h
+7
-2
No files found.
include/ut0byte.h
View file @
630a1fc0
...
...
@@ -192,28 +192,6 @@ ut_dulint_sort(dulint* arr, dulint* aux_arr, ulint low, ulint high);
/*===============================================================*/
#endif
/* notdefined */
/************************************************************
The following function calculates the value of an integer n rounded
to the least product of align_no which is >= n. align_no has to be a
power of 2. */
UNIV_INLINE
ulint
ut_calc_align
(
/*==========*/
/* out: rounded value */
ulint
n
,
/* in: number to be rounded */
ulint
align_no
);
/* in: align by this number */
/************************************************************
The following function calculates the value of an integer n rounded
to the biggest product of align_no which is <= n. align_no has to be a
power of 2. */
UNIV_INLINE
ulint
ut_calc_align_down
(
/*===============*/
/* out: rounded value */
ulint
n
,
/* in: number to be rounded */
ulint
align_no
);
/* in: align by this number */
/*************************************************************
The following function rounds up a pointer to the nearest aligned address. */
UNIV_INLINE
...
...
include/ut0byte.ic
View file @
630a1fc0
...
...
@@ -296,24 +296,6 @@ ut_uint64_align_up(
return((n + align_1) & ~align_1);
}
/************************************************************
The following function calculates the value of an integer n rounded
to the least product of align_no which is >= n. align_no
has to be a power of 2. */
UNIV_INLINE
ulint
ut_calc_align(
/*==========*/
/* out: rounded value */
ulint n, /* in: number to be rounded */
ulint align_no) /* in: align by this number */
{
ut_ad(align_no > 0);
ut_ad(ut_is_2pow(align_no));
return((n + align_no - 1) & ~(align_no - 1));
}
/*************************************************************
The following function rounds up a pointer to the nearest aligned address. */
UNIV_INLINE
...
...
@@ -333,24 +315,6 @@ ut_align(
return((void*)((((ulint)ptr) + align_no - 1) & ~(align_no - 1)));
}
/************************************************************
The following function calculates the value of an integer n rounded
to the biggest product of align_no which is <= n. align_no has to be a
power of 2. */
UNIV_INLINE
ulint
ut_calc_align_down(
/*===============*/
/* out: rounded value */
ulint n, /* in: number to be rounded */
ulint align_no) /* in: align by this number */
{
ut_ad(align_no > 0);
ut_ad(ut_is_2pow(align_no));
return(n & ~(align_no - 1));
}
/*************************************************************
The following function rounds down a pointer to the nearest
aligned address. */
...
...
include/ut0ut.h
View file @
630a1fc0
...
...
@@ -103,9 +103,14 @@ Determines if a number is zero or a power of two. */
Calculates fast the remainder of n/m when m is a power of two. */
#define ut_2pow_remainder(n, m) ((n) & ((m) - 1))
/*****************************************************************
Calculates
n rounded down to the nearest multiple of m
when m is a power of two. */
Calculates
the biggest multiple of m that is not bigger than n
when m is a power of two.
In other words, rounds n down to m * k.
*/
#define ut_2pow_round(n, m) ((n) & ~((m) - 1))
#define ut_calc_align_down(n, m) ut_2pow_round(n, m)
/************************************************************
Calculates the smallest multiple of m that is not smaller than n
when m is a power of two. In other words, rounds n up to m * k. */
#define ut_calc_align(n, m) (((n) + ((m) - 1)) & ~((m) - 1))
/*****************************************************************
Calculates fast the 2-logarithm of a number, rounded upward to an
integer. */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment