~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/innobase/include/ut0byte.ic

  • Committer: Brian Aker
  • Date: 2008-09-04 19:31:00 UTC
  • Revision ID: brian@tangent.org-20080904193100-l849hgghfy4urj43
Changing default character set from this point on.

Show diffs side-by-side

added added

removed removed

Lines of Context:
52
52
}
53
53
 
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
56
56
integer type. */
57
57
UNIV_INLINE
58
 
ib_int64_t
 
58
ib_longlong
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 */
63
63
{
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));
66
66
}
67
67
 
68
68
/***********************************************************
261
261
}
262
262
 
263
263
/************************************************************
264
 
Rounds ib_uint64_t downward to a multiple of a power of 2. */
265
 
UNIV_INLINE
266
 
ib_uint64_t
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 */
273
 
{
274
 
        ut_ad(align_no > 0);
275
 
        ut_ad(ut_is_2pow(align_no));
276
 
 
277
 
        return(n & ~((ib_uint64_t) align_no - 1));
278
 
}
279
 
 
280
 
/************************************************************
281
 
Rounds ib_uint64_t upward to a multiple of a power of 2. */
282
 
UNIV_INLINE
283
 
ib_uint64_t
284
 
ut_uint64_align_up(
285
 
/*===============*/
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 */
290
 
{
291
 
        ib_uint64_t     align_1 = (ib_uint64_t) align_no - 1;
292
 
 
293
 
        ut_ad(align_no > 0);
294
 
        ut_ad(ut_is_2pow(align_no));
295
 
 
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. */
 
267
UNIV_INLINE
 
268
ulint
 
269
ut_calc_align(
 
270
/*==========*/
 
271
                                /* out: rounded value */
 
272
        ulint    n,             /* in: number to be rounded */
 
273
        ulint    align_no)      /* in: align by this number */
 
274
{
 
275
        ut_ad(align_no > 0);
 
276
        ut_ad(((align_no - 1) & align_no) == 0);
 
277
 
 
278
        return((n + align_no - 1) & ~(align_no - 1));
297
279
}
298
280
 
299
281
/*************************************************************
303
285
ut_align(
304
286
/*=====*/
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 */
308
290
{
309
291
        ut_ad(align_no > 0);
315
297
        return((void*)((((ulint)ptr) + align_no - 1) & ~(align_no - 1)));
316
298
}
317
299
 
 
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
 
303
power of 2. */
 
304
UNIV_INLINE
 
305
ulint
 
306
ut_calc_align_down(
 
307
/*===============*/
 
308
                                /* out: rounded value */
 
309
        ulint    n,              /* in: number to be rounded */
 
310
        ulint    align_no)       /* in: align by this number */
 
311
{
 
312
        ut_ad(align_no > 0);
 
313
        ut_ad(((align_no - 1) & align_no) == 0);
 
314
 
 
315
        return(n & ~(align_no - 1));
 
316
}
 
317
 
318
318
/*************************************************************
319
319
The following function rounds down a pointer to the nearest
320
320
aligned address. */
322
322
void*
323
323
ut_align_down(
324
324
/*==========*/
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 */
328
328
{
329
329
        ut_ad(align_no > 0);
330
330
        ut_ad(((align_no - 1) & align_no) == 0);