From f772b592b75d3144174d4c645b916f2718d9cce5 Mon Sep 17 00:00:00 2001 From: Jan Beulich Date: Fri, 18 Dec 2020 13:25:40 +0100 Subject: [PATCH] lib: move sort code Build this code into an archive, partly paralleling bsearch(). Signed-off-by: Jan Beulich Acked-by: Julien Grall Acked-by: Wei Liu Reviewed-by: Bertrand Marquis --- xen/common/Makefile | 1 - xen/lib/Makefile | 1 + xen/{common => lib}/sort.c | 4 ++-- 3 files changed, 3 insertions(+), 3 deletions(-) rename xen/{common => lib}/sort.c (96%) diff --git a/xen/common/Makefile b/xen/common/Makefile index e8ce23acea..7a4e652b57 100644 --- a/xen/common/Makefile +++ b/xen/common/Makefile @@ -36,7 +36,6 @@ obj-y += rcupdate.o obj-y += rwlock.o obj-y += shutdown.o obj-y += softirq.o -obj-y += sort.o obj-y += smp.o obj-y += spinlock.o obj-y += stop_machine.o diff --git a/xen/lib/Makefile b/xen/lib/Makefile index f12dab7a73..42cf7a1164 100644 --- a/xen/lib/Makefile +++ b/xen/lib/Makefile @@ -6,3 +6,4 @@ lib-y += ctype.o lib-y += list-sort.o lib-y += parse-size.o lib-y += rbtree.o +lib-y += sort.o diff --git a/xen/common/sort.c b/xen/lib/sort.c similarity index 96% rename from xen/common/sort.c rename to xen/lib/sort.c index 7b7544bbc2..ee983d0bc3 100644 --- a/xen/common/sort.c +++ b/xen/lib/sort.c @@ -46,9 +46,9 @@ void sort(void *base, size_t num, size_t size, void (*swap)(void *, void *, int size)) { /* pre-scale counters for performance */ - int i = (num/2 - 1) * size, n = num * size, c, r; + int i = (num / 2 - 1) * size, n = num * size, c, r; - if (!swap) + if ( !swap ) swap = (size == 4 ? u32_swap : generic_swap); /* heapify */ -- 2.30.2