Re: [RFC PATCH] maint: let MIN/MAX evaluate only once, on modern compilers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
> ---
> 
> 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

Attachment: signature.asc
Description: OpenPGP digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux