From 5cd357cc797ac725ca90b13cb7020ba4dd924f18 Mon Sep 17 00:00:00 2001 From: Charles Manning Date: Mon, 2 May 2016 07:23:33 +1200 Subject: [PATCH] Split qsort from the main Yaffs Direct base Use the system qsort if available. If not, then add in the optional qsort.c Signed-off-by: Charles Manning --- direct/optional_sort/README_qsort.txt | 19 +++++++++++++++++++ .../{yaffs_qsort.c => optional_sort/qsort.c} | 6 +++--- direct/test-framework/FrameworkRules.mk | 4 ++-- direct/ydirectenv.h | 5 +---- 4 files changed, 25 insertions(+), 9 deletions(-) create mode 100644 direct/optional_sort/README_qsort.txt rename direct/{yaffs_qsort.c => optional_sort/qsort.c} (97%) diff --git a/direct/optional_sort/README_qsort.txt b/direct/optional_sort/README_qsort.txt new file mode 100644 index 0000000..571803f --- /dev/null +++ b/direct/optional_sort/README_qsort.txt @@ -0,0 +1,19 @@ +Optional QSort +~~~~~~~~~~~~~~ + +Yaffs needs a sort function for sorting block indices during scanning. + +Most systems already have qsort (or an equivalent that can be used) +as part of the standard library and generally it is best to use that. + +For those systems that do not have this, we supply the qsort in this +directory. + +This qsort.c file is the only code that is supplied as part of the +Yaffs Direct code that is NOT written, from the ground up, by Aleph One. + +The licensing terms are fairly innocuous. Please read the banner at the top +of qsort.c + + + diff --git a/direct/yaffs_qsort.c b/direct/optional_sort/qsort.c similarity index 97% rename from direct/yaffs_qsort.c rename to direct/optional_sort/qsort.c index afd1ffa..9c77899 100644 --- a/direct/yaffs_qsort.c +++ b/direct/optional_sort/qsort.c @@ -27,8 +27,8 @@ * SUCH DAMAGE. */ -#include "yportenv.h" -/* #include */ +#include +#include /* * Qsort routine from Bentley & McIlroy's "Engineering a Sort Function". @@ -80,7 +80,7 @@ med3(char *a, char *b, char *c, int (*cmp)(const void *, const void *)) #endif void -yaffs_qsort(void *aa, size_t n, size_t es, +qsort(void *aa, size_t n, size_t es, int (*cmp)(const void *, const void *)) { char *pa, *pb, *pc, *pd, *pl, *pm, *pn; diff --git a/direct/test-framework/FrameworkRules.mk b/direct/test-framework/FrameworkRules.mk index f4d955c..5f77f99 100644 --- a/direct/test-framework/FrameworkRules.mk +++ b/direct/test-framework/FrameworkRules.mk @@ -34,7 +34,7 @@ COMMONTESTOBJS = yaffscfg2k.o yaffs_osglue.o yaffs_hweight.o yaffs_error.o\ yaffs_packedtags1.o yaffs_ramdisk.o yaffs_ramem2k.o \ yaffs_tagscompat.o yaffs_tagsmarshall.o \ yaffs_packedtags2.o yaffs_nand.o \ - yaffs_checkptrw.o yaffs_qsort.o\ + yaffs_checkptrw.o \ yaffs_nameval.o yaffs_attribs.o \ yaffs_m18_drv.o yaffs_nor_drv.o ynorsim.o \ yaffs_nand_drv.o \ @@ -54,7 +54,7 @@ ALLOBJS = $(sort $(ALL_UNSORTED_OBJS)) YAFFSDIRECTSYMLINKS = \ yaffsfs.c yaffs_flashif.h yaffs_flashif2.h\ yaffsfs.h yaffs_osglue.h ydirectenv.h \ - yaffscfg.h yaffs_qsort.c \ + yaffscfg.h \ yaffs_nandemul2k.h yaffs_list.h \ yaffs_attribs.c \ yportenv.h \ diff --git a/direct/ydirectenv.h b/direct/ydirectenv.h index b2293a6..b15147c 100644 --- a/direct/ydirectenv.h +++ b/direct/ydirectenv.h @@ -54,10 +54,7 @@ void yaffs_bug_fn(const char *file_name, int line_no); #define hweight8(x) yaffs_hweight8(x) #define hweight32(x) yaffs_hweight32(x) -void yaffs_qsort(void *aa, size_t n, size_t es, - int (*cmp)(const void *, const void *)); - -#define sort(base, n, sz, cmp_fn, swp) yaffs_qsort(base, n, sz, cmp_fn) +#define sort(base, n, sz, cmp_fn, swp) qsort(base, n, sz, cmp_fn) #define YAFFS_PATH_DIVIDERS "/" -- 2.30.2