diff options
author | Olli Savia <ops@iki.fi> | 2016-05-16 23:05:52 +0300 |
---|---|---|
committer | Olli Savia <ops@iki.fi> | 2016-05-16 23:05:52 +0300 |
commit | 93679e1d90c81ee76254a959d943ecc616e8ac84 (patch) | |
tree | fa068bc44a2141478cf0ec4316ea1265613d14b0 | |
parent | 6cb9f44e33a87619240b858a57630ac3d9d0d5de (diff) | |
download | ATCD-93679e1d90c81ee76254a959d943ecc616e8ac84.tar.gz |
Handle system functions that may be defined as macros on some platforms
-rw-r--r-- | ACE/ace/OS_NS_stdlib.h | 10 | ||||
-rw-r--r-- | ACE/ace/OS_NS_stdlib.inl | 2 | ||||
-rw-r--r-- | ACE/ace/OS_NS_time.cpp | 2 | ||||
-rw-r--r-- | ACE/ace/OS_NS_time.h | 45 | ||||
-rw-r--r-- | ACE/ace/OS_NS_time.inl | 6 |
5 files changed, 60 insertions, 5 deletions
diff --git a/ACE/ace/OS_NS_stdlib.h b/ACE/ace/OS_NS_stdlib.h index c7b89a06fc3..95e65410297 100644 --- a/ACE/ace/OS_NS_stdlib.h +++ b/ACE/ace/OS_NS_stdlib.h @@ -77,6 +77,16 @@ inline ACE_INT64 ace_strtoull_helper (const char *s, char **ptr, int base) } #endif /* !ACE_LACKS_STRTOULL && !ACE_STRTOULL_EQUIVALENT */ +inline int ace_rand_r_helper (unsigned *seed) +{ +#if defined (rand_r) + return rand_r (seed); +#undef rand_r +#else + return ACE_STD_NAMESPACE::rand_r (seed); +#endif /* rand_r */ +} + ACE_BEGIN_VERSIONED_NAMESPACE_DECL namespace ACE_OS { diff --git a/ACE/ace/OS_NS_stdlib.inl b/ACE/ace/OS_NS_stdlib.inl index 2c0f4c36991..cb59874b3cf 100644 --- a/ACE/ace/OS_NS_stdlib.inl +++ b/ACE/ace/OS_NS_stdlib.inl @@ -431,7 +431,7 @@ ACE_OS::rand_r (unsigned int *seed) *seed = (unsigned int)new_seed; return (int) (new_seed & RAND_MAX); #else - return ::rand_r (seed); + return ace_rand_r_helper (seed); # endif /* ACE_LACKS_RAND_R */ } diff --git a/ACE/ace/OS_NS_time.cpp b/ACE/ace/OS_NS_time.cpp index 3d4fcc93d47..2ab3c7ebe47 100644 --- a/ACE/ace/OS_NS_time.cpp +++ b/ACE/ace/OS_NS_time.cpp @@ -287,7 +287,7 @@ ACE_OS::localtime_r (const time_t *t, struct tm *res) return res; } #else - ACE_OSCALL_RETURN (::localtime_r (t, res), struct tm *, 0); + return ace_localtime_r_helper (t, res); #endif /* ACE_HAS_TR24731_2005_CRT */ } diff --git a/ACE/ace/OS_NS_time.h b/ACE/ace/OS_NS_time.h index 11d226ea28b..4ef60a3c8ab 100644 --- a/ACE/ace/OS_NS_time.h +++ b/ACE/ace/OS_NS_time.h @@ -90,6 +90,51 @@ inline long ace_timezone() #endif } +/* + * We inline and undef some functions that may be implemented + * as macros on some platforms. This way macro definitions will + * be usable later as there is no way to save the macro definition + * using the pre-processor. + */ +inline char *ace_asctime_r_helper (const struct tm *t, char *buf) +{ +#if defined (asctime_r) + return asctime_r (t, buf); +#undef asctime_r +#else + return ACE_STD_NAMESPACE::asctime_r (t, buf); +#endif /* defined (asctime_r) */ +} + +inline char *ace_ctime_r_helper (const time_t *t, char *bufp) +{ +#if defined (ctime_r) + return ctime_r (t, bufp); +#undef ctime_r +#else + return ACE_STD_NAMESPACE::ctime_r (t, bufp); +#endif /* defined (ctime_r) */ +} + +inline struct tm *ace_gmtime_r_helper (const time_t *clock, struct tm *res) +{ +#if defined (gmtime_r) + return gmtime_r (clock, res); +#undef gmtime_r +#else + return ACE_STD_NAMESPACE::gmtime_r (clock, res); +#endif /* defined (gmtime_r) */ +} + +inline struct tm *ace_localtime_r_helper (const time_t *clock, struct tm *res) +{ +#if defined (localtime_r) + return localtime_r (clock, res); +#undef localtime_r +#else + return ACE_STD_NAMESPACE::localtime_r (clock, res); +#endif /* defined (localtime_r) */ +} #if !defined (ACE_LACKS_DIFFTIME) # if defined (_WIN32_WCE) && ((_WIN32_WCE >= 0x600) && (_WIN32_WCE <= 0x700)) && !defined (_USE_32BIT_TIME_T) \ diff --git a/ACE/ace/OS_NS_time.inl b/ACE/ace/OS_NS_time.inl index c821530bc82..48468ce2837 100644 --- a/ACE/ace/OS_NS_time.inl +++ b/ACE/ace/OS_NS_time.inl @@ -26,7 +26,7 @@ ACE_OS::asctime_r (const struct tm *t, char *buf, int buflen) #if defined (ACE_HAS_REENTRANT_FUNCTIONS) # if defined (ACE_HAS_2_PARAM_ASCTIME_R_AND_CTIME_R) char *result = 0; - ACE_OSCALL (::asctime_r (t, buf), char *, 0, result); + ace_asctime_r_helper (t, buf); ACE_OS::strsncpy (buf, result, buflen); return buf; # else @@ -143,7 +143,7 @@ ACE_OS::ctime_r (const time_t *t, ACE_TCHAR *buf, int buflen) return 0; } # if defined (ACE_HAS_2_PARAM_ASCTIME_R_AND_CTIME_R) - ACE_OSCALL (::ctime_r (t, bufp), char *, 0, bufp); + return ace_ctime_r_helper (t, bufp); # else /* ACE_HAS_2_PARAM_ASCTIME_R_AND_CTIME_R */ # if defined (ACE_HAS_SIZET_PTR_ASCTIME_R_AND_CTIME_R) @@ -375,7 +375,7 @@ ACE_OS::gmtime_r (const time_t *t, struct tm *res) { ACE_OS_TRACE ("ACE_OS::gmtime_r"); #if defined (ACE_HAS_REENTRANT_FUNCTIONS) - ACE_OSCALL_RETURN (::gmtime_r (t, res), struct tm *, 0); + return ace_gmtime_r_helper (t, res); #elif defined (ACE_HAS_TR24731_2005_CRT) struct tm *tm_p = res; ACE_SECURECRTCALL (gmtime_s (res, t), struct tm *, 0, tm_p); |