summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohnny Willemsen <jwillemsen@users.noreply.github.com>2016-09-11 11:18:32 +0200
committerGitHub <noreply@github.com>2016-09-11 11:18:32 +0200
commit4b78b50b8a0ebeb75a285d0f5c7240bb6bad7ca6 (patch)
tree02d203ba778333bd89d04a3fa7def23ed5070ca3
parent5a33d55ef56723226a3d4ac779ecd4fe96530c38 (diff)
parentf4bfd1ca023c8ea58aa3ca4147ff883b12ecde37 (diff)
downloadATCD-4b78b50b8a0ebeb75a285d0f5c7240bb6bad7ca6.tar.gz
Merge pull request #291 from ops/master
Take 2: Handle system functions that may be defined as macros on someā€¦
-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
-rw-r--r--ACE/ace/config-win32-borland.h2
-rw-r--r--ACE/ace/config-win32-mingw.h2
-rw-r--r--ACE/ace/config-win32-mingw64.h2
-rw-r--r--ACE/ace/config-win32-msvc-7.h1
-rw-r--r--ACE/ace/config-win32-msvc.h4
10 files changed, 67 insertions, 5 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..9db4d39204b 100644
--- a/ACE/ace/config-win32-msvc-7.h
+++ b/ACE/ace/config-win32-msvc-7.h
@@ -47,7 +47,6 @@
#define ACE_LACKS_STRPTIME
#define ACE_LACKS_STRTOK_R
-#define ACE_LACKS_LOCALTIME_R
#define ACE_HAS_SIG_ATOMIC_T
#define ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES
diff --git a/ACE/ace/config-win32-msvc.h b/ACE/ace/config-win32-msvc.h
index 7b4c7e6b9ee..65973367530 100644
--- a/ACE/ace/config-win32-msvc.h
+++ b/ACE/ace/config-win32-msvc.h
@@ -125,6 +125,10 @@
#define ACE_LACKS_TERMIOS_H
#define ACE_LACKS_REGEX_H
+#define ACE_LACKS_LOCALTIME_R
+#define ACE_LACKS_GMTIME_R
+#define ACE_LACKS_ASCTIME_R
+
#define ACE_INT64_FORMAT_SPECIFIER_ASCII "%I64d"
#define ACE_UINT64_FORMAT_SPECIFIER_ASCII "%I64u"