1
0
Fork 0
alistair23-linux/include
Miguel Ojeda c0d9782f5b Compiler Attributes: add support for __copy (gcc >= 9)
From the GCC manual:

  copy
  copy(function)

    The copy attribute applies the set of attributes with which function
    has been declared to the declaration of the function to which
    the attribute is applied. The attribute is designed for libraries
    that define aliases or function resolvers that are expected
    to specify the same set of attributes as their targets. The copy
    attribute can be used with functions, variables, or types. However,
    the kind of symbol to which the attribute is applied (either
    function or variable) must match the kind of symbol to which
    the argument refers. The copy attribute copies only syntactic and
    semantic attributes but not attributes that affect a symbol’s
    linkage or visibility such as alias, visibility, or weak.
    The deprecated attribute is also not copied.

  https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html

The upcoming GCC 9 release extends the -Wmissing-attributes warnings
(enabled by -Wall) to C and aliases: it warns when particular function
attributes are missing in the aliases but not in their target, e.g.:

    void __cold f(void) {}
    void __alias("f") g(void);

diagnoses:

    warning: 'g' specifies less restrictive attribute than
    its target 'f': 'cold' [-Wmissing-attributes]

Using __copy(f) we can copy the __cold attribute from f to g:

    void __cold f(void) {}
    void __copy(f) __alias("f") g(void);

This attribute is most useful to deal with situations where an alias
is declared but we don't know the exact attributes the target has.

For instance, in the kernel, the widely used module_init/exit macros
define the init/cleanup_module aliases, but those cannot be marked
always as __init/__exit since some modules do not have their
functions marked as such.

Suggested-by: Martin Sebor <msebor@gcc.gnu.org>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
2019-02-15 19:52:17 +01:00
..
acpi Merge branch 'x86-cleanups-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2018-12-26 17:03:51 -08:00
asm-generic Merge branch 'akpm' (patches from Andrew) 2019-01-05 09:16:18 -08:00
clocksource
crypto crypto: skcipher - remove remnants of internal IV generators 2018-12-23 11:52:45 +08:00
drm Merge tag 'drm-intel-fixes-2019-01-11' of git://anongit.freedesktop.org/drm/drm-intel into drm-fixes 2019-01-11 10:26:21 +01:00
dt-bindings Mostly driver fixes, but there's a core framework fix in here too. 2019-01-31 23:22:57 -08:00
keys
kvm KVM: arm/arm64: Remove arch timer workqueue 2018-12-19 17:47:07 +00:00
linux Compiler Attributes: add support for __copy (gcc >= 9) 2019-02-15 19:52:17 +01:00
math-emu
media media fixes for v4.20-rc8 2018-12-25 13:11:30 -08:00
memory
misc
net net: tls: Save iv in tls_rec for async crypto requests 2019-01-28 23:05:55 -08:00
pcmcia
ras
rdma RDMA/device: Expose ib_device_try_get(() 2019-01-21 14:33:08 -07:00
scsi 4.21 merge window pull request 2018-12-28 14:57:10 -08:00
soc ARM: SoC driver updates 2018-12-31 17:32:35 -08:00
sound ASoC: Fixes for v5.0 2019-01-18 15:17:17 +01:00
target scsi: target: consistently null-terminate t10_wwn strings 2018-12-07 21:54:33 -05:00
trace afs: Fix race in async call refcounting 2019-01-17 15:17:28 +00:00
uapi Second 5.0 rc pull request 2019-02-01 10:39:24 -08:00
video drm/exynos: fimd: Make pixel blend mode configurable 2018-12-14 15:46:15 +09:00
xen arm64/xen: fix xen-swiotlb cache flushing 2019-01-23 22:14:56 +01:00