Skip to content

Commit

Permalink
apr.h: __attribute__ and __has_attribute exist for !__GNUC__ compiler…
Browse files Browse the repository at this point in the history
…s. PR 69009.

There are more compilers than __GNUC__ that provide __attribute__ so let's not
no-op it based on (un)known compilers but simply if it's not already defined
(it should be provided as a pre-defined macro if defined by the compiler).

While at, do the same for __has_attribute.

Submitted by: Petr Sumbera <petr.sumbera oracle.com>



git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1917741 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
ylavic committed May 15, 2024
1 parent bdf1cf9 commit 9ae02d3
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 15 deletions.
9 changes: 6 additions & 3 deletions include/apr.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,18 @@
#if !defined(__GNUC__) || __GNUC__ < 2 || \
(__GNUC__ == 2 && __GNUC_MINOR__ < 7) ||\
defined(NEXT)
#ifndef __attribute__
#define __attribute__(__x)
#endif
#define APR_INLINE
#define APR_HAS_INLINE 0
#else
#define APR_INLINE __inline__
#define APR_HAS_INLINE 1
#endif
#ifndef __has_attribute
#define __has_attribute(__x) 0
#endif
#ifndef __attribute__
#define __attribute__(__x)
#endif

#define APR_HAVE_ARPA_INET_H @arpa_ineth@
#define APR_HAVE_CONIO_H @conioh@
Expand Down
3 changes: 3 additions & 0 deletions include/apr.hnw
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ extern "C" {

#define APR_INLINE
#define APR_HAS_INLINE 0
#ifndef __has_attribute
#define __has_attribute(__x) 0
#endif
#ifndef __attribute__
#define __attribute__(__x)
#endif
Expand Down
12 changes: 6 additions & 6 deletions include/apr.hw
Original file line number Diff line number Diff line change
Expand Up @@ -107,21 +107,21 @@
#if defined(_MSC_VER)
#define APR_INLINE __inline
#define APR_HAS_INLINE 1
#ifndef __attribute__
#define __attribute__(__x)
#endif
#elif !defined(__GNUC__) || __GNUC__ < 2 || \
(__GNUC__ == 2 && __GNUC_MINOR__ < 7) ||\
defined(NEXT)
#ifndef __attribute__
#define __attribute__(__x)
#endif
#define APR_INLINE
#define APR_HAS_INLINE 0
#else
#define APR_INLINE __inline__
#define APR_HAS_INLINE 1
#endif
#ifndef __has_attribute
#define __has_attribute(__x) 0
#endif
#ifndef __attribute__
#define __attribute__(__x)
#endif

#define APR_HAVE_ARPA_INET_H 0
#define APR_HAVE_CONIO_H 1
Expand Down
12 changes: 6 additions & 6 deletions include/apr.hwc
Original file line number Diff line number Diff line change
Expand Up @@ -97,21 +97,21 @@
#if defined(_MSC_VER)
#define APR_INLINE __inline
#define APR_HAS_INLINE 1
#ifndef __attribute__
#define __attribute__(__x)
#endif
#elif !defined(__GNUC__) || __GNUC__ < 2 || \
(__GNUC__ == 2 && __GNUC_MINOR__ < 7) ||\
defined(NEXT)
#ifndef __attribute__
#define __attribute__(__x)
#endif
#define APR_INLINE
#define APR_HAS_INLINE 0
#else
#define APR_INLINE __inline__
#define APR_HAS_INLINE 1
#endif
#ifndef __has_attribute
#define __has_attribute(__x) 0
#endif
#ifndef __attribute__
#define __attribute__(__x)
#endif

#define APR_HAVE_ARPA_INET_H 0
#define APR_HAVE_CONIO_H 1
Expand Down

0 comments on commit 9ae02d3

Please sign in to comment.