+2016-12-01 KO Myung-Hun <komh78@gmail.com>
+
+ alphasort, scandir: Port to OS/2 kLIBC
+ * lib/alphasort.c (alphasort): Implement according to OS/2 kLIBC
+ declaration.
+ * lib/scandir.c (scandir): Add declaration for OS/2 kLIBC.
+
2016-12-01 KO Myung-Hun <komh78@gmail.com>
relocatable: Fix that /@unixroot prefix is not working on OS/2 kLIBC
#include <string.h>
int
+#ifndef __KLIBC__
alphasort (const struct dirent **a, const struct dirent **b)
{
return strcoll ((*a)->d_name, (*b)->d_name);
}
+#else
+/* On OS/2 kLIBC, the compare function declaration of scandir() is different
+ from POSIX. See <http://trac.netlabs.org/libc/browser/branches/libc-0.6/src/emx/include/dirent.h#L141>. */
+alphasort (const void *a, const void *b)
+{
+ return strcoll ((*(const struct dirent **)a)->d_name,
+ (*(const struct dirent **)b)->d_name);
+}
+#endif
int
+#ifndef __KLIBC__
SCANDIR (const char *dir,
DIRENT_TYPE ***namelist,
int (*select) (const DIRENT_TYPE *),
int (*cmp) (const DIRENT_TYPE **, const DIRENT_TYPE **))
+#else
+/* On OS/2 kLIBC, scandir() declaration is different from POSIX. See
+ <http://trac.netlabs.org/libc/browser/branches/libc-0.6/src/emx/include/dirent.h#L141>. */
+SCANDIR (const char *dir,
+ DIRENT_TYPE ***namelist,
+ int (*select) (DIRENT_TYPE *),
+ int (*cmp) (const void *, const void *))
+#endif
{
DIR *dp = __opendir (dir);
DIRENT_TYPE **v = NULL;