54
54
/***********************************************************
55
Converts a dulint (a struct of 2 ulints) to ib_int64_t, which is a 64-bit
55
Converts a dulint (a struct of 2 ulints) to ib_longlong, which is a 64-bit
59
59
ut_conv_dulint_to_longlong(
60
60
/*=======================*/
61
/* out: value in ib_int64_t type */
61
/* out: value in ib_longlong type */
62
62
dulint d) /* in: dulint */
64
return((ib_int64_t)d.low
65
+ (((ib_int64_t)d.high) << 32));
64
return((ib_longlong)d.low
65
+ (((ib_longlong)d.high) << 32));
68
68
/***********************************************************
263
263
/************************************************************
264
Rounds ib_uint64_t downward to a multiple of a power of 2. */
267
ut_uint64_align_down(
268
/*=================*/
269
/* out: rounded value */
270
ib_uint64_t n, /* in: number to be rounded */
271
ulint align_no) /* in: align by this number
272
which must be a power of 2 */
275
ut_ad(ut_is_2pow(align_no));
277
return(n & ~((ib_uint64_t) align_no - 1));
280
/************************************************************
281
Rounds ib_uint64_t upward to a multiple of a power of 2. */
286
/* out: rounded value */
287
ib_uint64_t n, /* in: number to be rounded */
288
ulint align_no) /* in: align by this number
289
which must be a power of 2 */
291
ib_uint64_t align_1 = (ib_uint64_t) align_no - 1;
294
ut_ad(ut_is_2pow(align_no));
296
return((n + align_1) & ~align_1);
264
The following function calculates the value of an integer n rounded
265
to the least product of align_no which is >= n. align_no
266
has to be a power of 2. */
271
/* out: rounded value */
272
ulint n, /* in: number to be rounded */
273
ulint align_no) /* in: align by this number */
276
ut_ad(((align_no - 1) & align_no) == 0);
278
return((n + align_no - 1) & ~(align_no - 1));
299
281
/*************************************************************
305
287
/* out: aligned pointer */
306
void* ptr, /* in: pointer */
288
const void* ptr, /* in: pointer */
307
289
ulint align_no) /* in: align by this number */
309
291
ut_ad(align_no > 0);
315
297
return((void*)((((ulint)ptr) + align_no - 1) & ~(align_no - 1)));
300
/************************************************************
301
The following function calculates the value of an integer n rounded
302
to the biggest product of align_no which is <= n. align_no has to be a
308
/* out: rounded value */
309
ulint n, /* in: number to be rounded */
310
ulint align_no) /* in: align by this number */
313
ut_ad(((align_no - 1) & align_no) == 0);
315
return(n & ~(align_no - 1));
318
318
/*************************************************************
319
319
The following function rounds down a pointer to the nearest
320
320
aligned address. */
325
/* out: aligned pointer */
325
/* out: aligned pointer */
326
326
const void* ptr, /* in: pointer */
327
ulint align_no) /* in: align by this number */
327
ulint align_no) /* in: align by this number */
329
329
ut_ad(align_no > 0);
330
330
ut_ad(((align_no - 1) & align_no) == 0);