1
/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
3
This library is free software; you can redistribute it and/or
4
modify it under the terms of the GNU Library General Public
5
License as published by the Free Software Foundation; either
6
version 2 of the License, or (at your option) any later version.
8
This library is distributed in the hope that it will be useful,
9
but WITHOUT ANY WARRANTY; without even the implied warranty of
10
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
Library General Public License for more details.
13
You should have received a copy of the GNU Library General Public
14
License along with this library; if not, write to the Free
15
Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
19
Storing of values in high byte first order.
21
integer keys and file pointers are stored with high byte first to get
25
#define mi_sint2korr(A) (int16) (((int16) ((uchar) (A)[1])) +\
26
((int16) ((int16) (A)[0]) << 8))
27
#define mi_sint3korr(A) ((int32) ((((uchar) (A)[0]) & 128) ? \
28
(((uint32) 255L << 24) | \
29
(((uint32) (uchar) (A)[0]) << 16) |\
30
(((uint32) (uchar) (A)[1]) << 8) | \
31
((uint32) (uchar) (A)[2])) : \
32
(((uint32) (uchar) (A)[0]) << 16) |\
33
(((uint32) (uchar) (A)[1]) << 8) | \
34
((uint32) (uchar) (A)[2])))
35
#define mi_sint4korr(A) (int32) (((int32) ((uchar) (A)[3])) +\
36
(((int32) ((uchar) (A)[2]) << 8)) +\
37
(((int32) ((uchar) (A)[1]) << 16)) +\
38
(((int32) ((int16) (A)[0]) << 24)))
39
#define mi_sint8korr(A) (longlong) mi_uint8korr(A)
40
#define mi_uint2korr(A) (uint16) (((uint16) ((uchar) (A)[1])) +\
41
((uint16) ((uchar) (A)[0]) << 8))
42
#define mi_uint3korr(A) (uint32) (((uint32) ((uchar) (A)[2])) +\
43
(((uint32) ((uchar) (A)[1])) << 8) +\
44
(((uint32) ((uchar) (A)[0])) << 16))
45
#define mi_uint4korr(A) (uint32) (((uint32) ((uchar) (A)[3])) +\
46
(((uint32) ((uchar) (A)[2])) << 8) +\
47
(((uint32) ((uchar) (A)[1])) << 16) +\
48
(((uint32) ((uchar) (A)[0])) << 24))
49
#define mi_uint5korr(A) ((ulonglong)(((uint32) ((uchar) (A)[4])) +\
50
(((uint32) ((uchar) (A)[3])) << 8) +\
51
(((uint32) ((uchar) (A)[2])) << 16) +\
52
(((uint32) ((uchar) (A)[1])) << 24)) +\
53
(((ulonglong) ((uchar) (A)[0])) << 32))
54
#define mi_uint6korr(A) ((ulonglong)(((uint32) ((uchar) (A)[5])) +\
55
(((uint32) ((uchar) (A)[4])) << 8) +\
56
(((uint32) ((uchar) (A)[3])) << 16) +\
57
(((uint32) ((uchar) (A)[2])) << 24)) +\
58
(((ulonglong) (((uint32) ((uchar) (A)[1])) +\
59
(((uint32) ((uchar) (A)[0]) << 8)))) <<\
61
#define mi_uint7korr(A) ((ulonglong)(((uint32) ((uchar) (A)[6])) +\
62
(((uint32) ((uchar) (A)[5])) << 8) +\
63
(((uint32) ((uchar) (A)[4])) << 16) +\
64
(((uint32) ((uchar) (A)[3])) << 24)) +\
65
(((ulonglong) (((uint32) ((uchar) (A)[2])) +\
66
(((uint32) ((uchar) (A)[1])) << 8) +\
67
(((uint32) ((uchar) (A)[0])) << 16))) <<\
69
#define mi_uint8korr(A) ((ulonglong)(((uint32) ((uchar) (A)[7])) +\
70
(((uint32) ((uchar) (A)[6])) << 8) +\
71
(((uint32) ((uchar) (A)[5])) << 16) +\
72
(((uint32) ((uchar) (A)[4])) << 24)) +\
73
(((ulonglong) (((uint32) ((uchar) (A)[3])) +\
74
(((uint32) ((uchar) (A)[2])) << 8) +\
75
(((uint32) ((uchar) (A)[1])) << 16) +\
76
(((uint32) ((uchar) (A)[0])) << 24))) <<\
79
#define mi_int2store(T,A) { uint def_temp= (uint) (A) ;\
80
*((uchar*) ((T)+1))= (uchar)(def_temp); \
81
*((uchar*) ((T)+0))= (uchar)(def_temp >> 8); }
82
#define mi_int3store(T,A) { /*lint -save -e734 */\
83
ulong def_temp= (ulong) (A);\
84
*(((T)+2))=(char) (def_temp);\
85
*((T)+1)= (char) (def_temp >> 8);\
86
*((T)+0)= (char) (def_temp >> 16);\
88
#define mi_int4store(T,A) { ulong def_temp= (ulong) (A);\
89
*((T)+3)=(char) (def_temp);\
90
*((T)+2)=(char) (def_temp >> 8);\
91
*((T)+1)=(char) (def_temp >> 16);\
92
*((T)+0)=(char) (def_temp >> 24); }
93
#define mi_int5store(T,A) { ulong def_temp= (ulong) (A),\
94
def_temp2= (ulong) ((A) >> 32);\
95
*((T)+4)=(char) (def_temp);\
96
*((T)+3)=(char) (def_temp >> 8);\
97
*((T)+2)=(char) (def_temp >> 16);\
98
*((T)+1)=(char) (def_temp >> 24);\
99
*((T)+0)=(char) (def_temp2); }
100
#define mi_int6store(T,A) { ulong def_temp= (ulong) (A),\
101
def_temp2= (ulong) ((A) >> 32);\
102
*((T)+5)=(char) (def_temp);\
103
*((T)+4)=(char) (def_temp >> 8);\
104
*((T)+3)=(char) (def_temp >> 16);\
105
*((T)+2)=(char) (def_temp >> 24);\
106
*((T)+1)=(char) (def_temp2);\
107
*((T)+0)=(char) (def_temp2 >> 8); }
108
#define mi_int7store(T,A) { ulong def_temp= (ulong) (A),\
109
def_temp2= (ulong) ((A) >> 32);\
110
*((T)+6)=(char) (def_temp);\
111
*((T)+5)=(char) (def_temp >> 8);\
112
*((T)+4)=(char) (def_temp >> 16);\
113
*((T)+3)=(char) (def_temp >> 24);\
114
*((T)+2)=(char) (def_temp2);\
115
*((T)+1)=(char) (def_temp2 >> 8);\
116
*((T)+0)=(char) (def_temp2 >> 16); }
117
#define mi_int8store(T,A) { ulong def_temp3= (ulong) (A), \
118
def_temp4= (ulong) ((A) >> 32); \
119
mi_int4store((T),def_temp4); \
120
mi_int4store((T+4),def_temp3); \
123
#ifdef WORDS_BIGENDIAN
125
#define mi_float4store(T,A) { *(T)= ((byte *) &A)[0];\
126
*((T)+1)=(char) ((byte *) &A)[1];\
127
*((T)+2)=(char) ((byte *) &A)[2];\
128
*((T)+3)=(char) ((byte *) &A)[3]; }
130
#define mi_float4get(V,M) { float def_temp;\
131
((byte*) &def_temp)[0]=(M)[0];\
132
((byte*) &def_temp)[1]=(M)[1];\
133
((byte*) &def_temp)[2]=(M)[2];\
134
((byte*) &def_temp)[3]=(M)[3];\
137
#define mi_float8store(T,V) { *(T)= ((byte *) &V)[0];\
138
*((T)+1)=(char) ((byte *) &V)[1];\
139
*((T)+2)=(char) ((byte *) &V)[2];\
140
*((T)+3)=(char) ((byte *) &V)[3];\
141
*((T)+4)=(char) ((byte *) &V)[4];\
142
*((T)+5)=(char) ((byte *) &V)[5];\
143
*((T)+6)=(char) ((byte *) &V)[6];\
144
*((T)+7)=(char) ((byte *) &V)[7]; }
146
#define mi_float8get(V,M) { double def_temp;\
147
((byte*) &def_temp)[0]=(M)[0];\
148
((byte*) &def_temp)[1]=(M)[1];\
149
((byte*) &def_temp)[2]=(M)[2];\
150
((byte*) &def_temp)[3]=(M)[3];\
151
((byte*) &def_temp)[4]=(M)[4];\
152
((byte*) &def_temp)[5]=(M)[5];\
153
((byte*) &def_temp)[6]=(M)[6];\
154
((byte*) &def_temp)[7]=(M)[7]; \
158
#define mi_float4store(T,A) { *(T)= ((byte *) &A)[3];\
159
*((T)+1)=(char) ((byte *) &A)[2];\
160
*((T)+2)=(char) ((byte *) &A)[1];\
161
*((T)+3)=(char) ((byte *) &A)[0]; }
163
#define mi_float4get(V,M) { float def_temp;\
164
((byte*) &def_temp)[0]=(M)[3];\
165
((byte*) &def_temp)[1]=(M)[2];\
166
((byte*) &def_temp)[2]=(M)[1];\
167
((byte*) &def_temp)[3]=(M)[0];\
170
#define mi_float8store(T,V) { *(T)= ((byte *) &V)[7];\
171
*((T)+1)=(char) ((byte *) &V)[6];\
172
*((T)+2)=(char) ((byte *) &V)[5];\
173
*((T)+3)=(char) ((byte *) &V)[4];\
174
*((T)+4)=(char) ((byte *) &V)[3];\
175
*((T)+5)=(char) ((byte *) &V)[2];\
176
*((T)+6)=(char) ((byte *) &V)[1];\
177
*((T)+7)=(char) ((byte *) &V)[0];}
179
#define mi_float8get(V,M) { double def_temp;\
180
((byte*) &def_temp)[0]=(M)[7];\
181
((byte*) &def_temp)[1]=(M)[6];\
182
((byte*) &def_temp)[2]=(M)[5];\
183
((byte*) &def_temp)[3]=(M)[4];\
184
((byte*) &def_temp)[4]=(M)[3];\
185
((byte*) &def_temp)[5]=(M)[2];\
186
((byte*) &def_temp)[6]=(M)[1];\
187
((byte*) &def_temp)[7]=(M)[0];\
191
/* Fix to avoid warnings when sizeof(ha_rows) == sizeof(long) */
194
#define mi_rowstore(T,A) mi_int8store(T,A)
195
#define mi_rowkorr(T,A) mi_uint8korr(T)
197
#define mi_rowstore(T,A) { mi_int4store(T,0); mi_int4store(((T)+4),A); }
198
#define mi_rowkorr(T) mi_uint4korr((T)+4)
202
#define mi_sizestore(T,A) mi_int8store(T,A)
203
#define mi_sizekorr(T) mi_uint8korr(T)
205
#define mi_sizestore(T,A) { if ((A) == HA_OFFSET_ERROR) bfill((char*) (T),8,255); else { mi_int4store((T),0); mi_int4store(((T)+4),A); }}
206
#define mi_sizekorr(T) mi_uint4korr((T)+4)