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 2006 Sun Microsystems, Inc.  All rights reserved.
  28  * Use is subject to license terms.
  29  */
  30 
  31 #ifndef _FMA_H
  32 #define _FMA_H
  33 
  34 #ifdef __cplusplus
  35 extern "C" {
  36 #endif
  37 
  38 #ifdef __sparc
  39 /*
  40  * Common definitions for fma routines (SPARC)
  41  */
  42 
  43 /* fsr fields */
  44 
  45 /* current exception bits */
  46 #define FSR_NXC         0x1
  47 #define FSR_DZC         0x2
  48 #define FSR_UFC         0x4
  49 #define FSR_OFC         0x8
  50 #define FSR_NVC         0x10
  51 #define FSR_CEXC        0x1f            /* mask for all cexc bits */
  52 
  53 /* accrued exception bits */
  54 #define FSR_NXA         0x20
  55 #define FSR_DZA         0x40
  56 #define FSR_UFA         0x80
  57 #define FSR_OFA         0x100
  58 #define FSR_NVA         0x200
  59 
  60 /* trap enable bits */
  61 #define FSR_NXM         0x00800000
  62 #define FSR_DZM         0x01000000
  63 #define FSR_UFM         0x02000000
  64 #define FSR_OFM         0x04000000
  65 #define FSR_NVM         0x08000000
  66 
  67 /* rounding directions (right-adjusted) */
  68 #define FSR_RN          0
  69 #define FSR_RZ          1
  70 #define FSR_RP          2
  71 #define FSR_RM          3
  72 
  73 /* inline templates */
  74 extern void __fenv_getfsr32(unsigned int *);
  75 extern void __fenv_setfsr32(const unsigned int *);
  76 #endif /* __sparc */
  77 
  78 #if defined(__x86)
  79 /*
  80  * Common definitions for fma routines (x86)
  81  */
  82 
  83 /* control and status word fields */
  84 
  85 /* exception flags */
  86 #define FSW_NV          0x1
  87 #define FSW_DN          0x2
  88 #define FSW_DZ          0x4
  89 #define FSW_OF          0x8
  90 #define FSW_UF          0x10
  91 #define FSW_NX          0x20
  92 
  93 /* exception masks */
  94 #define FCW_NVM         0x00010000
  95 #define FCW_DNM         0x00020000
  96 #define FCW_DZM         0x00040000
  97 #define FCW_OFM         0x00080000
  98 #define FCW_UFM         0x00100000
  99 #define FCW_NXM         0x00200000
 100 #define FCW_ALLM        0x003f0000
 101 
 102 /* rounding directions */
 103 #define FCW_RN          0x00000000
 104 #define FCW_RM          0x04000000
 105 #define FCW_RP          0x08000000
 106 #define FCW_RZ          0x0c000000
 107 
 108 /* rounding precisions */
 109 #define FCW_P24         0x00000000
 110 #define FCW_P53         0x02000000
 111 #define FCW_P64         0x03000000
 112 
 113 /* inline templates */
 114 extern void __fenv_getcwsw(unsigned int *);
 115 extern void __fenv_setcwsw(const unsigned int *);
 116 #endif /* __x86 */
 117 
 118 #ifdef __cplusplus
 119 }
 120 #endif
 121 #endif /* _FMA_H */