On 1/4/19 10:00 AM, Eric Blake wrote:
We might as well take advantage of gcc's extensions for a safer
MIN()/MAX() macro.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
RFC because we could also try to fall back to older gcc's typeof(a)_a=(a)
when the newer __auto_type _a=(a) is not present, and because I don't
know how to properly probe for __auto_type and/or typeof support in
clang (I know that clang added __auto_type in 2015, per
https://reviews.llvm.org/D12686); I also don't know if we have officially
stated that we require gcc/clang (because of attribute((cleanup)), which
really cannot be emulated without extensions), or if we still try to
allow compilation with other compilers; if we have, I don't know if we
have declared a minimum compiler version that we demand (qemu has recently
demanded gcc 4.8 or clang 3.4 [branded 5.1 on Apple]).
Also RFC because:
In file included from util/virlog.c:46:
util/virutil.h:43:22: error: braced-group within expression allowed only
inside a function
# define MAX(a, b) ({ \
^
util/virlog.c:899:29: note: in expansion of macro 'MAX'
# define JOURNAL_BUF_SIZE (MAX(INT_BUFSIZE_BOUND(int), sizeof(uint64_t)))
^~~
util/virlog.c:904:18: note: in expansion of macro 'JOURNAL_BUF_SIZE'
char (*bufs)[JOURNAL_BUF_SIZE], (*bufs_end)[JOURNAL_BUF_SIZE];
^~~~~~~~~~~~~~~~
util/virutil.h:43:22: error: braced-group within expression allowed only
inside a function
# define MAX(a, b) ({ \
^
util/virlog.c:899:29: note: in expansion of macro 'MAX'
# define JOURNAL_BUF_SIZE (MAX(INT_BUFSIZE_BOUND(int), sizeof(uint64_t)))
^~~
util/virlog.c:904:49: note: in expansion of macro 'JOURNAL_BUF_SIZE'
char (*bufs)[JOURNAL_BUF_SIZE], (*bufs_end)[JOURNAL_BUF_SIZE];
^~~~~~~~~~~~~~~~
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization:
qemu.org |
libvirt.org