Changeset 750636a in mainline for uspace/lib/softfloat/generic


Ignore:
Timestamp:
2011-05-06T14:21:25Z (14 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
7b90778d, b5e68c8
Parents:
042fbe0
Message:

softfloat: slightly improve coding style (no change in functionality)

Location:
uspace/lib/softfloat/generic
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/softfloat/generic/add.c

    r042fbe0 r750636a  
    2727 */
    2828
    29 /** @addtogroup softfloat       
     29/** @addtogroup softfloat
    3030 * @{
    3131 */
     
    3333 */
    3434
    35 #include<sftypes.h>
    36 #include<add.h>
    37 #include<comparison.h>
     35#include <sftypes.h>
     36#include <add.h>
     37#include <comparison.h>
    3838
    3939/** Add two Float32 numbers with same signs
     
    139139        a.parts.exp = exp1;
    140140       
    141         /*Clear hidden bit and shift */
     141        /* Clear hidden bit and shift */
    142142        a.parts.fraction = ((frac1 >> 6) & (~FLOAT32_HIDDEN_BIT_MASK)) ;
    143143        return a;
    144144}
    145 
    146145
    147146/** Add two Float64 numbers with same signs
     
    250249       
    251250        a.parts.exp = exp1;
    252         /*Clear hidden bit and shift */
     251        /* Clear hidden bit and shift */
    253252        a.parts.fraction = ( (frac1 >> 6 ) & (~FLOAT64_HIDDEN_BIT_MASK));
    254253       
  • uspace/lib/softfloat/generic/common.c

    r042fbe0 r750636a  
    2727 */
    2828
    29 /** @addtogroup softfloat       
     29/** @addtogroup softfloat
    3030 * @{
    3131 */
     
    3333 */
    3434
    35 #include<sftypes.h>
    36 #include<common.h>
     35#include <sftypes.h>
     36#include <common.h>
    3737
    3838/* Table for fast leading zeroes counting */
     
    213213/** @}
    214214 */
    215 
  • uspace/lib/softfloat/generic/comparison.c

    r042fbe0 r750636a  
    2727 */
    2828
    29 /** @addtogroup softfloat       
     29/** @addtogroup softfloat
    3030 * @{
    3131 */
     
    3333 */
    3434
    35 #include<sftypes.h>
    36 #include<comparison.h>
     35#include <sftypes.h>
     36#include <comparison.h>
    3737
    38 inline int isFloat32NaN(float32 f)
    39 {       /* NaN : exp = 0xff and nonzero fraction */
    40         return ((f.parts.exp==0xFF)&&(f.parts.fraction));
     38/* NaN : exp = 0xff and nonzero fraction */
     39int isFloat32NaN(float32 f)
     40{
     41        return ((f.parts.exp == 0xFF) && (f.parts.fraction));
    4142}
    4243
    43 inline int isFloat64NaN(float64 d)
    44 {       /* NaN : exp = 0x7ff and nonzero fraction */
    45         return ((d.parts.exp==0x7FF)&&(d.parts.fraction));
     44/* NaN : exp = 0x7ff and nonzero fraction */
     45int isFloat64NaN(float64 d)
     46{
     47        return ((d.parts.exp == 0x7FF) && (d.parts.fraction));
    4648}
    4749
    48 inline int isFloat32SigNaN(float32 f)
    49 {       /* SigNaN : exp = 0xff fraction = 0xxxxx..x (binary), where at least one x is nonzero */
    50         return ((f.parts.exp==0xFF)&&(f.parts.fraction<0x400000)&&(f.parts.fraction));
     50/* SigNaN : exp = 0xff fraction = 0xxxxx..x (binary), where at least one x is nonzero */
     51int isFloat32SigNaN(float32 f)
     52{
     53        return ((f.parts.exp == 0xFF) && (f.parts.fraction < 0x400000) && (f.parts.fraction));
    5154}
    5255
    53 inline int isFloat64SigNaN(float64 d)
    54 {       /* SigNaN : exp = 0x7ff fraction = 0xxxxx..x (binary), where at least one x is nonzero */
    55         return ((d.parts.exp==0x7FF)&&(d.parts.fraction)&&(d.parts.fraction<0x8000000000000ll));
     56/* SigNaN : exp = 0x7ff fraction = 0xxxxx..x (binary), where at least one x is nonzero */
     57int isFloat64SigNaN(float64 d)
     58{
     59        return ((d.parts.exp == 0x7FF) && (d.parts.fraction) && (d.parts.fraction < 0x8000000000000ll));
    5660}
    5761
    58 inline int isFloat32Infinity(float32 f)
     62int isFloat32Infinity(float32 f)
    5963{
    60         return ((f.parts.exp==0xFF)&&(f.parts.fraction==0x0));
     64        return ((f.parts.exp == 0xFF) && (f.parts.fraction == 0x0));
    6165}
    6266
    63 inline int isFloat64Infinity(float64 d)
     67int isFloat64Infinity(float64 d)
    6468{
    65         return ((d.parts.exp==0x7FF)&&(d.parts.fraction==0x0));
     69        return ((d.parts.exp == 0x7FF) && (d.parts.fraction == 0x0));
    6670}
    6771
    68 inline int isFloat32Zero(float32 f)
     72int isFloat32Zero(float32 f)
    6973{
    7074        return (((f.binary) & 0x7FFFFFFF) == 0);
    7175}
    7276
    73 inline int isFloat64Zero(float64 d)
     77int isFloat64Zero(float64 d)
    7478{
    7579        return (((d.binary) & 0x7FFFFFFFFFFFFFFFll) == 0);
     
    7781
    7882/**
    79  * @return 1, if both floats are equal - but NaNs are not recognized
     83 * @return 1 if both floats are equal - but NaNs are not recognized
    8084 */
    81 inline int isFloat32eq(float32 a, float32 b)
     85int isFloat32eq(float32 a, float32 b)
    8286{
    83         return ((a.binary==b.binary)||(((a.binary| b.binary)&0x7FFFFFFF)==0)); /* a equals to b or both are zeros (with any sign) */
     87        /* a equals to b or both are zeros (with any sign) */
     88        return ((a.binary==b.binary) || (((a.binary | b.binary) & 0x7FFFFFFF) == 0));
    8489}
    8590
    8691/**
    87  * @return 1, if a<b - but NaNs are not recognized
     92 * @return 1 if a < b - but NaNs are not recognized
    8893 */
    89 inline int isFloat32lt(float32 a, float32 b)
     94int isFloat32lt(float32 a, float32 b)
    9095{
    91         if (((a.binary| b.binary)&0x7FFFFFFF)==0) {
     96        if (((a.binary | b.binary) & 0x7FFFFFFF) == 0)
    9297                return 0; /* +- zeroes */
    93         };
    9498       
    95         if ((a.parts.sign)&&(b.parts.sign)) {
    96                 /*if both are negative, smaller is that with greater binary value*/
    97                 return (a.binary>b.binary);
    98                 };
     99        if ((a.parts.sign) && (b.parts.sign))
     100                /* if both are negative, smaller is that with greater binary value */
     101                return (a.binary > b.binary);
    99102       
    100         /* lets negate signs - now will be positive numbers allways bigger than negative (first bit will be set for unsigned integer comparison)*/
    101         a.parts.sign=!a.parts.sign;
    102         b.parts.sign=!b.parts.sign;
    103         return (a.binary<b.binary);
    104                        
     103        /* lets negate signs - now will be positive numbers allways bigger than negative (first bit will be set for unsigned integer comparison) */
     104        a.parts.sign = !a.parts.sign;
     105        b.parts.sign = !b.parts.sign;
     106        return (a.binary < b.binary);
    105107}
    106108
    107109/**
    108  * @return 1, if a>b - but NaNs are not recognized
     110 * @return 1 if a > b - but NaNs are not recognized
    109111 */
    110 inline int isFloat32gt(float32 a, float32 b)
     112int isFloat32gt(float32 a, float32 b)
    111113{
    112         if (((a.binary| b.binary)&0x7FFFFFFF)==0) {
     114        if (((a.binary | b.binary) & 0x7FFFFFFF) == 0)
    113115                return 0; /* zeroes are equal with any sign */
    114         };
    115116       
    116         if ((a.parts.sign)&&(b.parts.sign)) {
    117                 /*if both are negative, greater is that with smaller binary value*/
    118                 return (a.binary<b.binary);
    119                 };
     117        if ((a.parts.sign) && (b.parts.sign))
     118                /* if both are negative, greater is that with smaller binary value */
     119                return (a.binary < b.binary);
    120120       
    121         /* lets negate signs - now will be positive numbers allways bigger than negative (first bit will be set for unsigned integer comparison)*/
    122         a.parts.sign=!a.parts.sign;
    123         b.parts.sign=!b.parts.sign;
    124         return (a.binary>b.binary);
    125                        
     121        /* lets negate signs - now will be positive numbers allways bigger than negative (first bit will be set for unsigned integer comparison) */
     122        a.parts.sign = !a.parts.sign;
     123        b.parts.sign = !b.parts.sign;
     124        return (a.binary > b.binary);
    126125}
    127126
  • uspace/lib/softfloat/generic/div.c

    r042fbe0 r750636a  
    2727 */
    2828
    29 /** @addtogroup softfloat       
     29/** @addtogroup softfloat
    3030 * @{
    3131 */
     
    3333 */
    3434
    35 #include<sftypes.h>
    36 #include<add.h>
    37 #include<div.h>
    38 #include<comparison.h>
    39 #include<mul.h>
    40 #include<common.h>
    41 
     35#include <sftypes.h>
     36#include <add.h>
     37#include <div.h>
     38#include <comparison.h>
     39#include <mul.h>
     40#include <common.h>
    4241
    4342float32 divFloat32(float32 a, float32 b)
  • uspace/lib/softfloat/generic/mul.c

    r042fbe0 r750636a  
    2727 */
    2828
    29 /** @addtogroup softfloat       
     29/** @addtogroup softfloat
    3030 * @{
    3131 */
     
    3333 */
    3434
    35 #include<sftypes.h>
    36 #include<mul.h>
    37 #include<comparison.h>
    38 #include<common.h>
     35#include <sftypes.h>
     36#include <mul.h>
     37#include <comparison.h>
     38#include <common.h>
    3939
    4040/** Multiply two 32 bit float numbers
  • uspace/lib/softfloat/generic/other.c

    r042fbe0 r750636a  
    2727 */
    2828
    29 /** @addtogroup softfloat       
     29/** @addtogroup softfloat
    3030 * @{
    3131 */
  • uspace/lib/softfloat/generic/softfloat.c

    r042fbe0 r750636a  
    3535 */
    3636
    37 #include<softfloat.h>
    38 #include<sftypes.h>
    39 
    40 #include<add.h>
    41 #include<sub.h>
    42 #include<mul.h>
    43 #include<div.h>
    44 
    45 #include<conversion.h>
    46 #include<comparison.h>
    47 #include<other.h>
    48 
    49 #include<functions.h>
     37#include <softfloat.h>
     38#include <sftypes.h>
     39
     40#include <add.h>
     41#include <sub.h>
     42#include <mul.h>
     43#include <div.h>
     44
     45#include <conversion.h>
     46#include <comparison.h>
     47#include <other.h>
     48
     49#include <functions.h>
    5050
    5151/* Arithmetic functions */
     
    494494}
    495495
    496 
    497496/** @}
    498497 */
    499 
  • uspace/lib/softfloat/generic/sub.c

    r042fbe0 r750636a  
    2727 */
    2828
    29  /** @addtogroup softfloat     
     29/** @addtogroup softfloat
    3030 * @{
    3131 */
     
    3333 */
    3434
    35 #include<sftypes.h>
    36 #include<sub.h>
    37 #include<comparison.h>
     35#include <sftypes.h>
     36#include <sub.h>
     37#include <comparison.h>
    3838
    3939/** Subtract two float32 numbers with same signs
     
    260260}
    261261
    262 
    263  /** @}
    264  */
    265 
     262/** @}
     263 */
Note: See TracChangeset for help on using the changeset viewer.