Blame m4/builtin-expect.m4

Packit Service a2489d
dnl Check for __builtin_expect.
Packit Service a2489d
Packit Service a2489d
dnl Copyright 2016-2018 Free Software Foundation, Inc.
Packit Service a2489d
dnl This file is free software; the Free Software Foundation
Packit Service a2489d
dnl gives unlimited permission to copy and/or distribute it,
Packit Service a2489d
dnl with or without modifications, as long as this notice is preserved.
Packit Service a2489d
Packit Service a2489d
dnl Written by Paul Eggert.
Packit Service a2489d
Packit Service a2489d
AC_DEFUN([gl___BUILTIN_EXPECT],
Packit Service a2489d
[
Packit Service a2489d
  AC_CACHE_CHECK([for __builtin_expect],
Packit Service a2489d
    [gl_cv___builtin_expect],
Packit Service a2489d
    [AC_LINK_IFELSE(
Packit Service a2489d
       [AC_LANG_SOURCE([[
Packit Service a2489d
         int
Packit Service a2489d
         main (int argc, char **argv)
Packit Service a2489d
         {
Packit Service a2489d
           argc = __builtin_expect (argc, 100);
Packit Service a2489d
           return argv[argc != 100][0];
Packit Service a2489d
         }]])],
Packit Service a2489d
       [gl_cv___builtin_expect=yes],
Packit Service a2489d
       [AC_LINK_IFELSE(
Packit Service a2489d
          [AC_LANG_SOURCE([[
Packit Service a2489d
             #include <builtins.h>
Packit Service a2489d
             int
Packit Service a2489d
             main (int argc, char **argv)
Packit Service a2489d
             {
Packit Service a2489d
               argc = __builtin_expect (argc, 100);
Packit Service a2489d
               return argv[argc != 100][0];
Packit Service a2489d
             }]])],
Packit Service a2489d
          [gl_cv___builtin_expect="in <builtins.h>"],
Packit Service a2489d
          [gl_cv___builtin_expect=no])])])
Packit Service a2489d
  if test "$gl_cv___builtin_expect" = yes; then
Packit Service a2489d
    AC_DEFINE([HAVE___BUILTIN_EXPECT], [1])
Packit Service a2489d
  elif test "$gl_cv___builtin_expect" = "in <builtins.h>"; then
Packit Service a2489d
    AC_DEFINE([HAVE___BUILTIN_EXPECT], [2])
Packit Service a2489d
  fi
Packit Service a2489d
  AH_VERBATIM([HAVE___BUILTIN_EXPECT],
Packit Service a2489d
    [/* Define to 1 if the compiler supports __builtin_expect,
Packit Service a2489d
   and to 2 if <builtins.h> does.  */
Packit Service a2489d
#undef HAVE___BUILTIN_EXPECT
Packit Service a2489d
#ifndef HAVE___BUILTIN_EXPECT
Packit Service a2489d
# define __builtin_expect(e, c) (e)
Packit Service a2489d
#elif HAVE___BUILTIN_EXPECT == 2
Packit Service a2489d
# include <builtins.h>
Packit Service a2489d
#endif
Packit Service a2489d
    ])
Packit Service a2489d
])