android-tools: Support libselinux to build with musl which now has gettid

Signed-off-by: Khem Raj <raj.khem@gmail.com>
This commit is contained in:
Khem Raj
2020-09-10 09:56:00 -07:00
parent 14f193be82
commit ad26afac60
@@ -29,24 +29,21 @@ Signed-off-by: Khem Raj <raj.khem@gmail.com>
--- a/src/procattr.c --- a/src/procattr.c
+++ b/src/procattr.c +++ b/src/procattr.c
@@ -8,7 +8,19 @@ @@ -8,12 +8,16 @@
#include "selinux_internal.h" #include "selinux_internal.h"
#include "policy.h" #include "policy.h"
-#ifndef __BIONIC__ -#ifndef __BIONIC__
+/* Bionic and glibc >= 2.30 declare gettid() system call wrapper in unistd.h and +/* Bionic and glibc >= 2.30 declare gettid() system call wrapper in unistd.h and
+ * has a definition for it */ + * has a definition for it */
+#ifdef __BIONIC__ +#if defined(__GLIBC_)
+ #define OVERRIDE_GETTID 0 +#if !__GLIBC_PREREQ(2,30)
+#elif !defined(__GLIBC_PREREQ)
+ #define OVERRIDE_GETTID 1
+#elif !__GLIBC_PREREQ(2,29)
+ #define OVERRIDE_GETTID 1
+#else
+ #define OVERRIDE_GETTID 0
+#endif
+
+#if OVERRIDE_GETTID
static pid_t gettid(void) static pid_t gettid(void)
{ {
return syscall(__NR_gettid); return syscall(__NR_gettid);
}
#endif
+#endif
static int getprocattrcon(char ** context,
pid_t pid, const char *attr)