Fix fnmatch to use it.
Problem reported for z/OS by Daniel Richard G.
* lib/fnmatch.c (__builtin_expect):
* lib/glob.c (__builtin_expect):
* lib/grantpt.c (__builtin_expect) [!_LIBC]:
* lib/memmem.c (__builtin_expect) [!_LIBC]:
* lib/scandir.c (__builtin_expect):
* lib/strstr.c (__builtin_expect) [!_LIBC]:
Remove macro; config.h now does this.
* lib/gl_anytreehash_list1.h (add_to_bucket):
* lib/regex_internal.h (BE):
Assume __builtin_expect.
* m4/builtin-expect.m4, modules/builtin-expect: New files.
* modules/avltreehash-list, modules/fnmatch, modules/glob:
* modules/grantpt, modules/memmem-simple, modules/rbtreehash-list:
* modules/scandir, modules/strstr-simple:
Depend on builtin-expect.
+2016-12-16 Paul Eggert <eggert@cs.ucla.edu>
+
+ builtin-expect: new module
+ Fix fnmatch to use it.
+ Problem reported for z/OS by Daniel Richard G.
+ * lib/fnmatch.c (__builtin_expect):
+ * lib/glob.c (__builtin_expect):
+ * lib/grantpt.c (__builtin_expect) [!_LIBC]:
+ * lib/memmem.c (__builtin_expect) [!_LIBC]:
+ * lib/scandir.c (__builtin_expect):
+ * lib/strstr.c (__builtin_expect) [!_LIBC]:
+ Remove macro; config.h now does this.
+ * lib/gl_anytreehash_list1.h (add_to_bucket):
+ * lib/regex_internal.h (BE):
+ Assume __builtin_expect.
+ * m4/builtin-expect.m4, modules/builtin-expect: New files.
+ * modules/avltreehash-list, modules/fnmatch, modules/glob:
+ * modules/grantpt, modules/memmem-simple, modules/rbtreehash-list:
+ * modules/scandir, modules/strstr-simple:
+ Depend on builtin-expect.
+
2016-12-15 Bruno Haible <bruno@clisp.org>
init.sh: Add possibility to not delete temporary files.
# define _GNU_SOURCE 1
#endif
-#if ! defined __builtin_expect && (!defined __GNUC__ || __GNUC__ < 3)
-# define __builtin_expect(expr, expected) (expr)
-#endif
-
#include <fnmatch.h>
#include <alloca.h>
return 0;
}
/* Tell GCC that the likely return value is 0. */
-#if __GNUC__ >= 3
-# define add_to_bucket(list,node) \
+#define add_to_bucket(list,node) \
__builtin_expect ((add_to_bucket) (list, node), 0)
-#endif
/* Remove a node from the hash table structure.
If duplicates are allowed, this function performs in average time
# endif
#endif
-#if ! defined __builtin_expect && __GNUC__ < 3
-# define __builtin_expect(expr, expected) (expr)
-#endif
-
#ifndef __glibc_unlikely
# define __glibc_unlikely(expr) __builtin_expect (expr, 0)
#endif
#include "pty-private.h"
#ifndef _LIBC
-# define __builtin_expect(expr,val) (expr)
# define __set_errno(e) errno = (e)
# define __dup2 dup2
# define __fork fork
/* Specification of memmem. */
#include <string.h>
-#ifndef _LIBC
-# define __builtin_expect(expr, val) (expr)
-#endif
-
#define RETURN_TYPE void *
#define AVAILABLE(h, h_l, j, n_l) ((j) <= (h_l) - (n_l))
#include "str-two-way.h"
# define RE_ENABLE_I18N
#endif
-#if __GNUC__ >= 3
-# define BE(expr, val) __builtin_expect (expr, val)
-#else
-# define BE(expr, val) (expr)
-#endif
+#define BE(expr, val) __builtin_expect (expr, val)
/* Number of ASCII characters. */
#define ASCII_CHARS 0x80
# include <bits/libc-lock.h>
#endif
-#if ! defined __builtin_expect && __GNUC__ < 3
-# define __builtin_expect(expr, expected) (expr)
-#endif
-
#undef select
#ifndef _D_EXACT_NAMLEN
#include <stdbool.h>
-#ifndef _LIBC
-# define __builtin_expect(expr, val) (expr)
-#endif
-
#define RETURN_TYPE char *
#define AVAILABLE(h, h_l, j, n_l) \
(!memchr ((h) + (h_l), '\0', (j) + (n_l) - (h_l)) \
--- /dev/null
+dnl Check for __builtin_expect.
+
+dnl Copyright 2016 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl Written by Paul Eggert.
+
+AC_DEFUN([gl___BUILTIN_EXPECT],
+[
+ AC_CACHE_CHECK([for __builtin_expect],
+ [gl_cv___builtin_expect],
+ [AC_LINK_IFELSE(
+ [AC_LANG_SOURCE([[
+ int
+ main (int argc, char **argv)
+ {
+ argc = __builtin_expect (argc, 100);
+ return argv[argc != 100][0];
+ }]])],
+ [gl_cv___builtin_expect=yes],
+ [gl_cv___builtin_expect=no])])
+ if test "$gl_cv___builtin_expect" = yes; then
+ AC_DEFINE([HAVE___BUILTIN_EXPECT], [1])
+ fi
+ AH_VERBATIM([HAVE___BUILTIN_EXPECT],
+ [/* Define to 1 if the compiler understands __builtin_expect. */
+#undef HAVE___BUILTIN_EXPECT
+#ifndef HAVE___BUILTIN_EXPECT
+# define __builtin_expect(e, c) (e)
+#endif
+ ])
+])
lib/gl_anytreehash_list2.h
Depends-on:
+builtin-expect
list
avltree-oset
stdint
--- /dev/null
+Description:
+Check for __builtin_expect.
+
+Files:
+m4/builtin-expect.m4
+
+Depends-on:
+
+configure.ac:
+gl___BUILTIN_EXPECT
+
+Makefile.am:
+
+Include:
+
+License:
+LGPLv2+
+
+Maintainer:
+all
extensions
snippet/arg-nonnull
alloca [test -n "$FNMATCH_H"]
+builtin-expect [test -n "$FNMATCH_H"]
flexmember [test -n "$FNMATCH_H"]
stdbool [test -n "$FNMATCH_H"]
wchar [test -n "$FNMATCH_H"]
snippet/c++defs
snippet/warn-on-use
alloca [test -n "$GLOB_H"]
+builtin-expect [test -n "$GLOB_H"]
closedir [test -n "$GLOB_H"]
d-type [test -n "$GLOB_H"]
dirfd [test -n "$GLOB_H"]
Depends-on:
stdlib
extensions
+builtin-expect [test $HAVE_GRANTPT = 0]
pt_chown [test $HAVE_GRANTPT = 0]
waitpid [test $HAVE_GRANTPT = 0]
configmake [test $HAVE_GRANTPT = 0]
m4/memmem.m4
Depends-on:
+builtin-expect
extensions
string
stdint
lib/gl_anytreehash_list2.h
Depends-on:
+builtin-expect
list
rbtree-oset
stdint
m4/scandir.m4
Depends-on:
+builtin-expect
closedir
dirent
extensions
Maintainer:
all, glibc
-
Depends-on:
string
+builtin-expect [test $REPLACE_STRSTR = 1]
stdbool [test $REPLACE_STRSTR = 1]
memchr [test $REPLACE_STRSTR = 1]
memcmp [test $REPLACE_STRSTR = 1]