You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by yl...@apache.org on 2024/05/15 15:59:25 UTC
svn commit: r1917748 - in /apr/apr/branches/1.7.x: ./ include/apr.h.in include/apr.hw include/apr.hwc
Author: ylavic
Date: Wed May 15 15:59:24 2024
New Revision: 1917748
URL: http://svn.apache.org/viewvc?rev=1917748&view=rev
Log:
apr.h: __attribute__ and __has_attribute exist for !__GNUC__ compilers. 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.
[ This merge does not #define a missing __has_attribute(), for compatibility ]
Submitted by: Petr Sumbera <petr.sumbera oracle.com>
Merges r1917747 from ^/apr/apr/branches/1.8.x
Merges r1917746 from trunk
Modified:
apr/apr/branches/1.7.x/ (props changed)
apr/apr/branches/1.7.x/include/apr.h.in
apr/apr/branches/1.7.x/include/apr.hw
apr/apr/branches/1.7.x/include/apr.hwc
Propchange: apr/apr/branches/1.7.x/
------------------------------------------------------------------------------
Merged /apr/apr/branches/1.8.x:r1917747
Merged /apr/apr/trunk:r1917746
Modified: apr/apr/branches/1.7.x/include/apr.h.in
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.7.x/include/apr.h.in?rev=1917748&r1=1917747&r2=1917748&view=diff
==============================================================================
--- apr/apr/branches/1.7.x/include/apr.h.in (original)
+++ apr/apr/branches/1.7.x/include/apr.h.in Wed May 15 15:59:24 2024
@@ -47,8 +47,8 @@
/* So that we can use inline on some critical functions, and use
* GNUC attributes (such as to get -Wall warnings for printf-like
- * functions). Only do this in gcc 2.7 or later ... it may work
- * on earlier stuff, but why chance it.
+ * functions). Both __inline__ and __attribute__ exist for gcc >= 2.7,
+ * other !__GNUC__ compilers may provide __attribute__ still.
*
* We've since discovered that the gcc shipped with NeXT systems
* as "cc" is completely broken. It claims to be __GNUC__ and so
@@ -56,18 +56,22 @@
* means. In particular it's missing inline and the __attribute__
* stuff. So we hack around it. PR#1613. -djg
*/
-#if !defined(__GNUC__) || __GNUC__ < 2 || \
- (__GNUC__ == 2 && __GNUC_MINOR__ < 7) ||\
- defined(NEXT)
-#ifndef __attribute__
-#define __attribute__(__x)
-#endif
+#if defined(__GNUC__) \
+ && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)) \
+ && !defined(NEXT)
+#define APR_INLINE __inline__
+#define APR_HAS_INLINE 1
+#else /* !__GNUC__ */
#define APR_INLINE
-#define APR_HAS_INLINE 0
-#else
-#define APR_INLINE __inline__
-#define APR_HAS_INLINE 1
+#define APR_HAS_INLINE 0
+/* __has_attribute should always be a pre-defined macro, but not
+ * necessarily __attribute__ (e.g. builtin), so check for both to
+ * avoid overriding __attribute__.
+ */
+#if !(defined(__attribute__) || defined(__has_attribute))
+#define __attribute__(__x)
#endif
+#endif /* !__GNUC__ */
#define APR_HAVE_ARPA_INET_H @arpa_ineth@
#define APR_HAVE_CONIO_H @conioh@
Modified: apr/apr/branches/1.7.x/include/apr.hw
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.7.x/include/apr.hw?rev=1917748&r1=1917747&r2=1917748&view=diff
==============================================================================
--- apr/apr/branches/1.7.x/include/apr.hw (original)
+++ apr/apr/branches/1.7.x/include/apr.hw Wed May 15 15:59:24 2024
@@ -125,11 +125,38 @@
* are platform specific and should NOT be relied upon!</em></strong>
*/
-#define APR_INLINE __inline
+/* So that we can use inline on some critical functions, and use
+ * GNUC attributes (such as to get -Wall warnings for printf-like
+ * functions). Both __inline__ and __attribute__ exist for gcc >= 2.7,
+ * other !__GNUC__ compilers may provide __attribute__ still.
+ *
+ * We've since discovered that the gcc shipped with NeXT systems
+ * as "cc" is completely broken. It claims to be __GNUC__ and so
+ * on, but it doesn't implement half of the things that __GNUC__
+ * means. In particular it's missing inline and the __attribute__
+ * stuff. So we hack around it. PR#1613. -djg
+ */
+#if defined(__GNUC__) \
+ && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)) \
+ && !defined(NEXT)
+#define APR_INLINE __inline__
+#define APR_HAS_INLINE 1
+#else /* !__GNUC__ */
+#if defined(_MSC_VER)
+#define APR_INLINE __inline
#define APR_HAS_INLINE 1
-#if !defined(__GNUC__) && !defined(__attribute__)
+#else /* !_MSC_VER */
+#define APR_INLINE
+#define APR_HAS_INLINE 0
+#endif /* !_MSC_VER */
+/* __has_attribute should always be a pre-defined macro, but not
+ * necessarily __attribute__ (e.g. builtin), so check for both to
+ * avoid overriding __attribute__.
+ */
+#if !(defined(__attribute__) || defined(__has_attribute))
#define __attribute__(__x)
#endif
+#endif /* !__GNUC__ */
#ifndef _WIN32_WCE
#define APR_HAVE_ARPA_INET_H 0
Modified: apr/apr/branches/1.7.x/include/apr.hwc
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.7.x/include/apr.hwc?rev=1917748&r1=1917747&r2=1917748&view=diff
==============================================================================
--- apr/apr/branches/1.7.x/include/apr.hwc (original)
+++ apr/apr/branches/1.7.x/include/apr.hwc Wed May 15 15:59:24 2024
@@ -112,11 +112,38 @@
* are platform specific and should NOT be relied upon!</em></strong>
*/
-#define APR_INLINE __inline
+/* So that we can use inline on some critical functions, and use
+ * GNUC attributes (such as to get -Wall warnings for printf-like
+ * functions). Both __inline__ and __attribute__ exist for gcc >= 2.7,
+ * other !__GNUC__ compilers may provide __attribute__ still.
+ *
+ * We've since discovered that the gcc shipped with NeXT systems
+ * as "cc" is completely broken. It claims to be __GNUC__ and so
+ * on, but it doesn't implement half of the things that __GNUC__
+ * means. In particular it's missing inline and the __attribute__
+ * stuff. So we hack around it. PR#1613. -djg
+ */
+#if defined(__GNUC__) \
+ && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)) \
+ && !defined(NEXT)
+#define APR_INLINE __inline__
+#define APR_HAS_INLINE 1
+#else /* !__GNUC__ */
+#if defined(_MSC_VER)
+#define APR_INLINE __inline
#define APR_HAS_INLINE 1
-#if !defined(__GNUC__) && !defined(__attribute__)
+#else /* !_MSC_VER */
+#define APR_INLINE
+#define APR_HAS_INLINE 0
+#endif /* !_MSC_VER */
+/* __has_attribute should always be a pre-defined macro, but not
+ * necessarily __attribute__ (e.g. builtin), so check for both to
+ * avoid overriding __attribute__.
+ */
+#if !(defined(__attribute__) || defined(__has_attribute))
#define __attribute__(__x)
#endif
+#endif /* !__GNUC__ */
#ifndef _WIN32_WCE
#define APR_HAVE_ARPA_INET_H 0