Index: libcfa/src/math.hfa
===================================================================
--- libcfa/src/math.hfa	(revision ec43cf9bd03a6adc6b7f40ae9daa3cae62acd7e1)
+++ libcfa/src/math.hfa	(revision 4c4e444f4eaf11309c7a94a97b5b9b50be2a54fc)
@@ -10,6 +10,6 @@
 // Created On       : Mon Apr 18 23:37:04 2016
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Mon Aug 24 08:56:20 2020
-// Update Count     : 126
+// Last Modified On : Mon Apr 12 18:35:39 2021
+// Update Count     : 131
 //
 
@@ -100,4 +100,9 @@
 	long double _Complex log( long double _Complex x ) { return clogl( x ); }
 
+	// O(1) polymorphic integer log2, using clz, which returns the number of leading 0-bits, starting at the most
+	// significant bit (single instruction on x86)
+	int log2( unsigned int n ) { return n == 0 ? -1 : sizeof(n) * __CHAR_BIT__ - 1 - __builtin_clz( n ); }
+	long int log2( unsigned long int n ) { return n == 0 ? -1 : sizeof(n) * __CHAR_BIT__ - 1 - __builtin_clzl( n ); }
+	long long int log2( unsigned long long int n ) { return n == 0 ? -1 : sizeof(n) * __CHAR_BIT__ - 1 - __builtin_clzl( n ); }
 	float log2( float x ) { return log2f( x ); }
 	// extern "C" { double log2( double ); }
