1 /*
   2  * CDDL HEADER START
   3  *
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
  24  */
  25 
  26 /*
  27  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
  28  * Use is subject to license terms.
  29  */
  30 
  31 #ifndef _LIBM_MACROS_H
  32 #define _LIBM_MACROS_H
  33 
  34 #include <sys/isa_defs.h>
  35 
  36 #if defined(__sparc)
  37 #define HIWORD          0
  38 #define LOWORD          1
  39 #define HIXWORD         0               /* index of int containing exponent */
  40 #define XSGNMSK         0x80000000      /* exponent bit mask within the int */
  41 #define XBIASED_EXP(x)  ((((int *)&x)[HIXWORD] & ~0x80000000) >> 16)
  42 #define ISZEROL(x)      (((((int *)&x)[0] & ~XSGNMSK) | ((int *)&x)[1] | \
  43         ((int *)&x)[2] | ((int *)&x)[3]) == 0)
  44 #elif defined(__x86)
  45 #define HIWORD          1
  46 #define LOWORD          0
  47 #define HIXWORD         2
  48 #define XSGNMSK         0x8000
  49 #define XBIASED_EXP(x)  (((int *)&x)[HIXWORD] & 0x7fff)
  50 #define ISZEROL(x)      (x == 0.0L)
  51 
  52 #define HANDLE_UNSUPPORTED
  53 
  54 /*
  55  * "convert" the high-order 32 bits of a SPARC quad precision
  56  * value ("I") to the sign, exponent, and high-order bits of an
  57  * x86 extended double precision value ("E"); the low-order bits
  58  * in the 12-byte quantity are left intact
  59  */
  60 #define ITOX(I, E) \
  61         E[2] = 0xffff & ((I) >> 16); \
  62         E[1] = (((I) & 0x7fff0000) == 0) ? (E[1] & 0x7fff) | (0x7fff8000 & \
  63         ((I) << 15)) : 0x80000000 | (E[1] & 0x7fff) | (0x7fff8000 & ((I) << \
  64         15))
  65 
  66 /*
  67  * "convert" the sign, exponent, and high-order bits of an x86
  68  * extended double precision value ("E") to the high-order 32 bits
  69  * of a SPARC quad precision value ("I")
  70  */
  71 #define XTOI(E, I) \
  72         I = ((E[2] << 16) | (0xffff & (E[1] >> 15)))
  73 #else
  74 #error Unknown architecture
  75 #endif
  76 #endif /* _LIBM_MACROS_H */