Build tzcode with hidden visibility.

Bug: 11156955
Change-Id: Ib98d837b56cbbdfd01687cb3054fe3103eec0da9
diff --git a/libc/Android.mk b/libc/Android.mk
index 4ed9468..a6298a0 100644
--- a/libc/Android.mk
+++ b/libc/Android.mk
@@ -585,7 +585,10 @@
 # tzcode doesn't include wcsftime, so we use the OpenBSD one.
 LOCAL_SRC_FILES += upstream-openbsd/lib/libc/time/wcsftime.c
 
-LOCAL_CFLAGS := $(libc_common_cflags)
+LOCAL_CFLAGS := $(libc_common_cflags) \
+    -fvisibility=hidden \
+    -Werror \
+
 # Don't use ridiculous amounts of stack.
 LOCAL_CFLAGS += -DALL_STATE
 # Include tzsetwall, timelocal, timegm, time2posix, and posix2time.
@@ -597,7 +600,7 @@
 # Include timezone and daylight globals.
 LOCAL_CFLAGS += -DUSG_COMPAT=1
 LOCAL_CFLAGS += -DNO_RUN_TIME_WARNINGS_ABOUT_YEAR_2000_PROBLEMS_THANK_YOU
-LOCAL_CFLAGS += -Dlint -Werror
+LOCAL_CFLAGS += -Dlint
 
 LOCAL_CONLYFLAGS := $(libc_common_conlyflags)
 LOCAL_CPPFLAGS := $(libc_common_cppflags)
diff --git a/libc/include/time.h b/libc/include/time.h
index 0f86fd3..a1f5260 100644
--- a/libc/include/time.h
+++ b/libc/include/time.h
@@ -58,44 +58,43 @@
 
 #define TM_ZONE tm_zone
 
-extern time_t time(time_t*);
-extern int nanosleep(const struct timespec*, struct timespec*);
+extern time_t time(time_t*) __LIBC_ABI_PUBLIC__;
+extern int nanosleep(const struct timespec*, struct timespec*) __LIBC_ABI_PUBLIC__;
 
-extern char* asctime(const struct tm*);
-extern char* asctime_r(const struct tm*, char*);
+extern char* asctime(const struct tm*) __LIBC_ABI_PUBLIC__;
+extern char* asctime_r(const struct tm*, char*) __LIBC_ABI_PUBLIC__;
 
-extern double difftime(time_t, time_t);
-extern time_t mktime(struct tm*);
+extern double difftime(time_t, time_t) __LIBC_ABI_PUBLIC__;
+extern time_t mktime(struct tm*) __LIBC_ABI_PUBLIC__;
 
-extern struct tm* localtime(const time_t*);
-extern struct tm* localtime_r(const time_t*, struct tm*);
+extern struct tm* localtime(const time_t*) __LIBC_ABI_PUBLIC__;
+extern struct tm* localtime_r(const time_t*, struct tm*) __LIBC_ABI_PUBLIC__;
 
-extern struct tm* gmtime(const time_t*);
-extern struct tm* gmtime_r(const time_t*, struct tm*);
+extern struct tm* gmtime(const time_t*) __LIBC_ABI_PUBLIC__;
+extern struct tm* gmtime_r(const time_t*, struct tm*) __LIBC_ABI_PUBLIC__;
 
-extern char* strptime(const char*, const char*, struct tm*);
-extern size_t strftime(char*, size_t, const char*, const struct tm*);
+extern char* strptime(const char*, const char*, struct tm*) __LIBC_ABI_PUBLIC__;
+extern size_t strftime(char*, size_t, const char*, const struct tm*) __LIBC_ABI_PUBLIC__;
 
-extern char* ctime(const time_t*);
-extern char* ctime_r(const time_t*, char*);
+extern char* ctime(const time_t*) __LIBC_ABI_PUBLIC__;
+extern char* ctime_r(const time_t*, char*) __LIBC_ABI_PUBLIC__;
 
-extern void tzset(void);
+extern void tzset(void) __LIBC_ABI_PUBLIC__;
 
-extern clock_t clock(void);
+extern clock_t clock(void) __LIBC_ABI_PUBLIC__;
 
-extern int clock_getres(int, struct timespec*);
-extern int clock_gettime(int, struct timespec*);
+extern int clock_getres(int, struct timespec*) __LIBC_ABI_PUBLIC__;
+extern int clock_gettime(int, struct timespec*) __LIBC_ABI_PUBLIC__;
 
-extern int timer_create(int, struct sigevent*, timer_t*);
-extern int timer_delete(timer_t);
-extern int timer_settime(timer_t, int, const struct itimerspec*, struct itimerspec*);
-extern int timer_gettime(timer_t, struct itimerspec*);
-extern int timer_getoverrun(timer_t);
+extern int timer_create(int, struct sigevent*, timer_t*) __LIBC_ABI_PUBLIC__;
+extern int timer_delete(timer_t) __LIBC_ABI_PUBLIC__;
+extern int timer_settime(timer_t, int, const struct itimerspec*, struct itimerspec*) __LIBC_ABI_PUBLIC__;
+extern int timer_gettime(timer_t, struct itimerspec*) __LIBC_ABI_PUBLIC__;
+extern int timer_getoverrun(timer_t) __LIBC_ABI_PUBLIC__;
 
-extern time_t timelocal(struct tm*);
-extern time_t timegm(struct tm*);
-extern time_t time2posix(time_t);
-extern time_t posix2time(time_t);
+/* Non-standard extensions that are in the BSDs and glibc. */
+extern time_t timelocal(struct tm*) __LIBC_ABI_PUBLIC__;
+extern time_t timegm(struct tm*) __LIBC_ABI_PUBLIC__;
 
 __END_DECLS
 
diff --git a/libc/include/wchar.h b/libc/include/wchar.h
index d50e9ec..014fed3 100644
--- a/libc/include/wchar.h
+++ b/libc/include/wchar.h
@@ -118,7 +118,7 @@
 extern int               wcscoll(const wchar_t *, const wchar_t *);
 extern wchar_t          *wcscpy(wchar_t *, const wchar_t *);
 extern size_t            wcscspn(const wchar_t *, const wchar_t *);
-extern size_t            wcsftime(wchar_t *, size_t, const wchar_t *, const struct tm *);
+extern size_t            wcsftime(wchar_t *, size_t, const wchar_t *, const struct tm *) __LIBC_ABI_PUBLIC__;
 extern size_t            wcslen(const wchar_t *);
 extern int               wcsncasecmp(const wchar_t *, const wchar_t *, size_t);
 extern wchar_t          *wcsncat(wchar_t *, const wchar_t *, size_t);
diff --git a/libc/private/bionic_time.h b/libc/private/bionic_time.h
index 7c80f59..ca5c146 100644
--- a/libc/private/bionic_time.h
+++ b/libc/private/bionic_time.h
@@ -52,10 +52,11 @@
 
 /*
  * Note: you should consider these extensions deprecated and use managed code or icu4c instead.
+ * We'd like to hide them but they're currently still used in frameworks code.
  */
-extern size_t strftime_tz(char* s, size_t max, const char* format, const struct tm* tm, const struct strftime_locale* lc);
-extern time_t mktime_tz(struct tm* const tmp, char const* tz);
-extern void localtime_tz(const time_t* const timep, struct tm* tmp, const char* tz);
+extern size_t strftime_tz(char*, size_t, const char*, const struct tm*, const struct strftime_locale*);
+extern time_t mktime_tz(struct tm* const, char const*);
+extern void localtime_tz(const time_t* const, struct tm*, const char*);
 
 #endif /* _BIONIC_STRFTIME_TZ_DECLARED */
 
diff --git a/libc/tzcode/localtime.c b/libc/tzcode/localtime.c
index f0fd9e3..4dd7ab0 100644
--- a/libc/tzcode/localtime.c
+++ b/libc/tzcode/localtime.c
@@ -2293,7 +2293,7 @@
 }
 
 // Non-standard API: mktime(3) but with an explicit timezone parameter.
-time_t mktime_tz(struct tm* const tmp, const char* tz) {
+time_t __attribute__((visibility("default"))) mktime_tz(struct tm* const tmp, const char* tz) {
   struct state* st = malloc(sizeof(*st));
   time_t return_value;
 
@@ -2310,7 +2310,7 @@
 }
 
 // Non-standard API: localtime(3) but with an explicit timezone parameter.
-void localtime_tz(const time_t* const timep, struct tm* tmp, const char* tz) {
+void __attribute__((visibility("default"))) localtime_tz(const time_t* const timep, struct tm* tmp, const char* tz) {
   struct state* st = malloc(sizeof(*st));
 
   if (st == NULL)
diff --git a/libc/tzcode/strftime.c b/libc/tzcode/strftime.c
index a926164..f996f48 100644
--- a/libc/tzcode/strftime.c
+++ b/libc/tzcode/strftime.c
@@ -144,7 +144,7 @@
 }
 
 size_t
-strftime_tz(s, maxsize, format, t, locale)
+__attribute__((visibility("default"))) strftime_tz(s, maxsize, format, t, locale)
 char * const        s;
 const size_t        maxsize;
 const char * const  format;