Fix some easy cases of __ANDROID__ versus __BIONIC__.
We need to make a clearer distinction for bionic on the host. This patch
doesn't fully address things like "should host bionic try to talk to netd?"
for now, but is a step in the right direction.
Bug: http://b/31559095
Test: bionic tests.
Change-Id: I49812f8b75d9d78c4fd8a8ddf5df1201d63771d6
diff --git a/libc/dns/net/getaddrinfo.c b/libc/dns/net/getaddrinfo.c
index cc8b8b4..13000f7 100644
--- a/libc/dns/net/getaddrinfo.c
+++ b/libc/dns/net/getaddrinfo.c
@@ -108,9 +108,9 @@
#include <stdarg.h>
#include "nsswitch.h"
-#ifdef ANDROID_CHANGES
+#if defined(__BIONIC__)
#include <sys/system_properties.h>
-#endif /* ANDROID_CHANGES */
+#endif
typedef union sockaddr_union {
struct sockaddr generic;
@@ -325,7 +325,7 @@
{
struct addrinfo *next;
-#if __ANDROID__
+#if defined(__BIONIC__)
if (ai == NULL) return;
#else
_DIAGASSERT(ai != NULL);
diff --git a/libc/dns/resolv/res_init.c b/libc/dns/resolv/res_init.c
index 713b6e0..a5413dd 100644
--- a/libc/dns/resolv/res_init.c
+++ b/libc/dns/resolv/res_init.c
@@ -166,23 +166,23 @@
/* This function has to be reachable by res_data.c but not publicly. */
int
__res_vinit(res_state statp, int preinit) {
-#if !defined(__ANDROID__)
+#if !defined(__BIONIC__)
register FILE *fp;
#endif
register char *cp, **pp;
-#if !defined(__ANDROID__)
+#if !defined(__BIONIC__)
register int n;
#endif
char buf[BUFSIZ];
int nserv = 0; /* number of nameserver records read from file */
-#if !defined(__ANDROID__)
+#if !defined(__BIONIC__)
int haveenv = 0;
#endif
int havesearch = 0;
#ifdef RESOLVSORT
int nsort = 0;
#endif
-#if !defined(__ANDROID__)
+#if !defined(__BIONIC__)
char *net;
#endif
int dots;
@@ -243,7 +243,9 @@
statp->nsort = 0;
res_setservers(statp, u, nserv);
-#if !defined(__ANDROID__) /* IGNORE THE ENVIRONMENT */
+#if defined(__BIONIC__)
+ /* Ignore the environment. */
+#else
/* Allow user to override the local domain definition */
if ((cp = getenv("LOCALDOMAIN")) != NULL) {
(void)strncpy(statp->defdname, cp, sizeof(statp->defdname) - 1);
diff --git a/libc/stdio/refill.c b/libc/stdio/refill.c
index 5b0811f..a7c4bff 100644
--- a/libc/stdio/refill.c
+++ b/libc/stdio/refill.c
@@ -53,7 +53,7 @@
{
fp->_r = 0; /* largely a convenience for callers */
-#if !defined(__ANDROID__)
+#if !defined(__BIONIC__)
/* SysV does not make this test; take it out for compatibility */
if (fp->_flags & __SEOF)
return (EOF);
diff --git a/libc/tzcode/localtime.c b/libc/tzcode/localtime.c
index cf0fd6b..adc2f1b 100644
--- a/libc/tzcode/localtime.c
+++ b/libc/tzcode/localtime.c
@@ -382,7 +382,7 @@
register int fid;
register int stored;
register ssize_t nread;
-#if !defined(__ANDROID__)
+#if !defined(__BIONIC__)
register bool doaccess;
register char *fullname = lsp->fullname;
#endif
@@ -397,7 +397,7 @@
return EINVAL;
}
-#if defined(__ANDROID__)
+#if defined(__BIONIC__)
fid = __bionic_open_tzdata(name);
#else
if (name[0] == ':')
@@ -1308,7 +1308,7 @@
}
#endif
-#if defined(__ANDROID__)
+#if defined(__BIONIC__)
#define _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_
#include <sys/_system_properties.h> // For __system_property_serial.
#endif
@@ -1316,7 +1316,7 @@
static void
tzset_unlocked(void)
{
-#if defined(__ANDROID__)
+#if defined(__BIONIC__)
// The TZ environment variable is meant to override the system-wide setting.
const char* name = getenv("TZ");
@@ -2174,7 +2174,7 @@
time_t
mktime(struct tm *tmp)
{
-#if __ANDROID__
+#if defined(__BIONIC__)
int saved_errno = errno;
#endif
@@ -2188,7 +2188,7 @@
t = mktime_tzname(lclptr, tmp, true);
unlock();
-#if __ANDROID__
+#if defined(__BIONIC__)
errno = (t == -1) ? EOVERFLOW : saved_errno;
#endif
return t;
diff --git a/libc/tzcode/strftime.c b/libc/tzcode/strftime.c
index b1e0d1c..c05f6b5 100644
--- a/libc/tzcode/strftime.c
+++ b/libc/tzcode/strftime.c
@@ -39,7 +39,7 @@
#include "fcntl.h"
#include "locale.h"
-#if __ANDROID__
+#if defined(__BIONIC__)
/* LP32 had a 32-bit time_t, so we need to work around that here. */
#if defined(__LP64__)