summaryrefslogtreecommitdiff
path: root/lib/ccan/ilog/_info
diff options
context:
space:
mode:
authorRusty Russell <rusty@rustcorp.com.au>2011-06-20 16:54:15 +0930
committerRusty Russell <rusty@rustcorp.com.au>2011-06-20 11:18:34 +0200
commit754c677b0bbf3ea6c7d2a73c93848f1b0d68c91e (patch)
tree54d99c9f66d5a57bf7f70d53e744a31df18f9e0e /lib/ccan/ilog/_info
parenta8c3d38bc806c6972d10b6a371de8941da25a9ae (diff)
downloadsamba-754c677b0bbf3ea6c7d2a73c93848f1b0d68c91e.tar.gz
samba-754c677b0bbf3ea6c7d2a73c93848f1b0d68c91e.tar.bz2
samba-754c677b0bbf3ea6c7d2a73c93848f1b0d68c91e.zip
lib: import ccan modules for tdb2
Imported from git://git.ozlabs.org/~ccan/ccan init-1161-g661d41f Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'lib/ccan/ilog/_info')
-rw-r--r--lib/ccan/ilog/_info47
1 files changed, 47 insertions, 0 deletions
diff --git a/lib/ccan/ilog/_info b/lib/ccan/ilog/_info
new file mode 100644
index 0000000000..56de50d610
--- /dev/null
+++ b/lib/ccan/ilog/_info
@@ -0,0 +1,47 @@
+/**
+ * ilog - Integer logarithm.
+ *
+ * ilog_32() and ilog_64() compute the minimum number of bits required to store
+ * an unsigned 32-bit or 64-bit value without any leading zero bits.
+ * This can also be thought of as the location of the highest set bit, with
+ * counting starting from one (so that 0 returns 0, 1 returns 1, and 2**31
+ * returns 32).
+ * When the value is known to be non-zero ilog32_nz() and ilog64_nz() can
+ * compile into as few as two instructions, one of which may get optimized out
+ * later.
+ * STATIC_ILOG_32 and STATIC_ILOG_64 allow computation on compile-time
+ * constants, so other compile-time constants can be derived from them.
+ *
+ * Example:
+ * #include <stdio.h>
+ * #include <limits.h>
+ * #include <ccan/ilog/ilog.h>
+ *
+ * int main(void){
+ * int i;
+ * printf("ilog32(0x%08X)=%i\n",0,ilog32(0));
+ * for(i=1;i<=STATIC_ILOG_32(USHRT_MAX);i++){
+ * uint32_t v;
+ * v=(uint32_t)1U<<(i-1);
+ * //Here we know v is non-zero, so we can use ilog32_nz().
+ * printf("ilog32(0x%08X)=%i\n",v,ilog32_nz(v));
+ * }
+ * return 0;
+ * }
+ *
+ * License: LGPL (v2 or later)
+ * Author: Timothy B. Terriberry <tterribe@xiph.org>
+ */
+#include <string.h>
+#include <stdio.h>
+#include "config.h"
+
+int main(int _argc,const char *_argv[]){
+ /*Expect exactly one argument.*/
+ if(_argc!=2)return 1;
+ if(strcmp(_argv[1],"depends")==0){
+ printf("ccan/compiler\n");
+ return 0;
+ }
+ return 1;
+}