Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d1515582 authored by Will Deacon's avatar Will Deacon Committed by Ingo Molnar
Browse files

linux/compiler.h: Split into compiler.h and compiler_types.h



linux/compiler.h is included indirectly by linux/types.h via
uapi/linux/types.h -> uapi/linux/posix_types.h -> linux/stddef.h
-> uapi/linux/stddef.h and is needed to provide a proper definition of
offsetof.

Unfortunately, compiler.h requires a definition of
smp_read_barrier_depends() for defining lockless_dereference() and soon
for defining READ_ONCE(), which means that all
users of READ_ONCE() will need to include asm/barrier.h to avoid splats
such as:

   In file included from include/uapi/linux/stddef.h:1:0,
                    from include/linux/stddef.h:4,
                    from arch/h8300/kernel/asm-offsets.c:11:
   include/linux/list.h: In function 'list_empty':
>> include/linux/compiler.h:343:2: error: implicit declaration of function 'smp_read_barrier_depends' [-Werror=implicit-function-declaration]
     smp_read_barrier_depends(); /* Enforce dependency ordering from x */ \
     ^

A better alternative is to include asm/barrier.h in linux/compiler.h,
but this requires a type definition for "bool" on some architectures
(e.g. x86), which is defined later by linux/types.h. Type "bool" is also
used directly in linux/compiler.h, so the whole thing is pretty fragile.

This patch splits compiler.h in two: compiler_types.h contains type
annotations, definitions and the compiler-specific parts, whereas
compiler.h #includes compiler-types.h and additionally defines macros
such as {READ,WRITE.ACCESS}_ONCE().

uapi/linux/stddef.h and linux/linkage.h are then moved over to include
linux/compiler_types.h, which fixes the build for h8 and blackfin.

Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/1508840570-22169-2-git-send-email-will.deacon@arm.com


Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
parent 9babb091
Loading
Loading
Loading
Loading
+1 −2
Original line number Original line Diff line number Diff line
@@ -126,8 +126,7 @@ extern unsigned long profile_pc(struct pt_regs *regs);
/*
/*
 * kprobe-based event tracer support
 * kprobe-based event tracer support
 */
 */
#include <linux/stddef.h>
#include <linux/compiler.h>
#include <linux/types.h>
#define MAX_REG_OFFSET (offsetof(struct pt_regs, ARM_ORIG_r0))
#define MAX_REG_OFFSET (offsetof(struct pt_regs, ARM_ORIG_r0))


extern int regs_query_register_offset(const char *name);
extern int regs_query_register_offset(const char *name);
+1 −0
Original line number Original line Diff line number Diff line
@@ -6,6 +6,7 @@
#if defined(__sparc__) && defined(__arch64__)
#if defined(__sparc__) && defined(__arch64__)
#ifndef __ASSEMBLY__
#ifndef __ASSEMBLY__


#include <linux/compiler.h>
#include <linux/threads.h>
#include <linux/threads.h>
#include <asm/switch_to.h>
#include <asm/switch_to.h>


+1 −1
Original line number Original line Diff line number Diff line
@@ -40,7 +40,7 @@
typedef int (*initcall_t)(void);
typedef int (*initcall_t)(void);
typedef void (*exitcall_t)(void);
typedef void (*exitcall_t)(void);


#include <linux/compiler.h>
#include <linux/compiler_types.h>


/* These are for everybody (although not all archs will actually
/* These are for everybody (although not all archs will actually
   discard it in modules) */
   discard it in modules) */
+1 −1
Original line number Original line Diff line number Diff line
#ifndef __LINUX_COMPILER_H
#ifndef __LINUX_COMPILER_TYPES_H
#error "Please don't include <linux/compiler-clang.h> directly, include <linux/compiler.h> instead."
#error "Please don't include <linux/compiler-clang.h> directly, include <linux/compiler.h> instead."
#endif
#endif


+1 −1
Original line number Original line Diff line number Diff line
#ifndef __LINUX_COMPILER_H
#ifndef __LINUX_COMPILER_TYPES_H
#error "Please don't include <linux/compiler-gcc.h> directly, include <linux/compiler.h> instead."
#error "Please don't include <linux/compiler-gcc.h> directly, include <linux/compiler.h> instead."
#endif
#endif


Loading