diff mbox

procattr.c: Use __ANDROID__ instead of ANDROID

Message ID 1479955630-85378-1-git-send-email-nnk@google.com (mailing list archive)
State Not Applicable
Headers show

Commit Message

Nick Kralevich Nov. 24, 2016, 2:47 a.m. UTC
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.

Signed-off-by: Nick Kralevich <nnk@google.com>
---
 libselinux/src/procattr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Stephen Smalley Nov. 28, 2016, 2:38 p.m. UTC | #1
On 11/23/2016 09:47 PM, Nick Kralevich wrote:
> 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.

Thanks, applied.

> 
> Signed-off-by: Nick Kralevich <nnk@google.com>
> ---
>  libselinux/src/procattr.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libselinux/src/procattr.c b/libselinux/src/procattr.c
> index 7efcd7e..8cd59af 100644
> --- a/libselinux/src/procattr.c
> +++ b/libselinux/src/procattr.c
> @@ -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)
>  {
>
diff mbox

Patch

diff --git a/libselinux/src/procattr.c b/libselinux/src/procattr.c
index 7efcd7e..8cd59af 100644
--- a/libselinux/src/procattr.c
+++ b/libselinux/src/procattr.c
@@ -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)
 {