diff options
author | Olli Savia <ops@iki.fi> | 2016-09-09 17:47:40 +0300 |
---|---|---|
committer | Olli Savia <ops@iki.fi> | 2016-09-09 17:47:40 +0300 |
commit | c982c07989a3286e0f91705f0583b1ffad2dcda0 (patch) | |
tree | d628705a8c361d1f2ac353cf700fb9fd9ed801ee | |
parent | 376300884df0d01977f37baac26040e6bcee8e25 (diff) | |
download | ATCD-c982c07989a3286e0f91705f0583b1ffad2dcda0.tar.gz |
Take 2: Handle system functions that may be defined as macros on some platforms
-rw-r--r-- | ACE/ace/OS_NS_stdlib.h | 12 | ||||
-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 | 41 | ||||
-rw-r--r-- | ACE/ace/OS_NS_time.inl | 4 | ||||
-rw-r--r-- | ACE/ace/config-win32-borland.h | 2 | ||||
-rw-r--r-- | ACE/ace/config-win32-mingw.h | 2 | ||||
-rw-r--r-- | ACE/ace/config-win32-mingw64.h | 2 | ||||
-rw-r--r-- | ACE/ace/config-win32-msvc-7.h | 2 |
9 files changed, 65 insertions, 4 deletions
diff --git a/ACE/ace/OS_NS_stdlib.h b/ACE/ace/OS_NS_stdlib.h index c7b89a06fc3..6d5d0baf642 100644 --- a/ACE/ace/OS_NS_stdlib.h +++ b/ACE/ace/OS_NS_stdlib.h @@ -77,6 +77,18 @@ inline ACE_INT64 ace_strtoull_helper (const char *s, char **ptr, int base) } #endif /* !ACE_LACKS_STRTOULL && !ACE_STRTOULL_EQUIVALENT */ +#if !defined (ACE_LACKS_RAND_R) +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 */ +} +#endif /* !ACE_LACKS_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..dec111def52 100644 --- a/ACE/ace/OS_NS_time.h +++ b/ACE/ace/OS_NS_time.h @@ -90,6 +90,47 @@ 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. + */ +#if !defined (ACE_LACKS_ASCTIME_R) +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 /* asctime_r */ +} +#endif /* !ACE_LACKS_ASCTIME_R */ + +#if !defined (ACE_LACKS_GMTIME_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 /* gmtime_r */ +} +#endif /* !ACE_LACKS_GMTIME_R */ + +#if !defined (ACE_LACKS_LOCALTIME_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 /* localtime_r */ +} +#endif /* !ACE_LACKS_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..f066be30b60 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 @@ -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); diff --git a/ACE/ace/config-win32-borland.h b/ACE/ace/config-win32-borland.h index 316dcb26333..bae65845d21 100644 --- a/ACE/ace/config-win32-borland.h +++ b/ACE/ace/config-win32-borland.h @@ -154,6 +154,8 @@ #if (__BORLANDC__ <= 0x680) # define ACE_LACKS_LOCALTIME_R +# define ACE_LACKS_GMTIME_R +# define ACE_LACKS_ASCTIME_R #endif #define ACE_WCSDUP_EQUIVALENT ::_wcsdup diff --git a/ACE/ace/config-win32-mingw.h b/ACE/ace/config-win32-mingw.h index 36b61cf48cc..63a78386938 100644 --- a/ACE/ace/config-win32-mingw.h +++ b/ACE/ace/config-win32-mingw.h @@ -87,6 +87,8 @@ #define ACE_LACKS_PDHMSG_H #define ACE_LACKS_STRTOK_R #define ACE_LACKS_LOCALTIME_R +#define ACE_LACKS_GMTIME_R +#define ACE_LACKS_ASCTIME_R #define ACE_HAS_NONCONST_WCSDUP #define ACE_HAS_WINSOCK2_GQOS #define ACE_ISCTYPE_EQUIVALENT ::_isctype diff --git a/ACE/ace/config-win32-mingw64.h b/ACE/ace/config-win32-mingw64.h index 939b2663d37..e62150b5bc8 100644 --- a/ACE/ace/config-win32-mingw64.h +++ b/ACE/ace/config-win32-mingw64.h @@ -122,6 +122,8 @@ #define ACE_LACKS_PDHMSG_H #define ACE_LACKS_STRTOK_R #define ACE_LACKS_LOCALTIME_R +#define ACE_LACKS_GMTIME_R +#define ACE_LACKS_ASCTIME_R #define ACE_HAS_NONCONST_WCSDUP #define ACE_ISCTYPE_EQUIVALENT ::_isctype diff --git a/ACE/ace/config-win32-msvc-7.h b/ACE/ace/config-win32-msvc-7.h index 7aac881e6ec..3b4858a4984 100644 --- a/ACE/ace/config-win32-msvc-7.h +++ b/ACE/ace/config-win32-msvc-7.h @@ -48,6 +48,8 @@ #define ACE_LACKS_STRTOK_R #define ACE_LACKS_LOCALTIME_R +#define ACE_LACKS_GMTIME_R +#define ACE_LACKS_ASCTIME_R #define ACE_HAS_SIG_ATOMIC_T #define ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES |