summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohnny Willemsen <jwillemsen@users.noreply.github.com>2016-09-04 11:30:25 +0200
committerGitHub <noreply@github.com>2016-09-04 11:30:25 +0200
commite13ee56ffabd908059f5bc74c85d22370ea39412 (patch)
treefda21ad0ba4181f3c5a929bc6ad3ab26f663f8d0
parent0ce207c1a728b55cdb5a7cee832d89e6e47ff7b0 (diff)
parentc4f77c4178fbd6546342ddf55a2ffc92af91729c (diff)
downloadATCD-e13ee56ffabd908059f5bc74c85d22370ea39412.tar.gz
Merge pull request #262 from ops/master
Handle system functions that may be defined as macros on some platforms
-rw-r--r--ACE/ace/OS_NS_stdlib.h12
-rw-r--r--ACE/ace/OS_NS_stdlib.inl2
-rw-r--r--ACE/ace/OS_NS_time.cpp2
-rw-r--r--ACE/ace/OS_NS_time.h41
-rw-r--r--ACE/ace/OS_NS_time.inl4
5 files changed, 57 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..4fddbdb1571 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) && !defined (ACE_HAS_TR24731_2005_CRT)
+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 && !ACE_HAS_TR24731_2005_CRT */
+
+#if !defined (ACE_LACKS_GMTIME_R) && !defined (ACE_HAS_TR24731_2005_CRT)
+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 && !ACE_HAS_TR24731_2005_CRT */
+
+#if !defined (ACE_LACKS_LOCALTIME_R) && !defined (ACE_HAS_TR24731_2005_CRT)
+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 && !ACE_HAS_TR24731_2005_CRT */
#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);