aboutsummaryrefslogtreecommitdiffstats
path: root/tools/include/linux
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2014-12-15 14:04:11 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2014-12-17 09:09:41 -0500
commit0389cd1f5fda34c14941c37a39547d16af5d56e2 (patch)
tree247ed2257e6656420fe7aa6a2f0063de8b6c91a4 /tools/include/linux
parent2dc0b9721956f4314364f68a99d8bef490870438 (diff)
tools: Move code originally from linux/log2.h to tools/include/linux/
From tools/perf/util/include/linux, so that it becomes accessible to other tools/. Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Borislav Petkov <bp@suse.de> Cc: David Ahern <dsahern@gmail.com> Cc: Don Zickus <dzickus@redhat.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/n/tip-uqohgzilp3ebd3cbybnf3luc@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/include/linux')
-rw-r--r--tools/include/linux/log2.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/tools/include/linux/log2.h b/tools/include/linux/log2.h
new file mode 100644
index 000000000000..141b7665d842
--- /dev/null
+++ b/tools/include/linux/log2.h
@@ -0,0 +1,26 @@
1/* Integer base 2 logarithm calculation
2 *
3 * Copyright (C) 2006 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11
12#ifndef _TOOLS_LINUX_LOG2_H
13#define _TOOLS_LINUX_LOG2_H
14
15/*
16 * Determine whether some value is a power of two, where zero is
17 * *not* considered a power of two.
18 */
19
20static inline __attribute__((const))
21bool is_power_of_2(unsigned long n)
22{
23 return (n != 0 && ((n & (n - 1)) == 0));
24}
25
26#endif /* _TOOLS_LINUX_LOG2_H */