Index: libcfa/src/bitmanip.hfa
===================================================================
--- libcfa/src/bitmanip.hfa	(revision 03eabf482e5459c81efc9cecd2bfb8190e0bad34)
+++ libcfa/src/bitmanip.hfa	(revision 76bf23c91ce652f59c3996bbd5df16c260e4c0a1)
@@ -11,6 +11,6 @@
 // Created On       : Sat Mar 14 18:12:27 2020
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Mon Mar 16 14:28:46 2020
-// Update Count     : 49
+// Last Modified On : Mon Apr  6 22:17:19 2020
+// Update Count     : 78
 // 
 
@@ -23,62 +23,79 @@
 #include <assert.h>
 
+#define __bitsizeof( n ) (sizeof(n) * __CHAR_BIT__)
+
 static inline {
     // Count leading 0 bits.
-    unsigned int cl0( unsigned char n ) { return n != 0 ? __builtin_clz( n ) - (sizeof(unsigned int) * __CHAR_BIT__ - sizeof(n) * __CHAR_BIT__) : sizeof(n) * __CHAR_BIT__; }
-    unsigned int cl0( unsigned short int n ) { return n != 0 ? __builtin_clz( n ) - (sizeof(unsigned int) * __CHAR_BIT__ - sizeof(n) * __CHAR_BIT__) : sizeof(n) * __CHAR_BIT__; }
-    unsigned int cl0( unsigned int n ) { return n != 0 ? __builtin_clz( n ) : sizeof(n) * __CHAR_BIT__; }
-    unsigned int cl0( unsigned long int n ) { return n != 0 ? __builtin_clzl( n ) : sizeof(n) * __CHAR_BIT__; }
-    unsigned int cl0( unsigned long long int n ) { return n != 0 ? __builtin_clzll( n ) : sizeof(n) * __CHAR_BIT__; }
+    unsigned int leading0s( unsigned char n ) { return n != 0 ? __builtin_clz( n ) - (__bitsizeof(unsigned int) - __bitsizeof(n)) : __bitsizeof(n); }
+    unsigned int leading0s( unsigned short int n ) { return n != 0 ? __builtin_clz( n ) - (__bitsizeof(unsigned int) - __bitsizeof(n)) : __bitsizeof(n); }
+    unsigned int leading0s( unsigned int n ) { return n != 0 ? __builtin_clz( n ) : __bitsizeof(n); }
+    unsigned int leading0s( unsigned long int n ) { return n != 0 ? __builtin_clzl( n ) : __bitsizeof(n); }
+    unsigned int leading0s( unsigned long long int n ) { return n != 0 ? __builtin_clzll( n ) : __bitsizeof(n); }
 
     // Count trailing 0 bits.
-    unsigned int ct0( unsigned char n ) { return n != 0 ? __builtin_ctz( n ) : sizeof(n) * __CHAR_BIT__; }
-    unsigned int ct0( unsigned short int n ) { return n != 0 ? __builtin_ctz( n ) : sizeof(n) * __CHAR_BIT__; }
-    unsigned int ct0( unsigned int n ) { return n != 0 ? __builtin_ctz( n ) : sizeof(n) * __CHAR_BIT__; }
-    unsigned int ct0( unsigned long int n ) { return n != 0 ? __builtin_ctzl( n ) : sizeof(n) * __CHAR_BIT__; }
-    unsigned int ct0( unsigned long long int n ) { return n != 0 ? __builtin_ctzll( n ) : sizeof(n) * __CHAR_BIT__; }
+    unsigned int trailing0s( unsigned char n ) { return n != 0 ? __builtin_ctz( n ) : __bitsizeof(n); }
+    unsigned int trailing0s( unsigned short int n ) { return n != 0 ? __builtin_ctz( n ) : __bitsizeof(n); }
+    unsigned int trailing0s( unsigned int n ) { return n != 0 ? __builtin_ctz( n ) : __bitsizeof(n); }
+    unsigned int trailing0s( unsigned long int n ) { return n != 0 ? __builtin_ctzl( n ) : __bitsizeof(n); }
+    unsigned int trailing0s( unsigned long long int n ) { return n != 0 ? __builtin_ctzll( n ) : __bitsizeof(n); }
 
     // Count all 1 bits.
-    unsigned int ca1( unsigned char n ) { return __builtin_popcount( n ); }
-    unsigned int ca1( unsigned short int n ) { return __builtin_popcount( n ); }
-    unsigned int ca1( unsigned int n ) { return __builtin_popcount( n ); }
-    unsigned int ca1( unsigned long int n ) { return __builtin_popcountl( n ); }
-    unsigned int ca1( unsigned long long int n ) { return __builtin_popcountll( n ); }
+    unsigned int all1s( unsigned char n ) { return __builtin_popcount( n ); }
+    unsigned int all1s( unsigned short int n ) { return __builtin_popcount( n ); }
+    unsigned int all1s( unsigned int n ) { return __builtin_popcount( n ); }
+    unsigned int all1s( unsigned long int n ) { return __builtin_popcountl( n ); }
+    unsigned int all1s( unsigned long long int n ) { return __builtin_popcountll( n ); }
 
     // Count all 0 bits.
-    unsigned int ca0( unsigned char n ) { return sizeof(n) * __CHAR_BIT__ - __builtin_popcount( n ); }
-    unsigned int ca0( unsigned short int n ) { return sizeof(n) * __CHAR_BIT__ - __builtin_popcount( n ); }
-    unsigned int ca0( unsigned int n ) { return sizeof(n) * __CHAR_BIT__ - __builtin_popcount( n ); }
-    unsigned int ca0( unsigned long int n ) { return sizeof(n) * __CHAR_BIT__ - __builtin_popcountl( n ); }
-    unsigned int ca0( unsigned long long int n ) { return sizeof(n) * __CHAR_BIT__ - __builtin_popcountll( n ); }
+    unsigned int all0s( unsigned char n ) { return __bitsizeof(n) - __builtin_popcount( n ); }
+    unsigned int all0s( unsigned short int n ) { return __bitsizeof(n) - __builtin_popcount( n ); }
+    unsigned int all0s( unsigned int n ) { return __bitsizeof(n) - __builtin_popcount( n ); }
+    unsigned int all0s( unsigned long int n ) { return __bitsizeof(n) - __builtin_popcountl( n ); }
+    unsigned int all0s( unsigned long long int n ) { return __bitsizeof(n) - __builtin_popcountll( n ); }
 
-    // Find least significiant set bit. (ffs)
-    unsigned int fls( unsigned int n ) { return __builtin_ffs( n ); }
-    unsigned int fls( unsigned long int n ) { return __builtin_ffsl( n ); }
-    unsigned int fls( unsigned long long int n ) { return __builtin_ffsll( n ); }
+    // Find least significiant zero bit. (ffs)
+    unsigned int low0( unsigned char n ) { return __builtin_ffs( (typeof(n))~n ); }
+    unsigned int low0( unsigned short int n ) { return __builtin_ffs( (typeof(n))~n ); }
+    unsigned int low0( unsigned int n ) { return __builtin_ffs( ~n ); }
+    unsigned int low0( unsigned long int n ) { return __builtin_ffsl( ~n ); }
+    unsigned int low0( unsigned long long int n ) { return __builtin_ffsll( ~n ); }
 
-    // Find most significiant set bit.
-    unsigned int fms( unsigned char n ) { return n != 0 ? sizeof(unsigned int) * __CHAR_BIT__ - __builtin_clz( n ) : 0; }
-    unsigned int fms( unsigned short int n ) { return n != 0 ? sizeof(unsigned int) * __CHAR_BIT__ - __builtin_clz( n ) : 0; }
-    unsigned int fms( unsigned int n ) { return n != 0 ? sizeof(n) * __CHAR_BIT__ - __builtin_clz( n ) : 0; }
-    unsigned int fms( unsigned long int n ) { return n != 0 ? sizeof(n) * __CHAR_BIT__ - __builtin_clzl( n ) : 0; }
-    unsigned int fms( unsigned long long int n ) { return n != 0 ? sizeof(n) * __CHAR_BIT__ - __builtin_clzll( n ) : 0; }
+    // Find least significiant one bit.
+    unsigned int low1( unsigned int n ) { return __builtin_ffs( n ); }
+    unsigned int low1( unsigned long int n ) { return __builtin_ffsl( n ); }
+    unsigned int low1( unsigned long long int n ) { return __builtin_ffsll( n ); }
 
-    // Check for power of 2
-    bool pow2( unsigned long int value ) {
-		return (value & (value - 1)) == 0;				// clears bits below value, rounding down to the next lower multiple of value
-    } // pow2
+    // Find most significiant zero bit.
+    unsigned int high0( unsigned char n ) { return n != (typeof(n))-1 ? __bitsizeof(unsigned int) - __builtin_clz( (typeof(n))~n ) : 0; }
+    unsigned int high0( unsigned short int n ) { return n != (typeof(n))-1 ? __bitsizeof(unsigned int) - __builtin_clz( (typeof(n))~n ) : 0; }
+    unsigned int high0( unsigned int n ) { return n != -1 ? __bitsizeof(n) - __builtin_clz( ~n ) : 0; }
+    unsigned int high0( unsigned long int n ) { return n != -1 ? __bitsizeof(n) - __builtin_clzl( ~n ) : 0; }
+    unsigned int high0( unsigned long long int n ) { return n != -1 ? __bitsizeof(n) - __builtin_clzll( ~n ) : 0; }
 
-    // Returns value aligned at the floor of align.
-    unsigned long int floor( unsigned long int value, unsigned long int align ) {
-		assert( pow2( align ) );
-		return value & -align;							// clear bits above or equal to align, giving value % align
-    } // floor
+    // Find most significiant one bit.
+    unsigned int high1( unsigned char n ) { return n != 0 ? __bitsizeof(unsigned int) - __builtin_clz( n ) : 0; }
+    unsigned int high1( unsigned short int n ) { return n != 0 ? __bitsizeof(unsigned int) - __builtin_clz( n ) : 0; }
+    unsigned int high1( unsigned int n ) { return n != 0 ? __bitsizeof(n) - __builtin_clz( n ) : 0; }
+    unsigned int high1( unsigned long int n ) { return n != 0 ? __bitsizeof(n) - __builtin_clzl( n ) : 0; }
+    unsigned int high1( unsigned long long int n ) { return n != 0 ? __bitsizeof(n) - __builtin_clzll( n ) : 0; }
 
-    // Returns value aligned at the ceiling of align.
-    unsigned long int ceiling( unsigned long int value, unsigned long int align ) {
-		assert( pow2( align ) );
-		return -floor( -value, align );					// negate, round down, negate is the same as round up
-    } // ceiling
-}
+    // Check for power of 2, clears bits below value, rounding down to the next lower multiple of value.
+    bool is_pow2( int value ) { return (value & (value - 1)) == 0; }
+    bool is_pow2( unsigned long long int value ) { return (value & (value - 1)) == 0; }
+
+    // Returns value aligned at the floor of align, clear bits above or equal to align, giving value % align.
+    unsigned int floor2( unsigned int value, unsigned int align ) { assert( is_pow2( align ) ); return value & -align; }
+    unsigned long long int floor2( unsigned long long int value, unsigned long long int align ) { assert( is_pow2( align ) ); return value & -align; }
+
+    unsigned int floor( unsigned int value, unsigned int align ) { return value / align * align; }
+    unsigned long long int floor( unsigned long long int value, unsigned long long int align ) { return value / align * align; }
+
+    // Returns value aligned at the ceiling of align, negate, round down, negate is the same as round up.
+    unsigned int ceiling2( unsigned int value, unsigned int align ) { assert( is_pow2( align ) ); return -floor2( -value, align ); }
+    unsigned long long int ceiling2( unsigned long long int value, unsigned long long int align ) { assert( is_pow2( align ) ); return -floor2( -value, align ); }
+
+    unsigned int ceiling( unsigned int value, unsigned int align ) { return (value + (align - 1)) / align; }
+    unsigned long long int ceiling( unsigned long long int value, unsigned long long int align ) { return (value + (align - 1)) / align; }
+} // distribution
 
 // Local Variables: //
