Drop support for very old GCC versions

They don't support C11 anyway. Additionally, CLang defines a very
conservative __GNUC__ value (which is also configurable via the
-fgnuc-version= command-line argument)
This commit is contained in:
Luca Bacci 2025-06-16 18:52:39 +02:00
parent ff4f2f4301
commit 6989158f4c
6 changed files with 21 additions and 24 deletions

View file

@ -73,7 +73,7 @@
#define CAIRO_BOILERPLATE_DEBUG(x)
#endif
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)
#if defined (__GNUC__)
#ifdef __MINGW32__
#define CAIRO_BOILERPLATE_PRINTF_FORMAT(fmt_index, va_index) \
__attribute__((__format__(__MINGW_PRINTF_FORMAT, fmt_index, va_index)))

View file

@ -54,7 +54,7 @@
#define CAIRO_STACK_ARRAY_LENGTH(T) (CAIRO_STACK_BUFFER_SIZE / sizeof(T))
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)
#if defined (__GNUC__)
#ifdef __MINGW32__
#define CAIRO_PRINTF_FORMAT(fmt_index, va_index) \
__attribute__((__format__(__MINGW_PRINTF_FORMAT, fmt_index, va_index)))
@ -67,7 +67,7 @@
#endif
#define CAIRO_HAS_HIDDEN_SYMBOLS 1
#if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)) && \
#if defined(__GNUC__) && \
(defined(__ELF__) || defined(__APPLE__)) && \
!defined(__sun)
#define cairo_private_no_warn __attribute__((__visibility__("hidden")))
@ -97,7 +97,7 @@
indicating that the old function has been deprecated by the new
function.
*/
#if __GNUC__ >= 2 && defined(__ELF__)
#if defined (__GNUC__) && defined(__ELF__)
# define CAIRO_FUNCTION_ALIAS(old, new) \
extern __typeof (new) old \
__asm__ ("" #old) \
@ -126,17 +126,21 @@
* constant-folding, with 'cairo_const 'also guaranteeing that pointer contents
* do not change across the function call.
*/
#if __GNUC__ >= 3
#if defined (__GNUC__)
#define cairo_pure __attribute__((pure))
#define cairo_const __attribute__((const))
#define cairo_always_inline inline __attribute__((always_inline))
#elif defined (_MSC_VER)
#define cairo_pure
#define cairo_const
#define cairo_always_inline __forceinline
#else
#define cairo_pure
#define cairo_const
#define cairo_always_inline inline
#endif
#if defined(__GNUC__) && (__GNUC__ > 2) && defined(__OPTIMIZE__)
#if defined(__GNUC__) && defined(__OPTIMIZE__)
#define likely(expr) (__builtin_expect (!!(expr), 1))
#define unlikely(expr) (__builtin_expect (!!(expr), 0))
#else
@ -144,7 +148,7 @@
#define unlikely(expr) (expr)
#endif
#ifndef __GNUC__
#if !defined(__GNUC__)
#undef __attribute__
#define __attribute__(x)
#endif
@ -161,18 +165,11 @@
#define strdup _strdup
#define unlink _unlink
#if _MSC_VER < 1900
#define vsnprintf _vsnprintf
#define vsnprintf _vsnprintf // TODO
#define snprintf _snprintf
#endif
#endif
#ifdef _MSC_VER
#ifndef __cplusplus
#undef inline
#define inline __inline
#endif
#endif
#if defined(_MSC_VER) && defined(_M_IX86)
/* When compiling with /Gy and /OPT:ICF identical functions will be folded in together.
The CAIRO_ENSURE_UNIQUE macro ensures that a function is always unique and

View file

@ -53,7 +53,7 @@
#if (defined(_WIN32) || defined(__CYGWIN__)) && !defined(CAIRO_WIN32_STATIC_BUILD)
# define _cairo_export __declspec(dllexport)
# define _cairo_import __declspec(dllimport)
#elif defined(__GNUC__) && (__GNUC__ >= 4)
#elif defined(__GNUC__)
# define _cairo_export __attribute__((__visibility__("default")))
# define _cairo_import
#else

View file

@ -175,7 +175,7 @@ do { \
static inline int cairo_const
_cairo_popcount (uint32_t mask)
{
#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
#if defined (__GNUC__)
return __builtin_popcount (mask);
#else
register int y;

View file

@ -98,7 +98,7 @@
#endif
#if __GNUC__ >= 3
#if defined (__GNUC__)
#define csi_pure __attribute__((pure))
#define csi_const __attribute__((const))
#else
@ -106,7 +106,7 @@
#define csi_const
#endif
#if defined(__GNUC__) && (__GNUC__ > 2) && defined(__OPTIMIZE__)
#if defined(__GNUC__) && defined(__OPTIMIZE__)
#define _CSI_BOOLEAN_EXPR(expr) \
__extension__ ({ \
int _csi_boolean_var_; \
@ -133,7 +133,7 @@
(type *)((char *) (ptr) - (char *) &((type *)0)->member)
#endif
#if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)) && defined(__ELF__) && !defined(__sun)
#if defined(__GNUC__) && defined(__ELF__) && !defined(__sun)
#define csi_private_no_warn __attribute__((__visibility__("hidden")))
#elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550)
#define csi_private_no_warn __hidden

View file

@ -100,7 +100,7 @@
*/
#define CAIRO_BITSWAP8(c) ((((c) * 0x0802LU & 0x22110LU) | ((c) * 0x8020LU & 0x88440LU)) * 0x10101LU >> 16)
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)
#if defined(__GNUC__)
#ifdef __MINGW32__
#define CAIRO_PRINTF_FORMAT(fmt_index, va_index) \
__attribute__((__format__(__MINGW_PRINTF_FORMAT, fmt_index, va_index)))
@ -143,7 +143,7 @@ static void *_dlhandle = RTLD_NEXT;
#endif
#define BUCKET(b, ptr) (((uintptr_t) (ptr) >> PTR_SHIFT) % ARRAY_LENGTH (b))
#if defined(__GNUC__) && (__GNUC__ > 2) && defined(__OPTIMIZE__)
#if defined(__GNUC__) && defined(__OPTIMIZE__)
#define _BOOLEAN_EXPR(expr) \
__extension__ ({ \
int _boolean_var_; \
@ -220,7 +220,7 @@ static void _init_trace (void);
#define INIT_TRACE_ONCE() pthread_once (&once_control, _init_trace)
#if __GNUC__ >= 3 && defined(__ELF__) && !defined(__sun)
#if defined(__GNUC__) && defined(__ELF__) && !defined(__sun)
# define _enter_trace() INIT_TRACE_ONCE ()
# define _exit_trace() do { } while (0)
# define _should_trace() 1