andrey                                   Thu, 14 Jan 2010 09:47:57 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=293535

Log:
Fix build of mysqli when libmysql is used, mysqlnd_portability.h
might not be available for some weird reasons. Added the macros
that we need, in that case

Code by Jess Portnoy

Changed paths:
    U   php/php-src/branches/PHP_5_3/ext/mysqli/mysqli.c
    U   php/php-src/branches/PHP_5_3/ext/mysqli/mysqli_api.c
    U   php/php-src/branches/PHP_5_3/ext/mysqli/mysqli_libmysql.h
    U   php/php-src/branches/PHP_5_3/ext/mysqli/mysqli_mysqlnd.h
    U   php/php-src/trunk/ext/mysqli/mysqli.c
    U   php/php-src/trunk/ext/mysqli/mysqli_api.c
    U   php/php-src/trunk/ext/mysqli/mysqli_libmysql.h
    U   php/php-src/trunk/ext/mysqli/mysqli_mysqlnd.h

Modified: php/php-src/branches/PHP_5_3/ext/mysqli/mysqli.c
===================================================================
--- php/php-src/branches/PHP_5_3/ext/mysqli/mysqli.c	2010-01-14 09:33:37 UTC (rev 293534)
+++ php/php-src/branches/PHP_5_3/ext/mysqli/mysqli.c	2010-01-14 09:47:57 UTC (rev 293535)
@@ -32,7 +32,6 @@
 #include "ext/standard/php_string.h"
 #include "php_mysqli_structs.h"
 #include "zend_exceptions.h"
-#include "ext/mysqlnd/mysqlnd_portability.h"

 ZEND_DECLARE_MODULE_GLOBALS(mysqli)
 static PHP_GINIT_FUNCTION(mysqli);

Modified: php/php-src/branches/PHP_5_3/ext/mysqli/mysqli_api.c
===================================================================
--- php/php-src/branches/PHP_5_3/ext/mysqli/mysqli_api.c	2010-01-14 09:33:37 UTC (rev 293534)
+++ php/php-src/branches/PHP_5_3/ext/mysqli/mysqli_api.c	2010-01-14 09:47:57 UTC (rev 293535)
@@ -31,7 +31,6 @@
 #include "php_globals.h"
 #include "ext/standard/info.h"
 #include "php_mysqli_structs.h"
-#include "ext/mysqlnd/mysqlnd_portability.h"

 /* {{{ proto mixed mysqli_affected_rows(object link)
    Get number of affected rows in previous MySQL operation */

Modified: php/php-src/branches/PHP_5_3/ext/mysqli/mysqli_libmysql.h
===================================================================
--- php/php-src/branches/PHP_5_3/ext/mysqli/mysqli_libmysql.h	2010-01-14 09:33:37 UTC (rev 293534)
+++ php/php-src/branches/PHP_5_3/ext/mysqli/mysqli_libmysql.h	2010-01-14 09:47:57 UTC (rev 293535)
@@ -1,9 +1,9 @@
 /*
-  +----------------------------------------------------------------------+
+  ----------------------------------------------------------------------
   | PHP Version 6                                                        |
-  +----------------------------------------------------------------------+
+  ----------------------------------------------------------------------
   | Copyright (c) 2007 The PHP Group                                     |
-  +----------------------------------------------------------------------+
+  ----------------------------------------------------------------------
   | This source file is subject to version 3.01 of the PHP license,      |
   | that is bundled with this package in the file LICENSE, and is        |
   | available through the world-wide-web at the following url:           |
@@ -11,14 +11,17 @@
   | If you did not receive a copy of the PHP license and are unable to   |
   | obtain it through the world-wide-web, please send a note to          |
   | lice...@php.net so we can mail you a copy immediately.               |
-  +----------------------------------------------------------------------+
+  ----------------------------------------------------------------------
   | Authors: Georg Richter <ge...@mysql.com>                             |
   |          Andrey Hristov <and...@mysql.com>                           |
   |          Ulf Wendel <uwen...@mysql.com>                              |
-  +----------------------------------------------------------------------+
+  ----------------------------------------------------------------------

 */

+#ifndef MYSQLI_LIBMYSQL_H
+#define MYSQLI_LIBMYSQL_H
+
 /* These are unused */
 #define MYSQLI_CLOSE_EXPLICIT 0
 #define MYSQLI_CLOSE_IMPLICIT 1
@@ -36,3 +39,78 @@
 #define mysqli_free_result(r, is_forced)	mysql_free_result((r))
 #define mysqli_change_user_silent(c, u, p, d)   mysql_change_user((c), (u), (p), (d))

+
+/*
+  These functions also reside in ext/mysqlnd/mysqlnd_portability.h but since it is only made
+  available if one wants to build mysqli against mysqlnd and they are useful for libmysql as
+  well, we check whether they're not defined [build with libmysql is desired] and define them.
+
+  Bit values are sent in reverted order of bytes, compared to normal !!!
+*/
+
+
+#ifndef uint1korr
+#define uint1korr(A)	(*(((uint8_t*)(A))))
+#endif
+
+#ifndef bit_uint2korr
+#define bit_uint2korr(A) ((uint16_t) (((uint16_t) (((unsigned char*) (A))[1])) +\
+                                   ((uint16_t) (((unsigned char*) (A))[0]) << 8)))
+#endif
+
+#ifndef bit_uint3korr
+#define bit_uint3korr(A) ((uint32_t) (((uint32_t) (((unsigned char*) (A))[2])) +\
+                                   (((uint32_t) (((unsigned char*) (A))[1])) << 8) +\
+                                   (((uint32_t) (((unsigned char*) (A))[0])) << 16)))
+#endif
+
+#ifndef bit_uint4korr
+#define bit_uint4korr(A) ((uint32_t) (((uint32_t) (((unsigned char*) (A))[3])) +\
+                                   (((uint32_t) (((unsigned char*) (A))[2])) << 8) +\
+                                   (((uint32_t) (((unsigned char*) (A))[1])) << 16) +\
+                                   (((uint32_t) (((unsigned char*) (A))[0])) << 24)))
+#endif
+
+#ifndef bit_uint5korr
+#define bit_uint5korr(A) ((uint64_t)(((uint32_t) (((unsigned char*) (A))[4])) +\
+                                    (((uint32_t) (((unsigned char*) (A))[3])) << 8) +\
+                                    (((uint32_t) (((unsigned char*) (A))[2])) << 16) +\
+                                   (((uint32_t) (((unsigned char*) (A))[1])) << 24)) +\
+                                    (((uint64_t) (((unsigned char*) (A))[0])) << 32))
+#endif
+
+#ifndef bit_uint6korr
+#define bit_uint6korr(A) ((uint64_t)(((uint32_t) (((unsigned char*) (A))[5])) +\
+                                    (((uint32_t) (((unsigned char*) (A))[4])) << 8) +\
+                                    (((uint32_t) (((unsigned char*) (A))[3])) << 16) +\
+                                    (((uint32_t) (((unsigned char*) (A))[2])) << 24)) +\
+                        (((uint64_t) (((uint32_t) (((unsigned char*) (A))[1])) +\
+                                    (((uint32_t) (((unsigned char*) (A))[0]) << 8)))) <<\
+                                     32))
+#endif
+
+#ifndef bit_uint7korr
+#define bit_uint7korr(A) ((uint64_t)(((uint32_t) (((unsigned char*) (A))[6])) +\
+                                    (((uint32_t) (((unsigned char*) (A))[5])) << 8) +\
+                                    (((uint32_t) (((unsigned char*) (A))[4])) << 16) +\
+                                   (((uint32_t) (((unsigned char*) (A))[3])) << 24)) +\
+                        (((uint64_t) (((uint32_t) (((unsigned char*) (A))[2])) +\
+                                    (((uint32_t) (((unsigned char*) (A))[1])) << 8) +\
+                                    (((uint32_t) (((unsigned char*) (A))[0])) << 16))) <<\
+                                     32))
+#endif
+
+#ifndef bit_uint8korr
+#define bit_uint8korr(A) ((uint64_t)(((uint32_t) (((unsigned char*) (A))[7])) +\
+                                    (((uint32_t) (((unsigned char*) (A))[6])) << 8) +\
+                                    (((uint32_t) (((unsigned char*) (A))[5])) << 16) +\
+                                    (((uint32_t) (((unsigned char*) (A))[4])) << 24)) +\
+                        (((uint64_t) (((uint32_t) (((unsigned char*) (A))[3])) +\
+                                    (((uint32_t) (((unsigned char*) (A))[2])) << 8) +\
+                                    (((uint32_t) (((unsigned char*) (A))[1])) << 16) +\
+                                    (((uint32_t) (((unsigned char*) (A))[0])) << 24))) <<\
+                                    32))
+#endif
+
+#endif /* MYSQLI_LIBMYSQL_H */
+

Modified: php/php-src/branches/PHP_5_3/ext/mysqli/mysqli_mysqlnd.h
===================================================================
--- php/php-src/branches/PHP_5_3/ext/mysqli/mysqli_mysqlnd.h	2010-01-14 09:33:37 UTC (rev 293534)
+++ php/php-src/branches/PHP_5_3/ext/mysqli/mysqli_mysqlnd.h	2010-01-14 09:47:57 UTC (rev 293535)
@@ -23,6 +23,7 @@
 #define MYSQLI_MYSQLND_H

 #include "ext/mysqlnd/mysqlnd_libmysql_compat.h"
+#include "ext/mysqlnd/mysqlnd_portability.h"

 /* Here comes non-libmysql API to have less ifdefs in mysqli*/
 #define MYSQLI_CLOSE_EXPLICIT                  MYSQLND_CLOSE_EXPLICIT

Modified: php/php-src/trunk/ext/mysqli/mysqli.c
===================================================================
--- php/php-src/trunk/ext/mysqli/mysqli.c	2010-01-14 09:33:37 UTC (rev 293534)
+++ php/php-src/trunk/ext/mysqli/mysqli.c	2010-01-14 09:47:57 UTC (rev 293535)
@@ -32,7 +32,6 @@
 #include "ext/standard/php_string.h"
 #include "php_mysqli_structs.h"
 #include "zend_exceptions.h"
-#include "ext/mysqlnd/mysqlnd_portability.h"

 ZEND_DECLARE_MODULE_GLOBALS(mysqli)
 static PHP_GINIT_FUNCTION(mysqli);

Modified: php/php-src/trunk/ext/mysqli/mysqli_api.c
===================================================================
--- php/php-src/trunk/ext/mysqli/mysqli_api.c	2010-01-14 09:33:37 UTC (rev 293534)
+++ php/php-src/trunk/ext/mysqli/mysqli_api.c	2010-01-14 09:47:57 UTC (rev 293535)
@@ -31,7 +31,6 @@
 #include "php_globals.h"
 #include "ext/standard/info.h"
 #include "php_mysqli_structs.h"
-#include "ext/mysqlnd/mysqlnd_portability.h"

 /* {{{ proto mixed mysqli_affected_rows(object link) U
    Get number of affected rows in previous MySQL operation */

Modified: php/php-src/trunk/ext/mysqli/mysqli_libmysql.h
===================================================================
--- php/php-src/trunk/ext/mysqli/mysqli_libmysql.h	2010-01-14 09:33:37 UTC (rev 293534)
+++ php/php-src/trunk/ext/mysqli/mysqli_libmysql.h	2010-01-14 09:47:57 UTC (rev 293535)
@@ -19,6 +19,9 @@

 */

+#ifndef MYSQLI_LIBMYSQL_H
+#define MYSQLI_LIBMYSQL_H
+
 /* These are unused */
 #define MYSQLI_CLOSE_EXPLICIT 0
 #define MYSQLI_CLOSE_IMPLICIT 1
@@ -36,3 +39,68 @@
 #define mysqli_free_result(r, is_forced)	mysql_free_result((r))
 #define mysqli_change_user_silent(c, u, p, d)   mysql_change_user((c), (u), (p), (d))

+#ifndef uint1korr
+#define uint1korr(A)	(*(((uint8_t*)(A))))
+#endif
+
+#ifndef bit_uint2korr
+#define bit_uint2korr(A) ((uint16_t) (((uint16_t) (((unsigned char*) (A))[1])) +\
+                                   ((uint16_t) (((unsigned char*) (A))[0]) << 8)))
+#endif
+
+#ifndef bit_uint3korr
+#define bit_uint3korr(A) ((uint32_t) (((uint32_t) (((unsigned char*) (A))[2])) +\
+                                   (((uint32_t) (((unsigned char*) (A))[1])) << 8) +\
+                                   (((uint32_t) (((unsigned char*) (A))[0])) << 16)))
+#endif
+
+#ifndef bit_uint4korr
+#define bit_uint4korr(A) ((uint32_t) (((uint32_t) (((unsigned char*) (A))[3])) +\
+                                   (((uint32_t) (((unsigned char*) (A))[2])) << 8) +\
+                                   (((uint32_t) (((unsigned char*) (A))[1])) << 16) +\
+                                   (((uint32_t) (((unsigned char*) (A))[0])) << 24)))
+#endif
+
+#ifndef bit_uint5korr
+#define bit_uint5korr(A) ((uint64_t)(((uint32_t) (((unsigned char*) (A))[4])) +\
+                                    (((uint32_t) (((unsigned char*) (A))[3])) << 8) +\
+                                    (((uint32_t) (((unsigned char*) (A))[2])) << 16) +\
+                                   (((uint32_t) (((unsigned char*) (A))[1])) << 24)) +\
+                                    (((uint64_t) (((unsigned char*) (A))[0])) << 32))
+#endif
+
+#ifndef bit_uint6korr
+#define bit_uint6korr(A) ((uint64_t)(((uint32_t) (((unsigned char*) (A))[5])) +\
+                                    (((uint32_t) (((unsigned char*) (A))[4])) << 8) +\
+                                    (((uint32_t) (((unsigned char*) (A))[3])) << 16) +\
+                                    (((uint32_t) (((unsigned char*) (A))[2])) << 24)) +\
+                        (((uint64_t) (((uint32_t) (((unsigned char*) (A))[1])) +\
+                                    (((uint32_t) (((unsigned char*) (A))[0]) << 8)))) <<\
+                                     32))
+#endif
+
+#ifndef bit_uint7korr
+#define bit_uint7korr(A) ((uint64_t)(((uint32_t) (((unsigned char*) (A))[6])) +\
+                                    (((uint32_t) (((unsigned char*) (A))[5])) << 8) +\
+                                    (((uint32_t) (((unsigned char*) (A))[4])) << 16) +\
+                                   (((uint32_t) (((unsigned char*) (A))[3])) << 24)) +\
+                        (((uint64_t) (((uint32_t) (((unsigned char*) (A))[2])) +\
+                                    (((uint32_t) (((unsigned char*) (A))[1])) << 8) +\
+                                    (((uint32_t) (((unsigned char*) (A))[0])) << 16))) <<\
+                                     32))
+#endif
+
+#ifndef bit_uint8korr
+#define bit_uint8korr(A) ((uint64_t)(((uint32_t) (((unsigned char*) (A))[7])) +\
+                                    (((uint32_t) (((unsigned char*) (A))[6])) << 8) +\
+                                    (((uint32_t) (((unsigned char*) (A))[5])) << 16) +\
+                                    (((uint32_t) (((unsigned char*) (A))[4])) << 24)) +\
+                        (((uint64_t) (((uint32_t) (((unsigned char*) (A))[3])) +\
+                                    (((uint32_t) (((unsigned char*) (A))[2])) << 8) +\
+                                    (((uint32_t) (((unsigned char*) (A))[1])) << 16) +\
+                                    (((uint32_t) (((unsigned char*) (A))[0])) << 24))) <<\
+                                    32))
+#endif
+
+
+#endif /* MYSQLI_LIBMYSQL_H */

Modified: php/php-src/trunk/ext/mysqli/mysqli_mysqlnd.h
===================================================================
--- php/php-src/trunk/ext/mysqli/mysqli_mysqlnd.h	2010-01-14 09:33:37 UTC (rev 293534)
+++ php/php-src/trunk/ext/mysqli/mysqli_mysqlnd.h	2010-01-14 09:47:57 UTC (rev 293535)
@@ -23,6 +23,7 @@
 #define MYSQLI_MYSQLND_H

 #include "ext/mysqlnd/mysqlnd_libmysql_compat.h"
+#include "ext/mysqlnd/mysqlnd_portability.h"

 /* Here comes non-libmysql API to have less ifdefs in mysqli*/
 #define MYSQLI_CLOSE_EXPLICIT                  MYSQLND_CLOSE_EXPLICIT
-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to