~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/innobase/include/ut0rnd.h

Merge of Jay

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/**********************************************************************
2
 
Random numbers and hashing
3
 
 
4
 
(c) 1994, 1995 Innobase Oy
5
 
 
6
 
Created 1/20/1994 Heikki Tuuri
7
 
***********************************************************************/
8
 
 
9
 
#ifndef ut0rnd_h
10
 
#define ut0rnd_h
11
 
 
12
 
#include "univ.i"
13
 
 
14
 
#include "ut0byte.h"
15
 
 
16
 
/* The 'character code' for end of field or string (used
17
 
in folding records */
18
 
#define UT_END_OF_FIELD         257
19
 
 
20
 
/************************************************************
21
 
This is used to set the random number seed. */
22
 
UNIV_INLINE
23
 
void
24
 
ut_rnd_set_seed(
25
 
/*============*/
26
 
        ulint    seed);          /* in: seed */
27
 
/************************************************************
28
 
The following function generates a series of 'random' ulint integers. */
29
 
UNIV_INLINE
30
 
ulint
31
 
ut_rnd_gen_next_ulint(
32
 
/*==================*/
33
 
                        /* out: the next 'random' number */
34
 
        ulint   rnd);   /* in: the previous random number value */
35
 
/*************************************************************
36
 
The following function generates 'random' ulint integers which
37
 
enumerate the value space (let there be N of them) of ulint integers
38
 
in a pseudo-random fashion. Note that the same integer is repeated
39
 
always after N calls to the generator. */
40
 
UNIV_INLINE
41
 
ulint
42
 
ut_rnd_gen_ulint(void);
43
 
/*==================*/
44
 
                        /* out: the 'random' number */
45
 
/************************************************************
46
 
Generates a random integer from a given interval. */
47
 
UNIV_INLINE
48
 
ulint
49
 
ut_rnd_interval(
50
 
/*============*/
51
 
                        /* out: the 'random' number */
52
 
        ulint   low,    /* in: low limit; can generate also this value */
53
 
        ulint   high);  /* in: high limit; can generate also this value */
54
 
/*************************************************************
55
 
Generates a random iboolean value. */
56
 
UNIV_INLINE
57
 
ibool
58
 
ut_rnd_gen_ibool(void);
59
 
/*=================*/
60
 
                        /* out: the random value */
61
 
/***********************************************************
62
 
The following function generates a hash value for a ulint integer
63
 
to a hash table of size table_size, which should be a prime or some
64
 
random number to work reliably. */
65
 
UNIV_INLINE
66
 
ulint
67
 
ut_hash_ulint(
68
 
/*==========*/
69
 
                                /* out: hash value */
70
 
        ulint    key,           /* in: value to be hashed */
71
 
        ulint    table_size);   /* in: hash table size */
72
 
/*****************************************************************
73
 
Folds a pair of ulints. */
74
 
UNIV_INLINE
75
 
ulint
76
 
ut_fold_ulint_pair(
77
 
/*===============*/
78
 
                        /* out: folded value */
79
 
        ulint   n1,     /* in: ulint */
80
 
        ulint   n2);    /* in: ulint */
81
 
/*****************************************************************
82
 
Folds a dulint. */
83
 
UNIV_INLINE
84
 
ulint
85
 
ut_fold_dulint(
86
 
/*===========*/
87
 
                        /* out: folded value */
88
 
        dulint  d);     /* in: dulint */
89
 
/*****************************************************************
90
 
Folds a character string ending in the null character. */
91
 
UNIV_INLINE
92
 
ulint
93
 
ut_fold_string(
94
 
/*===========*/
95
 
                                /* out: folded value */
96
 
        const char*     str);   /* in: null-terminated string */
97
 
/*****************************************************************
98
 
Folds a binary string. */
99
 
UNIV_INLINE
100
 
ulint
101
 
ut_fold_binary(
102
 
/*===========*/
103
 
                                /* out: folded value */
104
 
        const byte*     str,    /* in: string of bytes */
105
 
        ulint           len);   /* in: length */
106
 
/***************************************************************
107
 
Looks for a prime number slightly greater than the given argument.
108
 
The prime is chosen so that it is not near any power of 2. */
109
 
 
110
 
ulint
111
 
ut_find_prime(
112
 
/*==========*/
113
 
                        /* out: prime */
114
 
        ulint    n);     /* in: positive number > 100 */
115
 
 
116
 
 
117
 
#ifndef UNIV_NONINL
118
 
#include "ut0rnd.ic"
119
 
#endif
120
 
 
121
 
#endif