Daniel Richard G. wrote:

As an aside: It's not that the headers #define __builtin_expect as a
macro on this platform, but rather (from builtins.h):

Thanks. We should address this underyling problem. I installed the attached to try to work around the problem. I don't want to have to modify lots of programs to include seemingly-irrelevant headers like stdint.h.
>From b96858242b326999c8bac2949a85d02a0706a3a3 Mon Sep 17 00:00:00 2001
From: Paul Eggert <egg...@cs.ucla.edu>
Date: Fri, 16 Dec 2016 18:20:21 -0800
Subject: [PATCH] builtin-expect: improve port to IBM XL C

Problem reported for z/OS by Daniel Richard G. in:
http://lists.gnu.org/archive/html/bug-gnulib/2016-12/msg00079.html
* m4/builtin-expect.m4 (gl___BUILTIN_EXPECT):
Test for <builtins.h> directly.
---
 ChangeLog            |  6 ++++++
 m4/builtin-expect.m4 | 22 ++++++++++++++++++----
 2 files changed, 24 insertions(+), 4 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 2c44748..fc8bef9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2016-12-16  Paul Eggert  <egg...@cs.ucla.edu>
 
+	builtin-expect: improve port to IBM XL C
+	Problem reported for z/OS by Daniel Richard G. in:
+	http://lists.gnu.org/archive/html/bug-gnulib/2016-12/msg00079.html
+	* m4/builtin-expect.m4 (gl___BUILTIN_EXPECT):
+	Test for <builtins.h> directly.
+
 	builtin-expect: port to IBM XL C
 	Problem reported for z/OS by Daniel Richard G. in:
 	http://lists.gnu.org/archive/html/bug-gnulib/2016-12/msg00074.html
diff --git a/m4/builtin-expect.m4 b/m4/builtin-expect.m4
index ce048ae..e448066 100644
--- a/m4/builtin-expect.m4
+++ b/m4/builtin-expect.m4
@@ -12,7 +12,7 @@ AC_DEFUN([gl___BUILTIN_EXPECT],
   AC_CACHE_CHECK([for __builtin_expect],
     [gl_cv___builtin_expect],
     [AC_LINK_IFELSE(
-       [AC_LANG_SOURCE([AC_INCLUDES_DEFAULT[
+       [AC_LANG_SOURCE([[
          int
          main (int argc, char **argv)
          {
@@ -20,16 +20,30 @@ AC_DEFUN([gl___BUILTIN_EXPECT],
            return argv[argc != 100][0];
          }]])],
        [gl_cv___builtin_expect=yes],
-       [gl_cv___builtin_expect=no])])
+       [AC_LINK_IFELSE(
+          [AC_LANG_SOURCE([[
+             #include <builtins.h>
+             int
+             main (int argc, char **argv)
+             {
+               argc = __builtin_expect (argc, 100);
+               return argv[argc != 100][0];
+             }]])],
+          [gl_cv___builtin_expect="in <builtins.h>"],
+          [gl_cv___builtin_expect=no])])])
   if test "$gl_cv___builtin_expect" = yes; then
     AC_DEFINE([HAVE___BUILTIN_EXPECT], [1])
+  elif test "$gl_cv___builtin_expect" = "in <builtins.h>"; then
+    AC_DEFINE([HAVE___BUILTIN_EXPECT], [2])
   fi
   AH_VERBATIM([HAVE___BUILTIN_EXPECT],
-    [/* Define to 1 if the compiler or standard include files support
-   __builtin_expect.  */
+    [/* Define to 1 if the compiler supports __builtin_expect,
+   and to 2 if <builtins.h> does.  */
 #undef HAVE___BUILTIN_EXPECT
 #ifndef HAVE___BUILTIN_EXPECT
 # define __builtin_expect(e, c) (e)
+#elif HAVE___BUILTIN_EXPECT == 2
+# include <builtins.h>
 #endif
     ])
 ])
-- 
2.7.4

Reply via email to