From: KO Myung-Hun Date: Thu, 1 Dec 2016 10:52:45 +0000 (+0900) Subject: alphasort, scandir: Port to OS/2 kLIBC X-Git-Tag: v1.0~6520 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=44686d94aefa095d0a4a6bf0f88a6a05c2e7e657;p=gnulib.git alphasort, scandir: Port to OS/2 kLIBC On OS/2 kLIBC, scandir() declaration is different from POSIX. As a result, alphasort() declaration is different, too. * lib/alphasort.c (alphasort): Implement according to OS/2 kLIBC declaration. * lib/scandir.c (scandir): Add declaration for OS/2 kLIBC. --- diff --git a/ChangeLog b/ChangeLog index 6b4d0d5c97..432be6f139 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2016-12-01 KO Myung-Hun + + 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 relocatable: Fix that /@unixroot prefix is not working on OS/2 kLIBC diff --git a/lib/alphasort.c b/lib/alphasort.c index 49f4bd7fdd..9a8c0eac39 100644 --- a/lib/alphasort.c +++ b/lib/alphasort.c @@ -21,7 +21,17 @@ #include 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 . */ +alphasort (const void *a, const void *b) +{ + return strcoll ((*(const struct dirent **)a)->d_name, + (*(const struct dirent **)b)->d_name); +} +#endif diff --git a/lib/scandir.c b/lib/scandir.c index d9cb4c48fe..9da342d8ba 100644 --- a/lib/scandir.c +++ b/lib/scandir.c @@ -89,10 +89,19 @@ cancel_handler (void *arg) 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 + . */ +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;