This is the mail archive of the glibc-cvs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

GNU C Library master sources branch master updated. glibc-2.17-212-g41eda41


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".

The branch, master has been updated
       via  41eda41d7489a428abb46202482136a540ec23dc (commit)
      from  8ded91fb377ad48c66e8b44929af7214f40f3557 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=41eda41d7489a428abb46202482136a540ec23dc

commit 41eda41d7489a428abb46202482136a540ec23dc
Author: Ondrej Bilka <neleai@seznam.cz>
Date:   Mon Feb 11 23:18:09 2013 +0100

    Add inline bsearch expansion.

diff --git a/ChangeLog b/ChangeLog
index e6a7fdf..99ec097 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2013-02-09   OndÅ?ej Bílka  <neleai@seznam.cz>
+
+	* bits/stdlib-bsearch.h: New file.
+	* stdlib/bsearch.c: Include bits/stdlib-bsearch.h.
+	* stdlib/stdlib.h (bsearch): Add inline bsearch.
+
 2013-02-11  Roland McGrath  <roland@hack.frob.com>
 
 	* manual/conf.texi (General Limits): Fix SSIZE_MAX type to ssize_t.
diff --git a/stdlib/bsearch.c b/bits/stdlib-bsearch.h
similarity index 53%
copy from stdlib/bsearch.c
copy to bits/stdlib-bsearch.h
index 55b4f37..4cb58ab 100644
--- a/stdlib/bsearch.c
+++ b/bits/stdlib-bsearch.h
@@ -1,4 +1,5 @@
-/* Copyright (C) 1991-2013 Free Software Foundation, Inc.
+/* Perform binary search - inline version.
+   Copyright (C) 1991-2013 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -15,34 +16,28 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <stdlib.h>
-
-
-/* Perform a binary search for KEY in BASE which has NMEMB elements
-   of SIZE bytes each.  The comparisons are done by (*COMPAR)().  */
-void *
-bsearch (const void *key, const void *base, size_t nmemb, size_t size,
-	 int (*compar) (const void *, const void *))
+__extern_inline void *
+bsearch (const void *__key, const void *__base, size_t __nmemb, size_t __size,
+	 __compar_fn_t __compar)
 {
-  size_t l, u, idx;
-  const void *p;
-  int comparison;
+  size_t __l, __u, __idx;
+  const void *__p;
+  int __comparison;
 
-  l = 0;
-  u = nmemb;
-  while (l < u)
+  __l = 0;
+  __u = __nmemb;
+  while (__l < __u)
     {
-      idx = (l + u) / 2;
-      p = (void *) (((const char *) base) + (idx * size));
-      comparison = (*compar) (key, p);
-      if (comparison < 0)
-	u = idx;
-      else if (comparison > 0)
-	l = idx + 1;
+      __idx = (__l + __u) / 2;
+      __p = (void *) (((const char *) __base) + (__idx * __size));
+      __comparison = (*__compar) (__key, __p);
+      if (__comparison < 0)
+	__u = __idx;
+      else if (__comparison > 0)
+	__l = __idx + 1;
       else
-	return (void *) p;
+	return (void *) __p;
     }
 
   return NULL;
 }
-libc_hidden_def (bsearch)
diff --git a/stdlib/bsearch.c b/stdlib/bsearch.c
index 55b4f37..4a357ef 100644
--- a/stdlib/bsearch.c
+++ b/stdlib/bsearch.c
@@ -17,32 +17,7 @@
 
 #include <stdlib.h>
 
-
-/* Perform a binary search for KEY in BASE which has NMEMB elements
-   of SIZE bytes each.  The comparisons are done by (*COMPAR)().  */
-void *
-bsearch (const void *key, const void *base, size_t nmemb, size_t size,
-	 int (*compar) (const void *, const void *))
-{
-  size_t l, u, idx;
-  const void *p;
-  int comparison;
-
-  l = 0;
-  u = nmemb;
-  while (l < u)
-    {
-      idx = (l + u) / 2;
-      p = (void *) (((const char *) base) + (idx * size));
-      comparison = (*compar) (key, p);
-      if (comparison < 0)
-	u = idx;
-      else if (comparison > 0)
-	l = idx + 1;
-      else
-	return (void *) p;
-    }
-
-  return NULL;
-}
+#undef  __extern_inline
+#define __extern_inline /* Empty, so we get a normal definition.  */
+#include <bits/stdlib-bsearch.h>
 libc_hidden_def (bsearch)
diff --git a/stdlib/stdlib.h b/stdlib/stdlib.h
index b49a41c..fa1175c 100644
--- a/stdlib/stdlib.h
+++ b/stdlib/stdlib.h
@@ -756,6 +756,10 @@ extern void *bsearch (const void *__key, const void *__base,
 		      size_t __nmemb, size_t __size, __compar_fn_t __compar)
      __nonnull ((1, 2, 5)) __wur;
 
+#ifdef __USE_EXTERN_INLINES
+# include <bits/stdlib-bsearch.h>
+#endif
+
 /* Sort NMEMB elements of BASE, of SIZE bytes each,
    using COMPAR to perform the comparisons.  */
 extern void qsort (void *__base, size_t __nmemb, size_t __size,

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog                                |    6 ++++
 io/euidaccess.c => bits/stdlib-bsearch.h |   39 ++++++++++++++++-------------
 stdlib/bsearch.c                         |   31 ++---------------------
 stdlib/stdlib.h                          |    4 +++
 4 files changed, 34 insertions(+), 46 deletions(-)
 copy io/euidaccess.c => bits/stdlib-bsearch.h (58%)


hooks/post-receive
-- 
GNU C Library master sources


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]