3 dnl Copyright 2016-2024 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 Check for __builtin_expect.
10 dnl Written by Paul Eggert.
12 AC_DEFUN([gl___BUILTIN_EXPECT],
14 AC_CACHE_CHECK([for __builtin_expect],
15 [gl_cv___builtin_expect],
19 main (int argc, char **argv)
21 argc = __builtin_expect (argc, 100);
22 return argv[argc != 100][0];
24 [gl_cv___builtin_expect=yes],
29 main (int argc, char **argv)
31 argc = __builtin_expect (argc, 100);
32 return argv[argc != 100][0];
34 [gl_cv___builtin_expect="in <builtins.h>"],
35 [gl_cv___builtin_expect=no])])])
36 if test "$gl_cv___builtin_expect" = yes; then
37 AC_DEFINE([HAVE___BUILTIN_EXPECT], [1])
38 elif test "$gl_cv___builtin_expect" = "in <builtins.h>"; then
39 AC_DEFINE([HAVE___BUILTIN_EXPECT], [2])
41 AH_VERBATIM([HAVE___BUILTIN_EXPECT],
42 [/* Define to 1 if the compiler supports __builtin_expect,
43 and to 2 if <builtins.h> does. */
44 #undef HAVE___BUILTIN_EXPECT
45 #ifndef HAVE___BUILTIN_EXPECT
46 # define __builtin_expect(e, c) (e)
47 #elif HAVE___BUILTIN_EXPECT == 2
48 # include <builtins.h>