Ignore:
Timestamp:
Aug 24, 2020, 8:34:24 PM (14 months ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
arm-eh, jacob/cs343-translation, master, new-ast-unique-expr
Children:
0254454
Parents:
97cba9f
Message:

move routines floor, ceiling, ceiling_div from bitmanip.hfa to math.hfa

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/bitmanip.hfa

    r97cba9f r7cfef0d  
    1111// Created On       : Sat Mar 14 18:12:27 2020
    1212// Last Modified By : Peter A. Buhr
    13 // Last Modified On : Mon Aug 10 09:21:02 2020
    14 // Update Count     : 139
     13// Last Modified On : Sun Aug 23 21:39:28 2020
     14// Update Count     : 140
    1515//
    1616
     
    103103        // T floor2( T n, T align ) { verify( is_pow2( align ) ); return n & -align; }
    104104
    105         signed char floor( signed char n, signed char align ) { return n / align * align; }
    106         unsigned char floor( unsigned char n, unsigned char align ) { return n / align * align; }
    107         short int floor( short int n, short int align ) { return n / align * align; }
    108         unsigned short int floor( unsigned short int n, unsigned short int align ) { return n / align * align; }
    109         int floor( int n, int align ) { return n / align * align; }
    110         unsigned int floor( unsigned int n, unsigned int align ) { return n / align * align; }
    111         long int floor( long int n, long int align ) { return n / align * align; }
    112         unsigned long int floor( unsigned long int n, unsigned long int align ) { return n / align * align; }
    113         long long int floor( long long int n, long long int align ) { return n / align * align; }
    114         unsigned long long int floor( unsigned long long int n, unsigned long long int align ) { return n / align * align; }
    115 
    116         // forall( otype T | { T ?/?( T, T ); T ?*?( T, T ); } )
    117         // T floor( T n, T align ) { return n / align * align; }
    118 
    119105        // Returns n aligned at the ceiling of align, negate, round down, negate is the same as round up.
    120106        signed char ceiling2( signed char n, signed char align ) { verify( is_pow2( align ) ); return -floor2( -n, align ); }
     
    131117        // forall( otype T | { T floor2( T, T ); T -?( T ); } )
    132118        // T ceiling2( T n, T align ) { verify( is_pow2( align ) ); return -floor2( -n, align ); }
    133 
    134         signed char ceiling_div( signed char n, char align ) { return (n + (align - 1)) / align; }
    135         unsigned char ceiling_div( unsigned char n, unsigned char align ) { return (n + (align - 1)) / align; }
    136         short int ceiling_div( short int n, short int align ) { return (n + (align - 1)) / align; }
    137         unsigned short int ceiling_div( unsigned short int n, unsigned short int align ) { return (n + (align - 1)) / align; }
    138         int ceiling_div( int n, int align ) { return (n + (align - 1)) / align; }
    139         unsigned int ceiling_div( unsigned int n, unsigned int align ) { return (n + (align - 1)) / align; }
    140         long int ceiling_div( long int n, long int align ) { return (n + (align - 1)) / align; }
    141         unsigned long int ceiling_div( unsigned long int n, unsigned long int align ) { return (n + (align - 1)) / align; }
    142         long long int ceiling_div( long long int n, long long int align ) { return (n + (align - 1)) / align; }
    143         unsigned long long int ceiling_div( unsigned long long int n, unsigned long long int align ) { return (n + (align - 1)) / align; }
    144 
    145         // forall( otype T | { T ?+?( T, T ); T ?-?( T, T ); T ?%?( T, T ); } )
    146         // T ceiling_div( T n, T align ) { verify( is_pow2( align ) );return (n + (align - 1)) / align; }
    147        
    148         // gcc notices the div/mod pair and saves both so only one div.
    149         signed char ceiling( signed char n, signed char align ) { return floor( n + (n % align != 0 ? align - 1 : 0), align ); }
    150         unsigned char ceiling( unsigned char n, unsigned char align ) { return floor( n + (n % align != 0 ? align - 1 : 0), align ); }
    151         short int ceiling( short int n, short int align ) { return floor( n + (n % align != 0 ? align - 1 : 0), align ); }
    152         unsigned short int ceiling( unsigned short int n, unsigned short int align ) { return floor( n + (n % align != 0 ? align - 1 : 0), align ); }
    153         int ceiling( int n, int align ) { return floor( n + (n % align != 0 ? align - 1 : 0), align ); }
    154         unsigned int ceiling( unsigned int n, unsigned int align ) { return floor( n + (n % align != 0 ? align - 1 : 0), align ); }
    155         long int ceiling( long int n, long int align ) { return floor( n + (n % align != 0 ? align - 1 : 0), align ); }
    156         unsigned long int ceiling( unsigned long int n, unsigned long int align ) { return floor( n + (n % align != 0 ? align - 1 : 0) , align); }
    157         long long int ceiling( long long int n, long long int align ) { return floor( n + (n % align != 0 ? align - 1 : 0), align ); }
    158         unsigned long long int ceiling( unsigned long long int n, unsigned long long int align ) { return floor( n + (n % align != 0 ? align - 1 : 0), align ); }
    159 
    160         // forall( otype T | { void ?{}( T &, one_t ); T ?+?( T, T ); T ?-?( T, T ); T ?/?( T, T ); } )
    161         // T ceiling( T n, T align ) { return return floor( n + (n % align != 0 ? align - 1 : 0), align ); *}
    162119} // distribution
    163120
Note: See TracChangeset for help on using the changeset viewer.