mirror-linux/tools/include/linux
Arnaldo Carvalho de Melo 6ae8eefc6c tools include: Do not use poison with C++
LIST_POISON[12] are used to initialize list_head and hlist_node
pointers, and do void pointer arithmetic, which C++ doesn't like, so, to
avoid drifting from the kernel by introducing some HLIST_POISON to do
away with void pointer math, just make those poisoned pointers be NULL
when building it with a C++ compiler.

Noticed with:

  $ make LLVM_CONFIG=/usr/bin/llvm-config-3.9 LIBCLANGLLVM=1
    CXX      util/c++/clang.o
    CXX	   util/c++/clang-test.o
  In file included from /home/lizj/linux/tools/include/linux/list.h:5:0,
                   from /home/lizj/linux/tools/perf/util/namespaces.h:13,
                   from /home/lizj/linux/tools/perf/util/util.h:15,
                   from /home/lizj/linux/tools/perf/util/util-cxx.h:20,
                   from util/c++/clang-c.h:5,
                   from util/c++/clang-test.cpp:2:
  /home/lizj/linux/tools/include/linux/list.h: In function ‘void list_del(list_head*)’:
  /home/lizj/linux/tools/include/linux/poison.h:14:31: error: pointer of type ‘void *’ used in arithmetic [-Werror=pointer-arith]
   # define POISON_POINTER_DELTA 0
                                 ^
  /home/lizj/linux/tools/include/linux/poison.h:22:41: note: in expansion of macro ‘POISON_POINTER_DELTA’
   #define LIST_POISON1  ((void *) 0x100 + POISON_POINTER_DELTA)
                                           ^
  /home/lizj/linux/tools/include/linux/list.h:107:16: note: in expansion of macro ‘LIST_POISON1’
    entry->next = LIST_POISON1;
                  ^
  In file included from /home/lizj/linux/tools/perf/util/namespaces.h:13:0,
                   from /home/lizj/linux/tools/perf/util/util.h:15,
                   from /home/lizj/linux/tools/perf/util/util-cxx.h:20,
                   from util/c++/clang-c.h:5,
                   from util/c++/clang-test.cpp:2:
  /home/lizj/linux/tools/include/linux/list.h:107:14: error: invalid conversion from ‘void*’ to ‘list_head*’ [-fpermissive]

Reported-by: Li Zhijian <lizhijian@cn.fujitsu.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Philip Li <philip.li@intel.com>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-m5ei2o0mjshucbr28baf5lqz@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2017-09-21 13:13:00 -03:00
..
sched tools/lib/lockdep: Remove private kernel headers 2017-06-05 09:28:14 +02:00
unaligned tools/lib/lockdep: Fix compilation for 4.11 2017-06-05 09:28:09 +02:00
atomic.h tools include: Introduce atomic_cmpxchg_{relaxed,release}() 2017-03-03 19:07:14 -03:00
bitmap.h radix tree test suite: Remove duplicate bitops code 2017-01-27 21:29:39 -05:00
bitops.h tools/lib/lockdep: Fix compilation for 4.11 2017-06-05 09:28:09 +02:00
bug.h tools include: Introduce linux/bug.h, from the kernel sources 2017-04-19 13:01:42 -03:00
compiler-gcc.h tools include linux: Guard against redefinition of some macros 2017-09-12 12:33:39 -03:00
compiler.h Merge branch 'perf-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2017-07-03 12:40:46 -07:00
coresight-pmu.h perf: cs-etm: Fix ETMv4 CONFIGR entry in perf.data file 2017-08-28 17:35:43 +02:00
debug_locks.h tools/lib/lockdep: Remove private kernel headers 2017-06-05 09:28:14 +02:00
delay.h tools/lib/lockdep: Remove private kernel headers 2017-06-05 09:28:14 +02:00
err.h tools/include: Add IS_ERR_OR_NULL to err.h 2017-06-05 09:28:12 +02:00
export.h tools: Restore export.h 2015-08-25 09:44:22 +02:00
filter.h bpf: add various verifier test cases 2017-05-25 13:44:28 -04:00
ftrace.h tools/lib/lockdep: Remove private kernel headers 2017-06-05 09:28:14 +02:00
gfp.h tools/lib/lockdep: Remove private kernel headers 2017-06-05 09:28:14 +02:00
hardirq.h tools/lib/lockdep: Remove private kernel headers 2017-06-05 09:28:14 +02:00
hash.h tools: Copy linux/{hash,poison}.h and check for drift 2016-07-18 18:41:50 -03:00
hashtable.h tools include: Drop ARRAY_SIZE() definition from linux/hashtable.h 2017-04-19 13:01:45 -03:00
interrupt.h tools/lib/lockdep: Remove private kernel headers 2017-06-05 09:28:14 +02:00
irqflags.h tools/lib/lockdep: Remove private kernel headers 2017-06-05 09:28:14 +02:00
jhash.h tools/lib/lockdep: Fix compilation for 4.11 2017-06-05 09:28:09 +02:00
kallsyms.h tools/lib/lockdep: Remove private kernel headers 2017-06-05 09:28:14 +02:00
kern_levels.h tools/lib/lockdep: Remove private kernel headers 2017-06-05 09:28:14 +02:00
kernel.h Merge branch 'perf-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2017-07-03 12:40:46 -07:00
kmemcheck.h tools/lib/lockdep: Remove private kernel headers 2017-06-05 09:28:14 +02:00
linkage.h tools/lib/lockdep: Remove private kernel headers 2017-06-05 09:28:14 +02:00
list.h tools: Make list.h self-sufficient 2016-01-12 12:42:07 -03:00
lockdep.h tools/lib/lockdep: Remove private kernel headers 2017-06-05 09:28:14 +02:00
log2.h tools include: Include missing headers for fls() and types in linux/log2.h 2017-04-19 13:01:49 -03:00
module.h tools/lib/lockdep: Remove private kernel headers 2017-06-05 09:28:14 +02:00
mutex.h tools/lib/lockdep: Remove private kernel headers 2017-06-05 09:28:14 +02:00
poison.h tools include: Do not use poison with C++ 2017-09-21 13:13:00 -03:00
proc_fs.h tools/lib/lockdep: Remove private kernel headers 2017-06-05 09:28:14 +02:00
rbtree.h tools: Move rbtree.h from tools/perf/ 2015-07-05 22:54:01 -03:00
rbtree_augmented.h tools: Copy rbtree_augmented.h from the kernel 2015-07-05 22:59:05 -03:00
rcu.h tools/lib/lockdep: Remove private kernel headers 2017-06-05 09:28:14 +02:00
refcount.h tools include: Adopt kernel's refcount.h 2017-03-03 19:07:14 -03:00
seq_file.h tools/lib/lockdep: Remove private kernel headers 2017-06-05 09:28:14 +02:00
spinlock.h tools/lib/lockdep: Remove private kernel headers 2017-06-05 09:28:14 +02:00
stacktrace.h tools/lib/lockdep: Remove private kernel headers 2017-06-05 09:28:14 +02:00
string.h tools include: Adopt strstarts() from the kernel 2017-07-20 15:46:10 -03:00
stringify.h tools include: Copy linux/stringify.h from the kernel 2016-03-23 15:14:27 -03:00
time64.h tools: Introduce tools/include/linux/time64.h for *SEC_PER_*SEC macros 2016-08-23 15:37:33 -03:00
types.h tools include uapi: Grab copies of stat.h and fcntl.h 2017-03-31 11:26:03 -03:00