added ilog2() implementation in case log2 is not available.
authorGengbin Zheng <gzheng@illinois.edu>
Mon, 17 Nov 2008 18:20:33 +0000 (18:20 +0000)
committerGengbin Zheng <gzheng@illinois.edu>
Mon, 17 Nov 2008 18:20:33 +0000 (18:20 +0000)
src/conv-core/convcore.c
src/conv-core/converse.h

index 20115fa174db0319913539a055db60bc7e86df1d..caba9715951c9dd01ee9f00477a7825d61202ddc 100644 (file)
@@ -1621,7 +1621,7 @@ void CthResumeNormalThread(CthThreadToken* token)
                resumeTraceCore();*/
 #endif
 #endif
-    
+
   CthResume(t);
 }
 
@@ -3069,4 +3069,14 @@ unsigned char computeCheckSum(unsigned char *data, int len)
   return ret;
 }
 
+#if !CMK_HAS_LOG2
+unsigned int ilog2(unsigned int val) {
+  unsigned int log = 0u;
+  if ( val != 0u ) {
+      while ( val > (1u<<log) ) { log++; }
+  }
+  return log;
+}
+#endif
+
 /*@}*/
index 5b7fd1011cbbd898e7255914f4d52fdeab1c357f..d38d29824cea69edcc98179bb55a06fa25de4456 100644 (file)
@@ -1648,5 +1648,10 @@ extern int CmiGridQueueLookupMsg (char *msg);
 
 #include "debug-conv.h"
 
+#if CMK_HAS_LOG2
+#define ilog2  log2
+#else
+extern unsigned int ilog2(unsigned int);
+#endif
 
 #endif /* CONVERSE_H */