Use default hidden visibility to build libc_dns.

Bug: 11156955
Change-Id: Ia443705f5fbee0681039d4480abc89850968f475
diff --git a/libc/Android.mk b/libc/Android.mk
index cd5cb02..3eaed90 100644
--- a/libc/Android.mk
+++ b/libc/Android.mk
@@ -272,8 +272,6 @@
     upstream-netbsd/lib/libc/gen/psignal.c \
     upstream-netbsd/lib/libc/gen/utime.c \
     upstream-netbsd/lib/libc/gen/utmp.c \
-    upstream-netbsd/lib/libc/isc/ev_streams.c \
-    upstream-netbsd/lib/libc/isc/ev_timers.c \
     upstream-netbsd/lib/libc/regex/regcomp.c \
     upstream-netbsd/lib/libc/regex/regerror.c \
     upstream-netbsd/lib/libc/regex/regexec.c \
@@ -617,15 +615,21 @@
 
 include $(CLEAR_VARS)
 
-LOCAL_SRC_FILES := $(call all-c-files-under,dns)
+LOCAL_SRC_FILES := \
+    $(call all-c-files-under,dns) \
+    upstream-netbsd/lib/libc/isc/ev_streams.c \
+    upstream-netbsd/lib/libc/isc/ev_timers.c \
+
 LOCAL_CFLAGS := \
     $(libc_common_cflags) \
     -DANDROID_CHANGES \
     -DINET6 \
+    -fvisibility=hidden \
     -I$(LOCAL_PATH)/dns/include \
     -I$(LOCAL_PATH)/private \
     -I$(LOCAL_PATH)/upstream-netbsd/lib/libc/include \
-    -include upstream-netbsd/android/include/netbsd-compat.h \
+    -I$(LOCAL_PATH)/upstream-netbsd/android/include \
+    -include netbsd-compat.h \
 #    -Werror \
 
 LOCAL_CONLYFLAGS := $(libc_common_conlyflags)
diff --git a/libc/dns/include/resolv_netid.h b/libc/dns/include/resolv_netid.h
index 991a0bf..63ecdd8 100644
--- a/libc/dns/include/resolv_netid.h
+++ b/libc/dns/include/resolv_netid.h
@@ -50,20 +50,24 @@
 
 struct addrinfo;
 
-struct hostent *android_gethostbyaddrfornet(const void *, socklen_t, int, unsigned, unsigned);
-struct hostent *android_gethostbyaddrfornet_proxy(const void *, socklen_t, int , unsigned);
-struct hostent *android_gethostbynamefornet(const char *, int, unsigned, unsigned);
+#define __used_in_netd __attribute__((visibility ("default")))
+
+struct hostent *android_gethostbyaddrfornet(const void *, socklen_t, int, unsigned, unsigned) __used_in_netd;
+struct hostent *android_gethostbynamefornet(const char *, int, unsigned, unsigned) __used_in_netd;
 int android_getaddrinfofornet(const char *, const char *, const struct addrinfo *, unsigned,
-		unsigned, struct addrinfo **);
-int android_getnameinfofornet(const struct sockaddr *, socklen_t, char *, size_t, char *, size_t,
-		 int, unsigned, unsigned);
+		unsigned, struct addrinfo **) __used_in_netd;
 
 /* set name servers for a network */
 extern void _resolv_set_nameservers_for_net(unsigned netid,
-    const char** servers, int numservers, const char *domains);
+    const char** servers, int numservers, const char *domains) __used_in_netd;
 
 /* flush the cache associated with a certain network */
-extern void _resolv_flush_cache_for_net(unsigned netid);
+extern void _resolv_flush_cache_for_net(unsigned netid) __used_in_netd;
+
+/* Internal use only. */
+struct hostent *android_gethostbyaddrfornet_proxy(const void *, socklen_t, int , unsigned);
+int android_getnameinfofornet(const struct sockaddr *, socklen_t, char *, size_t, char *, size_t,
+		 int, unsigned, unsigned);
 
 __END_DECLS
 
diff --git a/libc/include/netdb.h b/libc/include/netdb.h
index ead5954..527d5c1 100644
--- a/libc/include/netdb.h
+++ b/libc/include/netdb.h
@@ -196,6 +196,8 @@
 #define	SCOPE_DELIMITER	'%'
 
 __BEGIN_DECLS
+#pragma GCC visibility push(default)
+
 /* BIONIC-BEGIN */
 #define  h_errno   (*__get_h_errno())
 int*  __get_h_errno(void);
@@ -245,6 +247,7 @@
 void setnetgrent(const char *);
 void setservent(int);
 
+#pragma GCC visibility pop
 __END_DECLS
 
 #endif /* !_NETDB_H_ */
diff --git a/libc/include/resolv.h b/libc/include/resolv.h
index 36b93ee..c8899ed 100644
--- a/libc/include/resolv.h
+++ b/libc/include/resolv.h
@@ -37,6 +37,7 @@
 #include <netinet/in.h>
 
 __BEGIN_DECLS
+#pragma GCC visibility push(default)
 
 struct res_state;
 
@@ -52,6 +53,7 @@
 extern int dn_comp(const char*, u_char*, int, u_char**, u_char**);
 extern int dn_expand(const u_char*, const u_char*, const u_char*, char*, int);
 
+#pragma GCC visibility pop
 __END_DECLS
 
 #endif /* _RESOLV_H_ */