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

View file

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

View file

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

View file

@ -100,7 +100,7 @@
*/ */
#define CAIRO_BITSWAP8(c) ((((c) * 0x0802LU & 0x22110LU) | ((c) * 0x8020LU & 0x88440LU)) * 0x10101LU >> 16) #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__ #ifdef __MINGW32__
#define CAIRO_PRINTF_FORMAT(fmt_index, va_index) \ #define CAIRO_PRINTF_FORMAT(fmt_index, va_index) \
__attribute__((__format__(__MINGW_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 #endif
#define BUCKET(b, ptr) (((uintptr_t) (ptr) >> PTR_SHIFT) % ARRAY_LENGTH (b)) #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) \ #define _BOOLEAN_EXPR(expr) \
__extension__ ({ \ __extension__ ({ \
int _boolean_var_; \ int _boolean_var_; \
@ -220,7 +220,7 @@ static void _init_trace (void);
#define INIT_TRACE_ONCE() pthread_once (&once_control, _init_trace) #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 _enter_trace() INIT_TRACE_ONCE ()
# define _exit_trace() do { } while (0) # define _exit_trace() do { } while (0)
# define _should_trace() 1 # define _should_trace() 1