Skip to content

Commit

Permalink
tools: Move code originally from linux/log2.h to tools/include/linux/
Browse files Browse the repository at this point in the history
From tools/perf/util/include/linux, so that it becomes accessible to
other tools/.

Cc: Adrian Hunter <[email protected]>
Cc: Borislav Petkov <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Don Zickus <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Mike Galbraith <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Stephane Eranian <[email protected]>
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
  • Loading branch information
acmel committed Dec 17, 2014
1 parent 2dc0b97 commit 0389cd1
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 12 deletions.
26 changes: 26 additions & 0 deletions tools/include/linux/log2.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/* Integer base 2 logarithm calculation
*
* Copyright (C) 2006 Red Hat, Inc. All Rights Reserved.
* Written by David Howells ([email protected])
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*/

#ifndef _TOOLS_LINUX_LOG2_H
#define _TOOLS_LINUX_LOG2_H

/*
* Determine whether some value is a power of two, where zero is
* *not* considered a power of two.
*/

static inline __attribute__((const))
bool is_power_of_2(unsigned long n)
{
return (n != 0 && ((n & (n - 1)) == 0));
}

#endif /* _TOOLS_LINUX_LOG2_H */
3 changes: 2 additions & 1 deletion tools/perf/MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ tools/lib/symbol/kallsyms.h
tools/include/asm/bug.h
tools/include/asm-generic/bitops/__ffs.h
tools/include/linux/compiler.h
tools/include/linux/hash.h
tools/include/linux/export.h
tools/include/linux/hash.h
tools/include/linux/log2.h
tools/include/linux/types.h
include/linux/const.h
include/linux/perf_event.h
Expand Down
1 change: 1 addition & 0 deletions tools/perf/Makefile.perf
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ LIB_H += util/include/linux/bitmap.h
LIB_H += util/include/linux/bitops.h
LIB_H += ../include/asm-generic/bitops/__ffs.h
LIB_H += ../include/linux/compiler.h
LIB_H += ../include/linux/log2.h
LIB_H += util/include/linux/const.h
LIB_H += util/include/linux/ctype.h
LIB_H += util/include/linux/kernel.h
Expand Down
1 change: 1 addition & 0 deletions tools/perf/util/evlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

#include <linux/bitops.h>
#include <linux/hash.h>
#include <linux/log2.h>

static void perf_evlist__mmap_put(struct perf_evlist *evlist, int idx);
static void __perf_evlist__munmap(struct perf_evlist *evlist, int idx);
Expand Down
11 changes: 0 additions & 11 deletions tools/perf/util/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -269,17 +269,6 @@ void event_attr_init(struct perf_event_attr *attr);
#define _STR(x) #x
#define STR(x) _STR(x)

/*
* Determine whether some value is a power of two, where zero is
* *not* considered a power of two.
*/

static inline __attribute__((const))
bool is_power_of_2(unsigned long n)
{
return (n != 0 && ((n & (n - 1)) == 0));
}

static inline unsigned next_pow2(unsigned x)
{
if (!x)
Expand Down

0 comments on commit 0389cd1

Please sign in to comment.