1
/*****************************************************************************
3
Copyright (c) 1994, 2009, Innobase Oy. All Rights Reserved.
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.
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.
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., 59 Temple
15
Place, Suite 330, Boston, MA 02111-1307 USA
17
*****************************************************************************/
19
/******************************************************************//**
20
@file include/ut0rnd.h
21
Random numbers and hashing
23
Created 1/20/1994 Heikki Tuuri
24
***********************************************************************/
33
/** The 'character code' for end of field or string (used
35
#define UT_END_OF_FIELD 257
37
/********************************************************//**
38
This is used to set the random number seed. */
43
ulint seed); /*!< in: seed */
44
/********************************************************//**
45
The following function generates a series of 'random' ulint integers.
46
@return the next 'random' number */
49
ut_rnd_gen_next_ulint(
50
/*==================*/
51
ulint rnd); /*!< in: the previous random number value */
52
/*********************************************************//**
53
The following function generates 'random' ulint integers which
54
enumerate the value space (let there be N of them) of ulint integers
55
in a pseudo-random fashion. Note that the same integer is repeated
56
always after N calls to the generator.
57
@return the 'random' number */
60
ut_rnd_gen_ulint(void);
61
/*==================*/
62
/********************************************************//**
63
Generates a random integer from a given interval.
64
@return the 'random' number */
69
ulint low, /*!< in: low limit; can generate also this value */
70
ulint high); /*!< in: high limit; can generate also this value */
71
/*********************************************************//**
72
Generates a random iboolean value.
73
@return the random value */
76
ut_rnd_gen_ibool(void);
78
/*******************************************************//**
79
The following function generates a hash value for a ulint integer
80
to a hash table of size table_size, which should be a prime or some
81
random number to work reliably.
87
ulint key, /*!< in: value to be hashed */
88
ulint table_size); /*!< in: hash table size */
89
/*************************************************************//**
90
Folds a pair of ulints.
91
@return folded value */
96
ulint n1, /*!< in: ulint */
97
ulint n2) /*!< in: ulint */
98
__attribute__((const));
99
/*************************************************************//**
101
@return folded value */
106
dulint d) /*!< in: dulint */
107
__attribute__((const));
108
/*************************************************************//**
109
Folds a character string ending in the null character.
110
@return folded value */
115
const char* str) /*!< in: null-terminated string */
116
__attribute__((pure));
117
/*************************************************************//**
118
Folds a binary string.
119
@return folded value */
124
const byte* str, /*!< in: string of bytes */
125
ulint len) /*!< in: length */
126
__attribute__((pure));
127
/***********************************************************//**
128
Looks for a prime number slightly greater than the given argument.
129
The prime is chosen so that it is not near any power of 2.
135
ulint n) /*!< in: positive number > 100 */
136
__attribute__((const));