Print this page
11210 libm should be cstyle(1ONBLD) clean

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libm/common/m9x/feexcept.c
          +++ new/usr/src/lib/libm/common/m9x/feexcept.c
↓ open down ↓ 14 lines elided ↑ open up ↑
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  
  22   22  /*
  23   23   * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
  24   24   */
       25 +
  25   26  /*
  26   27   * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
  27   28   * Use is subject to license terms.
  28   29   */
  29   30  
  30   31  #pragma weak __feclearexcept = feclearexcept
  31   32  #pragma weak __feraiseexcept = feraiseexcept
  32   33  #pragma weak __fetestexcept = fetestexcept
  33   34  #pragma weak __fegetexceptflag = fegetexceptflag
  34   35  #pragma weak __fesetexceptflag = fesetexceptflag
↓ open down ↓ 4 lines elided ↑ open up ↑
  39   40  #pragma weak fegetexceptflag96 = fegetexceptflag
  40   41  #pragma weak fesetexceptflag96 = fesetexceptflag
  41   42  
  42   43  #include <fenv.h>
  43   44  #include <sys/ieeefp.h>
  44   45  #include <ucontext.h>
  45   46  #include <thread.h>
  46   47  #include "fex_handler.h"
  47   48  #include "fenv_inlines.h"
  48   49  
  49      -
  50      -int feclearexcept(int e)
       50 +int
       51 +feclearexcept(int e)
  51   52  {
  52      -        unsigned long   fsr;
       53 +        unsigned long fsr;
  53   54  
  54   55          __fenv_getfsr(&fsr);
  55   56          __fenv_set_ex(fsr, __fenv_get_ex(fsr) & ~e);
  56   57          __fenv_setfsr(&fsr);
       58 +
  57   59          if (fex_get_log())
  58   60                  __fex_update_te();
  59      -        return 0;
       61 +
       62 +        return (0);
  60   63  }
  61   64  
  62   65  /*
  63      -*  note - __fex_hdlr depends on fetestexcept following feraiseexcept
  64      -*/
  65      -int feraiseexcept(int e)
       66 + *  note - __fex_hdlr depends on fetestexcept following feraiseexcept
       67 + */
       68 +int
       69 +feraiseexcept(int e)
  66   70  {
  67      -        volatile double t;
  68      -        unsigned long   fsr;
       71 +        volatile double t;
       72 +        unsigned long fsr;
  69   73  
  70   74          if (e & FE_INVALID) {
  71   75                  t = 0.0;
  72   76                  t /= 0.0;
  73   77          }
       78 +
  74   79          if (e & FE_DIVBYZERO) {
  75   80                  t = 1.0e300;
  76   81                  t /= 0.0;
  77   82          }
       83 +
  78   84          if (e & FE_OVERFLOW) {
  79   85                  /* if overflow is not trapped, avoid raising inexact */
  80   86                  __fenv_getfsr(&fsr);
       87 +
  81   88                  if (!(__fenv_get_te(fsr) & (1 << fp_trap_overflow))) {
  82   89                          __fenv_set_ex(fsr, __fenv_get_ex(fsr) | FE_OVERFLOW);
  83   90                          __fenv_setfsr(&fsr);
  84      -                }
  85      -                else {
       91 +                } else {
  86   92                          t = 1.0e300;
  87   93                          t *= 1.0e300;
  88   94                  }
  89   95          }
       96 +
  90   97          if (e & FE_UNDERFLOW) {
  91   98                  /* if underflow is not trapped, avoid raising inexact */
  92   99                  __fenv_getfsr(&fsr);
      100 +
  93  101                  if (!(__fenv_get_te(fsr) & (1 << fp_trap_underflow))) {
  94  102                          __fenv_set_ex(fsr, __fenv_get_ex(fsr) | FE_UNDERFLOW);
  95  103                          __fenv_setfsr(&fsr);
  96      -                }
  97      -                else {
      104 +                } else {
  98  105                          t = 1.0e-307;
  99  106                          t -= 1.001e-307;
 100  107                  }
 101  108          }
      109 +
 102  110          if (e & FE_INEXACT) {
 103  111                  t = 1.0e300;
 104  112                  t += 1.0e-307;
 105  113          }
 106      -        return 0;
      114 +
      115 +        return (0);
 107  116  }
 108  117  
 109      -int fetestexcept(int e)
      118 +int
      119 +fetestexcept(int e)
 110  120  {
 111      -        unsigned long   fsr;
      121 +        unsigned long fsr;
 112  122  
 113  123          __fenv_getfsr(&fsr);
 114      -        return (int)__fenv_get_ex(fsr) & e;
      124 +        return ((int)__fenv_get_ex(fsr) & e);
 115  125  }
 116  126  
 117      -int fegetexceptflag(fexcept_t *p, int e)
      127 +int
      128 +fegetexceptflag(fexcept_t *p, int e)
 118  129  {
 119      -        unsigned long   fsr;
      130 +        unsigned long fsr;
 120  131  
 121  132          __fenv_getfsr(&fsr);
 122  133          *p = (int)__fenv_get_ex(fsr) & e;
 123      -        return 0;
      134 +        return (0);
 124  135  }
 125  136  
 126      -int fesetexceptflag(const fexcept_t *p, int e)
      137 +int
      138 +fesetexceptflag(const fexcept_t *p, int e)
 127  139  {
 128      -        unsigned long   fsr;
      140 +        unsigned long fsr;
 129  141  
 130  142          __fenv_getfsr(&fsr);
 131  143          __fenv_set_ex(fsr, (((int)__fenv_get_ex(fsr) & ~e) | (*p & e)) &
 132      -                FE_ALL_EXCEPT);
      144 +            FE_ALL_EXCEPT);
 133  145          __fenv_setfsr(&fsr);
      146 +
 134  147          if (fex_get_log())
 135  148                  __fex_update_te();
 136      -        return 0;
      149 +
      150 +        return (0);
 137  151  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX