~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/innobase/include/ut0byte.h

  • Committer: Brian Aker
  • Date: 2009-08-04 06:21:17 UTC
  • mfrom: (1108.2.2 merge)
  • Revision ID: brian@gaz-20090804062117-fef8x6y3ydzrvab3
Merge Brian

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*****************************************************************************
2
 
 
3
 
Copyright (C) 1994, 2009, Innobase Oy. All Rights Reserved.
4
 
 
5
 
This program is free software; you can redistribute it and/or modify it under
6
 
the terms of the GNU General Public License as published by the Free Software
7
 
Foundation; version 2 of the License.
8
 
 
9
 
This program is distributed in the hope that it will be useful, but WITHOUT
10
 
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11
 
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12
 
 
13
 
You should have received a copy of the GNU General Public License along with
14
 
this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
15
 
St, Fifth Floor, Boston, MA 02110-1301 USA
16
 
 
17
 
*****************************************************************************/
18
 
 
19
 
/******************************************************************//**
20
 
@file include/ut0byte.h
21
 
Utilities for byte operations
22
 
 
23
 
Created 1/20/1994 Heikki Tuuri
24
 
***********************************************************************/
25
 
 
26
 
#ifndef ut0byte_h
27
 
#define ut0byte_h
28
 
 
29
 
 
30
 
 
31
 
#include "univ.i"
32
 
 
33
 
/*******************************************************//**
34
 
Creates a 64-bit integer out of two 32-bit integers.
35
 
@return created dulint */
36
 
UNIV_INLINE
37
 
ib_uint64_t
38
 
ut_ull_create(
39
 
/*==========*/
40
 
        ulint   high,   /*!< in: high-order 32 bits */
41
 
        ulint   low)    /*!< in: low-order 32 bits */
42
 
        __attribute__((const));
43
 
 
44
 
/********************************************************//**
45
 
Rounds a 64-bit integer downward to a multiple of a power of 2.
46
 
@return rounded value */
47
 
UNIV_INLINE
48
 
ib_uint64_t
49
 
ut_uint64_align_down(
50
 
/*=================*/
51
 
        ib_uint64_t      n,             /*!< in: number to be rounded */
52
 
        ulint            align_no);     /*!< in: align by this number
53
 
                                        which must be a power of 2 */
54
 
/********************************************************//**
55
 
Rounds ib_uint64_t upward to a multiple of a power of 2.
56
 
@return rounded value */
57
 
UNIV_INLINE
58
 
ib_uint64_t
59
 
ut_uint64_align_up(
60
 
/*===============*/
61
 
        ib_uint64_t      n,             /*!< in: number to be rounded */
62
 
        ulint            align_no);     /*!< in: align by this number
63
 
                                        which must be a power of 2 */
64
 
/*********************************************************//**
65
 
The following function rounds up a pointer to the nearest aligned address.
66
 
@return aligned pointer */
67
 
UNIV_INLINE
68
 
void*
69
 
ut_align(
70
 
/*=====*/
71
 
        const void*     ptr,            /*!< in: pointer */
72
 
        ulint           align_no);      /*!< in: align by this number */
73
 
/*********************************************************//**
74
 
The following function rounds down a pointer to the nearest
75
 
aligned address.
76
 
@return aligned pointer */
77
 
UNIV_INLINE
78
 
void*
79
 
ut_align_down(
80
 
/*==========*/
81
 
        const void*     ptr,            /*!< in: pointer */
82
 
        ulint           align_no)       /*!< in: align by this number */
83
 
                __attribute__((const));
84
 
/*********************************************************//**
85
 
The following function computes the offset of a pointer from the nearest
86
 
aligned address.
87
 
@return distance from aligned pointer */
88
 
UNIV_INLINE
89
 
ulint
90
 
ut_align_offset(
91
 
/*============*/
92
 
        const void*     ptr,            /*!< in: pointer */
93
 
        ulint           align_no)       /*!< in: align by this number */
94
 
                        __attribute__((const));
95
 
/*****************************************************************//**
96
 
Gets the nth bit of a ulint.
97
 
@return TRUE if nth bit is 1; 0th bit is defined to be the least significant */
98
 
UNIV_INLINE
99
 
ibool
100
 
ut_bit_get_nth(
101
 
/*===========*/
102
 
        ulint   a,      /*!< in: ulint */
103
 
        ulint   n);     /*!< in: nth bit requested */
104
 
/*****************************************************************//**
105
 
Sets the nth bit of a ulint.
106
 
@return the ulint with the bit set as requested */
107
 
UNIV_INLINE
108
 
ulint
109
 
ut_bit_set_nth(
110
 
/*===========*/
111
 
        ulint   a,      /*!< in: ulint */
112
 
        ulint   n,      /*!< in: nth bit requested */
113
 
        ibool   val);   /*!< in: value for the bit to set */
114
 
 
115
 
#ifndef UNIV_NONINL
116
 
#include "ut0byte.ic"
117
 
#endif
118
 
 
119
 
#endif