[klibc] [PATCH v2 2/4] klibc: Add alphasort() support.
Mike Waychison
mikew at google.com
Tue Aug 2 15:46:55 PDT 2011
Add support for alphasort() as defined in POSIX.1-2008.
Signed-off-by: Mike Waychison <mikew at google.com>
---
usr/include/dirent.h | 2 ++
usr/klibc/Kbuild | 2 +-
usr/klibc/alphasort.c | 12 ++++++++++++
3 files changed, 15 insertions(+), 1 deletions(-)
create mode 100644 usr/klibc/alphasort.c
diff --git a/usr/include/dirent.h b/usr/include/dirent.h
index 0bcf40b..725452e 100644
--- a/usr/include/dirent.h
+++ b/usr/include/dirent.h
@@ -35,4 +35,6 @@ __extern int scandir(const char *, struct dirent ***,
int (*)(const struct dirent **,
const struct dirent **));
+__extern int alphasort(const struct dirent **, const struct dirent **);
+
#endif /* _DIRENT_H */
diff --git a/usr/klibc/Kbuild b/usr/klibc/Kbuild
index 40e61da..c4f9ae2 100644
--- a/usr/klibc/Kbuild
+++ b/usr/klibc/Kbuild
@@ -42,7 +42,7 @@ klib-y := vsnprintf.o snprintf.o vsprintf.o sprintf.o \
seteuid.o setegid.o \
getenv.o setenv.o putenv.o __put_env.o unsetenv.o \
clearenv.o nullenv.o \
- getopt.o getopt_long.o readdir.o scandir.o remove.o \
+ getopt.o getopt_long.o readdir.o scandir.o alphasort.o remove.o \
syslog.o closelog.o pty.o getpt.o posix_openpt.o isatty.o reboot.o \
time.o utime.o llseek.o nice.o getpriority.o \
qsort.o bsearch.o \
diff --git a/usr/klibc/alphasort.c b/usr/klibc/alphasort.c
new file mode 100644
index 0000000..d420495
--- /dev/null
+++ b/usr/klibc/alphasort.c
@@ -0,0 +1,12 @@
+/*
+ * alphasort.c: alphasort
+ */
+
+#include <string.h>
+
+#include <dirent.h>
+
+int alphasort(const struct dirent **a, const struct dirent **b)
+{
+ return strcmp((*a)->d_name, (*b)->d_name);
+}
More information about the klibc
mailing list