Eneboo - Documentación para desarrolladores
|
00001 /* Copyright (C) 2000 MySQL AB 00002 00003 This program is free software; you can redistribute it and/or modify 00004 it under the terms of the GNU General Public License as published by 00005 the Free Software Foundation; either version 2 of the License, or 00006 (at your option) any later version. 00007 00008 This program is distributed in the hope that it will be useful, 00009 but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00011 GNU General Public License for more details. 00012 00013 You should have received a copy of the GNU General Public License 00014 along with this program; if not, write to the Free Software 00015 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ 00016 00017 /* 00018 Storing of values in high byte first order. 00019 00020 integer keys and file pointers are stored with high byte first to get 00021 better compression 00022 */ 00023 00024 /* these two are for uniformity */ 00025 #define mi_sint1korr(A) ((int8)(*A)) 00026 #define mi_uint1korr(A) ((uint8)(*A)) 00027 00028 #define mi_sint2korr(A) ((int16) (((int16) (((uchar*) (A))[1])) +\ 00029 ((int16) ((int16) ((char*) (A))[0]) << 8))) 00030 #define mi_sint3korr(A) ((int32) (((((uchar*) (A))[0]) & 128) ? \ 00031 (((uint32) 255L << 24) | \ 00032 (((uint32) ((uchar*) (A))[0]) << 16) |\ 00033 (((uint32) ((uchar*) (A))[1]) << 8) | \ 00034 ((uint32) ((uchar*) (A))[2])) : \ 00035 (((uint32) ((uchar*) (A))[0]) << 16) |\ 00036 (((uint32) ((uchar*) (A))[1]) << 8) | \ 00037 ((uint32) ((uchar*) (A))[2]))) 00038 #define mi_sint4korr(A) ((int32) (((int32) (((uchar*) (A))[3])) +\ 00039 ((int32) (((uchar*) (A))[2]) << 8) +\ 00040 ((int32) (((uchar*) (A))[1]) << 16) +\ 00041 ((int32) ((int16) ((char*) (A))[0]) << 24))) 00042 #define mi_sint8korr(A) ((longlong) mi_uint8korr(A)) 00043 #define mi_uint2korr(A) ((uint16) (((uint16) (((uchar*) (A))[1])) +\ 00044 ((uint16) (((uchar*) (A))[0]) << 8))) 00045 #define mi_uint3korr(A) ((uint32) (((uint32) (((uchar*) (A))[2])) +\ 00046 (((uint32) (((uchar*) (A))[1])) << 8) +\ 00047 (((uint32) (((uchar*) (A))[0])) << 16))) 00048 #define mi_uint4korr(A) ((uint32) (((uint32) (((uchar*) (A))[3])) +\ 00049 (((uint32) (((uchar*) (A))[2])) << 8) +\ 00050 (((uint32) (((uchar*) (A))[1])) << 16) +\ 00051 (((uint32) (((uchar*) (A))[0])) << 24))) 00052 #define mi_uint5korr(A) ((ulonglong)(((uint32) (((uchar*) (A))[4])) +\ 00053 (((uint32) (((uchar*) (A))[3])) << 8) +\ 00054 (((uint32) (((uchar*) (A))[2])) << 16) +\ 00055 (((uint32) (((uchar*) (A))[1])) << 24)) +\ 00056 (((ulonglong) (((uchar*) (A))[0])) << 32)) 00057 #define mi_uint6korr(A) ((ulonglong)(((uint32) (((uchar*) (A))[5])) +\ 00058 (((uint32) (((uchar*) (A))[4])) << 8) +\ 00059 (((uint32) (((uchar*) (A))[3])) << 16) +\ 00060 (((uint32) (((uchar*) (A))[2])) << 24)) +\ 00061 (((ulonglong) (((uint32) (((uchar*) (A))[1])) +\ 00062 (((uint32) (((uchar*) (A))[0]) << 8)))) <<\ 00063 32)) 00064 #define mi_uint7korr(A) ((ulonglong)(((uint32) (((uchar*) (A))[6])) +\ 00065 (((uint32) (((uchar*) (A))[5])) << 8) +\ 00066 (((uint32) (((uchar*) (A))[4])) << 16) +\ 00067 (((uint32) (((uchar*) (A))[3])) << 24)) +\ 00068 (((ulonglong) (((uint32) (((uchar*) (A))[2])) +\ 00069 (((uint32) (((uchar*) (A))[1])) << 8) +\ 00070 (((uint32) (((uchar*) (A))[0])) << 16))) <<\ 00071 32)) 00072 #define mi_uint8korr(A) ((ulonglong)(((uint32) (((uchar*) (A))[7])) +\ 00073 (((uint32) (((uchar*) (A))[6])) << 8) +\ 00074 (((uint32) (((uchar*) (A))[5])) << 16) +\ 00075 (((uint32) (((uchar*) (A))[4])) << 24)) +\ 00076 (((ulonglong) (((uint32) (((uchar*) (A))[3])) +\ 00077 (((uint32) (((uchar*) (A))[2])) << 8) +\ 00078 (((uint32) (((uchar*) (A))[1])) << 16) +\ 00079 (((uint32) (((uchar*) (A))[0])) << 24))) <<\ 00080 32)) 00081 00082 /* This one is for uniformity */ 00083 #define mi_int1store(T,A) *((uchar*)(T))= (uchar) (A) 00084 00085 #define mi_int2store(T,A) { uint def_temp= (uint) (A) ;\ 00086 ((uchar*) (T))[1]= (uchar) (def_temp);\ 00087 ((uchar*) (T))[0]= (uchar) (def_temp >> 8); } 00088 #define mi_int3store(T,A) { /*lint -save -e734 */\ 00089 ulong def_temp= (ulong) (A);\ 00090 ((uchar*) (T))[2]= (uchar) (def_temp);\ 00091 ((uchar*) (T))[1]= (uchar) (def_temp >> 8);\ 00092 ((uchar*) (T))[0]= (uchar) (def_temp >> 16);\ 00093 /*lint -restore */} 00094 #define mi_int4store(T,A) { ulong def_temp= (ulong) (A);\ 00095 ((uchar*) (T))[3]= (uchar) (def_temp);\ 00096 ((uchar*) (T))[2]= (uchar) (def_temp >> 8);\ 00097 ((uchar*) (T))[1]= (uchar) (def_temp >> 16);\ 00098 ((uchar*) (T))[0]= (uchar) (def_temp >> 24); } 00099 #define mi_int5store(T,A) { ulong def_temp= (ulong) (A),\ 00100 def_temp2= (ulong) ((A) >> 32);\ 00101 ((uchar*) (T))[4]= (uchar) (def_temp);\ 00102 ((uchar*) (T))[3]= (uchar) (def_temp >> 8);\ 00103 ((uchar*) (T))[2]= (uchar) (def_temp >> 16);\ 00104 ((uchar*) (T))[1]= (uchar) (def_temp >> 24);\ 00105 ((uchar*) (T))[0]= (uchar) (def_temp2); } 00106 #define mi_int6store(T,A) { ulong def_temp= (ulong) (A),\ 00107 def_temp2= (ulong) ((A) >> 32);\ 00108 ((uchar*) (T))[5]= (uchar) (def_temp);\ 00109 ((uchar*) (T))[4]= (uchar) (def_temp >> 8);\ 00110 ((uchar*) (T))[3]= (uchar) (def_temp >> 16);\ 00111 ((uchar*) (T))[2]= (uchar) (def_temp >> 24);\ 00112 ((uchar*) (T))[1]= (uchar) (def_temp2);\ 00113 ((uchar*) (T))[0]= (uchar) (def_temp2 >> 8); } 00114 #define mi_int7store(T,A) { ulong def_temp= (ulong) (A),\ 00115 def_temp2= (ulong) ((A) >> 32);\ 00116 ((uchar*) (T))[6]= (uchar) (def_temp);\ 00117 ((uchar*) (T))[5]= (uchar) (def_temp >> 8);\ 00118 ((uchar*) (T))[4]= (uchar) (def_temp >> 16);\ 00119 ((uchar*) (T))[3]= (uchar) (def_temp >> 24);\ 00120 ((uchar*) (T))[2]= (uchar) (def_temp2);\ 00121 ((uchar*) (T))[1]= (uchar) (def_temp2 >> 8);\ 00122 ((uchar*) (T))[0]= (uchar) (def_temp2 >> 16); } 00123 #define mi_int8store(T,A) { ulong def_temp3= (ulong) (A),\ 00124 def_temp4= (ulong) ((A) >> 32);\ 00125 mi_int4store((uchar*) (T) + 0, def_temp4);\ 00126 mi_int4store((uchar*) (T) + 4, def_temp3); } 00127 00128 #ifdef WORDS_BIGENDIAN 00129 00130 #define mi_float4store(T,A) { ((uchar*) (T))[0]= ((uchar*) &A)[0];\ 00131 ((uchar*) (T))[1]= ((uchar*) &A)[1];\ 00132 ((uchar*) (T))[2]= ((uchar*) &A)[2];\ 00133 ((uchar*) (T))[3]= ((uchar*) &A)[3]; } 00134 00135 #define mi_float4get(V,M) { float def_temp;\ 00136 ((uchar*) &def_temp)[0]= ((uchar*) (M))[0];\ 00137 ((uchar*) &def_temp)[1]= ((uchar*) (M))[1];\ 00138 ((uchar*) &def_temp)[2]= ((uchar*) (M))[2];\ 00139 ((uchar*) &def_temp)[3]= ((uchar*) (M))[3];\ 00140 (V)= def_temp; } 00141 00142 #define mi_float8store(T,V) { ((uchar*) (T))[0]= ((uchar*) &V)[0];\ 00143 ((uchar*) (T))[1]= ((uchar*) &V)[1];\ 00144 ((uchar*) (T))[2]= ((uchar*) &V)[2];\ 00145 ((uchar*) (T))[3]= ((uchar*) &V)[3];\ 00146 ((uchar*) (T))[4]= ((uchar*) &V)[4];\ 00147 ((uchar*) (T))[5]= ((uchar*) &V)[5];\ 00148 ((uchar*) (T))[6]= ((uchar*) &V)[6];\ 00149 ((uchar*) (T))[7]= ((uchar*) &V)[7]; } 00150 00151 #define mi_float8get(V,M) { double def_temp;\ 00152 ((uchar*) &def_temp)[0]= ((uchar*) (M))[0];\ 00153 ((uchar*) &def_temp)[1]= ((uchar*) (M))[1];\ 00154 ((uchar*) &def_temp)[2]= ((uchar*) (M))[2];\ 00155 ((uchar*) &def_temp)[3]= ((uchar*) (M))[3];\ 00156 ((uchar*) &def_temp)[4]= ((uchar*) (M))[4];\ 00157 ((uchar*) &def_temp)[5]= ((uchar*) (M))[5];\ 00158 ((uchar*) &def_temp)[6]= ((uchar*) (M))[6];\ 00159 ((uchar*) &def_temp)[7]= ((uchar*) (M))[7]; \ 00160 (V)= def_temp; } 00161 #else 00162 00163 #define mi_float4store(T,A) { ((uchar*) (T))[0]= ((uchar*) &A)[3];\ 00164 ((uchar*) (T))[1]= ((uchar*) &A)[2];\ 00165 ((uchar*) (T))[2]= ((uchar*) &A)[1];\ 00166 ((uchar*) (T))[3]= ((uchar*) &A)[0]; } 00167 00168 #define mi_float4get(V,M) { float def_temp;\ 00169 ((uchar*) &def_temp)[0]= ((uchar*) (M))[3];\ 00170 ((uchar*) &def_temp)[1]= ((uchar*) (M))[2];\ 00171 ((uchar*) &def_temp)[2]= ((uchar*) (M))[1];\ 00172 ((uchar*) &def_temp)[3]= ((uchar*) (M))[0];\ 00173 (V)= def_temp; } 00174 00175 #if defined(__FLOAT_WORD_ORDER) && (__FLOAT_WORD_ORDER == __BIG_ENDIAN) 00176 #define mi_float8store(T,V) { ((uchar*) (T))[0]= ((uchar*) &V)[3];\ 00177 ((uchar*) (T))[1]= ((uchar*) &V)[2];\ 00178 ((uchar*) (T))[2]= ((uchar*) &V)[1];\ 00179 ((uchar*) (T))[3]= ((uchar*) &V)[0];\ 00180 ((uchar*) (T))[4]= ((uchar*) &V)[7];\ 00181 ((uchar*) (T))[5]= ((uchar*) &V)[6];\ 00182 ((uchar*) (T))[6]= ((uchar*) &V)[5];\ 00183 ((uchar*) (T))[7]= ((uchar*) &V)[4];} 00184 00185 #define mi_float8get(V,M) { double def_temp;\ 00186 ((uchar*) &def_temp)[0]= ((uchar*) (M))[3];\ 00187 ((uchar*) &def_temp)[1]= ((uchar*) (M))[2];\ 00188 ((uchar*) &def_temp)[2]= ((uchar*) (M))[1];\ 00189 ((uchar*) &def_temp)[3]= ((uchar*) (M))[0];\ 00190 ((uchar*) &def_temp)[4]= ((uchar*) (M))[7];\ 00191 ((uchar*) &def_temp)[5]= ((uchar*) (M))[6];\ 00192 ((uchar*) &def_temp)[6]= ((uchar*) (M))[5];\ 00193 ((uchar*) &def_temp)[7]= ((uchar*) (M))[4];\ 00194 (V)= def_temp; } 00195 00196 #else 00197 #define mi_float8store(T,V) { ((uchar*) (T))[0]= ((uchar*) &V)[7];\ 00198 ((uchar*) (T))[1]= ((uchar*) &V)[6];\ 00199 ((uchar*) (T))[2]= ((uchar*) &V)[5];\ 00200 ((uchar*) (T))[3]= ((uchar*) &V)[4];\ 00201 ((uchar*) (T))[4]= ((uchar*) &V)[3];\ 00202 ((uchar*) (T))[5]= ((uchar*) &V)[2];\ 00203 ((uchar*) (T))[6]= ((uchar*) &V)[1];\ 00204 ((uchar*) (T))[7]= ((uchar*) &V)[0];} 00205 00206 #define mi_float8get(V,M) { double def_temp;\ 00207 ((uchar*) &def_temp)[0]= ((uchar*) (M))[7];\ 00208 ((uchar*) &def_temp)[1]= ((uchar*) (M))[6];\ 00209 ((uchar*) &def_temp)[2]= ((uchar*) (M))[5];\ 00210 ((uchar*) &def_temp)[3]= ((uchar*) (M))[4];\ 00211 ((uchar*) &def_temp)[4]= ((uchar*) (M))[3];\ 00212 ((uchar*) &def_temp)[5]= ((uchar*) (M))[2];\ 00213 ((uchar*) &def_temp)[6]= ((uchar*) (M))[1];\ 00214 ((uchar*) &def_temp)[7]= ((uchar*) (M))[0];\ 00215 (V)= def_temp; } 00216 #endif /* __FLOAT_WORD_ORDER */ 00217 #endif /* WORDS_BIGENDIAN */ 00218 00219 /* Fix to avoid warnings when sizeof(ha_rows) == sizeof(long) */ 00220 00221 #ifdef BIG_TABLES 00222 #define mi_rowstore(T,A) mi_int8store(T, A) 00223 #define mi_rowkorr(T) mi_uint8korr(T) 00224 #else 00225 #define mi_rowstore(T,A) { mi_int4store(T, 0);\ 00226 mi_int4store(((uchar*) (T) + 4), A); } 00227 #define mi_rowkorr(T) mi_uint4korr((uchar*) (T) + 4) 00228 #endif 00229 00230 #if SIZEOF_OFF_T > 4 00231 #define mi_sizestore(T,A) mi_int8store(T, A) 00232 #define mi_sizekorr(T) mi_uint8korr(T) 00233 #else 00234 #define mi_sizestore(T,A) { if ((A) == HA_OFFSET_ERROR)\ 00235 bfill((char*) (T), 8, 255);\ 00236 else { mi_int4store((T), 0);\ 00237 mi_int4store(((T) + 4), A); }} 00238 #define mi_sizekorr(T) mi_uint4korr((uchar*) (T) + 4) 00239 #endif