Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:65004 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 34928 invoked from network); 17 Jan 2013 14:04:00 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Jan 2013 14:04:00 -0000 X-Host-Fingerprint: 83.153.85.71 cag06-7-83-153-85-71.fbx.proxad.net Received: from [83.153.85.71] ([83.153.85.71:18059] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C3/31-23329-FC408F05 for ; Thu, 17 Jan 2013 09:04:00 -0500 Message-ID: To: internals@lists.php.net Date: Thu, 17 Jan 2013 15:03:50 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130106 Thunderbird/17.0.2 MIME-Version: 1.0 References: In-Reply-To: Content-Type: multipart/mixed; boundary="------------000605070604010106000300" X-Posted-By: 83.153.85.71 Subject: Re: Zend signed multiply for ARM From: ard.biesheuvel@linaro.org (Ard Biesheuvel) --------------000605070604010106000300 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Gmail ate my attachment the 1st time, trying Thunderbird instead ... --------------000605070604010106000300 Content-Type: text/x-patch; name="ARM-zend-multiply.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="ARM-zend-multiply.diff" diff --git a/Zend/zend_multiply.h b/Zend/zend_multiply.h index c3c9657..3053f8b 100644 --- a/Zend/zend_multiply.h +++ b/Zend/zend_multiply.h @@ -13,7 +13,7 @@ | license@zend.com so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: Sascha Schumann | - | Ard Biesheuvel | + | Ard Biesheuvel | +----------------------------------------------------------------------+ */ @@ -43,6 +43,31 @@ else (lval) = __tmpvar; \ } while (0) +#elif defined(__arm__) && defined(__GNUC__) + +#define ZEND_SIGNED_MULTIPLY_LONG(a, b, lval, dval, usedval) do { \ + long __tmpvar; \ + __asm__("smull %0, %1, %2, %3\n" \ + "sub %1, %1, %0, asr #31\n" \ + : "=r"(__tmpvar), "=r"(usedval) \ + : "r"(a), "r"(b)); \ + if (usedval) (dval) = (double) (a) * (double) (b); \ + else (lval) = __tmpvar; \ +} while (0) + +#elif defined(__aarch64__) && defined(__GNUC__) + +#define ZEND_SIGNED_MULTIPLY_LONG(a, b, lval, dval, usedval) do { \ + long __tmpvar; \ + __asm__("mul %0, %2, %3\n" \ + "smulh %1, %2, %3\n" \ + "sub %1, %1, %0, asr #63\n" \ + : "=X"(__tmpvar), "=X"(usedval) \ + : "X"(a), "X"(b)); \ + if (usedval) (dval) = (double) (a) * (double) (b); \ + else (lval) = __tmpvar; \ +} while (0) + #elif SIZEOF_LONG == 4 && defined(HAVE_ZEND_LONG64) #define ZEND_SIGNED_MULTIPLY_LONG(a, b, lval, dval, usedval) do { \ --------------000605070604010106000300--