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