Changes in / [4ea5308:5569a31]
- Files:
-
- 3 deleted
- 4 edited
-
libcfa/src/bitmanip.hfa (modified) (2 diffs)
-
libcfa/src/exception.c (modified) (2 diffs)
-
tests/.expect/bitmanip3.x64.txt (deleted)
-
tests/.expect/bitmanip3.x86.txt (deleted)
-
tests/bitmanip1.cfa (modified) (1 diff)
-
tests/bitmanip2.cfa (modified) (1 diff)
-
tests/bitmanip3.cfa (deleted)
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/bitmanip.hfa
r4ea5308 r5569a31 11 11 // Created On : Sat Mar 14 18:12:27 2020 12 12 // Last Modified By : Peter A. Buhr 13 // Last Modified On : Mon Apr 13 22:37:03202014 // Update Count : 11013 // Last Modified On : Mon Apr 6 22:17:19 2020 14 // Update Count : 78 15 15 // 16 16 … … 67 67 68 68 // Find most significiant zero bit. 69 unsigned int high0( unsigned char n ) { return n == (typeof(n))-1 ? 0 : __bitsizeof(unsigned int) - __builtin_clz( (typeof(n))~n ); }70 unsigned int high0( unsigned short int n ) { return n == (typeof(n))-1 ? 0 : __bitsizeof(unsigned int) - __builtin_clz( (typeof(n))~n ); }71 unsigned int high0( unsigned int n ) { return n == -1 ? 0 : __bitsizeof(n) - __builtin_clz( ~n ); }72 unsigned int high0( unsigned long int n ) { return n == -1 ? 0 : __bitsizeof(n) - __builtin_clzl( ~n ); }73 unsigned int high0( unsigned long long int n ) { return n == -1 ? 0 : __bitsizeof(n) - __builtin_clzll( ~n ); }69 unsigned int high0( unsigned char n ) { return n != (typeof(n))-1 ? __bitsizeof(unsigned int) - __builtin_clz( (typeof(n))~n ) : 0; } 70 unsigned int high0( unsigned short int n ) { return n != (typeof(n))-1 ? __bitsizeof(unsigned int) - __builtin_clz( (typeof(n))~n ) : 0; } 71 unsigned int high0( unsigned int n ) { return n != -1 ? __bitsizeof(n) - __builtin_clz( ~n ) : 0; } 72 unsigned int high0( unsigned long int n ) { return n != -1 ? __bitsizeof(n) - __builtin_clzl( ~n ) : 0; } 73 unsigned int high0( unsigned long long int n ) { return n != -1 ? __bitsizeof(n) - __builtin_clzll( ~n ) : 0; } 74 74 75 75 // Find most significiant one bit. 76 unsigned int high1( unsigned char n ) { return n == 0 ? 0 : __bitsizeof(unsigned int) - __builtin_clz( n ); }77 unsigned int high1( unsigned short int n ) { return n == 0 ? 0 : __bitsizeof(unsigned int) - __builtin_clz( n ); }78 unsigned int high1( unsigned int n ) { return n == 0 ? 0 : __bitsizeof(n) - __builtin_clz( n ); }79 unsigned int high1( unsigned long int n ) { return n == 0 ? 0 : __bitsizeof(n) - __builtin_clzl( n ); }80 unsigned int high1( unsigned long long int n ) { return n == 0 ? 0 : __bitsizeof(n) - __builtin_clzll( n ); }76 unsigned int high1( unsigned char n ) { return n != 0 ? __bitsizeof(unsigned int) - __builtin_clz( n ) : 0; } 77 unsigned int high1( unsigned short int n ) { return n != 0 ? __bitsizeof(unsigned int) - __builtin_clz( n ) : 0; } 78 unsigned int high1( unsigned int n ) { return n != 0 ? __bitsizeof(n) - __builtin_clz( n ) : 0; } 79 unsigned int high1( unsigned long int n ) { return n != 0 ? __bitsizeof(n) - __builtin_clzl( n ) : 0; } 80 unsigned int high1( unsigned long long int n ) { return n != 0 ? __bitsizeof(n) - __builtin_clzll( n ) : 0; } 81 81 82 // Check for power of 2, clears bits below n, rounding down to the next lower multiple of n. 83 bool is_pow2( unsigned char n ) { return n == 0 ? false : (n & (n - 1)) == 0; } 84 bool is_pow2( unsigned short int n ) { return n == 0 ? false : (n & (n - 1)) == 0; } 85 bool is_pow2( unsigned int n ) { return n == 0 ? false : (n & (n - 1)) == 0; } 86 bool is_pow2( unsigned long int n ) { return n == 0 ? false : (n & (n - 1)) == 0; } 87 bool is_pow2( unsigned long long int n ) { return n == 0 ? false : (n & (n - 1)) == 0; } 82 // Check for power of 2, clears bits below value, rounding down to the next lower multiple of value. 83 bool is_pow2( int value ) { return (value & (value - 1)) == 0; } 84 bool is_pow2( unsigned long long int value ) { return (value & (value - 1)) == 0; } 88 85 89 // Returns n aligned at the floor of align, clear bits above or equal to align, giving n % align. 90 // signed char floor2( signed char n, signed char align ) { /*assert( is_pow2( align ) );*/ return n & -align; } 91 // unsigned char floor2( unsigned char n, unsigned char align ) { /*assert( is_pow2( align ) );*/ return n & -align; } 92 // short int floor2( short int n, unsigned short int align ) { /*assert( is_pow2( align ) );*/ return n & -align; } 93 // unsigned short int floor2( unsigned short int n, unsigned short int align ) { /*assert( is_pow2( align ) );*/ return n & -align; } 94 // int floor2( int n, unsigned int align ) { /*assert( is_pow2( align ) );*/ return n & -align; } 95 // unsigned int floor2( unsigned int n, unsigned int align ) { /*assert( is_pow2( align ) );*/ return n & -align; } 96 // long int floor2( long int n, unsigned long int align ) { /*assert( is_pow2( align ) );*/ return n & -align; } 97 // unsigned long int floor2( unsigned long int n, unsigned long int align ) { /*assert( is_pow2( align ) );*/ return n & -align; } 98 // long long int floor2( long long int n, unsigned long long int align ) { /*assert( is_pow2( align ) );*/ return n & -align; } 99 // unsigned long long int floor2( unsigned long long int n, unsigned long long int align ) { /*assert( is_pow2( align ) );*/ return n & -align; } 86 // Returns value aligned at the floor of align, clear bits above or equal to align, giving value % align. 87 unsigned int floor2( unsigned int value, unsigned int align ) { assert( is_pow2( align ) ); return value & -align; } 88 unsigned long long int floor2( unsigned long long int value, unsigned long long int align ) { assert( is_pow2( align ) ); return value & -align; } 100 89 101 forall( otype T | { T ?&?( T, T ); T -?( T ); } ) 102 T floor2( T n, T align ) { /* assert( is_pow2( align ) ); */ return n & -align; }90 unsigned int floor( unsigned int value, unsigned int align ) { return value / align * align; } 91 unsigned long long int floor( unsigned long long int value, unsigned long long int align ) { return value / align * align; } 103 92 104 forall( otype T | { T ?/?( T, T ); T ?*?( T, T ); } ) 105 T floor( T n, T align ) { return n / align * align; } 93 // Returns value aligned at the ceiling of align, negate, round down, negate is the same as round up. 94 unsigned int ceiling2( unsigned int value, unsigned int align ) { assert( is_pow2( align ) ); return -floor2( -value, align ); } 95 unsigned long long int ceiling2( unsigned long long int value, unsigned long long int align ) { assert( is_pow2( align ) ); return -floor2( -value, align ); } 106 96 107 // Returns n aligned at the ceiling of align, negate, round down, negate is the same as round up. 108 forall( otype T | { T floor2( T, T ); T -?( T ); } ) 109 T ceiling2( T n, T align ) { /* assert( is_pow2( align ) ); */ return -floor2( -n, align ); } 110 111 forall( otype T | { void ?{}( T &, one_t ); T ?+?( T, T ); T ?-?( T, T ); T ?/?( T, T ); } ) 112 T ceiling( T n, T align ) { return (n + (align - (T){1})) / align; } 97 unsigned int ceiling( unsigned int value, unsigned int align ) { return (value + (align - 1)) / align; } 98 unsigned long long int ceiling( unsigned long long int value, unsigned long long int align ) { return (value + (align - 1)) / align; } 113 99 } // distribution 114 100 -
libcfa/src/exception.c
r4ea5308 r5569a31 10 10 // Created On : Mon Jun 26 15:13:00 2017 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : T ue Apr 14 12:01:00 202013 // Update Count : 1 812 // Last Modified On : Thr Apr 9 12:20:00 2020 13 // Update Count : 17 14 14 // 15 15 … … 445 445 446 446 #pragma GCC push_options 447 #if __GNUC__ != 7448 447 #pragma GCC optimize("no-toplevel-reorder") 449 #else450 #pragma GCC optimize("no-unit-at-a-time")451 #endif452 448 453 449 // Try statements are hoisted out see comments for details. While this could probably be unique -
tests/bitmanip1.cfa
r4ea5308 r5569a31 1 //2 // Cforall Version 1.0.0 Copyright (C) 2020 University of Waterloo3 //4 // The contents of this file are covered under the licence agreement in the5 // file "LICENCE" distributed with Cforall.6 //7 // bitmanip1.cfa<cfa-cc> --8 //9 // Author : Peter A. Buhr10 // Created On : Tue Apr 7 21:20:29 202011 // Last Modified By : Peter A. Buhr12 // Last Modified On : Tue Apr 7 21:20:57 202013 // Update Count : 114 //15 16 1 #include <fstream.hfa> 17 2 #include <bitmanip.hfa> -
tests/bitmanip2.cfa
r4ea5308 r5569a31 1 //2 // Cforall Version 1.0.0 Copyright (C) 2020 University of Waterloo3 //4 // The contents of this file are covered under the licence agreement in the5 // file "LICENCE" distributed with Cforall.6 //7 // bitmanip2.cfa --8 //9 // Author : Peter A. Buhr10 // Created On : Tue Apr 7 21:21:20 202011 // Last Modified By : Peter A. Buhr12 // Last Modified On : Tue Apr 7 21:21:40 202013 // Update Count : 114 //15 16 1 #include <fstream.hfa> 17 2 #include <bitmanip.hfa>
Note:
See TracChangeset
for help on using the changeset viewer.