diff mbox series

[8/9] lib: move bsearch code

Message ID 13e17bbd-4e58-d953-87c5-5fabafa21de2@suse.com (mailing list archive)
State Superseded
Headers show
Series xen: beginnings of moving library-like code into an archive | expand

Commit Message

Jan Beulich Sept. 14, 2020, 10:18 a.m. UTC
Build this code into an archive, which results in not linking it into
x86 final binaries. This saves a little bit of dead code.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
 xen/common/Makefile           | 1 -
 xen/lib/Makefile              | 1 +
 xen/{common => lib}/bsearch.c | 0
 3 files changed, 1 insertion(+), 1 deletion(-)
 rename xen/{common => lib}/bsearch.c (100%)

Comments

Andrew Cooper Sept. 22, 2020, 7:34 p.m. UTC | #1
On 14/09/2020 11:18, Jan Beulich wrote:
> Build this code into an archive, which results in not linking it into
> x86 final binaries. This saves a little bit of dead code.
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>

This wants to be an extern inline in the header file just like in stdlib.h.

The implementation is trivial, and much faster when the compiler can
inline the cmp() function pointer.

I doubt we actually need out-of-line implementation (except perhaps for
CONFIG_UBSAN builds or so).

~Andrew
Jan Beulich Sept. 24, 2020, 7:09 a.m. UTC | #2
On 22.09.2020 21:34, Andrew Cooper wrote:
> On 14/09/2020 11:18, Jan Beulich wrote:
>> Build this code into an archive, which results in not linking it into
>> x86 final binaries. This saves a little bit of dead code.
>>
>> Signed-off-by: Jan Beulich <jbeulich@suse.com>
> 
> This wants to be an extern inline in the header file just like in stdlib.h.

I can move it there, but why "extern" rather than "static"? We're
not at risk of conflicting with a C library implementation.

> The implementation is trivial, and much faster when the compiler can
> inline the cmp() function pointer.
> 
> I doubt we actually need out-of-line implementation (except perhaps for
> CONFIG_UBSAN builds or so).

The only references are in Arm code; I don't know enough of UBSAN to
see why uses may appear there.

Jan
diff mbox series

Patch

diff --git a/xen/common/Makefile b/xen/common/Makefile
index 46406dccdfd4..149466b473a8 100644
--- a/xen/common/Makefile
+++ b/xen/common/Makefile
@@ -1,6 +1,5 @@ 
 obj-$(CONFIG_ARGO) += argo.o
 obj-y += bitmap.o
-obj-y += bsearch.o
 obj-$(CONFIG_HYPFS_CONFIG) += config_data.o
 obj-$(CONFIG_CORE_PARKING) += core_parking.o
 obj-y += cpu.o
diff --git a/xen/lib/Makefile b/xen/lib/Makefile
index b469d2dff7b8..122eeb3d327b 100644
--- a/xen/lib/Makefile
+++ b/xen/lib/Makefile
@@ -1,6 +1,7 @@ 
 obj-y += ctors.o
 obj-$(CONFIG_X86) += x86/
 
+lib-y += bsearch.o
 lib-y += ctype.o
 lib-y += list-sort.o
 lib-y += parse-size.o
diff --git a/xen/common/bsearch.c b/xen/lib/bsearch.c
similarity index 100%
rename from xen/common/bsearch.c
rename to xen/lib/bsearch.c