Back to index

php5  5.3.10
mysqlnd_portability.h
Go to the documentation of this file.
00001 /* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB 
00002 This file is public domain and comes with NO WARRANTY of any kind */
00003 
00004 /*
00005   Parts of the original, which are not applicable to mysqlnd have been removed.
00006   
00007   With small modifications, mostly casting but adding few more macros by
00008   Andrey Hristov <andrey@mysql.com> . The additions are in the public domain and
00009   were added to improve the header file, to get it more consistent.
00010 */
00011 
00012 #ifndef MYSQLND_PORTABILITY_H
00013 #define MYSQLND_PORTABILITY_H
00014 
00015 
00016 
00017 /* Comes from global.h as OFFSET, renamed to STRUCT_OFFSET */
00018 #define STRUCT_OFFSET(t, f)   ((size_t)(char *)&((t *)0)->f)
00019 
00020 #ifndef __attribute
00021 #if !defined(__GNUC__)
00022 #define __attribute(A)
00023 #endif
00024 #endif
00025 
00026 #ifdef __CYGWIN__
00027 /* We use a Unix API, so pretend it's not Windows */
00028 #undef WIN
00029 #undef WIN32
00030 #undef _WIN
00031 #undef _WIN32
00032 #undef _WIN64
00033 #undef __WIN__
00034 #undef __WIN32__
00035 #endif /* __CYGWIN__ */
00036 
00037 #if defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(WIN32)
00038 #  include "ext/mysqlnd/config-win.h"
00039 #else 
00040 #  include <ext/mysqlnd/php_mysqlnd_config.h>
00041 #endif /* _WIN32... */
00042 
00043 #if __STDC_VERSION__ < 199901L && !defined(atoll)
00044   /* "inline" is a keyword */
00045   #define atoll atol
00046 #endif
00047 
00048 
00049 #ifdef HAVE_SYS_TYPES_H
00050 #include <sys/types.h>
00051 #endif
00052 
00053 #ifdef HAVE_STDINT_H
00054 #include <stdint.h>
00055 #endif
00056 
00057 #if SIZEOF_LONG_LONG > 4 && !defined(_LONG_LONG)
00058 #define _LONG_LONG 1        /* For AIX string library */
00059 #endif
00060 
00061 
00062 /* Go around some bugs in different OS and compilers */
00063 #if defined(_HPUX_SOURCE) && defined(HAVE_SYS_STREAM_H)
00064 #include <sys/stream.h>        /* HPUX 10.20 defines ulong here. UGLY !!! */
00065 #define HAVE_ULONG
00066 #endif
00067 
00068 
00069 #if SIZEOF_LONG_LONG > 4
00070 #define HAVE_LONG_LONG 1
00071 #endif
00072 
00073 
00074 /* Typdefs for easyier portability */
00075 #ifndef HAVE_INT8_T
00076 #ifndef HAVE_INT8
00077 typedef signed char int8_t;               /* Signed integer >= 8    bits */
00078 #else
00079 typedef int8 int8_t;                      /* Signed integer >= 8    bits */
00080 #endif
00081 #endif
00082 
00083 #ifndef HAVE_UINT8_T
00084 #ifndef HAVE_UINT8
00085 typedef unsigned char uint8_t;            /* Unsigned integer >= 8    bits */
00086 #else
00087 typedef uint8 uint8_t;                           /* Signed integer >= 8    bits */
00088 #endif
00089 #endif
00090 
00091 #ifndef HAVE_INT16_T
00092 #ifndef HAVE_INT16
00093 typedef signed short int16_t;             /* Signed integer >= 16 bits */
00094 #else
00095 typedef int16 int16_t;                           /* Signed integer >= 16 bits */
00096 #endif
00097 #endif
00098 
00099 #ifndef HAVE_UINT16_T
00100 #ifndef HAVE_UINT16
00101 typedef unsigned short uint16_t;          /* Signed integer >= 16 bits */
00102 #else
00103 typedef uint16 uint16_t;                  /* Signed integer >= 16 bits */
00104 #endif
00105 #endif
00106 
00107 
00108 #ifndef HAVE_INT32_T
00109 #ifdef HAVE_INT32
00110 typedef int32 int32_t;
00111 #elif SIZEOF_INT == 4
00112 typedef signed int int32_t;
00113 #elif SIZEOF_LONG == 4
00114 typedef signed long int32_t;
00115 #else
00116 error "Neither int nor long is of 4 bytes width"
00117 #endif
00118 #endif /* HAVE_INT32_T */
00119 
00120 #ifndef HAVE_UINT32_T
00121 #ifdef HAVE_UINT32
00122 typedef uint32 uint32_t;
00123 #elif SIZEOF_INT == 4
00124 typedef unsigned int uint32_t;
00125 #elif SIZEOF_LONG == 4
00126 typedef unsigned long uint32_t;
00127 #else
00128 #error "Neither int nor long is of 4 bytes width"
00129 #endif
00130 #endif /* HAVE_UINT32_T */
00131 
00132 #ifndef HAVE_INT64_T
00133 #ifdef HAVE_INT64
00134 typedef int64 int64_t;
00135 #elif SIZEOF_INT == 8
00136 typedef signed int int64_t;
00137 #elif SIZEOF_LONG == 8
00138 typedef signed long int64_t;
00139 #elif SIZEOF_LONG_LONG == 8
00140 #ifdef PHP_WIN32
00141 typedef __int64 int64_t;
00142 #else
00143 typedef signed long long int64_t;
00144 #endif
00145 #else
00146 #error "Neither int nor long nor long long is of 8 bytes width"
00147 #endif
00148 #endif /* HAVE_INT64_T */
00149 
00150 #ifndef HAVE_UINT64_T
00151 #ifdef HAVE_UINT64
00152 typedef uint64 uint64_t;
00153 #elif SIZEOF_INT == 8
00154 typedef unsigned int uint64_t;
00155 #elif SIZEOF_LONG == 8
00156 typedef unsigned long uint64_t;
00157 #elif SIZEOF_LONG_LONG == 8
00158 #ifdef PHP_WIN32
00159 typedef unsigned __int64 uint64_t;
00160 #else
00161 typedef unsigned long long uint64_t;
00162 #endif
00163 #else
00164 #error "Neither int nor long nor long long is of 8 bytes width"
00165 #endif
00166 #endif /* HAVE_INT64_T */
00167 
00168 
00169 #ifdef PHP_WIN32
00170 #define MYSQLND_LLU_SPEC "%I64u"
00171 #define MYSQLND_LL_SPEC "%I64d"
00172 #define MYSQLND_SZ_T_SPEC "%Id"
00173 #ifndef L64
00174 #define L64(x) x##i64
00175 #endif
00176 #else
00177 
00178 #if __i386__
00179 #define MYSQLND_LL_SPEC     "%lli"
00180 #define MYSQLND_LLU_SPEC "%llu"
00181 #endif
00182 
00183 #if __ia64__
00184 #define MYSQLND_LL_SPEC     "%li"
00185 #define MYSQLND_LLU_SPEC "%lu"
00186 #endif
00187 
00188 #if __powerpc64__ || __ppc64__
00189 #define MYSQLND_LL_SPEC     "%li"
00190 #define MYSQLND_LLU_SPEC "%lu"
00191 #endif
00192 
00193 #if (__powerpc__ || __ppc__ ) && !(__powerpc64__ || __ppc64__)
00194 #define MYSQLND_LL_SPEC     "%lli"
00195 #define MYSQLND_LLU_SPEC "%llu"
00196 #endif
00197 
00198 #if __x86_64__
00199 #define MYSQLND_LL_SPEC     "%li"
00200 #define MYSQLND_LLU_SPEC "%lu"
00201 #endif
00202 
00203 #if __s390x__
00204 #define MYSQLND_LL_SPEC     "%li"
00205 #define MYSQLND_LLU_SPEC "%lu"
00206 #endif
00207 
00208 #if __s390__ && !__s390x__
00209 #define MYSQLND_LL_SPEC     "%lli"
00210 #define MYSQLND_LLU_SPEC "%llu"
00211 #endif
00212 
00213 #ifdef _AIX
00214 #define MYSQLND_LL_SPEC "%lli"
00215 #define MYSQLND_LLU_SPEC "%llu"
00216 #endif
00217 
00218 #ifndef MYSQLND_LL_SPEC
00219   #if SIZEOF_LONG == 8
00220     #define MYSQLND_LL_SPEC "%li"
00221   #elif SIZEOF_LONG == 4
00222     #define MYSQLND_LL_SPEC "%lli"
00223   #endif
00224 #endif
00225 
00226 #ifndef MYSQLND_LLU_SPEC
00227   #if SIZEOF_LONG == 8
00228     #define MYSQLND_LLU_SPEC "%lu"
00229   #elif SIZEOF_LONG == 4
00230     #define MYSQLND_LLU_SPEC "%llu"
00231    #endif
00232 #endif /* MYSQLND_LLU_SPEC*/
00233 
00234 
00235 #define MYSQLND_SZ_T_SPEC "%zd"
00236 #ifndef L64
00237 #define L64(x) x##LL
00238 #endif
00239 #endif
00240 
00241 
00242 #define int1store(T,A)      do { *((int8_t*) (T)) = (A); } while(0)
00243 #define uint1korr(A) (*(((uint8_t*)(A))))
00244 
00245 /* Bit values are sent in reverted order of bytes, compared to normal !!! */
00246 #define bit_uint2korr(A) ((uint16_t) (((uint16_t) (((unsigned char*) (A))[1])) +\
00247                                    ((uint16_t) (((unsigned char*) (A))[0]) << 8)))
00248 #define bit_uint3korr(A) ((uint32_t) (((uint32_t) (((unsigned char*) (A))[2])) +\
00249                                    (((uint32_t) (((unsigned char*) (A))[1])) << 8) +\
00250                                    (((uint32_t) (((unsigned char*) (A))[0])) << 16)))
00251 #define bit_uint4korr(A) ((uint32_t) (((uint32_t) (((unsigned char*) (A))[3])) +\
00252                                    (((uint32_t) (((unsigned char*) (A))[2])) << 8) +\
00253                                    (((uint32_t) (((unsigned char*) (A))[1])) << 16) +\
00254                                    (((uint32_t) (((unsigned char*) (A))[0])) << 24)))
00255 #define bit_uint5korr(A) ((uint64_t)(((uint32_t) (((unsigned char*) (A))[4])) +\
00256                                     (((uint32_t) (((unsigned char*) (A))[3])) << 8) +\
00257                                     (((uint32_t) (((unsigned char*) (A))[2])) << 16) +\
00258                                    (((uint32_t) (((unsigned char*) (A))[1])) << 24)) +\
00259                                     (((uint64_t) (((unsigned char*) (A))[0])) << 32))
00260 #define bit_uint6korr(A) ((uint64_t)(((uint32_t) (((unsigned char*) (A))[5])) +\
00261                                     (((uint32_t) (((unsigned char*) (A))[4])) << 8) +\
00262                                     (((uint32_t) (((unsigned char*) (A))[3])) << 16) +\
00263                                     (((uint32_t) (((unsigned char*) (A))[2])) << 24)) +\
00264                         (((uint64_t) (((uint32_t) (((unsigned char*) (A))[1])) +\
00265                                     (((uint32_t) (((unsigned char*) (A))[0]) << 8)))) <<\
00266                                      32))
00267 #define bit_uint7korr(A) ((uint64_t)(((uint32_t) (((unsigned char*) (A))[6])) +\
00268                                     (((uint32_t) (((unsigned char*) (A))[5])) << 8) +\
00269                                     (((uint32_t) (((unsigned char*) (A))[4])) << 16) +\
00270                                    (((uint32_t) (((unsigned char*) (A))[3])) << 24)) +\
00271                         (((uint64_t) (((uint32_t) (((unsigned char*) (A))[2])) +\
00272                                     (((uint32_t) (((unsigned char*) (A))[1])) << 8) +\
00273                                     (((uint32_t) (((unsigned char*) (A))[0])) << 16))) <<\
00274                                      32))
00275 #define bit_uint8korr(A) ((uint64_t)(((uint32_t) (((unsigned char*) (A))[7])) +\
00276                                     (((uint32_t) (((unsigned char*) (A))[6])) << 8) +\
00277                                     (((uint32_t) (((unsigned char*) (A))[5])) << 16) +\
00278                                     (((uint32_t) (((unsigned char*) (A))[4])) << 24)) +\
00279                         (((uint64_t) (((uint32_t) (((unsigned char*) (A))[3])) +\
00280                                     (((uint32_t) (((unsigned char*) (A))[2])) << 8) +\
00281                                     (((uint32_t) (((unsigned char*) (A))[1])) << 16) +\
00282                                     (((uint32_t) (((unsigned char*) (A))[0])) << 24))) <<\
00283                                     32))
00284 
00285 
00286 /*
00287 ** Define-funktions for reading and storing in machine independent format
00288 **  (low byte first)
00289 */
00290 
00291 /* Optimized store functions for Intel x86, non-valid for WIN64. __i386__ is GCC */
00292 #if defined(__i386__) && !defined(_WIN64)
00293 #define sint2korr(A)    (*((int16_t *) (A)))
00294 #define sint3korr(A)    ((int32_t) ((((zend_uchar) (A)[2]) & 128) ? \
00295                    (((uint32_t) 255L << 24) | \
00296                    (((uint32_t) (zend_uchar) (A)[2]) << 16) |\
00297                    (((uint32_t) (zend_uchar) (A)[1]) << 8) | \
00298                     ((uint32_t) (zend_uchar) (A)[0])) : \
00299                    (((uint32_t) (zend_uchar) (A)[2]) << 16) |\
00300                    (((uint32_t) (zend_uchar) (A)[1]) << 8) | \
00301                     ((uint32_t) (zend_uchar) (A)[0])))
00302 #define sint4korr(A)  (*((long *) (A)))
00303 
00304 #define uint2korr(A)  (*((uint16_t *) (A)))
00305 #define uint3korr(A)  (uint32_t) (((uint32_t) ((zend_uchar) (A)[0])) +\
00306                                (((uint32_t) ((zend_uchar) (A)[1])) << 8) +\
00307                                (((uint32_t) ((zend_uchar) (A)[2])) << 16))
00308 #define uint4korr(A)  (*((unsigned long *) (A)))
00309 
00310 
00311 
00312 #define uint8korr(A)    (*((uint64_t *) (A)))
00313 #define sint8korr(A)    (*((int64_t *) (A)))
00314 #define int2store(T,A)    *((uint16_t*) (T))= (uint16_t) (A)
00315 #define int3store(T,A)   { \
00316                   *(T)=  (zend_uchar) ((A));\
00317                   *(T+1)=(zend_uchar) (((uint32_t) (A) >> 8));\
00318                   *(T+2)=(zend_uchar) (((A) >> 16)); }
00319 #define int4store(T,A)    *((long *) (T))= (long) (A)
00320 #define int5store(T,A)    { \
00321               *((zend_uchar *)(T))= (zend_uchar)((A));\
00322               *(((zend_uchar *)(T))+1)=(zend_uchar) (((A) >> 8));\
00323               *(((zend_uchar *)(T))+2)=(zend_uchar) (((A) >> 16));\
00324               *(((zend_uchar *)(T))+3)=(zend_uchar) (((A) >> 24)); \
00325               *(((zend_uchar *)(T))+4)=(zend_uchar) (((A) >> 32)); }
00326 
00327 /* From Andrey Hristov, based on int5store() */
00328 #define int6store(T,A)    { \
00329               *(((zend_uchar *)(T)))= (zend_uchar)((A));\
00330               *(((zend_uchar *)(T))+1))=(zend_uchar) (((A) >> 8));\
00331               *(((zend_uchar *)(T))+2))=(zend_uchar) (((A) >> 16));\
00332               *(((zend_uchar *)(T))+3))=(zend_uchar) (((A) >> 24)); \
00333               *(((zend_uchar *)(T))+4))=(zend_uchar) (((A) >> 32)); \
00334               *(((zend_uchar *)(T))+5))=(zend_uchar) (((A) >> 40)); }
00335 
00336 #define int8store(T,A)    *((uint64_t *) (T))= (uint64_t) (A)
00337 
00338 typedef union {
00339   double v;
00340   long m[2];
00341 } float8get_union;
00342 #define float8get(V,M)    { ((float8get_union *)&(V))->m[0] = *((long*) (M)); \
00343                             ((float8get_union *)&(V))->m[1] = *(((long*) (M))+1); }
00344 #define float8store(T,V) { *((long *) (T))     = ((float8get_union *)&(V))->m[0]; \
00345                            *(((long *) (T))+1) = ((float8get_union *)&(V))->m[1]; }
00346 #define float4get(V,M)      { *((float *) &(V)) = *((float*) (M)); }
00347 /* From Andrey Hristov based on float8get */
00348 #define floatget(V,M)    memcpy((char*) &(V),(char*) (M),sizeof(float))
00349 #endif /* __i386__ */ 
00350 
00351 
00352 /* If we haven't defined sint2korr, which is because the platform is not x86 or it's WIN64 */
00353 #ifndef sint2korr
00354 #define sint2korr(A)    (int16_t) (((int16_t) ((zend_uchar) (A)[0])) +\
00355                                  ((int16_t) ((int16_t) (A)[1]) << 8))
00356 #define sint3korr(A)    ((int32_t) ((((zend_uchar) (A)[2]) & 128) ? \
00357                   (((uint32_t) 255L << 24) | \
00358                   (((uint32_t) (zend_uchar) (A)[2]) << 16) |\
00359                   (((uint32_t) (zend_uchar) (A)[1]) << 8) | \
00360                    ((uint32_t) (zend_uchar) (A)[0])) : \
00361                   (((uint32_t) (zend_uchar) (A)[2]) << 16) |\
00362                   (((uint32_t) (zend_uchar) (A)[1]) << 8) | \
00363                   ((uint32_t) (zend_uchar) (A)[0])))
00364 #define sint4korr(A)  (int32_t) (((int32_t) ((zend_uchar) (A)[0])) +\
00365                               (((int32_t) ((zend_uchar) (A)[1]) << 8)) +\
00366                               (((int32_t) ((zend_uchar) (A)[2]) << 16)) +\
00367                               (((int32_t) ((int16_t) (A)[3]) << 24)))
00368 
00369 #define sint8korr(A)  (int64_t) uint8korr(A)
00370 #define uint2korr(A)  (uint16_t) (((uint16_t) ((zend_uchar) (A)[0])) +\
00371                                ((uint16_t) ((zend_uchar) (A)[1]) << 8))
00372 #define uint3korr(A)  (uint32_t) (((uint32_t) ((zend_uchar) (A)[0])) +\
00373                                (((uint32_t) ((zend_uchar) (A)[1])) << 8) +\
00374                                (((uint32_t) ((zend_uchar) (A)[2])) << 16))
00375 #define uint4korr(A)  (uint32_t) (((uint32_t) ((zend_uchar) (A)[0])) +\
00376                                (((uint32_t) ((zend_uchar) (A)[1])) << 8) +\
00377                                (((uint32_t) ((zend_uchar) (A)[2])) << 16) +\
00378                                (((uint32_t) ((zend_uchar) (A)[3])) << 24))
00379 
00380 #define uint8korr(A) ((uint64_t)(((uint32_t) ((zend_uchar) (A)[0])) +\
00381                                                                (((uint32_t) ((zend_uchar) (A)[1])) << 8) +\
00382                                                                (((uint32_t) ((zend_uchar) (A)[2])) << 16) +\
00383                                                                (((uint32_t) ((zend_uchar) (A)[3])) << 24)) +\
00384                                                                (((uint64_t) (((uint32_t) ((zend_uchar) (A)[4])) +\
00385                                                                (((uint32_t) ((zend_uchar) (A)[5])) << 8) +\
00386                                                                (((uint32_t) ((zend_uchar) (A)[6])) << 16) +\
00387                                                                (((uint32_t) ((zend_uchar) (A)[7])) << 24))) << 32))
00388 
00389 
00390 #define int2store(T,A)  do { uint32_t def_temp= (uint32_t) (A) ;\
00391                   *((zend_uchar*) (T))  =  (zend_uchar)(def_temp); \
00392                   *((zend_uchar*) (T+1)) = (zend_uchar)((def_temp >> 8)); } while (0)
00393 #define int3store(T,A)  do { /*lint -save -e734 */\
00394                   *(((char *)(T)))   = (char) ((A));\
00395                   *(((char *)(T))+1) = (char) (((A) >> 8));\
00396                   *(((char *)(T))+2) = (char) (((A) >> 16)); \
00397                   /*lint -restore */} while (0)
00398 #define int4store(T,A)  do { \
00399                   *(((char *)(T)))   = (char) ((A));\
00400                   *(((char *)(T))+1) = (char) (((A) >> 8));\
00401                   *(((char *)(T))+2) = (char) (((A) >> 16));\
00402                   *(((char *)(T))+3) = (char) (((A) >> 24)); } while (0)
00403 #define int5store(T,A)  do { \
00404                   *(((char *)(T)))   = (char)((A));\
00405                   *(((char *)(T))+1) = (char)(((A) >> 8));\
00406                   *(((char *)(T))+2) = (char)(((A) >> 16));\
00407                   *(((char *)(T))+3) = (char)(((A) >> 24)); \
00408                   *(((char *)(T))+4) = (char)(((A) >> 32)); } while (0)
00409 /* Based on int5store() from Andrey Hristov */
00410 #define int6store(T,A)  do { \
00411                   *(((char *)(T)))   = (char)((A));\
00412                   *(((char *)(T))+1) = (char)(((A) >> 8));\
00413                   *(((char *)(T))+2) = (char)(((A) >> 16));\
00414                   *(((char *)(T))+3) = (char)(((A) >> 24)); \
00415                   *(((char *)(T))+4) = (char)(((A) >> 32)); \
00416                   *(((char *)(T))+5) = (char)(((A) >> 40)); } while (0)
00417 #define int8store(T,A)        { uint32_t def_temp= (uint32_t) (A), def_temp2= (uint32_t) ((A) >> 32); \
00418                   int4store((T),def_temp); \
00419                   int4store((T+4),def_temp2); \
00420                 }
00421 #ifdef WORDS_BIGENDIAN
00422 #define float4get(V,M)   do { float def_temp;\
00423                           ((char*) &def_temp)[0] = (M)[3];\
00424                           ((char*) &def_temp)[1] = (M)[2];\
00425                           ((char*) &def_temp)[2] = (M)[1];\
00426                           ((char*) &def_temp)[3] = (M)[0];\
00427                           (V)=def_temp; } while (0)
00428 #define float8store(T,V)  do { \
00429                            *(((char *)(T)))   = (char) ((char *) &(V))[7];\
00430                            *(((char *)(T))+1) = (char) ((char *) &(V))[6];\
00431                            *(((char *)(T))+2) = (char) ((char *) &(V))[5];\
00432                            *(((char *)(T))+3) = (char) ((char *) &(V))[4];\
00433                            *(((char *)(T))+4) = (char) ((char *) &(V))[3];\
00434                            *(((char *)(T))+5) = (char) ((char *) &(V))[2];\
00435                            *(((char *)(T))+6) = (char) ((char *) &(V))[1];\
00436                            *(((char *)(T))+7) = (char) ((char *) &(V))[0]; } while (0)
00437 
00438 #define float8get(V,M)   do { double def_temp;\
00439                           ((char*) &def_temp)[0] = (M)[7];\
00440                           ((char*) &def_temp)[1] = (M)[6];\
00441                           ((char*) &def_temp)[2] = (M)[5];\
00442                           ((char*) &def_temp)[3] = (M)[4];\
00443                           ((char*) &def_temp)[4] = (M)[3];\
00444                           ((char*) &def_temp)[5] = (M)[2];\
00445                           ((char*) &def_temp)[6] = (M)[1];\
00446                           ((char*) &def_temp)[7] = (M)[0];\
00447                           (V) = def_temp; \
00448                          } while (0)
00449 #else
00450 #define float4get(V,M)   memcpy((char*) &(V),(char*) (M),sizeof(float))
00451 
00452 #if defined(__FLOAT_WORD_ORDER) && (__FLOAT_WORD_ORDER == __BIG_ENDIAN)
00453 #define float8store(T,V)  do { \
00454                          *(((char *)(T)))= ((char *) &(V))[4];\
00455                          *(((char *)(T))+1)=(char) ((char *) &(V))[5];\
00456                          *(((char *)(T))+2)=(char) ((char *) &(V))[6];\
00457                          *(((char *)(T))+3)=(char) ((char *) &(V))[7];\
00458                          *(((char *)(T))+4)=(char) ((char *) &(V))[0];\
00459                          *(((char *)(T))+5)=(char) ((char *) &(V))[1];\
00460                          *(((char *)(T))+6)=(char) ((char *) &(V))[2];\
00461                          *(((char *)(T))+7)=(char) ((char *) &(V))[3];} while (0)
00462 #define float8get(V,M) do { double def_temp;\
00463                          ((char*) &def_temp)[0]=(M)[4];\
00464                          ((char*) &def_temp)[1]=(M)[5];\
00465                          ((char*) &def_temp)[2]=(M)[6];\
00466                          ((char*) &def_temp)[3]=(M)[7];\
00467                          ((char*) &def_temp)[4]=(M)[0];\
00468                          ((char*) &def_temp)[5]=(M)[1];\
00469                          ((char*) &def_temp)[6]=(M)[2];\
00470                          ((char*) &def_temp)[7]=(M)[3];\
00471                          (V) = def_temp; } while (0)
00472 #endif /* __FLOAT_WORD_ORDER */
00473 
00474 #endif /* WORDS_BIGENDIAN */
00475 
00476 #endif /* sint2korr */
00477 /* To here if the platform is not x86 or it's WIN64 */
00478 
00479 
00480 /* Define-funktions for reading and storing in machine format from/to
00481    short/long to/from some place in memory V should be a (not
00482    register) variable, M is a pointer to byte */
00483 
00484 #ifndef float8get
00485 
00486 #ifdef WORDS_BIGENDIAN
00487 #define float8get(V,M)             memcpy((char*) &(V),(char*)  (M), sizeof(double))
00488 #define float8store(T,V)    memcpy((char*)  (T),(char*) &(V), sizeof(double))
00489 #else
00490 #define float8get(V,M)    memcpy((char*) &(V),(char*) (M),sizeof(double))
00491 #define float8store(T,V)  memcpy((char*) (T),(char*) &(V),sizeof(double))
00492 #endif /* WORDS_BIGENDIAN */
00493 
00494 #endif /* float8get */
00495 
00496 #endif /* MYSQLND_PORTABILITY_H */
00497 
00498 
00499 /*
00500  * Local variables:
00501  * tab-width: 4
00502  * c-basic-offset: 4
00503  * End:
00504  * vim600: noet sw=4 ts=4 fdm=marker
00505  * vim<600: noet sw=4 ts=4
00506  */