33
/*******************************************************//**
34
Creates a 64-bit integer out of two 32-bit integers.
35
@return created dulint */
40
ulint high, /*!< in: high-order 32 bits */
41
ulint low) /*!< in: low-order 32 bits */
42
__attribute__((const));
44
/********************************************************//**
45
Rounds a 64-bit integer downward to a multiple of a power of 2.
46
@return rounded value */
31
/* Type definition for a 64-bit unsigned integer, which works also
32
in 32-bit machines. NOTE! Access the fields only with the accessor
33
functions. This definition appears here only for the compiler to
34
know the size of a dulint. */
36
typedef struct dulint_struct dulint;
38
ulint high; /* most significant 32 bits */
39
ulint low; /* least significant 32 bits */
42
/* Zero value for a dulint */
43
extern const dulint ut_dulint_zero;
45
/* Maximum value for a dulint */
46
extern const dulint ut_dulint_max;
48
/***********************************************************
49
Creates a 64-bit dulint out of two ulints. */
54
/* out: created dulint */
55
ulint high, /* in: high-order 32 bits */
56
ulint low); /* in: low-order 32 bits */
57
/***********************************************************
58
Gets the high-order 32 bits of a dulint. */
63
/* out: 32 bits in ulint */
64
dulint d); /* in: dulint */
65
/***********************************************************
66
Gets the low-order 32 bits of a dulint. */
71
/* out: 32 bits in ulint */
72
dulint d); /* in: dulint */
73
/***********************************************************
74
Converts a dulint (a struct of 2 ulints) to ib_int64_t, which is a 64-bit
78
ut_conv_dulint_to_longlong(
79
/*=======================*/
80
/* out: value in ib_int64_t type */
81
dulint d); /* in: dulint */
82
/***********************************************************
83
Tests if a dulint is zero. */
88
/* out: TRUE if zero */
89
dulint a); /* in: dulint */
90
/***********************************************************
91
Compares two dulints. */
96
/* out: -1 if a < b, 0 if a == b,
98
dulint a, /* in: dulint */
99
dulint b); /* in: dulint */
100
/***********************************************************
101
Calculates the max of two dulints. */
107
dulint a, /* in: dulint */
108
dulint b); /* in: dulint */
109
/***********************************************************
110
Calculates the min of two dulints. */
116
dulint a, /* in: dulint */
117
dulint b); /* in: dulint */
118
/***********************************************************
119
Adds a ulint to a dulint. */
125
dulint a, /* in: dulint */
126
ulint b); /* in: ulint */
127
/***********************************************************
128
Subtracts a ulint from a dulint. */
134
dulint a, /* in: dulint */
135
ulint b); /* in: ulint, b <= a */
136
/***********************************************************
137
Subtracts a dulint from another. NOTE that the difference must be positive
138
and smaller that 4G. */
144
dulint a, /* in: dulint; NOTE a must be >= b and at most
145
2 to power 32 - 1 greater */
146
dulint b); /* in: dulint */
147
/************************************************************
148
Rounds a dulint downward to a multiple of a power of 2. */
151
ut_dulint_align_down(
152
/*=================*/
153
/* out: rounded value */
154
dulint n, /* in: number to be rounded */
155
ulint align_no); /* in: align by this number which must be a
157
/************************************************************
158
Rounds a dulint upward to a multiple of a power of 2. */
163
/* out: rounded value */
164
dulint n, /* in: number to be rounded */
165
ulint align_no); /* in: align by this number which must be a
167
/************************************************************
168
Rounds a dulint downward to a multiple of a power of 2. */
49
171
ut_uint64_align_down(
50
172
/*=================*/
51
ib_uint64_t n, /*!< in: number to be rounded */
52
ulint align_no); /*!< in: align by this number
173
/* out: rounded value */
174
ib_uint64_t n, /* in: number to be rounded */
175
ulint align_no); /* in: align by this number
53
176
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 */
177
/************************************************************
178
Rounds ib_uint64_t upward to a multiple of a power of 2. */
59
181
ut_uint64_align_up(
60
182
/*===============*/
61
ib_uint64_t n, /*!< in: number to be rounded */
62
ulint align_no); /*!< in: align by this number
183
/* out: rounded value */
184
ib_uint64_t n, /* in: number to be rounded */
185
ulint align_no); /* in: align by this number
63
186
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 */
187
/***********************************************************
188
Increments a dulint variable by 1. */
189
#define UT_DULINT_INC(D)\
191
if ((D).low == 0xFFFFFFFFUL) {\
192
(D).high = (D).high + 1;\
195
(D).low = (D).low + 1;\
198
/***********************************************************
199
Tests if two dulints are equal. */
200
#define UT_DULINT_EQ(D1, D2) (((D1).low == (D2).low)\
201
&& ((D1).high == (D2).high))
203
/****************************************************************
204
Sort function for dulint arrays. */
207
ut_dulint_sort(dulint* arr, dulint* aux_arr, ulint low, ulint high);
208
/*===============================================================*/
209
#endif /* notdefined */
211
/*************************************************************
212
The following function rounds up a pointer to the nearest aligned address. */
71
const void* ptr, /*!< in: pointer */
72
ulint align_no); /*!< in: align by this number */
73
/*********************************************************//**
217
/* out: aligned pointer */
218
void* ptr, /* in: pointer */
219
ulint align_no); /* in: align by this number */
220
/*************************************************************
74
221
The following function rounds down a pointer to the nearest
76
@return aligned pointer */
81
const void* ptr, /*!< in: pointer */
82
ulint align_no) /*!< in: align by this number */
83
__attribute__((const));
84
/*********************************************************//**
227
/* out: aligned pointer */
228
const void* ptr, /* in: pointer */
229
ulint align_no) /* in: align by this number */
230
__attribute__((__const__));
231
/*************************************************************
85
232
The following function computes the offset of a pointer from the nearest
87
@return distance from aligned pointer */
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 */
238
/* out: distance from aligned
240
const void* ptr, /* in: pointer */
241
ulint align_no) /* in: align by this number */
242
__attribute__((__const__));
243
/*********************************************************************
244
Gets the nth bit of a ulint. */
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 */
249
/* out: TRUE if nth bit is 1; 0th bit is defined to
250
be the least significant */
251
ulint a, /* in: ulint */
252
ulint n); /* in: nth bit requested */
253
/*********************************************************************
254
Sets the nth bit of a ulint. */
111
ulint a, /*!< in: ulint */
112
ulint n, /*!< in: nth bit requested */
113
ibool val); /*!< in: value for the bit to set */
259
/* out: the ulint with the bit set as requested */
260
ulint a, /* in: ulint */
261
ulint n, /* in: nth bit requested */
262
ibool val); /* in: value for the bit to set */
115
264
#ifndef UNIV_NONINL
116
265
#include "ut0byte.ic"