Split qsort from the main Yaffs Direct base
authorCharles Manning <cdhmanning@gmail.com>
Sun, 1 May 2016 19:23:33 +0000 (07:23 +1200)
committerCharles Manning <cdhmanning@gmail.com>
Sun, 1 May 2016 19:23:33 +0000 (07:23 +1200)
Use the system qsort if available. If not, then add in the
optional qsort.c

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
direct/optional_sort/README_qsort.txt [new file with mode: 0644]
direct/optional_sort/qsort.c [moved from direct/yaffs_qsort.c with 97% similarity]
direct/test-framework/FrameworkRules.mk
direct/ydirectenv.h

diff --git a/direct/optional_sort/README_qsort.txt b/direct/optional_sort/README_qsort.txt
new file mode 100644 (file)
index 0000000..571803f
--- /dev/null
@@ -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
+
+
+
similarity index 97%
rename from direct/yaffs_qsort.c
rename to direct/optional_sort/qsort.c
index afd1ffa799ead0a2d197b0a5f42f4e99a81ca3a1..9c7789932da0bb85b98cfa498641c5120be38123 100644 (file)
@@ -27,8 +27,8 @@
  * SUCH DAMAGE.
  */
 
-#include "yportenv.h"
-/* #include <linux/string.h> */
+#include <stdlib.h>
+#include <string.h>
 
 /*
  * 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;
index f4d955c6fa513d3243a747606c4c94fb8e71bc52..5f77f9951b6de4f4bf5e81131ded42f37050ec51 100644 (file)
@@ -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 \
index b2293a62fbdf4236092590d21e67ed5c451d93a7..b15147cad55fccf8e53578915d94b273070a0711 100644 (file)
@@ -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  "/"