summaryrefslogtreecommitdiff
path: root/lib/bsearch.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/bsearch.c')
-rw-r--r--lib/bsearch.c27
1 files changed, 5 insertions, 22 deletions
diff --git a/lib/bsearch.c b/lib/bsearch.c
index e33c179089db..bf86aa66f2b2 100644
--- a/lib/bsearch.c
+++ b/lib/bsearch.c
@@ -1,16 +1,14 @@
+// SPDX-License-Identifier: GPL-2.0-only
/*
* A generic implementation of binary search for the Linux kernel
*
* Copyright (C) 2008-2009 Ksplice, Inc.
* Author: Tim Abbott <tabbott@ksplice.com>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; version 2.
*/
#include <linux/export.h>
#include <linux/bsearch.h>
+#include <linux/kprobes.h>
/*
* bsearch - binary search an array of elements
@@ -30,24 +28,9 @@
* the key and elements in the array are of the same type, you can use
* the same comparison function for both sort() and bsearch().
*/
-void *bsearch(const void *key, const void *base, size_t num, size_t size,
- int (*cmp)(const void *key, const void *elt))
+void *bsearch(const void *key, const void *base, size_t num, size_t size, cmp_func_t cmp)
{
- size_t start = 0, end = num;
- int result;
-
- while (start < end) {
- size_t mid = start + (end - start) / 2;
-
- result = cmp(key, base + mid * size);
- if (result < 0)
- end = mid;
- else if (result > 0)
- start = mid + 1;
- else
- return (void *)base + mid * size;
- }
-
- return NULL;
+ return __inline_bsearch(key, base, num, size, cmp);
}
EXPORT_SYMBOL(bsearch);
+NOKPROBE_SYMBOL(bsearch);