1 dnl Check for __builtin_expect.
3 dnl Copyright 2016-2020 Free Software Foundation, Inc.
4 dnl This file is free software; the Free Software Foundation
5 dnl gives unlimited permission to copy and/or distribute it,
6 dnl with or without modifications, as long as this notice is preserved.
8 dnl Written by Paul Eggert.
10 AC_DEFUN([gl___BUILTIN_EXPECT],
12 AC_CACHE_CHECK([for __builtin_expect],
13 [gl_cv___builtin_expect],
17 main (int argc, char **argv)
19 argc = __builtin_expect (argc, 100);
20 return argv[argc != 100][0];
22 [gl_cv___builtin_expect=yes],
27 main (int argc, char **argv)
29 argc = __builtin_expect (argc, 100);
30 return argv[argc != 100][0];
32 [gl_cv___builtin_expect="in <builtins.h>"],
33 [gl_cv___builtin_expect=no])])])
34 if test "$gl_cv___builtin_expect" = yes; then
35 AC_DEFINE([HAVE___BUILTIN_EXPECT], [1])
36 elif test "$gl_cv___builtin_expect" = "in <builtins.h>"; then
37 AC_DEFINE([HAVE___BUILTIN_EXPECT], [2])
39 AH_VERBATIM([HAVE___BUILTIN_EXPECT],
40 [/* Define to 1 if the compiler supports __builtin_expect,
41 and to 2 if <builtins.h> does. */
42 #undef HAVE___BUILTIN_EXPECT
43 #ifndef HAVE___BUILTIN_EXPECT
44 # define __builtin_expect(e, c) (e)
45 #elif HAVE___BUILTIN_EXPECT == 2
46 # include <builtins.h>