make PHP_SAPI dynamic based on execution mode
[hiphop-php.git] / hphp / runtime / base / zend / zend_multiply.h
blobe6f8befceb1eb96ca97c9e3aa602427683d1a54a
1 /*
2 +----------------------------------------------------------------------+
3 | HipHop for PHP |
4 +----------------------------------------------------------------------+
5 | Copyright (c) 2010-2013 Facebook, Inc. (http://www.facebook.com) |
6 | Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
7 +----------------------------------------------------------------------+
8 | This source file is subject to version 2.00 of the Zend license, |
9 | that is bundled with this package in the file LICENSE, and is |
10 | available through the world-wide-web at the following url: |
11 | http://www.zend.com/license/2_00.txt. |
12 | If you did not receive a copy of the Zend license and are unable to |
13 | obtain it through the world-wide-web, please send a note to |
14 | license@zend.com so we can mail you a copy immediately. |
15 +----------------------------------------------------------------------+
18 #if (defined(__x86_64__) || defined(__i386__)) && defined(__GNUC__)
20 #define ZEND_SIGNED_MULTIPLY_LONG(a, b, lval, dval, usedval) do { \
21 long __tmpvar; \
22 __asm__ ("imul %3,%0\n" \
23 "adc $0,%1" \
24 : "=r"(__tmpvar),"=r"(usedval) \
25 : "0"(a), "r"(b), "1"(0)); \
26 if (usedval) (dval) = (double) (a) * (double) (b); \
27 else (lval) = __tmpvar; \
28 } while (0)
30 #else
32 #define ZEND_SIGNED_MULTIPLY_LONG(a, b, lval, dval, usedval) do { \
33 long __lres = (a) * (b); \
34 long double __dres = (long double)(a) * (long double)(b); \
35 long double __delta = (long double) __lres - __dres; \
36 if ( ((usedval) = (( __dres + __delta ) != __dres))) { \
37 (dval) = __dres; \
38 } else { \
39 (lval) = __lres; \
40 } \
41 } while (0)
43 #endif