Commit Graph

7 Commits

Author SHA1 Message Date
Eugene Syromyatnikov
e061d67dff Rename BUILD_BUG_ON_ZERO macro
In order to avoid name clash on distributions which decide to include
kernel headers instead of UAPI ones.  For example, on SLES 11SP4:

gcc -DHAVE_CONFIG_H -I./linux/x86_64 -I./linux -I. -Wall -O2 -c net.c
In file included from /usr/include/linux/sysctl.h:25:0,
                 from /usr/include/linux/netfilter.h:6,
                 from /usr/include/linux/netfilter_arp.h:8,
                 from /usr/include/linux/netfilter_arp/arp_tables.h:14,
                 from net.c:60:
net.c: In function 'print_packet_mreq':
gcc_compat.h:59:27: error: negative width in bit-field '<anonymous>'
 # define MUST_BE_ARRAY(a) BUILD_BUG_ON_ZERO(!SAME_TYPE((a), &(a)[0]))
                           ^
defs.h:76:53: note: in expansion of macro 'MUST_BE_ARRAY'
 #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]) + MUST_BE_ARRAY(a))
                                                     ^
net.c:747:22: note: in expansion of macro 'ARRAY_SIZE'
   if (mreq.mr_alen > ARRAY_SIZE(mreq.mr_address))
                      ^
due to the fact BUILD_BUG_ON_ZERO is already defined in <linux/kernel.h>.

* gcc_compat.h (BUILD_BUG_ON_ZERO): Rename to FAIL_BUILD_ON_ZERO.
(MUST_BE_ARRAY): Update usage.
2016-11-13 11:04:49 +00:00
98b944bb66 Introduce ALIGNOF macro
* gcc_compat.h (ALIGNOF): New macro.
2016-11-10 22:44:49 +03:00
Eugene Syromyatnikov
48252db2a2 defs: add check for argument being array to ARRAY_SIZE macro
* gcc_compat.h [GNUC_PREREQ(3, 0)] (BUILD_BUG_ON_ZERO): New macro.
(SAME_TYPE, MUST_BE_ARRAY): Likewise.
* defs.h (ARRAY_SIZE): Add MUST_BE_ARRAY for build-time type check.
2016-10-31 00:49:28 +03:00
42ceb0fd7f Change #include guard trailing part comments
* defs.h: Change comment of the trailing part of #include guard.
* flock.h: Likewise.
* gcc_compat.h: Likewise.
* ipc_defs.h: Likewise.
* kernel_types.h: Likewise.
* mpers_type.h: Likewise.
* msghdr.h: Likewise.
* printsiginfo.h: Likewise.
* ptrace.h: Likewise.
* regs.h: Likewise.
* seccomp_fprog.h: Likewise.
* sigevent.h: Likewise.
* statfs.h: Likewise.
* xlat.h: Likewise.
2016-08-07 22:02:46 +00:00
Eugene Syromyatnikov
18907920bb Unify usage of #include guards
This commit is an attempt to unify usage of include guards (in top-level
headers, at least).  As a side note, different files with *.h extension
have different semantics: for example, printargs.h is included multiple
times in order to generate slightly varying code depending on values of
macro definitions - maybe it's better to change extension of such files
to something like *.inc.

* defs.h: Add #include guard.
* flock.h: Likewise.
* ipc_defs.h: Likewise.
* mpers_type.h: Likewise.
* printsiginfo.h: Likewise.
* ptrace.h: Likewise.
* regs.h: Likewise.
* seccomp_fprog.h: Likewise.
* gcc_compat.h: Rename the macro used for #include guard.
* msghdr.h: Likewise.
* sigevent.h: Likewise.
* kernel_types.h: Comment the trailing part of #include guard.
* xlat.h: Add missing macro definition for #include guard.
2016-08-08 09:54:01 +00:00
b0d23cc2c0 Add sentinel attribute to printxvals
* gcc_compat.h (ATTRIBUTE_SENTINEL): New macro.
* defs.h (printxvals): Add ATTRIBUTE_SENTINEL.
2016-04-01 00:52:01 +00:00
f32126ba79 Move gcc compat macros to gcc_compat.h
* defs.h: Include "gcc_compat.h".
(GNUC_PREREQ, ATTRIBUTE_NORETURN, ATTRIBUTE_FORMAT,
ATTRIBUTE_ALIGNED, ATTRIBUTE_PACKED, ATTRIBUTE_MALLOC,
ATTRIBUTE_NOINLINE, ATTRIBUTE_ALLOC_SIZE): Move ...
* gcc_compat.h: ... here.
* Makefile.am (strace_SOURCES): Add gcc_compat.h.
2016-01-02 14:29:33 +00:00