Skip to contentSkip to conversation

2.6.6 add qsort library function

PATCH New Chris Wedgwood 3 participants 5 messages May 10, 2004 – Jun 4, 2004 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 2.6.6 add qsort library function

This is a rehash of a patch from Andreas Gruenbacher <[email protected]> to add qsort as a kernel library function. Right now the only user of this is XFS others users are expected.

The stack utilization is fairly modest and the function is not recursive.

I stupidly took the gnu-formatted function and ran Lindent over it which made a bit of a mess (I manually fixed most of this and am guilty of editing the diff...)

--cw

 include/linux/kernel.h |    2
 lib/Kconfig            |    3
 lib/Makefile           |    1
 lib/qsort.c            |  239 +++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 245 insertions(+)
include/linux/kernel.h +2 -0
diff -Nru a/include/linux/kernel.h b/include/linux/kernel.h
@@ -80,6 +80,8 @@
 	__attribute__ ((format (scanf,2,3)));
 extern int vsscanf(const char *, const char *, va_list);
 
+extern void qsort(void *, size_t, size_t, int (*)(const void *,const void *));
+
 extern int get_option(char **str, int *pint);
 extern char *get_options(const char *str, int nints, int *ints);
 extern unsigned long long memparse(char *ptr, char **retptr);
lib/Kconfig +3 -0
diff -Nru a/lib/Kconfig b/lib/Kconfig
@@ -21,6 +21,9 @@
 	  require M here.  See Castagnoli93.
 	  Module will be libcrc32c.
 
+config QSORT
+	bool "Quick Sort"
+
 #
 # compression support is select'ed if needed
 #
lib/Makefile +1 -0
diff -Nru a/lib/Makefile b/lib/Makefile
@@ -20,6 +20,7 @@
 
 obj-$(CONFIG_CRC32)	+= crc32.o
 obj-$(CONFIG_LIBCRC32C)	+= libcrc32c.o
+obj-$(CONFIG_QSORT)	+= qsort.o
 
 obj-$(CONFIG_ZLIB_INFLATE) += zlib_inflate/
 obj-$(CONFIG_ZLIB_DEFLATE) += zlib_deflate/
lib/qsort.c new file +238 -0

238 lines not on this page · raw message

#1 lore raw

PATCH 1/1 2.6.6 add qsort library function (UPDATED PATCH, symbol exported _GPL)

[ This is an updated patch where the symbol is exported GPL only
recognized the GPL origin in the code used. Thanks for those people who pointed this out. ]

This is a rehash of a patch from Andreas Gruenbacher <[email protected]> to add qsort as a kernel library function. Right now the only user of this is XFS others users are expected.

The stack utilization is fairly modest and the function is not recursive.

I stupidly took the gnu-formatted function and ran Lindent over it which made a bit of a mess (I manually fixed most of this and am guilty of editing the diff...)

--cw

 include/linux/kernel.h |    2
 lib/Kconfig            |    3
 lib/Makefile           |    1
 lib/qsort.c            |  239 +++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 245 insertions(+)
include/linux/kernel.h +2 -0
diff -Nru a/include/linux/kernel.h b/include/linux/kernel.h
@@ -80,6 +80,8 @@
 	__attribute__ ((format (scanf,2,3)));
 extern int vsscanf(const char *, const char *, va_list);
 
+extern void qsort(void *, size_t, size_t, int (*)(const void *,const void *));
+
 extern int get_option(char **str, int *pint);
 extern char *get_options(const char *str, int nints, int *ints);
 extern unsigned long long memparse(char *ptr, char **retptr);
lib/Kconfig +3 -0
diff -Nru a/lib/Kconfig b/lib/Kconfig
@@ -21,6 +21,9 @@
 	  require M here.  See Castagnoli93.
 	  Module will be libcrc32c.
 
+config QSORT
+	bool "Quick Sort"
+
 #
 # compression support is select'ed if needed
 #
lib/Makefile +1 -0
diff -Nru a/lib/Makefile b/lib/Makefile
@@ -20,6 +20,7 @@
 
 obj-$(CONFIG_CRC32)	+= crc32.o
 obj-$(CONFIG_LIBCRC32C)	+= libcrc32c.o
+obj-$(CONFIG_QSORT)	+= qsort.o
 
 obj-$(CONFIG_ZLIB_INFLATE) += zlib_inflate/
 obj-$(CONFIG_ZLIB_DEFLATE) += zlib_deflate/
lib/qsort.c new file +238 -0

238 lines not on this page · raw message

#2 lore raw

Re: [PATCH] 2.6.6 add qsort library function (UPDATED PATCH, symbol exported _GPL)

Am Montag, 10. Mai 2004 09:20 schrieb Chris Wedgwood:

lib/qsort.c line 8

Quoted 12 lines

diff -Nru a/lib/qsort.c b/lib/qsort.c

lib/qsort.c new file +8 -0
@@ -0,0 +1,239 @@
+/*
+ * qsort implementation for the Linux kernel.
+ *
+ * Original implementation taken form glibc and credited to Douglas
+ * C. Schmidt ([email protected]).
+ *
+ * This source code is licensed under the GNU General Public License,
+ * Version 2.  See the file COPYING for more details.
      ^^^^^^^^^

lib/qsort.c line 21

Quoted 13 lines
lib/qsort.c new file +13 -0
+ */
+
+/*
+ * If you consider tuning this algorithm, you should consult first:
+ * Engineering a sort function; Jon Bentley and M. Douglas McIlroy;
+ * Software - Practice and Experience; Vol. 23 (11), 1249-1265, 1993.
+ */
+
+# include <linux/module.h>
+# include <linux/slab.h>
+# include <linux/string.h>
+
+MODULE_LICENSE("GPL");

Shouldn't this be "GPLv2" then?

Eike

#3 lore raw

Re: [PATCH] 2.6.6 add qsort library function (UPDATED PATCH, symbol exported _GPL)

In reply to Chris Wedgwood
Quoted 5 lines · Chris Wedgwood

[ This is an updated patch where the symbol is exported GPL only
recognized the GPL origin in the code used. Thanks for those people who pointed this out. ]

+EXPORT_SYMBOL_GPL(qsort);

I'm sorry, but I don't see the connection. Just because the code is GPL, why should a caller be constrained to be GPL? Is there something about the qsort API that makes a caller intrinsically a derivative work?

=============================
Tim Bird
Architecture Group Co-Chair
CE Linux Forum
Senior Staff Engineer
Sony Electronics
E-mail: [email protected]
=============================

#4 lore raw

Re: [PATCH] 2.6.6 add qsort library function (UPDATED PATCH, symbol exported _GPL)

Quoted 2 lines · Tim Bird

I'm sorry, but I don't see the connection. Just because the code is GPL, why should a caller be constrained to be GPL?

Originally this wasnt he case, it was changed the request of the glibc people which I'm fine with.

--cw