Bug 1092004 - Use getdtablesize for non-gonk builds as well. r=glandium
When building non-gonk builds, ANDROID_VERSION is not set. Beginning with NDK 11, getdtablesize is no longer included. This means that we should use the stub version of the function that is defined in android_stub.h for all android platforms. This patch moves the function out of the "#if ANDROID_VERSION >=21" block so that all android code can use it.
Adding glandium as the reviewer, because he reviewed the original patch at
bug 1103816.
MozReview-Commit-ID: 2NmUl5XuvDS
--- a/security/manager/android_stub.h
+++ b/security/manager/android_stub.h
@@ -8,30 +8,32 @@
#ifndef ANDROID_STUB_H
#define ANDROID_STUB_H
/* sysinfo is defined but not implemented.
* we may be able to implement it ourselves. */
#define _SYS_SYSINFO_H_
#include <sys/cdefs.h>
+#include <sys/resource.h>
#include <linux/kernel.h>
-
-#if ANDROID_VERSION >= 21
-#include <sys/resource.h>
#include <unistd.h>
-static int getdtablesize(void)
+/* Use this stub version of getdtablesize
+ * instead of the one in the header */
+__attribute__((unused))
+static int getdtablesize_stub(void)
{
struct rlimit r;
if (getrlimit(RLIMIT_NOFILE, &r) < 0) {
return sysconf(_SC_OPEN_MAX);
}
return r.rlim_cur;
}
-#else
+#define getdtablesize() getdtablesize_stub()
+
+#if ANDROID_VERSION < 21
#define RTLD_NOLOAD 0
-extern int getdtablesize(void);
#endif
#define sysinfo(foo) -1
#endif /* ANDROID_STUB_H */