~ubuntu-branches/ubuntu/hardy/php5/hardy-updates

« back to all changes in this revision

Viewing changes to Zend/zend_multiply.h

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-10-09 03:14:32 UTC
  • Revision ID: james.westby@ubuntu.com-20051009031432-kspik3lobxstafv9
Tags: upstream-5.0.5
ImportĀ upstreamĀ versionĀ 5.0.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
   +----------------------------------------------------------------------+
 
3
   | Zend Engine                                                          |
 
4
   +----------------------------------------------------------------------+
 
5
   | Copyright (c) 1998-2004 Zend Technologies Ltd. (http://www.zend.com) |
 
6
   +----------------------------------------------------------------------+
 
7
   | This source file is subject to version 2.00 of the Zend license,     |
 
8
   | that is bundled with this package in the file LICENSE, and is        |
 
9
   | available through the world-wide-web at the following url:           |
 
10
   | http://www.zend.com/license/2_00.txt.                                |
 
11
   | If you did not receive a copy of the Zend license and are unable to  |
 
12
   | obtain it through the world-wide-web, please send a note to          |
 
13
   | license@zend.com so we can mail you a copy immediately.              |
 
14
   +----------------------------------------------------------------------+
 
15
   | Authors: Sascha Schumann <sascha@schumann.cx>                        |
 
16
   |          Ard Biesheuvel <ard@ard.nu>                                 |
 
17
   +----------------------------------------------------------------------+
 
18
*/
 
19
 
 
20
/* $Id: zend_multiply.h,v 1.9 2004/03/17 22:23:15 sas Exp $ */
 
21
 
 
22
#if defined(__i386__) && defined(__GNUC__)
 
23
 
 
24
#define ZEND_SIGNED_MULTIPLY_LONG(a, b, lval, dval, usedval) do {       \
 
25
        long __tmpvar;                                                                                                  \
 
26
        __asm__ ("imul %3,%0\n"                                                                                 \
 
27
                "adc $0,%1"                                                                                             \
 
28
                        : "=r"(__tmpvar),"=r"(usedval)                                                  \
 
29
                        : "0"(a), "r"(b), "1"(0));                                                              \
 
30
        if (usedval) (dval) = (double) (a) * (double) (b);                              \
 
31
        else (lval) = __tmpvar;                                                                                 \
 
32
} while (0)
 
33
 
 
34
#else
 
35
 
 
36
#define ZEND_SIGNED_MULTIPLY_LONG(a, b, lval, dval, usedval) do {               \
 
37
        long   __lres  = (a) * (b);                                                                                     \
 
38
        double __dres  = (double)(a) * (double)(b);                                                     \
 
39
        double __delta = (double) __lres - __dres;                                                      \
 
40
        if ( ((usedval) = (( __dres + __delta ) != __dres))) {                          \
 
41
                (dval) = __dres;                                                                                                \
 
42
        } else {                                                                                                                        \
 
43
                (lval) = __lres;                                                                                                \
 
44
        }                                                                                                                                       \
 
45
} while (0)
 
46
 
 
47
#endif