com php-src: PowerPC64 support in safe_address function: Zend/zend_multiply.h
| From: | Remi Collet | Date: | Tue, 16 Dec 2014 07:20:01 +0000 |
| Subject: | com php-src: PowerPC64 support in safe_address function: Zend/zend_multiply.h | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-83724@lists.php.net to get a copy of this message | ||
Commit: 1e82da8d170066fa8c456a98f0242b8a6d1e6f86
Author: Gustavo Frederico Temple Pedrosa <gustavo.pedrosa@eldorado.org.br> Mon, 15
Dec 2014 12:59:55 +0000
Committer: Remi Collet <remi@php.net> Tue, 16 Dec 2014 08:20:01 +0100
Parents: caf55214165ed32014aae7863bce621d1cb19a9e
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=1e82da8d170066fa8c456a98f0242b8a6d1e6f86
Log:
PowerPC64 support in safe_address function
Add a ppc64-specific implementation of the safe_address
function with overflow checking.
Changed paths:
M Zend/zend_multiply.h
Diff:
diff --git a/Zend/zend_multiply.h b/Zend/zend_multiply.h
index ab5fd62..b000044 100644
--- a/Zend/zend_multiply.h
+++ b/Zend/zend_multiply.h
@@ -224,6 +224,30 @@ static zend_always_inline size_t zend_safe_address(size_t nmemb, size_t size,
si
return res;
}
+#elif defined(__GNUC__) && defined(__powerpc64__)
+
+static zend_always_inline size_t zend_safe_address(size_t nmemb, size_t size, size_t offset, int
*overflow)
+{
+ size_t res;
+ unsigned long m_overflow;
+
+ __asm__ ("mulld %0,%2,%3\n\t"
+ "mulhdu %1,%2,%3\n\t"
+ "addc %0,%0,%4\n\t"
+ "addze %1,%1\n"
+ : "=&r"(res), "=&r"(m_overflow)
+ : "r"(nmemb),
+ "r"(size),
+ "r"(offset));
+
+ if (UNEXPECTED(m_overflow)) {
+ *overflow = 1;
+ return 0;
+ }
+ *overflow = 0;
+ return res;
+}
+
#elif SIZEOF_SIZE_T == 4
static zend_always_inline size_t zend_safe_address(size_t nmemb, size_t size, size_t offset, int
*overflow)