Skip to contentSkip to conversation

procattr.c: Use __ANDROID__ instead of ANDROID

PATCH Applied Nick Kralevich 2 participants 2 messages Nov 24, 2016 – Nov 28, 2016 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 procattr.c: Use __ANDROID__ instead of ANDROID

When code is compiled within the Android tree, the resulting binaries are intended to run either on the "host" (the machine doing the building) or the "target" (the machine running the Android operating system).

"ANDROID" is defined if the code is being compiled for the host or the target, whereas "__ANDROID__" is only defined for code being compiled for the target. (yes, I agree, this is not obvious).

gettid() is only declared in the target environment, not the host environment, so adjust the #ifdef to properly emit the gettid() definition for binaries targeting the host.

---
 libselinux/src/procattr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
libselinux/src/procattr.c +1 -1
index 7efcd7e..8cd59af 100644
@@ -22,7 +22,7 @@ static pthread_key_t destructor_key;
 static int destructor_key_initialized = 0;
 static __thread char destructor_initialized;
 
-#ifndef ANDROID
+#ifndef __ANDROID__
 /* Android declares this in unistd.h and has a definition for it */
 static pid_t gettid(void)
 {
Signature · 1 line
2.8.0.rc3.226.g39d4020
#1 lore raw
Quoted 5 lines · Nick Kralevich

When code is compiled within the Android tree, the resulting binaries are intended to run either on the "host" (the machine doing the building) or the "target" (the machine running the Android operating system).

Quoted 7 lines

"ANDROID" is defined if the code is being compiled for the host or the target, whereas "__ANDROID__" is only defined for code being compiled for the target. (yes, I agree, this is not obvious).

gettid() is only declared in the target environment, not the host environment, so adjust the #ifdef to properly emit the gettid() definition for binaries targeting the host.

Thanks, applied.

Quoted 20 lines
---
 libselinux/src/procattr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
libselinux/src/procattr.c +1 -1
index 7efcd7e..8cd59af 100644
@@ -22,7 +22,7 @@ static pthread_key_t destructor_key;
 static int destructor_key_initialized = 0;
 static __thread char destructor_initialized;
 
-#ifndef ANDROID
+#ifndef __ANDROID__
 /* Android declares this in unistd.h and has a definition for it */
 static pid_t gettid(void)
 {