Chromium Code Reviews| Index: content/zygote/zygote_main_linux.cc |
| diff --git a/content/zygote/zygote_main_linux.cc b/content/zygote/zygote_main_linux.cc |
| index 21f54d8dfa9318328c7874b398c5da6dfa021cf9..36b1a8db2239b17518282cfe047c4bb546b7b7e3 100644 |
| --- a/content/zygote/zygote_main_linux.cc |
| +++ b/content/zygote/zygote_main_linux.cc |
| @@ -173,7 +173,9 @@ typedef int (*Xstat64Function)(int version, const char *path, |
| static pthread_once_t g_libc_localtime_funcs_guard = PTHREAD_ONCE_INIT; |
| static LocaltimeFunction g_libc_localtime; |
| +static LocaltimeFunction g_libc_localtime64; |
| static LocaltimeRFunction g_libc_localtime_r; |
| +static LocaltimeRFunction g_libc_localtime64_r; |
| static pthread_once_t g_libc_file_io_funcs_guard = PTHREAD_ONCE_INIT; |
| static FopenFunction g_libc_fopen; |
| @@ -184,8 +186,12 @@ static Xstat64Function g_libc_xstat64; |
| static void InitLibcLocaltimeFunctions() { |
| g_libc_localtime = reinterpret_cast<LocaltimeFunction>( |
| dlsym(RTLD_NEXT, "localtime")); |
| + g_libc_localtime64 = reinterpret_cast<LocaltimeFunction>( |
| + dlsym(RTLD_NEXT, "localtime64")); |
| g_libc_localtime_r = reinterpret_cast<LocaltimeRFunction>( |
| dlsym(RTLD_NEXT, "localtime_r")); |
| + g_libc_localtime64_r = reinterpret_cast<LocaltimeRFunction>( |
| + dlsym(RTLD_NEXT, "localtime64_r")); |
| if (!g_libc_localtime || !g_libc_localtime_r) { |
|
Jorge Lucangeli Obes
2012/05/16 02:59:45
Shouldn't you add checks for the *64 versions of t
hshi1
2012/05/16 17:36:16
Done.
|
| // http://code.google.com/p/chromium/issues/detail?id=16800 |
| @@ -205,7 +211,11 @@ static void InitLibcLocaltimeFunctions() { |
| g_libc_localtime_r = gmtime_r; |
| } |
| -struct tm* localtime(const time_t* timep) { |
| +__attribute__ ((__visibility__("default"))) |
|
Jorge Lucangeli Obes
2012/05/16 02:59:45
Why do we need the visibility annotations?
hshi1
2012/05/16 03:04:09
This is a copy&paste based on the fopen/fopen64 co
hshi1
2012/05/16 17:36:16
It appears to be useless. I would assume that visi
hshi1
2012/05/16 17:44:57
Sorry, I take this back. It appears that the visib
|
| +struct tm* localtime_override(const time_t* timep) __asm__ ("localtime"); |
| + |
| +__attribute__ ((__visibility__("default"))) |
| +struct tm* localtime_override(const time_t* timep) { |
| if (g_am_zygote_or_renderer) { |
| static struct tm time_struct; |
| static char timezone_string[64]; |
| @@ -219,7 +229,30 @@ struct tm* localtime(const time_t* timep) { |
| } |
| } |
| -struct tm* localtime_r(const time_t* timep, struct tm* result) { |
| +__attribute__ ((__visibility__("default"))) |
| +struct tm* localtime64_override(const time_t* timep) __asm__ ("localtime64"); |
| + |
| +__attribute__ ((__visibility__("default"))) |
| +struct tm* localtime64_override(const time_t* timep) { |
| + if (g_am_zygote_or_renderer) { |
| + static struct tm time_struct; |
| + static char timezone_string[64]; |
| + ProxyLocaltimeCallToBrowser(*timep, &time_struct, timezone_string, |
| + sizeof(timezone_string)); |
| + return &time_struct; |
| + } else { |
| + CHECK_EQ(0, pthread_once(&g_libc_localtime_funcs_guard, |
| + InitLibcLocaltimeFunctions)); |
| + return g_libc_localtime64(timep); |
| + } |
| +} |
| + |
| +__attribute__ ((__visibility__("default"))) |
| +struct tm* localtime_r_override(const time_t* timep, |
| + struct tm* result) __asm__ ("localtime_r"); |
| + |
| +__attribute__ ((__visibility__("default"))) |
| +struct tm* localtime_r_override(const time_t* timep, struct tm* result) { |
| if (g_am_zygote_or_renderer) { |
| ProxyLocaltimeCallToBrowser(*timep, result, NULL, 0); |
| return result; |
| @@ -230,6 +263,22 @@ struct tm* localtime_r(const time_t* timep, struct tm* result) { |
| } |
| } |
| +__attribute__ ((__visibility__("default"))) |
| +struct tm* localtime64_r_override(const time_t* timep, |
| + struct tm* result) __asm__ ("localtime64_r"); |
| + |
| +__attribute__ ((__visibility__("default"))) |
| +struct tm* localtime64_r_override(const time_t* timep, struct tm* result) { |
| + if (g_am_zygote_or_renderer) { |
| + ProxyLocaltimeCallToBrowser(*timep, result, NULL, 0); |
| + return result; |
| + } else { |
| + CHECK_EQ(0, pthread_once(&g_libc_localtime_funcs_guard, |
| + InitLibcLocaltimeFunctions)); |
| + return g_libc_localtime64_r(timep, result); |
| + } |
| +} |
| + |
| // TODO(sergeyu): Currently this code doesn't work properly under ASAN |
| // - it crashes content_unittests. Make sure it works properly and |
| // enable it here. http://crbug.com/123263 |