64bit fixes:
- fixes to sprintf modifiers, cleaning warnings
- use _t types, like uint64_t instead of uint64, thus skipping series of
typedefs.
This commit is contained in:
Andrey Hristov 2008-10-31 20:32:17 +00:00
parent 4f5895a4d2
commit 77c1e145e1
11 changed files with 295 additions and 311 deletions

View file

@ -1372,7 +1372,7 @@ MYSQLND_METHOD(mysqlnd_conn, field_count)(const MYSQLND * const conn)
/* {{{ mysqlnd_conn::insert_id */ /* {{{ mysqlnd_conn::insert_id */
static uint64 static uint64_t
MYSQLND_METHOD(mysqlnd_conn, insert_id)(const MYSQLND * const conn) MYSQLND_METHOD(mysqlnd_conn, insert_id)(const MYSQLND * const conn)
{ {
return conn->upsert_status.last_insert_id; return conn->upsert_status.last_insert_id;
@ -1381,7 +1381,7 @@ MYSQLND_METHOD(mysqlnd_conn, insert_id)(const MYSQLND * const conn)
/* {{{ mysqlnd_conn::affected_rows */ /* {{{ mysqlnd_conn::affected_rows */
static uint64 static uint64_t
MYSQLND_METHOD(mysqlnd_conn, affected_rows)(const MYSQLND * const conn) MYSQLND_METHOD(mysqlnd_conn, affected_rows)(const MYSQLND * const conn)
{ {
return conn->upsert_status.affected_rows; return conn->upsert_status.affected_rows;
@ -1460,7 +1460,7 @@ MYSQLND_METHOD(mysqlnd_conn, charset_name)(const MYSQLND * const conn)
/* {{{ mysqlnd_conn::thread_id */ /* {{{ mysqlnd_conn::thread_id */
static uint64 static uint64_t
MYSQLND_METHOD(mysqlnd_conn, thread_id)(const MYSQLND * const conn) MYSQLND_METHOD(mysqlnd_conn, thread_id)(const MYSQLND * const conn)
{ {
return conn->thread_id; return conn->thread_id;

View file

@ -31,7 +31,7 @@
#define MYSQL_ROW MYSQLND_ROW_C #define MYSQL_ROW MYSQLND_ROW_C
#define MYSQL MYSQLND #define MYSQL MYSQLND
#define my_bool zend_bool #define my_bool zend_bool
#define my_ulonglong uint64 #define my_ulonglong uint64_t
#define MYSQL_VERSION_ID MYSQLND_VERSION_ID #define MYSQL_VERSION_ID MYSQLND_VERSION_ID
#define MYSQL_SERVER_VERSION MYSQLND_VERSION #define MYSQL_SERVER_VERSION MYSQLND_VERSION

View file

@ -61,36 +61,36 @@ This file is public domain and comes with NO WARRANTY of any kind */
/* Typdefs for easyier portability */ /* Typdefs for easyier portability */
#ifndef HAVE_INT8
#ifndef HAVE_INT8_T #ifndef HAVE_INT8_T
typedef signed char int8; /* Signed integer >= 8 bits */ #ifndef HAVE_INT8
typedef signed char int8_t; /* Signed integer >= 8 bits */
#else #else
typedef int8_t int8; /* Signed integer >= 8 bits */ typedef int8 int8_t; /* Signed integer >= 8 bits */
#endif #endif
#endif #endif
#ifndef HAVE_UINT8
#ifndef HAVE_UINT8_T #ifndef HAVE_UINT8_T
typedef unsigned char uint8; /* Unsigned integer >= 8 bits */ #ifndef HAVE_UINT8
typedef unsigned char uint8_t; /* Unsigned integer >= 8 bits */
#else #else
typedef uint8_t uint8; /* Signed integer >= 8 bits */ typedef uint8 uint8_t; /* Signed integer >= 8 bits */
#endif #endif
#endif #endif
#ifndef HAVE_INT16
#ifndef HAVE_INT16_T #ifndef HAVE_INT16_T
typedef signed short int16; /* Signed integer >= 16 bits */ #ifndef HAVE_INT16
typedef signed short int16_t; /* Signed integer >= 16 bits */
#else #else
typedef int16_t int16; /* Signed integer >= 16 bits */ typedef int16 int16_t; /* Signed integer >= 16 bits */
#endif #endif
#endif #endif
#ifndef HAVE_UINT16
#ifndef HAVE_UINT16_T #ifndef HAVE_UINT16_T
typedef unsigned short uint16; /* Signed integer >= 16 bits */ #ifndef HAVE_UINT16
typedef unsigned short uint16_t; /* Signed integer >= 16 bits */
#else #else
typedef uint16_t uint16; /* Signed integer >= 16 bits */ typedef uint16 uint16_t; /* Signed integer >= 16 bits */
#endif #endif
#endif #endif
@ -98,134 +98,136 @@ typedef uint16_t uint16; /* Signed integer >= 16 bits */
typedef unsigned char uchar; /* Short for unsigned char */ typedef unsigned char uchar; /* Short for unsigned char */
#endif #endif
#ifndef HAVE_INT32 #ifndef HAVE_INT32_T
#ifdef HAVE_INT32_T #ifdef HAVE_INT32
typedef int32_t int32; typedef int32 int32_t;
#elif SIZEOF_INT == 4 #elif SIZEOF_INT == 4
typedef signed int int32; typedef signed int int32_t;
#elif SIZEOF_LONG == 4 #elif SIZEOF_LONG == 4
typedef signed long int32; typedef signed long int32_t;
#else #else
error "Neither int nor long is of 4 bytes width" error "Neither int nor long is of 4 bytes width"
#endif #endif
#endif /* HAVE_INT32 */ #endif /* HAVE_INT32_T */
#ifndef HAVE_UINT32 #ifndef HAVE_UINT32_T
#ifdef HAVE_UINT32_T #ifdef HAVE_UINT32
typedef uint32_t uint32; typedef uint32 uint32_t;
#elif SIZEOF_INT == 4 #elif SIZEOF_INT == 4
typedef unsigned int uint32; typedef unsigned int uint32_t;
#elif SIZEOF_LONG == 4 #elif SIZEOF_LONG == 4
typedef unsigned long uint32; typedef unsigned long uint32_t;
#else #else
#error "Neither int nor long is of 4 bytes width" #error "Neither int nor long is of 4 bytes width"
#endif #endif
#endif /* HAVE_UINT32 */ #endif /* HAVE_UINT32_T */
#ifndef HAVE_INT64 #ifndef HAVE_INT64_T
#ifdef HAVE_INT64_T #ifdef HAVE_INT64
typedef int64_t int64; typedef int64 int64_t;
#elif SIZEOF_INT == 8 #elif SIZEOF_INT == 8
typedef signed int int64; typedef signed int int64_t;
#elif SIZEOF_LONG == 8 #elif SIZEOF_LONG == 8
typedef signed long int64; typedef signed long int64_t;
#elif SIZEOF_LONG_LONG == 8 #elif SIZEOF_LONG_LONG == 8
#ifdef PHP_WIN32 #ifdef PHP_WIN32
typedef __int64 int64; typedef __int64 int64_t;
#else #else
typedef signed long long int64; typedef signed long long int64_t;
#endif #endif
#else #else
#error "Neither int nor long nor long long is of 8 bytes width" #error "Neither int nor long nor long long is of 8 bytes width"
#endif #endif
#endif /* HAVE_INT64 */ #endif /* HAVE_INT64_T */
#ifndef HAVE_UINT64 #ifndef HAVE_UINT64_T
#ifdef HAVE_UINT64_T #ifdef HAVE_UINT64
typedef uint64_t uint64; typedef uint64 uint64_t;
#elif SIZEOF_INT == 8 #elif SIZEOF_INT == 8
typedef unsigned int uint64; typedef unsigned int uint64_t;
#elif SIZEOF_LONG == 8 #elif SIZEOF_LONG == 8
typedef unsigned long uint64; typedef unsigned long uint64_t;
#elif SIZEOF_LONG_LONG == 8 #elif SIZEOF_LONG_LONG == 8
#ifdef PHP_WIN32 #ifdef PHP_WIN32
typedef unsigned __int64 uint64; typedef unsigned __int64 uint64_t;
#else #else
typedef unsigned long long uint64; typedef unsigned long long uint64_t;
#endif #endif
#else #else
#error "Neither int nor long nor long long is of 8 bytes width" #error "Neither int nor long nor long long is of 8 bytes width"
#endif #endif
#endif /* HAVE_INT64 */ #endif /* HAVE_INT64_T */
#ifdef PHP_WIN32 #ifdef PHP_WIN32
#define MYSQLND_LLU_SPEC "%I64u" #define MYSQLND_LLU_SPEC "%I64u"
#define MYSQLND_LL_SPEC "%I64d" #define MYSQLND_LL_SPEC "%I64d"
#define MYSQLND_SZ_T_SPEC "%Id"
#ifndef L64 #ifndef L64
#define L64(x) x##i64 #define L64(x) x##i64
#endif #endif
#else #else
#define MYSQLND_LLU_SPEC "%llu" #define MYSQLND_LLU_SPEC "%llu"
#define MYSQLND_LL_SPEC "%lld" #define MYSQLND_LL_SPEC "%lld"
#define MYSQLND_SZ_T_SPEC "%zd"
#ifndef L64 #ifndef L64
#define L64(x) x##LL #define L64(x) x##LL
#endif #endif
#endif #endif
typedef int64 longlong; typedef int64_t longlong;
typedef uint64 ulonglong; typedef uint64_t ulonglong;
#define int1store(T,A) do { *((zend_uchar*) (T)) = (A); } while(0) #define int1store(T,A) do { *((zend_uchar*) (T)) = (A); } while(0)
#define uint1korr(A) (*(((uint8*)(A)))) #define uint1korr(A) (*(((uint8_t*)(A))))
/* Bit values are sent in reverted order of bytes, compared to normal !!! */ /* Bit values are sent in reverted order of bytes, compared to normal !!! */
#define bit_uint2korr(A) ((uint16) (((uint16) (((uchar*) (A))[1])) +\ #define bit_uint2korr(A) ((uint16_t) (((uint16_t) (((uchar*) (A))[1])) +\
((uint16) (((uchar*) (A))[0]) << 8))) ((uint16_t) (((uchar*) (A))[0]) << 8)))
#define bit_uint3korr(A) ((uint32) (((uint32) (((uchar*) (A))[2])) +\ #define bit_uint3korr(A) ((uint32_t) (((uint32_t) (((uchar*) (A))[2])) +\
(((uint32) (((uchar*) (A))[1])) << 8) +\ (((uint32_t) (((uchar*) (A))[1])) << 8) +\
(((uint32) (((uchar*) (A))[0])) << 16))) (((uint32_t) (((uchar*) (A))[0])) << 16)))
#define bit_uint4korr(A) ((uint32) (((uint32) (((uchar*) (A))[3])) +\ #define bit_uint4korr(A) ((uint32_t) (((uint32_t) (((uchar*) (A))[3])) +\
(((uint32) (((uchar*) (A))[2])) << 8) +\ (((uint32_t) (((uchar*) (A))[2])) << 8) +\
(((uint32) (((uchar*) (A))[1])) << 16) +\ (((uint32_t) (((uchar*) (A))[1])) << 16) +\
(((uint32) (((uchar*) (A))[0])) << 24))) (((uint32_t) (((uchar*) (A))[0])) << 24)))
#define bit_uint5korr(A) ((ulonglong)(((uint32) ((uchar) (A)[4])) +\ #define bit_uint5korr(A) ((ulonglong)(((uint32_t) ((uchar) (A)[4])) +\
(((uint32) ((uchar) (A)[3])) << 8) +\ (((uint32_t) ((uchar) (A)[3])) << 8) +\
(((uint32) ((uchar) (A)[2])) << 16) +\ (((uint32_t) ((uchar) (A)[2])) << 16) +\
(((uint32) ((uchar) (A)[1])) << 24)) +\ (((uint32_t) ((uchar) (A)[1])) << 24)) +\
(((ulonglong) ((uchar) (A)[0])) << 32)) (((ulonglong) ((uchar) (A)[0])) << 32))
#define bit_uint6korr(A) ((ulonglong)(((uint32) (((uchar*) (A))[5])) +\ #define bit_uint6korr(A) ((ulonglong)(((uint32_t) (((uchar*) (A))[5])) +\
(((uint32) (((uchar*) (A))[4])) << 8) +\ (((uint32_t) (((uchar*) (A))[4])) << 8) +\
(((uint32) (((uchar*) (A))[3])) << 16) +\ (((uint32_t) (((uchar*) (A))[3])) << 16) +\
(((uint32) (((uchar*) (A))[2])) << 24)) +\ (((uint32_t) (((uchar*) (A))[2])) << 24)) +\
(((ulonglong) (((uint32) (((uchar*) (A))[1])) +\ (((ulonglong) (((uint32_t) (((uchar*) (A))[1])) +\
(((uint32) (((uchar*) (A))[0]) << 8)))) << 32)) (((uint32_t) (((uchar*) (A))[0]) << 8)))) << 32))
#define bit_uint7korr(A) ((ulonglong)(((uint32) (((uchar*) (A))[6])) +\ #define bit_uint7korr(A) ((ulonglong)(((uint32_t) (((uchar*) (A))[6])) +\
(((uint32) (((uchar*) (A))[5])) << 8) +\ (((uint32_t) (((uchar*) (A))[5])) << 8) +\
(((uint32) (((uchar*) (A))[4])) << 16) +\ (((uint32_t) (((uchar*) (A))[4])) << 16) +\
(((uint32) (((uchar*) (A))[3])) << 24)) +\ (((uint32_t) (((uchar*) (A))[3])) << 24)) +\
(((ulonglong) (((uint32) (((uchar*) (A))[2])) +\ (((ulonglong) (((uint32_t) (((uchar*) (A))[2])) +\
(((uint32) (((uchar*) (A))[1])) << 8) +\ (((uint32_t) (((uchar*) (A))[1])) << 8) +\
(((uint32) (((uchar*) (A))[0])) << 16))) << 32)) (((uint32_t) (((uchar*) (A))[0])) << 16))) << 32))
#define bit_uint8korr(A) ((ulonglong)(((uint32) (((uchar*) (A))[7])) +\ #define bit_uint8korr(A) ((ulonglong)(((uint32_t) (((uchar*) (A))[7])) +\
(((uint32) (((uchar*) (A))[6])) << 8) +\ (((uint32_t) (((uchar*) (A))[6])) << 8) +\
(((uint32) (((uchar*) (A))[5])) << 16) +\ (((uint32_t) (((uchar*) (A))[5])) << 16) +\
(((uint32) (((uchar*) (A))[4])) << 24)) +\ (((uint32_t) (((uchar*) (A))[4])) << 24)) +\
(((ulonglong) (((uint32) (((uchar*) (A))[3])) +\ (((ulonglong) (((uint32_t) (((uchar*) (A))[3])) +\
(((uint32) (((uchar*) (A))[2])) << 8) +\ (((uint32_t) (((uchar*) (A))[2])) << 8) +\
(((uint32) (((uchar*) (A))[1])) << 16) +\ (((uint32_t) (((uchar*) (A))[1])) << 16) +\
(((uint32) (((uchar*) (A))[0])) << 24))) << 32)) (((uint32_t) (((uchar*) (A))[0])) << 24))) << 32))
/* /*
@ -235,31 +237,31 @@ typedef uint64 ulonglong;
/* Optimized store functions for Intel x86, non-valid for WIN64 */ /* Optimized store functions for Intel x86, non-valid for WIN64 */
#if defined(__i386__) && !defined(_WIN64) #if defined(__i386__) && !defined(_WIN64)
#define sint2korr(A) (*((int16 *) (A))) #define sint2korr(A) (*((int16_t *) (A)))
#define sint3korr(A) ((int32) ((((uchar) (A)[2]) & 128) ? \ #define sint3korr(A) ((int32_t) ((((uchar) (A)[2]) & 128) ? \
(((uint32) 255L << 24) | \ (((uint32_t) 255L << 24) | \
(((uint32) (uchar) (A)[2]) << 16) |\ (((uint32_t) (uchar) (A)[2]) << 16) |\
(((uint32) (uchar) (A)[1]) << 8) | \ (((uint32_t) (uchar) (A)[1]) << 8) | \
((uint32) (uchar) (A)[0])) : \ ((uint32_t) (uchar) (A)[0])) : \
(((uint32) (uchar) (A)[2]) << 16) |\ (((uint32_t) (uchar) (A)[2]) << 16) |\
(((uint32) (uchar) (A)[1]) << 8) | \ (((uint32_t) (uchar) (A)[1]) << 8) | \
((uint32) (uchar) (A)[0]))) ((uint32_t) (uchar) (A)[0])))
#define sint4korr(A) (*((long *) (A))) #define sint4korr(A) (*((long *) (A)))
#define uint2korr(A) (*((uint16 *) (A))) #define uint2korr(A) (*((uint16_t *) (A)))
#define uint3korr(A) (uint32) (((uint32) ((uchar) (A)[0])) +\ #define uint3korr(A) (uint32_t) (((uint32_t) ((uchar) (A)[0])) +\
(((uint32) ((uchar) (A)[1])) << 8) +\ (((uint32_t) ((uchar) (A)[1])) << 8) +\
(((uint32) ((uchar) (A)[2])) << 16)) (((uint32_t) ((uchar) (A)[2])) << 16))
#define uint4korr(A) (*((unsigned long *) (A))) #define uint4korr(A) (*((unsigned long *) (A)))
#define uint8korr(A) (*((ulonglong *) (A))) #define uint8korr(A) (*((ulonglong *) (A)))
#define sint8korr(A) (*((longlong *) (A))) #define sint8korr(A) (*((longlong *) (A)))
#define int2store(T,A) *((uint16*) (T))= (uint16) (A) #define int2store(T,A) *((uint16_t*) (T))= (uint16_t) (A)
#define int3store(T,A) { \ #define int3store(T,A) { \
*(T)= (uchar) ((A));\ *(T)= (uchar) ((A));\
*(T+1)=(uchar) (((uint) (A) >> 8));\ *(T+1)=(uchar) (((uint32_t) (A) >> 8));\
*(T+2)=(uchar) (((A) >> 16)); } *(T+2)=(uchar) (((A) >> 16)); }
#define int4store(T,A) *((long *) (T))= (long) (A) #define int4store(T,A) *((long *) (T))= (long) (A)
#define int5store(T,A) { \ #define int5store(T,A) { \
@ -278,7 +280,7 @@ typedef uint64 ulonglong;
*(((uchar *)(T))+4))=(uchar) (((A) >> 32)); \ *(((uchar *)(T))+4))=(uchar) (((A) >> 32)); \
*(((uchar *)(T))+5))=(uchar) (((A) >> 40)); } *(((uchar *)(T))+5))=(uchar) (((A) >> 40)); }
#define int8store(T,A) *((ulonglong *) (T))= (ulonglong) (A) #define int8_tstore(T,A) *((ulonglong *) (T))= (ulonglong) (A)
typedef union { typedef union {
double v; double v;
@ -298,53 +300,53 @@ typedef union {
#endif /* __i386__ */ #endif /* __i386__ */
#ifndef sint2korr #ifndef sint2korr
#define sint2korr(A) (int16) (((int16) ((uchar) (A)[0])) +\ #define sint2korr(A) (int16_t) (((int16_t) ((uchar) (A)[0])) +\
((int16) ((int16) (A)[1]) << 8)) ((int16_t) ((int16_t) (A)[1]) << 8))
#define sint3korr(A) ((int32) ((((uchar) (A)[2]) & 128) ? \ #define sint3korr(A) ((int32_t) ((((uchar) (A)[2]) & 128) ? \
(((uint32) 255L << 24) | \ (((uint32_t) 255L << 24) | \
(((uint32) (uchar) (A)[2]) << 16) |\ (((uint32_t) (uchar) (A)[2]) << 16) |\
(((uint32) (uchar) (A)[1]) << 8) | \ (((uint32_t) (uchar) (A)[1]) << 8) | \
((uint32) (uchar) (A)[0])) : \ ((uint32_t) (uchar) (A)[0])) : \
(((uint32) (uchar) (A)[2]) << 16) |\ (((uint32_t) (uchar) (A)[2]) << 16) |\
(((uint32) (uchar) (A)[1]) << 8) | \ (((uint32_t) (uchar) (A)[1]) << 8) | \
((uint32) (uchar) (A)[0]))) ((uint32_t) (uchar) (A)[0])))
#define sint4korr(A) (int32) (((int32) ((uchar) (A)[0])) +\ #define sint4korr(A) (int32_t) (((int32_t) ((uchar) (A)[0])) +\
(((int32) ((uchar) (A)[1]) << 8)) +\ (((int32_t) ((uchar) (A)[1]) << 8)) +\
(((int32) ((uchar) (A)[2]) << 16)) +\ (((int32_t) ((uchar) (A)[2]) << 16)) +\
(((int32) ((int16) (A)[3]) << 24))) (((int32_t) ((int16_t) (A)[3]) << 24)))
#define sint8korr(A) (longlong) uint8korr(A) #define sint8korr(A) (longlong) uint8korr(A)
#define uint2korr(A) (uint16) (((uint16) ((uchar) (A)[0])) +\ #define uint2korr(A) (uint16_t) (((uint16_t) ((uchar) (A)[0])) +\
((uint16) ((uchar) (A)[1]) << 8)) ((uint16_t) ((uchar) (A)[1]) << 8))
#define uint3korr(A) (uint32) (((uint32) ((uchar) (A)[0])) +\ #define uint3korr(A) (uint32_t) (((uint32_t) ((uchar) (A)[0])) +\
(((uint32) ((uchar) (A)[1])) << 8) +\ (((uint32_t) ((uchar) (A)[1])) << 8) +\
(((uint32) ((uchar) (A)[2])) << 16)) (((uint32_t) ((uchar) (A)[2])) << 16))
#define uint4korr(A) (uint32) (((uint32) ((uchar) (A)[0])) +\ #define uint4korr(A) (uint32_t) (((uint32_t) ((uchar) (A)[0])) +\
(((uint32) ((uchar) (A)[1])) << 8) +\ (((uint32_t) ((uchar) (A)[1])) << 8) +\
(((uint32) ((uchar) (A)[2])) << 16) +\ (((uint32_t) ((uchar) (A)[2])) << 16) +\
(((uint32) ((uchar) (A)[3])) << 24)) (((uint32_t) ((uchar) (A)[3])) << 24))
#define bit_uint8korr(A) ((ulonglong)(((uint32) (((uchar*) (A))[7])) +\ #define bit_uint8korr(A) ((ulonglong)(((uint32_t) (((uchar*) (A))[7])) +\
(((uint32) (((uchar*) (A))[6])) << 8) +\ (((uint32_t) (((uchar*) (A))[6])) << 8) +\
(((uint32) (((uchar*) (A))[5])) << 16) +\ (((uint32_t) (((uchar*) (A))[5])) << 16) +\
(((uint32) (((uchar*) (A))[4])) << 24)) +\ (((uint32_t) (((uchar*) (A))[4])) << 24)) +\
(((ulonglong) (((uint32) (((uchar*) (A))[3])) +\ (((ulonglong) (((uint32_t) (((uchar*) (A))[3])) +\
(((uint32) (((uchar*) (A))[2])) << 8) +\ (((uint32_t) (((uchar*) (A))[2])) << 8) +\
(((uint32) (((uchar*) (A))[1])) << 16) +\ (((uint32_t) (((uchar*) (A))[1])) << 16) +\
(((uint32) (((uchar*) (A))[0])) << 24))) << 32)) (((uint32_t) (((uchar*) (A))[0])) << 24))) << 32))
#define uint8korr(A) ((ulonglong)(((uint32) ((uchar) (A)[0])) +\ #define uint8korr(A) ((ulonglong)(((uint32_t) ((uchar) (A)[0])) +\
(((uint32) ((uchar) (A)[1])) << 8) +\ (((uint32_t) ((uchar) (A)[1])) << 8) +\
(((uint32) ((uchar) (A)[2])) << 16) +\ (((uint32_t) ((uchar) (A)[2])) << 16) +\
(((uint32) ((uchar) (A)[3])) << 24)) +\ (((uint32_t) ((uchar) (A)[3])) << 24)) +\
(((ulonglong) (((uint32) ((uchar) (A)[4])) +\ (((ulonglong) (((uint32_t) ((uchar) (A)[4])) +\
(((uint32) ((uchar) (A)[5])) << 8) +\ (((uint32_t) ((uchar) (A)[5])) << 8) +\
(((uint32) ((uchar) (A)[6])) << 16) +\ (((uint32_t) ((uchar) (A)[6])) << 16) +\
(((uint32) ((uchar) (A)[7])) << 24))) << 32)) (((uint32_t) ((uchar) (A)[7])) << 24))) << 32))
#define int2store(T,A) do { uint def_temp= (uint) (A) ;\ #define int2store(T,A) do { uint32_t def_temp= (uint32_t) (A) ;\
*((uchar*) (T)) = (uchar)(def_temp); \ *((uchar*) (T)) = (uchar)(def_temp); \
*((uchar*) (T+1)) = (uchar)((def_temp >> 8)); } while (0) *((uchar*) (T+1)) = (uchar)((def_temp >> 8)); } while (0)
#define int3store(T,A) do { /*lint -save -e734 */\ #define int3store(T,A) do { /*lint -save -e734 */\
@ -371,7 +373,7 @@ typedef union {
*(((char *)(T))+3) = (char)(((A) >> 24)); \ *(((char *)(T))+3) = (char)(((A) >> 24)); \
*(((char *)(T))+4) = (char)(((A) >> 32)); \ *(((char *)(T))+4) = (char)(((A) >> 32)); \
*(((char *)(T))+5) = (char)(((A) >> 40)); } while (0) *(((char *)(T))+5) = (char)(((A) >> 40)); } while (0)
#define int8store(T,A) { uint def_temp= (uint) (A), def_temp2= (uint) ((A) >> 32); \ #define int8store(T,A) { uint32_t def_temp= (uint32_t) (A), def_temp2= (uint32_t) ((A) >> 32); \
int4store((T),def_temp); \ int4store((T),def_temp); \
int4store((T+4),def_temp2); \ int4store((T+4),def_temp2); \
} }
@ -447,24 +449,24 @@ typedef union {
#ifdef WORDS_BIGENDIAN #ifdef WORDS_BIGENDIAN
#define ushortget(V,M) { V = (uint16) (((uint16) ((uchar) (M)[1]))+\ #define ushortget(V,M) { V = (uint16_t) (((uint16_t) ((uchar) (M)[1]))+\
((uint16) ((uint16) (M)[0]) << 8)); } ((uint16_t) ((uint16_t) (M)[0]) << 8)); }
#define shortget(V,M) { V = (short) (((short) ((uchar) (M)[1]))+\ #define shortget(V,M) { V = (int16_t) (((int16_t) ((uchar) (M)[1]))+\
((short) ((short) (M)[0]) << 8)); } ((int16_t) ((int16_t) (M)[0]) << 8)); }
#define longget(V,M) do { int32 def_temp;\ #define longget(V,M) do { int32_t def_temp;\
((char*) &def_temp)[0]=(M)[0];\ ((char*) &def_temp)[0]=(M)[0];\
((char*) &def_temp)[1]=(M)[1];\ ((char*) &def_temp)[1]=(M)[1];\
((char*) &def_temp)[2]=(M)[2];\ ((char*) &def_temp)[2]=(M)[2];\
((char*) &def_temp)[3]=(M)[3];\ ((char*) &def_temp)[3]=(M)[3];\
(V)=def_temp; } while (0) (V)=def_temp; } while (0)
#define ulongget(V,M) do { uint32 def_temp;\ #define ulongget(V,M) do { uint32_t def_temp;\
((char*) &def_temp)[0]=(M)[0];\ ((char*) &def_temp)[0]=(M)[0];\
((char*) &def_temp)[1]=(M)[1];\ ((char*) &def_temp)[1]=(M)[1];\
((char*) &def_temp)[2]=(M)[2];\ ((char*) &def_temp)[2]=(M)[2];\
((char*) &def_temp)[3]=(M)[3];\ ((char*) &def_temp)[3]=(M)[3];\
(V)=def_temp; } while (0) (V)=def_temp; } while (0)
#define shortstore(T,A) do { \ #define shortstore(T,A) do { \
uint def_temp=(uint) (A) ;\ uint32_t def_temp=(uint32_t) (A) ;\
*(((char *)(T))+1)=(char)(def_temp); \ *(((char *)(T))+1)=(char)(def_temp); \
*(((char *)(T))+0)=(char)(def_temp >> 8); } while (0) *(((char *)(T))+0)=(char)(def_temp >> 8); } while (0)
#define longstore(T,A) do { \ #define longstore(T,A) do { \

View file

@ -98,7 +98,7 @@
#define MAX_CHARSET_LEN 32 #define MAX_CHARSET_LEN 32
#define SET_ERROR_AFF_ROWS(s) (s)->upsert_status.affected_rows = (uint64) ~0 #define SET_ERROR_AFF_ROWS(s) (s)->upsert_status.affected_rows = (uint64_t) ~0
/* Error handling */ /* Error handling */
#define SET_NEW_MESSAGE(buf, buf_len, message, len, persistent) \ #define SET_NEW_MESSAGE(buf, buf_len, message, len, persistent) \

View file

@ -724,7 +724,7 @@ mysqlnd_fetch_stmt_row_buffered(MYSQLND_RES *result, void *param, unsigned int f
zval **current_row = set->data_cursor; zval **current_row = set->data_cursor;
if (NULL == current_row[0]) { if (NULL == current_row[0]) {
uint64 row_num = (set->data_cursor - set->data) / field_count; uint64_t row_num = (set->data_cursor - set->data) / field_count;
set->initialized_rows++; set->initialized_rows++;
result->m.row_decoder(set->row_buffers[row_num], result->m.row_decoder(set->row_buffers[row_num],
current_row, current_row,
@ -1284,7 +1284,7 @@ MYSQLND_METHOD(mysqlnd_stmt, send_long_data)(MYSQLND_STMT * const stmt, unsigned
php_error_docref(NULL TSRMLS_CC, E_WARNING, "There was an error " php_error_docref(NULL TSRMLS_CC, E_WARNING, "There was an error "
"while sending long data. Probably max_allowed_packet_size " "while sending long data. Probably max_allowed_packet_size "
"is smaller than the data. You have to increase it or send " "is smaller than the data. You have to increase it or send "
"smaller chunks of data. Answer was %u bytes long.", packet_len); "smaller chunks of data. Answer was "MYSQLND_SZ_T_SPEC" bytes long.", packet_len);
SET_STMT_ERROR(stmt, CR_CONNECTION_ERROR, UNKNOWN_SQLSTATE, SET_STMT_ERROR(stmt, CR_CONNECTION_ERROR, UNKNOWN_SQLSTATE,
"Server responded to COM_STMT_SEND_LONG_DATA."); "Server responded to COM_STMT_SEND_LONG_DATA.");
ret = FAIL; ret = FAIL;
@ -1564,7 +1564,7 @@ MYSQLND_METHOD(mysqlnd_stmt, set_result_bind_dtor)(MYSQLND_STMT * const stmt,
/* {{{ mysqlnd_stmt::insert_id */ /* {{{ mysqlnd_stmt::insert_id */
static uint64 static uint64_t
MYSQLND_METHOD(mysqlnd_stmt, insert_id)(const MYSQLND_STMT * const stmt) MYSQLND_METHOD(mysqlnd_stmt, insert_id)(const MYSQLND_STMT * const stmt)
{ {
return stmt->upsert_status.last_insert_id; return stmt->upsert_status.last_insert_id;
@ -1573,7 +1573,7 @@ MYSQLND_METHOD(mysqlnd_stmt, insert_id)(const MYSQLND_STMT * const stmt)
/* {{{ mysqlnd_stmt::affected_rows */ /* {{{ mysqlnd_stmt::affected_rows */
static uint64 static uint64_t
MYSQLND_METHOD(mysqlnd_stmt, affected_rows)(const MYSQLND_STMT * const stmt) MYSQLND_METHOD(mysqlnd_stmt, affected_rows)(const MYSQLND_STMT * const stmt)
{ {
return stmt->upsert_status.affected_rows; return stmt->upsert_status.affected_rows;
@ -1582,7 +1582,7 @@ MYSQLND_METHOD(mysqlnd_stmt, affected_rows)(const MYSQLND_STMT * const stmt)
/* {{{ mysqlnd_stmt::num_rows */ /* {{{ mysqlnd_stmt::num_rows */
static uint64 static uint64_t
MYSQLND_METHOD(mysqlnd_stmt, num_rows)(const MYSQLND_STMT * const stmt) MYSQLND_METHOD(mysqlnd_stmt, num_rows)(const MYSQLND_STMT * const stmt)
{ {
return stmt->result? mysqlnd_num_rows(stmt->result):0; return stmt->result? mysqlnd_num_rows(stmt->result):0;
@ -1646,7 +1646,7 @@ MYSQLND_METHOD(mysqlnd_stmt, sqlstate)(const MYSQLND_STMT * const stmt)
/* {{{ mysqlnd_stmt::data_seek */ /* {{{ mysqlnd_stmt::data_seek */
static enum_func_status static enum_func_status
MYSQLND_METHOD(mysqlnd_stmt, data_seek)(const MYSQLND_STMT * const stmt, uint64 row TSRMLS_DC) MYSQLND_METHOD(mysqlnd_stmt, data_seek)(const MYSQLND_STMT * const stmt, uint64_t row TSRMLS_DC)
{ {
return stmt->result? stmt->result->m.seek_data(stmt->result, row TSRMLS_CC) : FAIL; return stmt->result? stmt->result->m.seek_data(stmt->result, row TSRMLS_CC) : FAIL;
} }

View file

@ -28,17 +28,6 @@
#define MYSQLND_SILENT #define MYSQLND_SILENT
typedef int8 my_int8;
typedef uint8 my_uint8;
typedef int16 my_int16;
typedef uint16 my_uint16;
typedef int32 my_int32;
typedef uint32 my_uint32;
enum mysqlnd_timestamp_type enum mysqlnd_timestamp_type
{ {
MYSQLND_TIMESTAMP_NONE= -2, MYSQLND_TIMESTAMP_NONE= -2,
@ -58,7 +47,6 @@ struct st_mysqlnd_time
}; };
struct st_mysqlnd_perm_bind mysqlnd_ps_fetch_functions[MYSQL_TYPE_LAST + 1]; struct st_mysqlnd_perm_bind mysqlnd_ps_fetch_functions[MYSQL_TYPE_LAST + 1];
#define MYSQLND_PS_SKIP_RESULT_W_LEN -1 #define MYSQLND_PS_SKIP_RESULT_W_LEN -1
@ -75,17 +63,17 @@ void ps_fetch_from_1_to_8_bytes(zval *zv, const MYSQLND_FIELD * const field,
DBG_ENTER("ps_fetch_from_1_to_8_bytes"); DBG_ENTER("ps_fetch_from_1_to_8_bytes");
DBG_INF_FMT("zv=%p byte_count=%d", zv, byte_count); DBG_INF_FMT("zv=%p byte_count=%d", zv, byte_count);
if (field->flags & UNSIGNED_FLAG) { if (field->flags & UNSIGNED_FLAG) {
uint64 uval = 0; uint64_t uval = 0;
switch (byte_count) { switch (byte_count) {
case 8:uval = is_bit? (uint64) bit_uint8korr(*row):(uint64) uint8korr(*row);break; case 8:uval = is_bit? (uint64_t) bit_uint8korr(*row):(uint64_t) uint8korr(*row);break;
case 7:uval = bit_uint7korr(*row);break; case 7:uval = bit_uint7korr(*row);break;
case 6:uval = bit_uint6korr(*row);break; case 6:uval = bit_uint6korr(*row);break;
case 5:uval = bit_uint5korr(*row);break; case 5:uval = bit_uint5korr(*row);break;
case 4:uval = is_bit? (uint64) bit_uint4korr(*row):(uint64) uint4korr(*row);break; case 4:uval = is_bit? (uint64_t) bit_uint4korr(*row):(uint64_t) uint4korr(*row);break;
case 3:uval = is_bit? (uint64) bit_uint3korr(*row):(uint64) uint3korr(*row);break; case 3:uval = is_bit? (uint64_t) bit_uint3korr(*row):(uint64_t) uint3korr(*row);break;
case 2:uval = is_bit? (uint64) bit_uint2korr(*row):(uint64) uint2korr(*row);break; case 2:uval = is_bit? (uint64_t) bit_uint2korr(*row):(uint64_t) uint2korr(*row);break;
case 1:uval = (uint64) uint1korr(*row);break; case 1:uval = (uint64_t) uint1korr(*row);break;
} }
#if SIZEOF_LONG==4 #if SIZEOF_LONG==4
@ -104,21 +92,21 @@ void ps_fetch_from_1_to_8_bytes(zval *zv, const MYSQLND_FIELD * const field,
} }
} else { } else {
/* SIGNED */ /* SIGNED */
int64 lval = 0; int64_t lval = 0;
switch (byte_count) { switch (byte_count) {
case 8:lval = (int64) sint8korr(*row);break; case 8:lval = (int64_t) sint8korr(*row);break;
/* /*
7, 6 and 5 are not possible. 7, 6 and 5 are not possible.
BIT is only unsigned, thus only uint5|6|7 macroses exist BIT is only unsigned, thus only uint5|6|7 macroses exist
*/ */
case 4:lval = (int64) sint4korr(*row);break; case 4:lval = (int64_t) sint4korr(*row);break;
case 3:lval = (int64) sint3korr(*row);break; case 3:lval = (int64_t) sint3korr(*row);break;
case 2:lval = (int64) sint2korr(*row);break; case 2:lval = (int64_t) sint2korr(*row);break;
case 1:lval = (int64) *(my_int8*)*row;break; case 1:lval = (int64_t) *(int8_t*)*row;break;
} }
#if SIZEOF_LONG==4 #if SIZEOF_LONG==4
if ((L64(2147483647) < (int64) lval) || (L64(-2147483648) > (int64) lval)) { if ((L64(2147483647) < (int64_t) lval) || (L64(-2147483648) > (int64_t) lval)) {
DBG_INF("stringify"); DBG_INF("stringify");
tmp_len = sprintf((char *)&tmp, MYSQLND_LL_SPEC, lval); tmp_len = sprintf((char *)&tmp, MYSQLND_LL_SPEC, lval);
} else } else
@ -609,8 +597,8 @@ mysqlnd_stmt_execute_store_params(MYSQLND_STMT *stmt, zend_uchar **buf, zend_uch
size_t *buf_len, unsigned int null_byte_offset TSRMLS_DC) size_t *buf_len, unsigned int null_byte_offset TSRMLS_DC)
{ {
unsigned int i = 0; unsigned int i = 0;
unsigned left = (*buf_len - (*p - *buf)); size_t left = (*buf_len - (*p - *buf));
unsigned int data_size = 0; size_t data_size = 0;
zval **copies = NULL;/* if there are different types */ zval **copies = NULL;/* if there are different types */
/* 1. Store type information */ /* 1. Store type information */

View file

@ -1030,7 +1030,7 @@ mysqlnd_fetch_row_buffered_c(MYSQLND_RES *result TSRMLS_DC)
unsigned int i; unsigned int i;
if (NULL == current_row[0]) { if (NULL == current_row[0]) {
uint64 row_num = (set->data_cursor - set->data) / result->meta->field_count; uint64_t row_num = (set->data_cursor - set->data) / result->meta->field_count;
set->initialized_rows++; set->initialized_rows++;
result->m.row_decoder(set->row_buffers[row_num], result->m.row_decoder(set->row_buffers[row_num],
current_row, current_row,
@ -1096,7 +1096,7 @@ mysqlnd_fetch_row_buffered(MYSQLND_RES *result, void *param, unsigned int flags,
struct mysqlnd_field_hash_key *zend_hash_key = result->meta->zend_hash_keys; struct mysqlnd_field_hash_key *zend_hash_key = result->meta->zend_hash_keys;
if (NULL == current_row[0]) { if (NULL == current_row[0]) {
uint64 row_num = (set->data_cursor - set->data) / result->meta->field_count; uint64_t row_num = (set->data_cursor - set->data) / result->meta->field_count;
set->initialized_rows++; set->initialized_rows++;
result->m.row_decoder(set->row_buffers[row_num], result->m.row_decoder(set->row_buffers[row_num],
current_row, current_row,
@ -1220,7 +1220,7 @@ mysqlnd_store_result_fetch_data(MYSQLND * const conn, MYSQLND_RES *result,
while (FAIL != (ret = PACKET_READ(row_packet, conn)) && !row_packet->eof) { while (FAIL != (ret = PACKET_READ(row_packet, conn)) && !row_packet->eof) {
if (!free_rows) { if (!free_rows) {
uint64 total_allocated_rows = free_rows = next_extend = next_extend * 11 / 10; /* extend with 10% */ uint64_t total_allocated_rows = free_rows = next_extend = next_extend * 11 / 10; /* extend with 10% */
total_allocated_rows += set->row_count; total_allocated_rows += set->row_count;
set->row_buffers = mnd_perealloc(set->row_buffers, set->row_buffers = mnd_perealloc(set->row_buffers,
total_allocated_rows * sizeof(MYSQLND_MEMORY_POOL_CHUNK *), total_allocated_rows * sizeof(MYSQLND_MEMORY_POOL_CHUNK *),
@ -1361,7 +1361,7 @@ mysqlnd_fetch_row_async_buffered(MYSQLND_RES *result, void *param, unsigned int
/* At the point we are still under LOCK */ /* At the point we are still under LOCK */
if (set->data_cursor && (set->data_cursor - set->data) < (set->row_count)) { if (set->data_cursor && (set->data_cursor - set->data) < (set->row_count)) {
uint64 row_num = set->data_cursor - set->data; uint64_t row_num = set->data_cursor - set->data;
zval **current_row = *set->data_cursor++; zval **current_row = *set->data_cursor++;
set->initialized_rows++; set->initialized_rows++;
/* We don't forget to release the lock */ /* We don't forget to release the lock */
@ -1482,8 +1482,8 @@ mysqlnd_background_store_result_fetch_data(MYSQLND_RES *result TSRMLS_DC)
while (FAIL != (ret = PACKET_READ(row_packet, conn)) && !row_packet->eof) { while (FAIL != (ret = PACKET_READ(row_packet, conn)) && !row_packet->eof) {
tsrm_mutex_lock(set->LOCK); tsrm_mutex_lock(set->LOCK);
if (!free_rows) { if (!free_rows) {
uint64 total_rows = free_rows = next_extend = next_extend * 5 / 3; /* extend with 33% */ uint64_t total_rows = free_rows = next_extend = next_extend * 5 / 3; /* extend with 33% */
uint64 old_size; uint64_t old_size;
total_rows += set->row_count; total_rows += set->row_count;
old_size = set->data_size; old_size = set->data_size;
@ -1698,7 +1698,7 @@ MYSQLND_METHOD(mysqlnd_res, free_result)(MYSQLND_RES *result, zend_bool implicit
/* {{{ mysqlnd_res::data_seek */ /* {{{ mysqlnd_res::data_seek */
static enum_func_status static enum_func_status
MYSQLND_METHOD(mysqlnd_res, data_seek)(MYSQLND_RES *result, uint64 row TSRMLS_DC) MYSQLND_METHOD(mysqlnd_res, data_seek)(MYSQLND_RES *result, uint64_t row TSRMLS_DC)
{ {
DBG_ENTER("mysqlnd_res::data_seek"); DBG_ENTER("mysqlnd_res::data_seek");
DBG_INF_FMT("row=%lu", row); DBG_INF_FMT("row=%lu", row);
@ -1720,7 +1720,7 @@ MYSQLND_METHOD(mysqlnd_res, data_seek)(MYSQLND_RES *result, uint64 row TSRMLS_DC
/* {{{ mysqlnd_res::num_rows */ /* {{{ mysqlnd_res::num_rows */
static uint64 static uint64_t
MYSQLND_METHOD(mysqlnd_res, num_rows)(const MYSQLND_RES * const result) MYSQLND_METHOD(mysqlnd_res, num_rows)(const MYSQLND_RES * const result)
{ {
/* Be compatible with libmysql. We count row_count, but will return 0 */ /* Be compatible with libmysql. We count row_count, but will return 0 */

View file

@ -62,8 +62,8 @@ extern const MYSQLND_STRING mysqlnd_stats_values_names[];
#define MYSQLND_INC_GLOBAL_STATISTIC_W_VALUE2(statistic1, value1, statistic2, value2) \ #define MYSQLND_INC_GLOBAL_STATISTIC_W_VALUE2(statistic1, value1, statistic2, value2) \
{ \ { \
if (MYSQLND_G(collect_statistics)) { \ if (MYSQLND_G(collect_statistics)) { \
uint64 v1 = (uint64) (value1); \ uint64_t v1 = (uint64_t) (value1); \
uint64 v2 = (uint64) (value2); \ uint64_t v2 = (uint64_t) (value2); \
DBG_INF_FMT("Global stat increase [%s] [%s]", mysqlnd_stats_values_names[statistic1], mysqlnd_stats_values_names[statistic2]); \ DBG_INF_FMT("Global stat increase [%s] [%s]", mysqlnd_stats_values_names[statistic1], mysqlnd_stats_values_names[statistic2]); \
\ \
tsrm_mutex_lock(mysqlnd_global_stats->LOCK_access); \ tsrm_mutex_lock(mysqlnd_global_stats->LOCK_access); \
@ -89,7 +89,7 @@ extern const MYSQLND_STRING mysqlnd_stats_values_names[];
#define MYSQLND_INC_CONN_STATISTIC_W_VALUE(conn_stats, statistic, value) \ #define MYSQLND_INC_CONN_STATISTIC_W_VALUE(conn_stats, statistic, value) \
{ \ { \
if (MYSQLND_G(collect_statistics) && statistic != STAT_LAST) { \ if (MYSQLND_G(collect_statistics) && statistic != STAT_LAST) { \
uint64 v = (uint64) (value); \ uint64_t v = (uint64_t) (value); \
DBG_INF_FMT("Global&Conn stat increase w value [%s]", mysqlnd_stats_values_names[statistic]); \ DBG_INF_FMT("Global&Conn stat increase w value [%s]", mysqlnd_stats_values_names[statistic]); \
tsrm_mutex_lock(mysqlnd_global_stats->LOCK_access); \ tsrm_mutex_lock(mysqlnd_global_stats->LOCK_access); \
mysqlnd_global_stats->values[(statistic)] += v; \ mysqlnd_global_stats->values[(statistic)] += v; \
@ -103,8 +103,8 @@ extern const MYSQLND_STRING mysqlnd_stats_values_names[];
#define MYSQLND_INC_CONN_STATISTIC_W_VALUE2(conn_stats, statistic1, value1, statistic2, value2) \ #define MYSQLND_INC_CONN_STATISTIC_W_VALUE2(conn_stats, statistic1, value1, statistic2, value2) \
{ \ { \
if (MYSQLND_G(collect_statistics)) { \ if (MYSQLND_G(collect_statistics)) { \
uint64 v1 = (uint64) (value1); \ uint64_t v1 = (uint64_t) (value1); \
uint64 v2 = (uint64) (value2); \ uint64_t v2 = (uint64_t) (value2); \
\ \
tsrm_mutex_lock(mysqlnd_global_stats->LOCK_access); \ tsrm_mutex_lock(mysqlnd_global_stats->LOCK_access); \
if (statistic1 != STAT_LAST) mysqlnd_global_stats->values[(statistic1)]+= v1; \ if (statistic1 != STAT_LAST) mysqlnd_global_stats->values[(statistic1)]+= v1; \
@ -121,9 +121,9 @@ extern const MYSQLND_STRING mysqlnd_stats_values_names[];
#define MYSQLND_INC_CONN_STATISTIC_W_VALUE3(conn_stats, statistic1, value1, statistic2, value2, statistic3, value3) \ #define MYSQLND_INC_CONN_STATISTIC_W_VALUE3(conn_stats, statistic1, value1, statistic2, value2, statistic3, value3) \
{ \ { \
if (MYSQLND_G(collect_statistics)) { \ if (MYSQLND_G(collect_statistics)) { \
uint64 v1 = (uint64) (value1); \ uint64_t v1 = (uint64_t) (value1); \
uint64 v2 = (uint64) (value2); \ uint64_t v2 = (uint64_t) (value2); \
uint64 v3 = (uint64) (value3); \ uint64_t v3 = (uint64_t) (value3); \
\ \
tsrm_mutex_lock(mysqlnd_global_stats->LOCK_access); \ tsrm_mutex_lock(mysqlnd_global_stats->LOCK_access); \
if (statistic1 != STAT_LAST) mysqlnd_global_stats->values[(statistic1)]+= v1; \ if (statistic1 != STAT_LAST) mysqlnd_global_stats->values[(statistic1)]+= v1; \
@ -164,8 +164,8 @@ extern const MYSQLND_STRING mysqlnd_stats_values_names[];
#define MYSQLND_INC_GLOBAL_STATISTIC_W_VALUE2(statistic1, value1, statistic2, value2) \ #define MYSQLND_INC_GLOBAL_STATISTIC_W_VALUE2(statistic1, value1, statistic2, value2) \
{ \ { \
if (MYSQLND_G(collect_statistics)) { \ if (MYSQLND_G(collect_statistics)) { \
uint64 v1 = (uint64) (value1); \ uint64_t v1 = (uint64_t) (value1); \
uint64 v2 = (uint64) (value2); \ uint64_t v2 = (uint64_t) (value2); \
DBG_INF_FMT("Global stat increase [%s] [%s]", mysqlnd_stats_values_names[statistic1], mysqlnd_stats_values_names[statistic2]); \ DBG_INF_FMT("Global stat increase [%s] [%s]", mysqlnd_stats_values_names[statistic1], mysqlnd_stats_values_names[statistic2]); \
\ \
if (statistic1 != STAT_LAST) mysqlnd_global_stats->values[(statistic1)]+= v1; \ if (statistic1 != STAT_LAST) mysqlnd_global_stats->values[(statistic1)]+= v1; \
@ -187,7 +187,7 @@ extern const MYSQLND_STRING mysqlnd_stats_values_names[];
#define MYSQLND_INC_CONN_STATISTIC_W_VALUE(conn_stats, statistic, value) \ #define MYSQLND_INC_CONN_STATISTIC_W_VALUE(conn_stats, statistic, value) \
{ \ { \
if (MYSQLND_G(collect_statistics) && statistic != STAT_LAST) { \ if (MYSQLND_G(collect_statistics) && statistic != STAT_LAST) { \
uint64 v = (uint64) (value); \ uint64_t v = (uint64_t) (value); \
DBG_INF_FMT("Global&Conn stats increase w value [%s]", mysqlnd_stats_values_names[statistic]); \ DBG_INF_FMT("Global&Conn stats increase w value [%s]", mysqlnd_stats_values_names[statistic]); \
mysqlnd_global_stats->values[(statistic)] += v; \ mysqlnd_global_stats->values[(statistic)] += v; \
if ((conn_stats)) { \ if ((conn_stats)) { \
@ -199,8 +199,8 @@ extern const MYSQLND_STRING mysqlnd_stats_values_names[];
#define MYSQLND_INC_CONN_STATISTIC_W_VALUE2(conn_stats, statistic1, value1, statistic2, value2) \ #define MYSQLND_INC_CONN_STATISTIC_W_VALUE2(conn_stats, statistic1, value1, statistic2, value2) \
{ \ { \
if (MYSQLND_G(collect_statistics)) { \ if (MYSQLND_G(collect_statistics)) { \
uint64 v1 = (uint64) (value1); \ uint64_t v1 = (uint64_t) (value1); \
uint64 v2 = (uint64) (value2); \ uint64_t v2 = (uint64_t) (value2); \
\ \
if (statistic1 != STAT_LAST) mysqlnd_global_stats->values[(statistic1)]+= v1; \ if (statistic1 != STAT_LAST) mysqlnd_global_stats->values[(statistic1)]+= v1; \
if (statistic2 != STAT_LAST) mysqlnd_global_stats->values[(statistic2)]+= v2; \ if (statistic2 != STAT_LAST) mysqlnd_global_stats->values[(statistic2)]+= v2; \
@ -214,9 +214,9 @@ extern const MYSQLND_STRING mysqlnd_stats_values_names[];
#define MYSQLND_INC_CONN_STATISTIC_W_VALUE3(conn_stats, statistic1, value1, statistic2, value2, statistic3, value3) \ #define MYSQLND_INC_CONN_STATISTIC_W_VALUE3(conn_stats, statistic1, value1, statistic2, value2, statistic3, value3) \
{ \ { \
if (MYSQLND_G(collect_statistics)) { \ if (MYSQLND_G(collect_statistics)) { \
uint64 v1 = (uint64) (value1); \ uint64_t v1 = (uint64_t) (value1); \
uint64 v2 = (uint64) (value2); \ uint64_t v2 = (uint64_t) (value2); \
uint64 v3 = (uint64) (value3); \ uint64_t v3 = (uint64_t) (value3); \
\ \
if (statistic1 != STAT_LAST) mysqlnd_global_stats->values[(statistic1)]+= v1; \ if (statistic1 != STAT_LAST) mysqlnd_global_stats->values[(statistic1)]+= v1; \
if (statistic2 != STAT_LAST) mysqlnd_global_stats->values[(statistic2)]+= v2; \ if (statistic2 != STAT_LAST) mysqlnd_global_stats->values[(statistic2)]+= v2; \

View file

@ -45,7 +45,7 @@ struct st_mysqlnd_memory_pool
struct st_mysqlnd_memory_pool_chunk struct st_mysqlnd_memory_pool_chunk
{ {
uint64 app; uint64_t app;
MYSQLND_MEMORY_POOL *pool; MYSQLND_MEMORY_POOL *pool;
zend_uchar *ptr; zend_uchar *ptr;
uint size; uint size;
@ -94,8 +94,8 @@ typedef struct st_mysqlnd_upsert_result
{ {
unsigned int warning_count; unsigned int warning_count;
unsigned int server_status; unsigned int server_status;
uint64 affected_rows; uint64_t affected_rows;
uint64 last_insert_id; uint64_t last_insert_id;
} mysqlnd_upsert_status; } mysqlnd_upsert_status;
@ -210,7 +210,7 @@ typedef enum_func_status (*mysqlnd_fetch_row_func)(MYSQLND_RES *result,
typedef struct st_mysqlnd_stats typedef struct st_mysqlnd_stats
{ {
uint64 values[STAT_LAST]; uint64_t values[STAT_LAST];
#ifdef ZTS #ifdef ZTS
MUTEX_T LOCK_access; MUTEX_T LOCK_access;
#endif #endif
@ -257,7 +257,7 @@ struct st_mysqlnd_conn_methods
unsigned int (*get_error_no)(const MYSQLND * const conn); unsigned int (*get_error_no)(const MYSQLND * const conn);
const char * (*get_error_str)(const MYSQLND * const conn); const char * (*get_error_str)(const MYSQLND * const conn);
const char * (*get_sqlstate)(const MYSQLND * const conn); const char * (*get_sqlstate)(const MYSQLND * const conn);
uint64 (*get_thread_id)(const MYSQLND * const conn); uint64_t (*get_thread_id)(const MYSQLND * const conn);
void (*get_statistics)(const MYSQLND * const conn, zval *return_value TSRMLS_DC ZEND_FILE_LINE_DC); void (*get_statistics)(const MYSQLND * const conn, zval *return_value TSRMLS_DC ZEND_FILE_LINE_DC);
unsigned long (*get_server_version)(const MYSQLND * const conn); unsigned long (*get_server_version)(const MYSQLND * const conn);
@ -270,8 +270,8 @@ struct st_mysqlnd_conn_methods
MYSQLND_RES * (*list_fields)(MYSQLND *conn, const char *table, const char *achtung_wild TSRMLS_DC); MYSQLND_RES * (*list_fields)(MYSQLND *conn, const char *table, const char *achtung_wild TSRMLS_DC);
MYSQLND_RES * (*list_method)(MYSQLND *conn, const char *query, const char *achtung_wild, char *par1 TSRMLS_DC); MYSQLND_RES * (*list_method)(MYSQLND *conn, const char *query, const char *achtung_wild, char *par1 TSRMLS_DC);
uint64 (*get_last_insert_id)(const MYSQLND * const conn); uint64_t (*get_last_insert_id)(const MYSQLND * const conn);
uint64 (*get_affected_rows)(const MYSQLND * const conn); uint64_t (*get_affected_rows)(const MYSQLND * const conn);
unsigned int (*get_warning_count)(const MYSQLND * const conn); unsigned int (*get_warning_count)(const MYSQLND * const conn);
unsigned int (*get_field_count)(const MYSQLND * const conn); unsigned int (*get_field_count)(const MYSQLND * const conn);
@ -302,10 +302,10 @@ struct st_mysqlnd_res_methods
MYSQLND_ROW_C (*fetch_row_c)(MYSQLND_RES *result TSRMLS_DC); MYSQLND_ROW_C (*fetch_row_c)(MYSQLND_RES *result TSRMLS_DC);
void (*fetch_all)(MYSQLND_RES *result, unsigned int flags, zval *return_value TSRMLS_DC ZEND_FILE_LINE_DC); void (*fetch_all)(MYSQLND_RES *result, unsigned int flags, zval *return_value TSRMLS_DC ZEND_FILE_LINE_DC);
void (*fetch_field_data)(MYSQLND_RES *result, unsigned int offset, zval *return_value TSRMLS_DC); void (*fetch_field_data)(MYSQLND_RES *result, unsigned int offset, zval *return_value TSRMLS_DC);
uint64 (*num_rows)(const MYSQLND_RES * const result); uint64_t (*num_rows)(const MYSQLND_RES * const result);
unsigned int (*num_fields)(const MYSQLND_RES * const result); unsigned int (*num_fields)(const MYSQLND_RES * const result);
enum_func_status (*skip_result)(MYSQLND_RES * const result TSRMLS_DC); enum_func_status (*skip_result)(MYSQLND_RES * const result TSRMLS_DC);
enum_func_status (*seek_data)(MYSQLND_RES * result, uint64 row TSRMLS_DC); enum_func_status (*seek_data)(MYSQLND_RES * result, uint64_t row TSRMLS_DC);
MYSQLND_FIELD_OFFSET (*seek_field)(MYSQLND_RES * const result, MYSQLND_FIELD_OFFSET field_offset); MYSQLND_FIELD_OFFSET (*seek_field)(MYSQLND_RES * const result, MYSQLND_FIELD_OFFSET field_offset);
MYSQLND_FIELD_OFFSET (*field_tell)(const MYSQLND_RES * const result); MYSQLND_FIELD_OFFSET (*field_tell)(const MYSQLND_RES * const result);
const MYSQLND_FIELD *(*fetch_field)(MYSQLND_RES * const result TSRMLS_DC); const MYSQLND_FIELD *(*fetch_field)(MYSQLND_RES * const result TSRMLS_DC);
@ -347,7 +347,7 @@ struct st_mysqlnd_stmt_methods
zend_bool (*more_results)(const MYSQLND_STMT * const stmt TSRMLS_DC); zend_bool (*more_results)(const MYSQLND_STMT * const stmt TSRMLS_DC);
enum_func_status (*next_result)(MYSQLND_STMT * const stmt TSRMLS_DC); enum_func_status (*next_result)(MYSQLND_STMT * const stmt TSRMLS_DC);
enum_func_status (*free_result)(MYSQLND_STMT * const stmt TSRMLS_DC); enum_func_status (*free_result)(MYSQLND_STMT * const stmt TSRMLS_DC);
enum_func_status (*seek_data)(const MYSQLND_STMT * const stmt, uint64 row TSRMLS_DC); enum_func_status (*seek_data)(const MYSQLND_STMT * const stmt, uint64_t row TSRMLS_DC);
enum_func_status (*reset)(MYSQLND_STMT * const stmt TSRMLS_DC); enum_func_status (*reset)(MYSQLND_STMT * const stmt TSRMLS_DC);
enum_func_status (*net_close)(MYSQLND_STMT * const stmt, zend_bool implicit TSRMLS_DC); /* private */ enum_func_status (*net_close)(MYSQLND_STMT * const stmt, zend_bool implicit TSRMLS_DC); /* private */
enum_func_status (*dtor)(MYSQLND_STMT * const stmt, zend_bool implicit TSRMLS_DC); /* use this for mysqlnd_stmt_close */ enum_func_status (*dtor)(MYSQLND_STMT * const stmt, zend_bool implicit TSRMLS_DC); /* use this for mysqlnd_stmt_close */
@ -366,9 +366,9 @@ struct st_mysqlnd_stmt_methods
MYSQLND_RES * (*get_parameter_metadata)(MYSQLND_STMT * const stmt); MYSQLND_RES * (*get_parameter_metadata)(MYSQLND_STMT * const stmt);
MYSQLND_RES * (*get_result_metadata)(MYSQLND_STMT * const stmt TSRMLS_DC); MYSQLND_RES * (*get_result_metadata)(MYSQLND_STMT * const stmt TSRMLS_DC);
uint64 (*get_last_insert_id)(const MYSQLND_STMT * const stmt); uint64_t (*get_last_insert_id)(const MYSQLND_STMT * const stmt);
uint64 (*get_affected_rows)(const MYSQLND_STMT * const stmt); uint64_t (*get_affected_rows)(const MYSQLND_STMT * const stmt);
uint64 (*get_num_rows)(const MYSQLND_STMT * const stmt); uint64_t (*get_num_rows)(const MYSQLND_STMT * const stmt);
unsigned int (*get_param_count)(const MYSQLND_STMT * const stmt); unsigned int (*get_param_count)(const MYSQLND_STMT * const stmt);
unsigned int (*get_field_count)(const MYSQLND_STMT * const stmt); unsigned int (*get_field_count)(const MYSQLND_STMT * const stmt);
@ -395,7 +395,7 @@ struct st_mysqlnd_connection
char *passwd; char *passwd;
unsigned int *passwd_len; unsigned int *passwd_len;
char *scheme; char *scheme;
uint64 thread_id; uint64_t thread_id;
char *server_version; char *server_version;
char *host_info; char *host_info;
unsigned char *scramble; unsigned char *scramble;
@ -502,11 +502,11 @@ struct st_mysqlnd_result_metadata
struct st_mysqlnd_background_buffered_result struct st_mysqlnd_background_buffered_result
{ {
zval ***data; zval ***data;
uint64 data_size; uint64_t data_size;
zval ***data_cursor; zval ***data_cursor;
MYSQLND_MEMORY_POOL_CHUNK **row_buffers; MYSQLND_MEMORY_POOL_CHUNK **row_buffers;
uint64 row_count; uint64_t row_count;
uint64 initialized_rows; uint64_t initialized_rows;
zend_bool persistent; zend_bool persistent;
MYSQLND_QCACHE *qcache; MYSQLND_QCACHE *qcache;
@ -529,8 +529,8 @@ struct st_mysqlnd_buffered_result
zval **data; zval **data;
zval **data_cursor; zval **data_cursor;
MYSQLND_MEMORY_POOL_CHUNK **row_buffers; MYSQLND_MEMORY_POOL_CHUNK **row_buffers;
uint64 row_count; uint64_t row_count;
uint64 initialized_rows; uint64_t initialized_rows;
zend_bool persistent; zend_bool persistent;
MYSQLND_QCACHE *qcache; MYSQLND_QCACHE *qcache;
@ -546,7 +546,7 @@ struct st_mysqlnd_unbuffered_result
zval **last_row_data; zval **last_row_data;
MYSQLND_MEMORY_POOL_CHUNK *last_row_buffer; MYSQLND_MEMORY_POOL_CHUNK *last_row_buffer;
uint64 row_count; uint64_t row_count;
zend_bool eof_reached; zend_bool eof_reached;
}; };

View file

@ -35,7 +35,6 @@
#include <winsock.h> #include <winsock.h>
#endif #endif
#define USE_CORK 0 #define USE_CORK 0
#define MYSQLND_SILENT 1 #define MYSQLND_SILENT 1
@ -159,48 +158,48 @@ unsigned long php_mysqlnd_net_field_length(zend_uchar **packet)
/* {{{ php_mysqlnd_net_field_length_ll /* {{{ php_mysqlnd_net_field_length_ll
Get next field's length */ Get next field's length */
uint64 php_mysqlnd_net_field_length_ll(zend_uchar **packet) uint64_t php_mysqlnd_net_field_length_ll(zend_uchar **packet)
{ {
register zend_uchar *p= (zend_uchar *)*packet; register zend_uchar *p= (zend_uchar *)*packet;
if (*p < 251) { if (*p < 251) {
(*packet)++; (*packet)++;
return (uint64) *p; return (uint64_t) *p;
} }
switch (*p) { switch (*p) {
case 251: case 251:
(*packet)++; (*packet)++;
return (uint64) MYSQLND_NULL_LENGTH; return (uint64_t) MYSQLND_NULL_LENGTH;
case 252: case 252:
(*packet) += 3; (*packet) += 3;
return (uint64) uint2korr(p + 1); return (uint64_t) uint2korr(p + 1);
case 253: case 253:
(*packet) += 4; (*packet) += 4;
return (uint64) uint3korr(p + 1); return (uint64_t) uint3korr(p + 1);
default: default:
(*packet) += 9; (*packet) += 9;
return (uint64) uint8korr(p + 1); return (uint64_t) uint8korr(p + 1);
} }
} }
/* }}} */ /* }}} */
/* {{{ php_mysqlnd_net_store_length */ /* {{{ php_mysqlnd_net_store_length */
zend_uchar *php_mysqlnd_net_store_length(zend_uchar *packet, uint64 length) zend_uchar *php_mysqlnd_net_store_length(zend_uchar *packet, uint64_t length)
{ {
if (length < (uint64) L64(251)) { if (length < (uint64_t) L64(251)) {
*packet = (zend_uchar) length; *packet = (zend_uchar) length;
return packet + 1; return packet + 1;
} }
if (length < (uint64) L64(65536)) { if (length < (uint64_t) L64(65536)) {
*packet++ = 252; *packet++ = 252;
int2store(packet,(uint) length); int2store(packet,(uint) length);
return packet + 2; return packet + 2;
} }
if (length < (uint64) L64(16777216)) { if (length < (uint64_t) L64(16777216)) {
*packet++ = 253; *packet++ = 253;
int3store(packet,(ulong) length); int3store(packet,(ulong) length);
return packet + 3; return packet + 3;
@ -248,8 +247,8 @@ size_t php_mysqlnd_consume_uneaten_data(MYSQLND * const conn, enum php_mysqlnd_s
DBG_ERR_FMT("Skipped %u bytes. Last command %s hasn't consumed all the output from the server", DBG_ERR_FMT("Skipped %u bytes. Last command %s hasn't consumed all the output from the server",
bytes_consumed, mysqlnd_command_to_text[net->last_command]); bytes_consumed, mysqlnd_command_to_text[net->last_command]);
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Skipped %u bytes. Last command %s hasn't " php_error_docref(NULL TSRMLS_CC, E_WARNING, "Skipped %u bytes. Last command %s hasn't "
"consumed all the output from the server. PID=%d", "consumed all the output from the server",
bytes_consumed, mysqlnd_command_to_text[net->last_command], getpid()); bytes_consumed, mysqlnd_command_to_text[net->last_command]);
} }
} }
net->last_command = cmd; net->last_command = cmd;
@ -316,7 +315,7 @@ int mysqlnd_set_sock_no_delay(php_stream *stream)
/* We assume that MYSQLND_HEADER_SIZE is 4 bytes !! */ /* We assume that MYSQLND_HEADER_SIZE is 4 bytes !! */
#define STORE_HEADER_SIZE(safe_storage, buffer) int4store((safe_storage), (*(uint32 *)(buffer))) #define STORE_HEADER_SIZE(safe_storage, buffer) int4store((safe_storage), (*(uint32_t *)(buffer)))
#define RESTORE_HEADER_SIZE(buffer, safe_storage) STORE_HEADER_SIZE((safe_storage), (buffer)) #define RESTORE_HEADER_SIZE(buffer, safe_storage) STORE_HEADER_SIZE((safe_storage), (buffer))
/* {{{ mysqlnd_stream_write_w_header */ /* {{{ mysqlnd_stream_write_w_header */
@ -499,8 +498,8 @@ mysqlnd_read_header(MYSQLND *conn, mysqlnd_packet_header *header TSRMLS_DC)
DBG_ERR_FMT("Packets out of order. Expected %d received %d. Packet size=%d", DBG_ERR_FMT("Packets out of order. Expected %d received %d. Packet size=%d",
net->packet_no, header->packet_no, header->size); net->packet_no, header->packet_no, header->size);
php_error(E_WARNING, "Packets out of order. Expected %d received %d. Packet size=%d. PID=%d", php_error(E_WARNING, "Packets out of order. Expected %d received %d. Packet size="MYSQLND_SZ_T_SPEC,
net->packet_no, header->packet_no, header->size, getpid()); net->packet_no, header->packet_no, header->size);
DBG_RETURN(FAIL); DBG_RETURN(FAIL);
} }
/* }}} */ /* }}} */
@ -629,8 +628,8 @@ php_mysqlnd_greet_read(void *_packet, MYSQLND *conn TSRMLS_DC)
if (p - begin > packet->header.size) { if (p - begin > packet->header.size) {
DBG_ERR_FMT("GREET packet %d bytes shorter than expected", p - begin - packet->header.size); DBG_ERR_FMT("GREET packet %d bytes shorter than expected", p - begin - packet->header.size);
php_error_docref(NULL TSRMLS_CC, E_WARNING, "GREET packet %d bytes shorter than expected. PID=%d", php_error_docref(NULL TSRMLS_CC, E_WARNING, "GREET packet "MYSQLND_SZ_T_SPEC" bytes shorter than expected",
p - begin - packet->header.size, getpid()); p - begin - packet->header.size);
} }
DBG_RETURN(PASS); DBG_RETURN(PASS);
@ -826,8 +825,8 @@ php_mysqlnd_ok_read(void *_packet, MYSQLND *conn TSRMLS_DC)
if (p - begin > packet->header.size) { if (p - begin > packet->header.size) {
DBG_ERR_FMT("OK packet %d bytes shorter than expected", p - begin - packet->header.size); DBG_ERR_FMT("OK packet %d bytes shorter than expected", p - begin - packet->header.size);
php_error_docref(NULL TSRMLS_CC, E_WARNING, "OK packet %d bytes shorter than expected. PID=%d", php_error_docref(NULL TSRMLS_CC, E_WARNING, "OK packet "MYSQLND_SZ_T_SPEC" bytes shorter than expected",
p - begin - packet->header.size, getpid()); p - begin - packet->header.size);
} }
DBG_RETURN(PASS); DBG_RETURN(PASS);
@ -899,8 +898,8 @@ php_mysqlnd_eof_read(void *_packet, MYSQLND *conn TSRMLS_DC)
if (p - begin > packet->header.size) { if (p - begin > packet->header.size) {
DBG_ERR_FMT("EOF packet %d bytes shorter than expected", p - begin - packet->header.size); DBG_ERR_FMT("EOF packet %d bytes shorter than expected", p - begin - packet->header.size);
php_error_docref(NULL TSRMLS_CC, E_WARNING, "EOF packet %d bytes shorter than expected. PID=%d", php_error_docref(NULL TSRMLS_CC, E_WARNING, "EOF packet "MYSQLND_SZ_T_SPEC" bytes shorter than expected",
p - begin - packet->header.size, getpid()); p - begin - packet->header.size);
} }
DBG_INF_FMT("EOF packet: fields=%d status=%d warnings=%d", DBG_INF_FMT("EOF packet: fields=%d status=%d warnings=%d",
@ -1064,8 +1063,8 @@ php_mysqlnd_rset_header_read(void *_packet, MYSQLND *conn TSRMLS_DC)
} }
if (p - begin > packet->header.size) { if (p - begin > packet->header.size) {
DBG_ERR_FMT("RSET_HEADER packet %d bytes shorter than expected", p - begin - packet->header.size); DBG_ERR_FMT("RSET_HEADER packet %d bytes shorter than expected", p - begin - packet->header.size);
php_error_docref(NULL TSRMLS_CC, E_WARNING, "GREET packet %d bytes shorter than expected. PID=%d", php_error_docref(NULL TSRMLS_CC, E_WARNING, "GREET packet "MYSQLND_SZ_T_SPEC" bytes shorter than expected",
p - begin - packet->header.size, getpid()); p - begin - packet->header.size);
} }
DBG_RETURN(PASS); DBG_RETURN(PASS);
@ -1204,8 +1203,8 @@ php_mysqlnd_rset_field_read(void *_packet, MYSQLND *conn TSRMLS_DC)
if (p - begin > packet->header.size) { if (p - begin > packet->header.size) {
DBG_ERR_FMT("RSET field packet %d bytes shorter than expected", p - begin - packet->header.size); DBG_ERR_FMT("RSET field packet %d bytes shorter than expected", p - begin - packet->header.size);
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Result set field packet %d bytes " php_error_docref(NULL TSRMLS_CC, E_WARNING, "Result set field packet "MYSQLND_SZ_T_SPEC" bytes "
"shorter than expected. PID=%d", p - begin - packet->header.size, getpid()); "shorter than expected", p - begin - packet->header.size);
} }
root_ptr = meta->root = mnd_emalloc(total_len); root_ptr = meta->root = mnd_emalloc(total_len);
@ -1282,7 +1281,7 @@ void php_mysqlnd_rset_field_free_mem(void *_packet, zend_bool alloca TSRMLS_DC)
static enum_func_status static enum_func_status
php_mysqlnd_read_row_ex(MYSQLND *conn, MYSQLND_MEMORY_POOL_CHUNK **buffer, php_mysqlnd_read_row_ex(MYSQLND *conn, MYSQLND_MEMORY_POOL_CHUNK **buffer,
uint64 *data_size, zend_bool persistent_alloc, uint64_t *data_size, zend_bool persistent_alloc,
unsigned int prealloc_more_bytes TSRMLS_DC) unsigned int prealloc_more_bytes TSRMLS_DC)
{ {
enum_func_status ret = PASS; enum_func_status ret = PASS;
@ -1337,7 +1336,7 @@ php_mysqlnd_read_row_ex(MYSQLND *conn, MYSQLND_MEMORY_POOL_CHUNK **buffer,
if (!mysqlnd_read_body(conn, p, header.size TSRMLS_CC)) { if (!mysqlnd_read_body(conn, p, header.size TSRMLS_CC)) {
DBG_ERR("Empty row packet body"); DBG_ERR("Empty row packet body");
php_error(E_WARNING, "Empty row packet body. PID=%d", getpid()); php_error(E_WARNING, "Empty row packet body");
ret = FAIL; ret = FAIL;
break; break;
} }
@ -1560,7 +1559,7 @@ void php_mysqlnd_rowp_read_text_protocol(MYSQLND_MEMORY_POOL_CHUNK * row_buffer,
if (perm_bind.pack_len < SIZEOF_LONG) if (perm_bind.pack_len < SIZEOF_LONG)
{ {
/* direct conversion */ /* direct conversion */
int64 v = int64_t v =
#ifndef PHP_WIN32 #ifndef PHP_WIN32
atoll((char *) p); atoll((char *) p);
#else #else
@ -1568,11 +1567,11 @@ void php_mysqlnd_rowp_read_text_protocol(MYSQLND_MEMORY_POOL_CHUNK * row_buffer,
#endif #endif
ZVAL_LONG(*current_field, v); ZVAL_LONG(*current_field, v);
} else { } else {
uint64 v = uint64_t v =
#ifndef PHP_WIN32 #ifndef PHP_WIN32
(uint64) atoll((char *) p); (uint64_t) atoll((char *) p);
#else #else
(uint64) _atoi64((char *) p); (uint64_t) _atoi64((char *) p);
#endif #endif
zend_bool uns = fields_metadata[i].flags & UNSIGNED_FLAG? TRUE:FALSE; zend_bool uns = fields_metadata[i].flags & UNSIGNED_FLAG? TRUE:FALSE;
/* We have to make it ASCIIZ temporarily */ /* We have to make it ASCIIZ temporarily */
@ -1580,13 +1579,13 @@ void php_mysqlnd_rowp_read_text_protocol(MYSQLND_MEMORY_POOL_CHUNK * row_buffer,
if (uns == TRUE && v > 9223372036854775807L) if (uns == TRUE && v > 9223372036854775807L)
#elif SIZEOF_LONG==4 #elif SIZEOF_LONG==4
if ((uns == TRUE && v > L64(2147483647)) || if ((uns == TRUE && v > L64(2147483647)) ||
(uns == FALSE && (( L64(2147483647) < (int64) v) || (uns == FALSE && (( L64(2147483647) < (int64_t) v) ||
(L64(-2147483648) > (int64) v)))) (L64(-2147483648) > (int64_t) v))))
#endif /* SIZEOF */ #endif /* SIZEOF */
{ {
ZVAL_STRINGL(*current_field, (char *)p, len, 0); ZVAL_STRINGL(*current_field, (char *)p, len, 0);
} else { } else {
ZVAL_LONG(*current_field, (int64)v); ZVAL_LONG(*current_field, (int64_t)v);
} }
} }
*(p + len) = save; *(p + len) = save;
@ -1617,8 +1616,7 @@ void php_mysqlnd_rowp_read_text_protocol(MYSQLND_MEMORY_POOL_CHUNK * row_buffer,
*/ */
p -= len; p -= len;
if (Z_TYPE_PP(current_field) == IS_LONG) { if (Z_TYPE_PP(current_field) == IS_LONG) {
bit_area += 1 + sprintf((char *)start, MYSQLND_LLU_SPEC, bit_area += 1 + sprintf((char *)start, "%ld", Z_LVAL_PP(current_field));
(int64) Z_LVAL_PP(current_field));
#if PHP_MAJOR_VERSION >= 6 #if PHP_MAJOR_VERSION >= 6
if (as_unicode) { if (as_unicode) {
ZVAL_UTF8_STRINGL(*current_field, start, bit_area - start - 1, 0); ZVAL_UTF8_STRINGL(*current_field, start, bit_area - start - 1, 0);
@ -1728,7 +1726,7 @@ php_mysqlnd_rowp_read(void *_packet, MYSQLND *conn TSRMLS_DC)
size_t old_chunk_size = net->stream->chunk_size; size_t old_chunk_size = net->stream->chunk_size;
php_mysql_packet_row *packet= (php_mysql_packet_row *) _packet; php_mysql_packet_row *packet= (php_mysql_packet_row *) _packet;
size_t post_alloc_for_bit_fields = 0; size_t post_alloc_for_bit_fields = 0;
uint64 data_size = 0; uint64_t data_size = 0;
DBG_ENTER("php_mysqlnd_rowp_read"); DBG_ENTER("php_mysqlnd_rowp_read");
@ -1918,7 +1916,7 @@ php_mysqlnd_prepare_read(void *_packet, MYSQLND *conn TSRMLS_DC)
data_size != PREPARE_RESPONSE_SIZE_50 && data_size != PREPARE_RESPONSE_SIZE_50 &&
!(data_size > PREPARE_RESPONSE_SIZE_50)) { !(data_size > PREPARE_RESPONSE_SIZE_50)) {
DBG_ERR_FMT("Wrong COM_STMT_PREPARE response size. Received %d", data_size); DBG_ERR_FMT("Wrong COM_STMT_PREPARE response size. Received %d", data_size);
php_error(E_WARNING, "Wrong COM_STMT_PREPARE response size. Received %d. PID=%d", data_size, getpid()); php_error(E_WARNING, "Wrong COM_STMT_PREPARE response size. Received %d", data_size);
DBG_RETURN(FAIL); DBG_RETURN(FAIL);
} }
@ -1944,8 +1942,8 @@ php_mysqlnd_prepare_read(void *_packet, MYSQLND *conn TSRMLS_DC)
if (p - begin > packet->header.size) { if (p - begin > packet->header.size) {
DBG_ERR_FMT("PREPARE packet %d bytes shorter than expected", p - begin - packet->header.size); DBG_ERR_FMT("PREPARE packet %d bytes shorter than expected", p - begin - packet->header.size);
php_error_docref(NULL TSRMLS_CC, E_WARNING, "PREPARE packet %d bytes shorter than expected. PID=%d", php_error_docref(NULL TSRMLS_CC, E_WARNING, "PREPARE packet "MYSQLND_SZ_T_SPEC" bytes shorter than expected",
p - begin - packet->header.size, getpid()); p - begin - packet->header.size);
} }
DBG_RETURN(PASS); DBG_RETURN(PASS);
@ -2004,8 +2002,8 @@ php_mysqlnd_chg_user_read(void *_packet, MYSQLND *conn TSRMLS_DC)
} }
if (p - begin > packet->header.size) { if (p - begin > packet->header.size) {
DBG_ERR_FMT("CHANGE_USER packet %d bytes shorter than expected", p - begin - packet->header.size); DBG_ERR_FMT("CHANGE_USER packet %d bytes shorter than expected", p - begin - packet->header.size);
php_error_docref(NULL TSRMLS_CC, E_WARNING, "CHANGE_USER packet %d bytes shorter than expected. PID=%d", php_error_docref(NULL TSRMLS_CC, E_WARNING, "CHANGE_USER packet "MYSQLND_SZ_T_SPEC" bytes shorter than expected",
p - begin - packet->header.size, getpid()); p - begin - packet->header.size);
} }
DBG_RETURN(PASS); DBG_RETURN(PASS);

View file

@ -27,10 +27,6 @@
#define MYSQLND_NULL_LENGTH (unsigned long) ~0 #define MYSQLND_NULL_LENGTH (unsigned long) ~0
typedef zend_uchar mysqlnd_1b;
typedef zend_ushort mysqlnd_2b;
typedef zend_uint mysqlnd_4b;
/* Used in mysqlnd_debug.c */ /* Used in mysqlnd_debug.c */
extern char * mysqlnd_read_header_name; extern char * mysqlnd_read_header_name;
extern char * mysqlnd_read_body_name; extern char * mysqlnd_read_body_name;
@ -137,19 +133,19 @@ typedef struct st_mysqlnd_packet_header {
/* Server greets the client */ /* Server greets the client */
typedef struct st_php_mysql_packet_greet { typedef struct st_php_mysql_packet_greet {
mysqlnd_packet_header header; mysqlnd_packet_header header;
mysqlnd_1b protocol_version; uint8_t protocol_version;
char *server_version; char *server_version;
mysqlnd_4b thread_id; uint32_t thread_id;
zend_uchar scramble_buf[SCRAMBLE_LENGTH]; zend_uchar scramble_buf[SCRAMBLE_LENGTH];
/* 1 byte pad */ /* 1 byte pad */
mysqlnd_2b server_capabilities; uint16_t server_capabilities;
mysqlnd_1b charset_no; uint8_t charset_no;
mysqlnd_2b server_status; uint16_t server_status;
/* 13 byte pad*/ /* 13 byte pad*/
zend_bool pre41; zend_bool pre41;
/* If error packet, we use these */ /* If error packet, we use these */
char error[MYSQLND_ERRMSG_SIZE+1]; char error[MYSQLND_ERRMSG_SIZE+1];
char sqlstate[MYSQLND_SQLSTATE_LENGTH + 1]; char sqlstate[MYSQLND_SQLSTATE_LENGTH + 1];
unsigned int error_no; unsigned int error_no;
} php_mysql_packet_greet; } php_mysql_packet_greet;
@ -157,9 +153,9 @@ typedef struct st_php_mysql_packet_greet {
/* Client authenticates */ /* Client authenticates */
typedef struct st_php_mysql_packet_auth { typedef struct st_php_mysql_packet_auth {
mysqlnd_packet_header header; mysqlnd_packet_header header;
mysqlnd_4b client_flags; uint32_t client_flags;
uint32 max_packet_size; uint32_t max_packet_size;
mysqlnd_1b charset_no; uint8_t charset_no;
/* 23 byte pad */ /* 23 byte pad */
const char *user; const char *user;
/* 8 byte scramble */ /* 8 byte scramble */
@ -176,16 +172,16 @@ typedef struct st_php_mysql_packet_auth {
/* OK packet */ /* OK packet */
typedef struct st_php_mysql_packet_ok { typedef struct st_php_mysql_packet_ok {
mysqlnd_packet_header header; mysqlnd_packet_header header;
mysqlnd_1b field_count; /* always 0x0 */ uint8_t field_count; /* always 0x0 */
uint64 affected_rows; uint64_t affected_rows;
uint64 last_insert_id; uint64_t last_insert_id;
mysqlnd_2b server_status; uint16_t server_status;
mysqlnd_2b warning_count; uint16_t warning_count;
char *message; char *message;
size_t message_len; size_t message_len;
/* If error packet, we use these */ /* If error packet, we use these */
char error[MYSQLND_ERRMSG_SIZE+1]; char error[MYSQLND_ERRMSG_SIZE+1];
char sqlstate[MYSQLND_SQLSTATE_LENGTH + 1]; char sqlstate[MYSQLND_SQLSTATE_LENGTH + 1];
unsigned int error_no; unsigned int error_no;
} php_mysql_packet_ok; } php_mysql_packet_ok;
@ -202,12 +198,12 @@ typedef struct st_php_mysql_packet_command {
/* EOF packet */ /* EOF packet */
typedef struct st_php_mysql_packet_eof { typedef struct st_php_mysql_packet_eof {
mysqlnd_packet_header header; mysqlnd_packet_header header;
mysqlnd_1b field_count; /* 0xFE */ uint8_t field_count; /* 0xFE */
mysqlnd_2b warning_count; uint16_t warning_count;
mysqlnd_2b server_status; uint16_t server_status;
/* If error packet, we use these */ /* If error packet, we use these */
char error[MYSQLND_ERRMSG_SIZE+1]; char error[MYSQLND_ERRMSG_SIZE+1];
char sqlstate[MYSQLND_SQLSTATE_LENGTH + 1]; char sqlstate[MYSQLND_SQLSTATE_LENGTH + 1];
unsigned int error_no; unsigned int error_no;
} php_mysql_packet_eof; } php_mysql_packet_eof;
/* EOF packet */ /* EOF packet */
@ -227,13 +223,13 @@ typedef struct st_php_mysql_packet_rset_header {
These are filled if no SELECT query. For SELECT warning_count These are filled if no SELECT query. For SELECT warning_count
and server status are in the last row packet, the EOF packet. and server status are in the last row packet, the EOF packet.
*/ */
mysqlnd_2b warning_count; uint16_t warning_count;
mysqlnd_2b server_status; uint16_t server_status;
uint64 affected_rows; uint64_t affected_rows;
uint64 last_insert_id; uint64_t last_insert_id;
/* This is for both LOAD DATA or info, when no result set */ /* This is for both LOAD DATA or info, when no result set */
char *info_or_local_file; char *info_or_local_file;
size_t info_or_local_file_len; size_t info_or_local_file_len;
/* If error packet, we use these */ /* If error packet, we use these */
mysqlnd_error_info error_info; mysqlnd_error_info error_info;
} php_mysql_packet_rset_header; } php_mysql_packet_rset_header;
@ -252,15 +248,15 @@ typedef struct st_php_mysql_packet_res_field {
/* Row packet */ /* Row packet */
struct st_php_mysql_packet_row { struct st_php_mysql_packet_row {
mysqlnd_packet_header header; mysqlnd_packet_header header;
zval **fields; zval **fields;
mysqlnd_4b field_count; uint32_t field_count;
zend_bool eof; zend_bool eof;
/* /*
These are, of course, only for SELECT in the EOF packet, These are, of course, only for SELECT in the EOF packet,
which is detected by this packet which is detected by this packet
*/ */
mysqlnd_2b warning_count; uint16_t warning_count;
mysqlnd_2b server_status; uint16_t server_status;
struct st_mysqlnd_memory_pool_chunk *row_buffer; struct st_mysqlnd_memory_pool_chunk *row_buffer;
@ -304,10 +300,10 @@ typedef struct st_php_mysql_packet_prepare_response {
/* Statistics packet */ /* Statistics packet */
typedef struct st_php_mysql_packet_chg_user_resp { typedef struct st_php_mysql_packet_chg_user_resp {
mysqlnd_packet_header header; mysqlnd_packet_header header;
mysqlnd_4b field_count; uint32_t field_count;
/* message_len is not part of the packet*/ /* message_len is not part of the packet*/
mysqlnd_2b server_capabilities; uint16_t server_capabilities;
/* If error packet, we use these */ /* If error packet, we use these */
mysqlnd_error_info error_info; mysqlnd_error_info error_info;
} php_mysql_packet_chg_user_resp; } php_mysql_packet_chg_user_resp;
@ -323,7 +319,7 @@ size_t php_mysqlnd_consume_uneaten_data(MYSQLND * const conn, enum php_mysqlnd_s
void php_mysqlnd_scramble(zend_uchar * const buffer, const zend_uchar * const scramble, const zend_uchar * const pass); void php_mysqlnd_scramble(zend_uchar * const buffer, const zend_uchar * const scramble, const zend_uchar * const pass);
unsigned long php_mysqlnd_net_field_length(zend_uchar **packet); unsigned long php_mysqlnd_net_field_length(zend_uchar **packet);
zend_uchar * php_mysqlnd_net_store_length(zend_uchar *packet, uint64 length); zend_uchar * php_mysqlnd_net_store_length(zend_uchar *packet, uint64_t length);
extern char * const mysqlnd_empty_string; extern char * const mysqlnd_empty_string;