mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 13:45:38 +00:00
Require use of GCC 4.4 or CLang compilers
We only ever test libvirt with GCC or CLang which provides a GCC compatible compilation environment. Between them, these compilers cover every important operating system platform, even Windows. Mandate their use to make it explicit that we don't care about compilers like Microsoft VCC or other UNIX vendor C compilers. GCC 4.4 was picked as the baseline, since RHEL-6 ships 4.4.7 and that lets us remove a large set of checks. There is a slight issue that CLang reports itself as GCC 4.2, so we must also check if __clang__ is defined. We could check a particular CLang version too, but that would require someone to figure out a suitable min version which is fun because OS-X reports totally different CLang version numbers from CLang builds on Linux/BSD Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
parent
83b98f194b
commit
24241c236e
@ -74,6 +74,10 @@
|
|||||||
# undef WITH_CAPNG
|
# undef WITH_CAPNG
|
||||||
#endif /* LIBVIRT_NSS */
|
#endif /* LIBVIRT_NSS */
|
||||||
|
|
||||||
|
#ifndef __GNUC__
|
||||||
|
# error "Libvirt requires GCC >= 4.4, or CLang"
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Define __GNUC_PREREQ to a sane default if it isn't yet defined.
|
* Define __GNUC_PREREQ to a sane default if it isn't yet defined.
|
||||||
* This is done here so that it's included as early as possible; gnulib relies
|
* This is done here so that it's included as early as possible; gnulib relies
|
||||||
@ -81,13 +85,11 @@
|
|||||||
* This doesn't happen on many non-glibc systems.
|
* This doesn't happen on many non-glibc systems.
|
||||||
* When __GNUC_PREREQ is not defined, gnulib defines it to 0, which breaks things.
|
* When __GNUC_PREREQ is not defined, gnulib defines it to 0, which breaks things.
|
||||||
*/
|
*/
|
||||||
#ifdef __GNUC__
|
#ifndef __GNUC_PREREQ
|
||||||
# ifndef __GNUC_PREREQ
|
# define __GNUC_PREREQ(maj, min) \
|
||||||
# if defined __GNUC__ && defined __GNUC_MINOR__
|
((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
|
||||||
# define __GNUC_PREREQ(maj, min) \
|
#endif
|
||||||
((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
|
|
||||||
# else
|
#if !(__GNUC_PREREQ(4, 4) || defined(__clang__))
|
||||||
# define __GNUC_PREREQ(maj, min) 0
|
# error "Libvirt requires GCC >= 4.4, or CLang"
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
#endif
|
#endif
|
||||||
|
121
src/internal.h
121
src/internal.h
@ -101,43 +101,32 @@
|
|||||||
# define NUL_TERMINATE(buf) do { (buf)[sizeof(buf)-1] = '\0'; } while (0)
|
# define NUL_TERMINATE(buf) do { (buf)[sizeof(buf)-1] = '\0'; } while (0)
|
||||||
# define ARRAY_CARDINALITY(Array) (sizeof(Array) / sizeof(*(Array)))
|
# define ARRAY_CARDINALITY(Array) (sizeof(Array) / sizeof(*(Array)))
|
||||||
|
|
||||||
/* C99 uses __func__. __FUNCTION__ is legacy. */
|
|
||||||
# ifndef __GNUC__
|
|
||||||
# define __FUNCTION__ __func__
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# ifdef __GNUC__
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ATTRIBUTE_UNUSED:
|
* ATTRIBUTE_UNUSED:
|
||||||
*
|
*
|
||||||
* Macro to flag consciously unused parameters to functions
|
* Macro to flag consciously unused parameters to functions
|
||||||
*/
|
*/
|
||||||
# ifndef ATTRIBUTE_UNUSED
|
# ifndef ATTRIBUTE_UNUSED
|
||||||
# define ATTRIBUTE_UNUSED __attribute__((__unused__))
|
# define ATTRIBUTE_UNUSED __attribute__((__unused__))
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ATTRIBUTE_NORETURN:
|
* ATTRIBUTE_NORETURN:
|
||||||
*
|
*
|
||||||
* Macro to indicate that a function won't return to the caller
|
* Macro to indicate that a function won't return to the caller
|
||||||
*/
|
*/
|
||||||
# ifndef ATTRIBUTE_NORETURN
|
# ifndef ATTRIBUTE_NORETURN
|
||||||
# define ATTRIBUTE_NORETURN __attribute__((__noreturn__))
|
# define ATTRIBUTE_NORETURN __attribute__((__noreturn__))
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ATTRIBUTE_SENTINEL:
|
* ATTRIBUTE_SENTINEL:
|
||||||
*
|
*
|
||||||
* Macro to check for NULL-terminated varargs lists
|
* Macro to check for NULL-terminated varargs lists
|
||||||
*/
|
*/
|
||||||
# ifndef ATTRIBUTE_SENTINEL
|
# ifndef ATTRIBUTE_SENTINEL
|
||||||
# if __GNUC_PREREQ (4, 0)
|
# define ATTRIBUTE_SENTINEL __attribute__((__sentinel__))
|
||||||
# define ATTRIBUTE_SENTINEL __attribute__((__sentinel__))
|
# endif
|
||||||
# else
|
|
||||||
# define ATTRIBUTE_SENTINEL
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ATTRIBUTE_NOINLINE:
|
* ATTRIBUTE_NOINLINE:
|
||||||
@ -145,13 +134,9 @@
|
|||||||
* Force compiler not to inline a method. Should be used if
|
* Force compiler not to inline a method. Should be used if
|
||||||
* the method need to be overridable by test mocks.
|
* the method need to be overridable by test mocks.
|
||||||
*/
|
*/
|
||||||
# ifndef ATTRIBUTE_NOINLINE
|
# ifndef ATTRIBUTE_NOINLINE
|
||||||
# if __GNUC_PREREQ (4, 0)
|
# define ATTRIBUTE_NOINLINE __attribute__((__noinline__))
|
||||||
# define ATTRIBUTE_NOINLINE __attribute__((__noinline__))
|
# endif
|
||||||
# else
|
|
||||||
# define ATTRIBUTE_NOINLINE
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ATTRIBUTE_FMT_PRINTF
|
* ATTRIBUTE_FMT_PRINTF
|
||||||
@ -163,23 +148,19 @@
|
|||||||
* printf format specifiers even on broken Win32 platforms
|
* printf format specifiers even on broken Win32 platforms
|
||||||
* hence we have to force 'gnu_printf' for new GCC
|
* hence we have to force 'gnu_printf' for new GCC
|
||||||
*/
|
*/
|
||||||
# ifndef ATTRIBUTE_FMT_PRINTF
|
# ifndef ATTRIBUTE_FMT_PRINTF
|
||||||
# if __GNUC_PREREQ (4, 4)
|
# ifndef __clang__
|
||||||
# define ATTRIBUTE_FMT_PRINTF(fmtpos, argpos) \
|
# define ATTRIBUTE_FMT_PRINTF(fmtpos, argpos) \
|
||||||
__attribute__((__format__ (__gnu_printf__, fmtpos, argpos)))
|
__attribute__((__format__ (__gnu_printf__, fmtpos, argpos)))
|
||||||
# else
|
# else
|
||||||
# define ATTRIBUTE_FMT_PRINTF(fmtpos, argpos) \
|
# define ATTRIBUTE_FMT_PRINTF(fmtpos, argpos) \
|
||||||
__attribute__((__format__ (__printf__, fmtpos, argpos)))
|
__attribute__((__format__ (__printf__, fmtpos, argpos)))
|
||||||
# endif
|
|
||||||
# endif
|
# endif
|
||||||
|
# endif
|
||||||
|
|
||||||
# ifndef ATTRIBUTE_RETURN_CHECK
|
# ifndef ATTRIBUTE_RETURN_CHECK
|
||||||
# if __GNUC_PREREQ (3, 4)
|
# define ATTRIBUTE_RETURN_CHECK __attribute__((__warn_unused_result__))
|
||||||
# define ATTRIBUTE_RETURN_CHECK __attribute__((__warn_unused_result__))
|
# endif
|
||||||
# else
|
|
||||||
# define ATTRIBUTE_RETURN_CHECK
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ATTRIBUTE_PACKED
|
* ATTRIBUTE_PACKED
|
||||||
@ -190,13 +171,9 @@
|
|||||||
* ethernet packets.
|
* ethernet packets.
|
||||||
* Others compiler than gcc may use something different e.g. #pragma pack(1)
|
* Others compiler than gcc may use something different e.g. #pragma pack(1)
|
||||||
*/
|
*/
|
||||||
# ifndef ATTRIBUTE_PACKED
|
# ifndef ATTRIBUTE_PACKED
|
||||||
# if __GNUC_PREREQ (3, 3)
|
# define ATTRIBUTE_PACKED __attribute__((packed))
|
||||||
# define ATTRIBUTE_PACKED __attribute__((packed))
|
# endif
|
||||||
# else
|
|
||||||
# error "Need an __attribute__((packed)) equivalent"
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
|
|
||||||
/* gcc's handling of attribute nonnull is less than stellar - it does
|
/* gcc's handling of attribute nonnull is less than stellar - it does
|
||||||
* NOT improve diagnostics, and merely allows gcc to optimize away
|
* NOT improve diagnostics, and merely allows gcc to optimize away
|
||||||
@ -207,45 +184,21 @@
|
|||||||
* based on whether we are compiling for real or for analysis, while
|
* based on whether we are compiling for real or for analysis, while
|
||||||
* still requiring correct gcc syntax when it is turned off. See also
|
* still requiring correct gcc syntax when it is turned off. See also
|
||||||
* http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17308 */
|
* http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17308 */
|
||||||
# ifndef ATTRIBUTE_NONNULL
|
# ifndef ATTRIBUTE_NONNULL
|
||||||
# if __GNUC_PREREQ (3, 3)
|
# if STATIC_ANALYSIS
|
||||||
# if STATIC_ANALYSIS
|
# define ATTRIBUTE_NONNULL(m) __attribute__((__nonnull__(m)))
|
||||||
# define ATTRIBUTE_NONNULL(m) __attribute__((__nonnull__(m)))
|
# else
|
||||||
# else
|
# define ATTRIBUTE_NONNULL(m) __attribute__(())
|
||||||
# define ATTRIBUTE_NONNULL(m) __attribute__(())
|
|
||||||
# endif
|
|
||||||
# else
|
|
||||||
# define ATTRIBUTE_NONNULL(m)
|
|
||||||
# endif
|
|
||||||
# endif
|
# endif
|
||||||
|
# endif
|
||||||
|
|
||||||
# ifndef ATTRIBUTE_FALLTHROUGH
|
# ifndef ATTRIBUTE_FALLTHROUGH
|
||||||
# if __GNUC_PREREQ (7, 0)
|
# if __GNUC_PREREQ (7, 0)
|
||||||
# define ATTRIBUTE_FALLTHROUGH __attribute__((fallthrough))
|
# define ATTRIBUTE_FALLTHROUGH __attribute__((fallthrough))
|
||||||
# else
|
# else
|
||||||
# define ATTRIBUTE_FALLTHROUGH do {} while(0)
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# else
|
|
||||||
# ifndef ATTRIBUTE_UNUSED
|
|
||||||
# define ATTRIBUTE_UNUSED
|
|
||||||
# endif
|
|
||||||
# ifndef ATTRIBUTE_FMT_PRINTF
|
|
||||||
# define ATTRIBUTE_FMT_PRINTF(...)
|
|
||||||
# endif
|
|
||||||
# ifndef ATTRIBUTE_RETURN_CHECK
|
|
||||||
# define ATTRIBUTE_RETURN_CHECK
|
|
||||||
# endif
|
|
||||||
# ifndef ATTRIBUTE_NOINLINE
|
|
||||||
# define ATTRIBUTE_NOINLINE
|
|
||||||
# endif
|
|
||||||
#
|
|
||||||
# ifndef ATTRIBUTE_FALLTHROUGH
|
|
||||||
# define ATTRIBUTE_FALLTHROUGH do {} while(0)
|
# define ATTRIBUTE_FALLTHROUGH do {} while(0)
|
||||||
# endif
|
# endif
|
||||||
# endif /* __GNUC__ */
|
# endif
|
||||||
|
|
||||||
|
|
||||||
# if WORKING_PRAGMA_PUSH
|
# if WORKING_PRAGMA_PUSH
|
||||||
# define VIR_WARNINGS_NO_CAST_ALIGN \
|
# define VIR_WARNINGS_NO_CAST_ALIGN \
|
||||||
|
Loading…
Reference in New Issue
Block a user