alphasort doesn't have the right signature on bionic which causes the build to
fail. This implements a new bionic_alphasort function when building on bionic
providing the right signature and a functional equivalent of glibc's alphasort.

This signature problem with alphasort was fixed in upstream bionic but hasn't
been released yet. This commit can therefore be reverted as soon as the
following commit hits the Android NDK: 40e467ec668b59be25491bd44bf348a884d6a68d

Signed-off-by: Stéphane Graber <stgra...@ubuntu.com>
---
 src/lxc/parse.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/src/lxc/parse.c b/src/lxc/parse.c
index cc6f146..fd78ebd 100644
--- a/src/lxc/parse.c
+++ b/src/lxc/parse.c
@@ -32,6 +32,17 @@
 #include "config.h"
 #include <lxc/log.h>
 
+/* Workaround for the broken signature of alphasort() in bionic.
+   This was fixed upstream in 40e467ec668b59be25491bd44bf348a884d6a68d so the
+   workaround can probably be dropped with the next version of the Android NDK.
+ */
+#ifdef IS_BIONIC
+int bionic_alphasort(const struct dirent** a, const struct dirent** b) {
+       return strcoll((*a)->d_name, (*b)->d_name);
+}
+#endif
+
+
 lxc_log_define(lxc_parse, lxc);
 
 static int dir_filter(const struct dirent *dirent)
@@ -48,7 +59,11 @@ int lxc_dir_for_each(const char *name, const char *directory,
        struct dirent **namelist;
        int n, ret = 0;
 
+#ifdef IS_BIONIC
+       n = scandir(directory, &namelist, dir_filter, bionic_alphasort);
+#else
        n = scandir(directory, &namelist, dir_filter, alphasort);
+#endif
        if (n < 0) {
                SYSERROR("failed to scan %s directory", directory);
                return -1;
-- 
1.8.0


------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122712
_______________________________________________
Lxc-devel mailing list
Lxc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lxc-devel

Reply via email to