summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ACE/NEWS8
-rw-r--r--ACE/ace/OS_NS_Thread.cpp108
-rw-r--r--ACE/ace/OS_NS_Thread.h5
-rw-r--r--ACE/ace/OS_NS_signal.inl8
-rw-r--r--ACE/ace/OS_NS_stdlib.cpp65
-rw-r--r--ACE/ace/Stack_Trace.cpp30
-rw-r--r--ACE/ace/Time_Value.h127
-rw-r--r--ACE/ace/Time_Value.inl158
-rw-r--r--ACE/ace/config-vxworks.h19
-rw-r--r--ACE/tests/Chrono_Test.cpp592
-rw-r--r--ACE/tests/run_test.lst1
-rw-r--r--ACE/tests/tests.mpc7
-rw-r--r--TAO/tao/PortableServer/PortableServer_Functions.cpp7
13 files changed, 1023 insertions, 112 deletions
diff --git a/ACE/NEWS b/ACE/NEWS
index ca95cd212f7..ead8d8db44f 100644
--- a/ACE/NEWS
+++ b/ACE/NEWS
@@ -1,6 +1,14 @@
USER VISIBLE CHANGES BETWEEN ACE-6.3.1 and ACE-6.3.2
====================================================
+. Added support for std::chrono to ACE_Time_Value. It's
+ now possible to construct an ACE_Time_Value with a
+ std::duration. Also streaming, adding and substracting
+ an ACE_Time_Value to and from a std::duration is
+ supported. Please see tests/Chrono_Test.cpp for more
+ details.
+
+
USER VISIBLE CHANGES BETWEEN ACE-6.3.0 and ACE-6.3.1
====================================================
diff --git a/ACE/ace/OS_NS_Thread.cpp b/ACE/ace/OS_NS_Thread.cpp
index a5bc7c4f836..2eeb79a580b 100644
--- a/ACE/ace/OS_NS_Thread.cpp
+++ b/ACE/ace/OS_NS_Thread.cpp
@@ -4436,9 +4436,9 @@ ACE_OS::thr_create (ACE_THR_FUNC func,
tid = ::taskSpawn (thr_name && *thr_name ? const_cast <char*> (*thr_name) : 0,
priority,
(int) flags,
- (int) stacksize,
+ stacksize,
thread_args->entry_point (),
- (int) thread_args,
+ (ACE_VX_USR_ARG_T) thread_args,
0, 0, 0, 0, 0, 0, 0, 0, 0);
# if 0 /* Don't support setting of stack, because it doesn't seem to work. */
}
@@ -4472,7 +4472,7 @@ ACE_OS::thr_create (ACE_THR_FUNC func,
}
# endif /* 0 */
- if (tid == ERROR)
+ if (tid == ACE_VX_TASK_ID_ERROR)
return -1;
else
{
@@ -4560,8 +4560,8 @@ ACE_OS::thr_exit (ACE_THR_FUNC_RETURN status)
# endif /* ACE_HAS_MFC && ACE_HAS_MFS != 0*/
# elif defined (ACE_HAS_VXTHREADS)
- ACE_thread_t tid = ACE_OS::thr_self ();
- *((int *) status) = ::taskDelete (tid);
+ ACE_UNUSED_ARG (status);
+ ::taskDelete (ACE_OS::thr_self ());
# endif /* ACE_HAS_PTHREADS */
#else
ACE_UNUSED_ARG (status);
@@ -5132,10 +5132,12 @@ ACE_END_VERSIONED_NAMESPACE_DECL
int
spa (FUNCPTR entry, ...)
{
- static const unsigned int ACE_MAX_ARGS = 10;
+ // The called entrypoint can get the function name plus the normal 10
+ // optional arguments.
+ static ACE_VX_USR_ARG_T const ACE_MAX_ARGS = 1 + 10;
static char *argv[ACE_MAX_ARGS] = { 0 };
va_list pvar;
- unsigned int argc;
+ ACE_VX_USR_ARG_T argc;
// Hardcode a program name because the real one isn't available
// through the VxWorks shell.
@@ -5149,7 +5151,7 @@ spa (FUNCPTR entry, ...)
// number of arguments would have to be passed.
va_start (pvar, entry);
- for (argc = 1; argc <= ACE_MAX_ARGS; ++argc)
+ for (argc = 1; argc < ACE_MAX_ARGS; ++argc)
{
argv[argc] = va_arg (pvar, char *);
@@ -5157,41 +5159,45 @@ spa (FUNCPTR entry, ...)
break;
}
- if (argc > ACE_MAX_ARGS && argv[argc-1] != 0)
+ if (argc >= ACE_MAX_ARGS && argv[ACE_MAX_ARGS - 1] != 0)
{
- // try to read another arg, and warn user if the limit was exceeded
+ // Try to read another arg, and warn user if the limit was exceeded.
+ //
+ // Note that the VxWorks shell arguments change from int to long when
+ // using a 64bit compiler. Cast the argument up so that the format
+ // specifier remains correct for either build type.
if (va_arg (pvar, char *) != 0)
- ACE_OS::fprintf (stderr, "spa(): number of arguments limited to %d\n",
- ACE_MAX_ARGS);
+ ACE_OS::fprintf (stderr, "spa(): number of arguments limited to %ld\n",
+ (long)ACE_MAX_ARGS);
}
else
{
// fill unused argv slots with 0 to get rid of leftovers
// from previous invocations
- for (unsigned int i = argc; i <= ACE_MAX_ARGS; ++i)
+ for (ACE_VX_USR_ARG_T i = argc; i < ACE_MAX_ARGS; ++i)
argv[i] = 0;
}
// The hard-coded options are what ::sp () uses, except for the
// larger stack size (instead of ::sp ()'s 20000).
- int const ret = ::taskSpawn (argv[0], // task name
- 100, // task priority
- VX_FP_TASK, // task options
- ACE_NEEDS_HUGE_THREAD_STACKSIZE, // stack size
- entry, // entry point
- argc, // first argument to main ()
- (int) argv, // second argument to main ()
- 0, 0, 0, 0, 0, 0, 0, 0);
+ ACE_VX_TASK_ID const ret = ::taskSpawn (argv[0], // task name
+ 100, // task priority
+ VX_FP_TASK, // task options
+ ACE_NEEDS_HUGE_THREAD_STACKSIZE, // stack size
+ entry, // entry point
+ argc, // first argument to main ()
+ (ACE_VX_USR_ARG_T) argv, // second argument to main ()
+ 0, 0, 0, 0, 0, 0, 0, 0);
va_end (pvar);
// ::taskSpawn () returns the taskID on success: return 0 instead if
// successful
- return ret > 0 ? 0 : ret;
+ return ret > 0 ? 0 : -1;
}
// A helper function for the extended spa functions
static void
-add_to_argv (int& argc, char** argv, int max_args, char* string)
+add_to_argv (ACE_VX_USR_ARG_T& argc, char** argv, int max_args, char* string)
{
char indouble = 0;
size_t previous = 0;
@@ -5267,10 +5273,10 @@ int
spae (FUNCPTR entry, ...)
{
static int const WINDSH_ARGS = 10;
- static int const ACE_MAX_ARGS = 128;
+ static ACE_VX_USR_ARG_T const ACE_MAX_ARGS = 128;
static char* argv[ACE_MAX_ARGS] = { const_cast<char*> ("ace_main"), 0 };
va_list pvar;
- int argc = 1;
+ ACE_VX_USR_ARG_T argc = 1;
// Peel off arguments to spa () and put into argv. va_arg () isn't
// necessarily supposed to return 0 when done, though since the
@@ -5292,19 +5298,19 @@ spae (FUNCPTR entry, ...)
// The hard-coded options are what ::sp () uses, except for the
// larger stack size (instead of ::sp ()'s 20000).
- int const ret = ::taskSpawn (argv[0], // task name
- 100, // task priority
- VX_FP_TASK, // task options
- ACE_NEEDS_HUGE_THREAD_STACKSIZE, // stack size
- entry, // entry point
- argc, // first argument to main ()
- (int) argv, // second argument to main ()
- 0, 0, 0, 0, 0, 0, 0, 0);
+ ACE_VX_TASK_ID const ret = ::taskSpawn (argv[0], // task name
+ 100, // task priority
+ VX_FP_TASK, // task options
+ ACE_NEEDS_HUGE_THREAD_STACKSIZE, // stack size
+ entry, // entry point
+ argc, // first argument to main ()
+ (ACE_VX_USR_ARG_T) argv, // second argument to main ()
+ 0, 0, 0, 0, 0, 0, 0, 0);
va_end (pvar);
// ::taskSpawn () returns the taskID on success: return 0 instead if
// successful
- return ret > 0 ? 0 : ret;
+ return ret > 0 ? 0 : -1;
}
// This global function can be used from the VxWorks shell to pass
@@ -5321,10 +5327,10 @@ int
spaef (FUNCPTR entry, ...)
{
static int const WINDSH_ARGS = 10;
- static int const ACE_MAX_ARGS = 128;
+ static ACE_VX_USR_ARG_T const ACE_MAX_ARGS = 128;
static char* argv[ACE_MAX_ARGS] = { const_cast<char*> ("ace_main"), 0 };
va_list pvar;
- int argc = 1;
+ ACE_VX_USR_ARG_T argc = 1;
// Peel off arguments to spa () and put into argv. va_arg () isn't
// necessarily supposed to return 0 when done, though since the
@@ -5371,11 +5377,11 @@ _vx_call_entry(FUNCPTR entry, int argc, char* argv[])
}
int
-vx_execae (FUNCPTR entry, char* arg, int prio, int opt, int stacksz, ...)
+vx_execae (FUNCPTR entry, char* arg, int prio, int opt, size_t stacksz, ...)
{
- static int const ACE_MAX_ARGS = 128;
+ static ACE_VX_USR_ARG_T const ACE_MAX_ARGS = 128;
static char* argv[ACE_MAX_ARGS] = { const_cast<char*> ("ace_main"), 0 };
- int argc = 1;
+ ACE_VX_USR_ARG_T argc = 1;
// Peel off arguments to run_main () and put into argv.
if (arg)
@@ -5385,22 +5391,22 @@ vx_execae (FUNCPTR entry, char* arg, int prio, int opt, int stacksz, ...)
// fill unused argv slots with 0 to get rid of leftovers
// from previous invocations
- for (int i = argc; i < ACE_MAX_ARGS; ++i)
+ for (ACE_VX_USR_ARG_T i = argc; i < ACE_MAX_ARGS; ++i)
argv[i] = 0;
// The hard-coded options are what ::sp () uses, except for the
// larger stack size (instead of ::sp ()'s 20000).
- int const ret = ::taskSpawn (argv[0], // task name
- prio==0 ? 100 : prio, // task priority
- opt==0 ? VX_FP_TASK : opt, // task options
- stacksz==0 ? ACE_NEEDS_HUGE_THREAD_STACKSIZE : stacksz, // stack size
- (FUNCPTR)_vx_call_entry, // entrypoint caller
- (int)entry, // entry point
- argc, // first argument to main ()
- (int) argv, // second argument to main ()
- 0, 0, 0, 0, 0, 0, 0);
-
- if (ret == ERROR)
+ ACE_VX_TASK_ID const ret = ::taskSpawn (argv[0], // task name
+ prio==0 ? 100 : prio, // task priority
+ opt==0 ? VX_FP_TASK : opt, // task options
+ stacksz==0 ? ACE_NEEDS_HUGE_THREAD_STACKSIZE : stacksz, // stack size
+ (FUNCPTR)_vx_call_entry, // entrypoint caller
+ (ACE_VX_USR_ARG_T)entry, // entry point
+ argc, // first argument to main ()
+ (ACE_VX_USR_ARG_T) argv, // second argument to main ()
+ 0, 0, 0, 0, 0, 0, 0);
+
+ if (ret == ACE_VX_TASK_ID_ERROR)
return 255;
while( ret > 0 && ::taskIdVerify (ret) != ERROR )
diff --git a/ACE/ace/OS_NS_Thread.h b/ACE/ace/OS_NS_Thread.h
index 42a48ee93e0..ce79d69198d 100644
--- a/ACE/ace/OS_NS_Thread.h
+++ b/ACE/ace/OS_NS_Thread.h
@@ -160,6 +160,7 @@ ACE_END_VERSIONED_NAMESPACE_DECL
# elif defined (ACE_VXWORKS)
# include /**/ <sysLib.h> // for sysClkRateGet()
+# include /**/ <types/vxTypes.h>
# if !defined (__RTP__)
# include /**/ <taskLib.h>
# include /**/ <taskHookLib.h>
@@ -228,8 +229,8 @@ typedef struct
char *name_;
} ACE_sema_t;
# endif /* !ACE_HAS_POSIX_SEM */
-typedef int ACE_thread_t;
-typedef int ACE_hthread_t;
+typedef ACE_VX_TASK_ID ACE_thread_t;
+typedef ACE_VX_TASK_ID ACE_hthread_t;
// Key type: the ACE TSS emulation requires the key type be unsigned,
// for efficiency. (Current POSIX and Solaris TSS implementations also
// use u_int, so the ACE TSS emulation is compatible with them.)
diff --git a/ACE/ace/OS_NS_signal.inl b/ACE/ace/OS_NS_signal.inl
index 562d2701f33..2872f27439a 100644
--- a/ACE/ace/OS_NS_signal.inl
+++ b/ACE/ace/OS_NS_signal.inl
@@ -15,6 +15,14 @@ kill (pid_t pid, int signum)
ACE_UNUSED_ARG (pid);
ACE_UNUSED_ARG (signum);
ACE_NOTSUP_RETURN (-1);
+#elif defined (ACE_VXWORKS)
+ /*
+ * The VxWorks kill interface is not really POSIX
+ * since they use a task id in place of a pid type.
+ * This only becomes an issue when using the 64bit compiler
+ * as the TASK_ID is no longer defined as an int.
+ */
+ ACE_OSCALL_RETURN (::kill ((ACE_VX_TASK_ID)pid, signum), int, -1);
#else
ACE_OSCALL_RETURN (::kill (pid, signum), int, -1);
#endif /* ACE_LACKS_KILL */
diff --git a/ACE/ace/OS_NS_stdlib.cpp b/ACE/ace/OS_NS_stdlib.cpp
index 0d8fd91ac7a..3526b9f74d6 100644
--- a/ACE/ace/OS_NS_stdlib.cpp
+++ b/ACE/ace/OS_NS_stdlib.cpp
@@ -283,47 +283,40 @@ ACE_OS::mktemp (ACE_TCHAR *s)
if (s == 0)
// check for null template string failed!
return 0;
- else
- {
- ACE_TCHAR *xxxxxx = ACE_OS::strstr (s, ACE_TEXT ("XXXXXX"));
- if (xxxxxx == 0)
- // the template string doesn't contain "XXXXXX"!
- return s;
- else
+ ACE_TCHAR *xxxxxx = ACE_OS::strstr (s, ACE_TEXT ("XXXXXX"));
+ if (xxxxxx == 0)
+ // the template string doesn't contain "XXXXXX"!
+ return s;
+
+ // Find an unused filename for this process. It is assumed
+ // that the user will open the file immediately after
+ // getting this filename back (so, yes, there is a race
+ // condition if multiple threads in a process use the same
+ // template). This appears to match the behavior of the
+ // SunOS 5.5 mktemp().
+ bool found = false;
+ for (ACE_TCHAR letter = ACE_TEXT ('a');
+ letter <= ACE_TEXT ('z');
+ ++letter)
+ {
+ ACE_stat sb;
+ ACE_OS::sprintf (xxxxxx,
+ ACE_TEXT ("%05d%c"),
+ (int)ACE_OS::getpid () % 100000,
+ letter);
+ if (ACE_OS::stat (s, &sb) < 0)
{
- ACE_TCHAR unique_letter = ACE_TEXT ('a');
- ACE_stat sb;
-
- // Find an unused filename for this process. It is assumed
- // that the user will open the file immediately after
- // getting this filename back (so, yes, there is a race
- // condition if multiple threads in a process use the same
- // template). This appears to match the behavior of the
- // SunOS 5.5 mktemp().
- ACE_OS::sprintf (xxxxxx,
- ACE_TEXT ("%05d%c"),
- ACE_OS::getpid (),
- unique_letter);
- while (ACE_OS::stat (s, &sb) >= 0)
- {
- if (++unique_letter <= ACE_TEXT ('z'))
- ACE_OS::sprintf (xxxxxx,
- ACE_TEXT ("%05d%c"),
- ACE_OS::getpid (),
- unique_letter);
- else
- {
- // maximum of 26 unique files per template, per process
- ACE_OS::sprintf (xxxxxx, ACE_TEXT ("%s"), ACE_TEXT (""));
- return s;
- }
- }
+ found = true;
+ break;
}
- return s;
}
+ if (!found)
+ // maximum of 26 unique files per template, per process
+ ACE_OS::sprintf (xxxxxx, ACE_TEXT ("%s"), ACE_TEXT (""));
+ return s;
}
-#endif /* ACE_LACKS_MKTEMP &7 !ACE_DISABLE_MKTEMP */
+#endif /* ACE_LACKS_MKTEMP && !ACE_DISABLE_MKTEMP */
void *
ACE_OS::realloc (void *ptr, size_t nbytes)
diff --git a/ACE/ace/Stack_Trace.cpp b/ACE/ace/Stack_Trace.cpp
index 582941a7b4b..9836a0e1f8a 100644
--- a/ACE/ace/Stack_Trace.cpp
+++ b/ACE/ace/Stack_Trace.cpp
@@ -123,9 +123,9 @@ static ACE_Stack_Trace_stackstate* ACE_Stack_Trace_stateptr = 0;
static void
ACE_Stack_Trace_Add_Frame_To_Buf (INSTR *caller,
- unsigned int func,
- unsigned int nargs,
- unsigned int *args)
+ INSTR *func,
+ int nargs,
+ ACE_VX_USR_ARG_T *args)
{
if (ACE_Stack_Trace_stateptr == 0)
return;
@@ -143,20 +143,21 @@ ACE_Stack_Trace_Add_Frame_To_Buf (INSTR *caller,
// These are references so that the structure gets updated
// in the code below.
char*& buf = stackstate->buf;
- unsigned int& len = stackstate->buflen;
+ size_t& len = stackstate->buflen;
// At some point try using symFindByValue() to lookup func (and caller?)
// to print out symbols rather than simply addresses.
// VxWorks can pass -1 for "nargs" if there was an error
- if (nargs == static_cast<unsigned int> (-1)) nargs = 0;
+ if (nargs == -1)
+ nargs = 0;
- len += ACE_OS::sprintf (&buf[len], "%#10x: %#10x (", (int)caller, func);
- for (unsigned int i = 0; i < nargs; ++i)
+ len += ACE_OS::sprintf (&buf[len], "%p: %p (", caller, func);
+ for (int i = 0; i < nargs; ++i)
{
if (i != 0)
len += ACE_OS::sprintf (&buf[len], ", ");
- len += ACE_OS::sprintf(&buf [len], "%#x", args [i]);
+ len += ACE_OS::sprintf(&buf[len], "0x" ACE_VX_ARG_FORMAT, args[i]);
}
len += ACE_OS::sprintf(&buf[len], ")\n");
@@ -180,7 +181,7 @@ ACE_Stack_Trace::generate_trace (ssize_t starting_frame_offset,
REG_SET regs;
- taskRegsGet ((int)taskIdSelf(), &regs);
+ taskRegsGet (taskIdSelf(), &regs);
// Maybe we should take a lock here to guard stateptr?
ACE_Stack_Trace_stateptr = &state;
trcStack (&regs, (FUNCPTR)ACE_Stack_Trace_Add_Frame_To_Buf, taskIdSelf ());
@@ -252,17 +253,6 @@ ACE_Stack_Trace::generate_trace (ssize_t starting_frame_offset,
const char *fnName = "(no symbols)";
static const int N_ARGS = 12;
-#if (ACE_VXWORKS < 0x690)
-# define ACE_VX_USR_ARG_T int
-# define ACE_VX_ARG_FORMAT "%x"
-#else
-# define ACE_VX_USR_ARG_T _Vx_usr_arg_t
-# ifdef _WRS_CONFIG_LP64
-# define ACE_VX_ARG_FORMAT "%lx"
-# else
-# define ACE_VX_ARG_FORMAT "%x"
-# endif
-#endif
ACE_VX_USR_ARG_T buf[N_ARGS];
ACE_VX_USR_ARG_T *pArgs = 0;
int numArgs =
diff --git a/ACE/ace/Time_Value.h b/ACE/ace/Time_Value.h
index bb0351c97be..4f7b011a3b0 100644
--- a/ACE/ace/Time_Value.h
+++ b/ACE/ace/Time_Value.h
@@ -21,6 +21,10 @@
# include "ace/os_include/os_time.h"
+#if defined (ACE_HAS_CPP11)
+#include <chrono>
+#endif /* ACE_HAS_CPP11 */
+
// Define some helpful constants.
// Not type-safe, and signed. For backward compatibility.
#define ACE_ONE_SECOND_IN_MSECS 1000L
@@ -78,6 +82,15 @@ public:
/// Construct the ACE_Time_Value object from a timespec_t.
explicit ACE_Time_Value (const timespec_t &t);
+#if defined (ACE_HAS_CPP11)
+ /// Construct the ACE_Time_Value object from a chrono duration.
+ template< class Rep, class Period >
+ explicit ACE_Time_Value (const std::chrono::duration<Rep, Period>& duration)
+ {
+ this->set (duration);
+ }
+#endif /* ACE_HAS_CPP11 */
+
/// Destructor
virtual ~ACE_Time_Value ();
@@ -100,10 +113,25 @@ public:
void set (const timespec_t &t);
# if defined (ACE_WIN32)
- /// Initializes the ACE_Time_Value object from a Win32 FILETIME.
+ /// Initializes the ACE_Time_Value object from a Win32 FILETIME.
void set (const FILETIME &ft);
# endif /* ACE_WIN32 */
+#if defined (ACE_HAS_CPP11)
+ /// Initializes the ACE_Time_Value object from a std::duration.
+ template< class Rep, class Period >
+ void set (const std::chrono::duration<Rep, Period>& duration)
+ {
+ std::chrono::seconds const s {
+ std::chrono::duration_cast<std::chrono::seconds> (duration)};
+
+ std::chrono::microseconds const usec {
+ std::chrono::duration_cast<std::chrono::microseconds>(
+ duration % std::chrono::seconds (1))};
+ this->set (s.count (), usec.count ());
+ }
+#endif /* ACE_HAS_CPP11 */
+
/// Converts from ACE_Time_Value format into milliseconds format.
/**
* @return Sum of second field (in milliseconds) and microsecond field
@@ -232,10 +260,10 @@ public:
/// Add @a tv to this.
ACE_Time_Value &operator += (time_t tv);
- /// Assign @ tv to this
+ /// Assign @a tv to this
ACE_Time_Value &operator = (const ACE_Time_Value &tv);
- /// Assign @ tv to this
+ /// Assign @a tv to this
ACE_Time_Value &operator = (time_t tv);
/// Subtract @a tv to this.
@@ -244,6 +272,39 @@ public:
/// Subtract @a tv to this.
ACE_Time_Value &operator -= (time_t tv);
+#if defined (ACE_HAS_CPP11)
+ /// Add @a std::duration to this.
+ template< class Rep, class Period >
+ ACE_Time_Value &operator += (const std::chrono::duration<Rep, Period>& duration)
+ {
+ const ACE_Time_Value tv (duration);
+ this->sec (this->sec () + tv.sec ());
+ this->usec (this->usec () + tv.usec ());
+ this->normalize ();
+ return *this;
+ }
+
+ /// Assign @a std::duration to this
+ template< class Rep, class Period >
+ ACE_Time_Value &operator = (const std::chrono::duration<Rep, Period>& duration)
+ {
+ this->set (duration);
+ return *this;
+ }
+
+ /// Subtract @a std::duration to this.
+ template< class Rep, class Period >
+ ACE_Time_Value &operator -= (const std::chrono::duration<Rep, Period>& duration)
+ {
+ const ACE_Time_Value tv (duration);
+ this->sec (this->sec () - tv.sec ());
+ this->usec (this->usec () - tv.usec ());
+ this->normalize ();
+ return *this;
+ }
+#endif /* ACE_HAS_CPP11 */
+
+
/**
\brief Multiply the time value by the @a d factor.
\note The result of the operator is valid for results from range
@@ -410,6 +471,66 @@ extern ACE_Export ostream &operator<<( ostream &o, const ACE_Time_Value &v );
ACE_END_VERSIONED_NAMESPACE_DECL
+#if defined (ACE_HAS_CPP11)
+
+// Additional chrono operators.
+
+namespace std
+{
+ namespace chrono
+ {
+ /**
+ * @name Streaming ACE_Time_Value to chrono
+ *
+ * Streaming an ACE_Time_Value into one of the chrono types (nanoseconds,
+ * microseconds, milliseconds, seconds, minutes, or hours).
+ *
+ */
+ //@{
+ nanoseconds& operator <<(nanoseconds &ns, ACE_Time_Value const &tv);
+ microseconds& operator <<(microseconds &us, ACE_Time_Value const &tv);
+ milliseconds& operator <<(milliseconds &ms, ACE_Time_Value const &tv);
+ seconds& operator <<(seconds &s, ACE_Time_Value const &tv);
+ minutes& operator <<(minutes &m, ACE_Time_Value const &tv);
+ hours& operator <<(hours &h, ACE_Time_Value const &tv);
+ //@}
+
+ /**
+ * @name Adding ACE_Time_Value to chrono
+ *
+ * Adding an ACE_Time_Value to one of the chrono types (nanoseconds,
+ * microseconds, milliseconds, seconds, minutes, or hours).
+ *
+ */
+ //@{
+ nanoseconds& operator +=(nanoseconds &ns, ACE_Time_Value const &tv);
+ microseconds& operator +=(microseconds &us, ACE_Time_Value const &tv);
+ milliseconds& operator +=(milliseconds &ms, ACE_Time_Value const &tv);
+ seconds& operator +=(seconds &s, ACE_Time_Value const &tv);
+ minutes& operator +=(minutes &m, ACE_Time_Value const &tv);
+ hours& operator +=(hours &h, ACE_Time_Value const &tv);
+ //@}
+
+ /**
+ * @name Substracting ACE_Time_Value from chrono
+ *
+ * Substracting an ACE_Time_Value from one of the chrono types (nanoseconds,
+ * microseconds, milliseconds, seconds, minutes, or hours).
+ *
+ */
+ //@{
+ nanoseconds& operator -=(nanoseconds &ns, ACE_Time_Value const &tv);
+ microseconds& operator -=(microseconds &us, ACE_Time_Value const &tv);
+ milliseconds& operator -=(milliseconds &ms, ACE_Time_Value const &tv);
+ seconds& operator -=(seconds &s, ACE_Time_Value const &tv);
+ minutes& operator -=(minutes &m, ACE_Time_Value const &tv);
+ hours& operator -=(hours &h, ACE_Time_Value const &tv);
+ //@}
+ }
+}
+
+#endif /* ACE_HAS_CPP11 */
+
#if defined (__ACE_INLINE__)
#include "ace/Time_Value.inl"
#endif /* __ACE_INLINE__ */
diff --git a/ACE/ace/Time_Value.inl b/ACE/ace/Time_Value.inl
index eaed073f45d..a4b095033e7 100644
--- a/ACE/ace/Time_Value.inl
+++ b/ACE/ace/Time_Value.inl
@@ -393,3 +393,161 @@ operator - (const ACE_Time_Value &tv1,
}
ACE_END_VERSIONED_NAMESPACE_DECL
+
+#if defined (ACE_HAS_CPP11)
+
+// Additional chrono streaming operators.
+
+namespace std
+{
+ namespace chrono
+ {
+ ACE_INLINE nanoseconds&
+ operator <<(nanoseconds &ns, ACE_Time_Value const &tv)
+ {
+ ns = duration_cast<nanoseconds>(seconds{tv.sec ()}) +
+ duration_cast<nanoseconds>(microseconds{tv.usec()});
+ return ns;
+ }
+
+ ACE_INLINE microseconds&
+ operator <<(microseconds &us, ACE_Time_Value const &tv)
+ {
+ us= duration_cast<microseconds>(seconds{tv.sec ()}) +
+ microseconds{tv.usec()};
+ return us;
+ }
+
+ ACE_INLINE milliseconds&
+ operator <<(milliseconds &ms, ACE_Time_Value const &tv)
+ {
+ ms = duration_cast<milliseconds>(seconds{tv.sec ()}) +
+ duration_cast<milliseconds>(microseconds{tv.usec()});
+ return ms;
+ }
+
+ ACE_INLINE seconds&
+ operator <<(seconds &s, ACE_Time_Value const &tv)
+ {
+ s = seconds{tv.sec ()} +
+ duration_cast<seconds>(microseconds{tv.usec()});
+ return s;
+ }
+
+ ACE_INLINE minutes&
+ operator <<(minutes &m, ACE_Time_Value const &tv)
+ {
+ m = duration_cast<minutes>(seconds{tv.sec ()}) +
+ duration_cast<minutes>(microseconds{tv.usec()});
+ return m;
+ }
+
+ ACE_INLINE hours&
+ operator <<(hours &h, ACE_Time_Value const &tv)
+ {
+ h = duration_cast<hours>(seconds{tv.sec ()}) +
+ duration_cast<hours>(microseconds{tv.usec()});
+ return h;
+ }
+
+
+ ACE_INLINE nanoseconds&
+ operator +=(nanoseconds &ns, ACE_Time_Value const &tv)
+ {
+ ns += duration_cast<nanoseconds>(seconds{tv.sec ()}) +
+ duration_cast<nanoseconds>(microseconds{tv.usec()});
+ return ns;
+ }
+
+ ACE_INLINE microseconds&
+ operator +=(microseconds &us, ACE_Time_Value const &tv)
+ {
+ us += duration_cast<microseconds>(seconds{tv.sec ()}) +
+ microseconds{tv.usec()};
+ return us;
+ }
+
+ ACE_INLINE milliseconds&
+ operator +=(milliseconds &ms, ACE_Time_Value const &tv)
+ {
+ ms += duration_cast<milliseconds>(seconds{tv.sec ()}) +
+ duration_cast<milliseconds>(microseconds{tv.usec()});
+ return ms;
+ }
+
+ ACE_INLINE seconds&
+ operator +=(seconds &s, ACE_Time_Value const &tv)
+ {
+ s += seconds{tv.sec ()} +
+ duration_cast<seconds>(microseconds{tv.usec()});
+ return s;
+ }
+
+ ACE_INLINE minutes&
+ operator +=(minutes &m, ACE_Time_Value const &tv)
+ {
+ m += duration_cast<minutes>(seconds{tv.sec ()}) +
+ duration_cast<minutes>(microseconds{tv.usec()});
+ return m;
+ }
+
+ ACE_INLINE hours&
+ operator +=(hours &h, ACE_Time_Value const &tv)
+ {
+ h += duration_cast<hours>(seconds{tv.sec ()}) +
+ duration_cast<hours>(microseconds{tv.usec()});
+ return h;
+ }
+
+
+ ACE_INLINE nanoseconds&
+ operator -=(nanoseconds &ns, ACE_Time_Value const &tv)
+ {
+ ns -= duration_cast<nanoseconds>(seconds{tv.sec ()}) +
+ duration_cast<nanoseconds>(microseconds{tv.usec()});
+ return ns;
+ }
+
+ ACE_INLINE microseconds&
+ operator -=(microseconds &us, ACE_Time_Value const &tv)
+ {
+ us -= duration_cast<microseconds>(seconds{tv.sec ()}) +
+ microseconds{tv.usec()};
+ return us;
+ }
+
+ ACE_INLINE milliseconds&
+ operator -=(milliseconds &ms, ACE_Time_Value const &tv)
+ {
+ ms -= duration_cast<milliseconds>(seconds{tv.sec ()}) +
+ duration_cast<milliseconds>(microseconds{tv.usec()});
+ return ms;
+ }
+
+ ACE_INLINE seconds&
+ operator -=(seconds &s, ACE_Time_Value const &tv)
+ {
+ s -= seconds{tv.sec ()} +
+ duration_cast<seconds>(microseconds{tv.usec()});
+ return s;
+ }
+
+ ACE_INLINE minutes&
+ operator -=(minutes &m, ACE_Time_Value const &tv)
+ {
+ m -= duration_cast<minutes>(seconds{tv.sec ()}) +
+ duration_cast<minutes>(microseconds{tv.usec()});
+ return m;
+ }
+
+ ACE_INLINE hours&
+ operator -=(hours &h, ACE_Time_Value const &tv)
+ {
+ h -= duration_cast<hours>(seconds{tv.sec ()}) +
+ duration_cast<hours>(microseconds{tv.usec()});
+ return h;
+ }
+ }
+}
+
+#endif /* ACE_HAS_CPP11 */
diff --git a/ACE/ace/config-vxworks.h b/ACE/ace/config-vxworks.h
index ee4e2286c76..9d0ea65e25c 100644
--- a/ACE/ace/config-vxworks.h
+++ b/ACE/ace/config-vxworks.h
@@ -54,6 +54,25 @@
#error Unknown or unsupported VxWorks version
#endif
+// Adapt to system argument changes added at VxWorks 6.9 and 64-bit.
+// It would be nicer to typedef the data types, but without including the
+// applicable VxWorks headers here, that doesn't work.
+#if (ACE_VXWORKS < 0x690)
+# define ACE_VX_USR_ARG_T int
+# define ACE_VX_TASK_ID int
+# define ACE_VX_ARG_FORMAT "%x"
+# define ACE_VX_TASK_ID_ERROR ERROR
+#else
+# define ACE_VX_USR_ARG_T _Vx_usr_arg_t
+# define ACE_VX_TASK_ID TASK_ID
+# ifdef _WRS_CONFIG_LP64
+# define ACE_VX_ARG_FORMAT "%lx"
+# else
+# define ACE_VX_ARG_FORMAT "%x"
+# endif
+# define ACE_VX_TASK_ID_ERROR TASK_ID_ERROR
+#endif
+
#include /**/ "ace/post.h"
#endif /* ACE_CONFIG_VXWORKS_H */
diff --git a/ACE/tests/Chrono_Test.cpp b/ACE/tests/Chrono_Test.cpp
new file mode 100644
index 00000000000..1963fce7824
--- /dev/null
+++ b/ACE/tests/Chrono_Test.cpp
@@ -0,0 +1,592 @@
+
+//=============================================================================
+/**
+ * @file Chrono_Test.cpp
+ *
+ * This is a test of the usage of 'std::chrono' throughout ACE
+ * The following items are tested:
+ * - ACE_OS::sleep
+ * - ACE_Time_Value
+ *
+ *
+ * @author Marcel Smit <msmit@remedy.nl>
+ */
+//=============================================================================
+
+
+#include "test_config.h"
+#include "ace/OS_NS_unistd.h"
+#include "ace/Time_Value.h"
+
+#if defined (ACE_HAS_CPP11)
+
+int
+test_assignments ()
+{
+ int errors {};
+ ACE_Time_Value tv { std::chrono::nanoseconds {100} };
+ if (tv.sec () != 0 || tv.usec () != 0)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("(%P|%t) unexpected value after converting ")
+ ACE_TEXT ("std::chrono::nanoseconds (100) to an ACE_Time_Value. ")
+ ACE_TEXT ("<sec=0,usec=0> - got <sec=%d,usec=%d>\n"),
+ tv.sec (), tv.usec ()));
+ ++errors;
+ }
+
+ tv = ACE_Time_Value { std::chrono::nanoseconds {10005} };
+ if (tv.sec () != 0 || tv.usec () != 10)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("(%P|%t) unexpected value after converting ")
+ ACE_TEXT ("std::chrono::nanoseconds (10005) to an ACE_Time_Value. ")
+ ACE_TEXT ("<sec=0,usec=10> - got <sec=%d,usec=%d>\n"),
+ tv.sec (), tv.usec ()));
+ ++errors;
+ }
+
+ tv = ACE_Time_Value { std::chrono::microseconds {1} };
+ if (tv.sec () != 0 || tv.usec () != 1)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("(%P|%t) unexpected value after converting ")
+ ACE_TEXT ("std::chrono::microseconds (1) to an ACE_Time_Value. ")
+ ACE_TEXT ("<sec=0,usec=1> - got <sec=%d,usec=%d>\n"),
+ tv.sec (), tv.usec ()));
+ ++errors;
+ }
+
+ tv = ACE_Time_Value { std::chrono::microseconds {10005} };
+ if (tv.sec () != 0 || tv.usec () != 10005)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("(%P|%t) unexpected value after converting ")
+ ACE_TEXT ("std::chrono::microseconds (10005) to an ACE_Time_Value. ")
+ ACE_TEXT ("<sec=0,usec=10005> - got <sec=%d,usec=%d>\n"),
+ tv.sec (), tv.usec ()));
+ ++errors;
+ }
+
+ std::chrono::milliseconds ms_test { tv.msec () };
+ if (ms_test.count () != 10)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("(%P|%t) unexpected value after get_chrono_msec. ")
+ ACE_TEXT ("Expected <10> - got <%q>\n"),
+ ms_test.count ()));
+ ++errors;
+ }
+
+ tv = ACE_Time_Value { std::chrono::milliseconds {1} };
+ if (tv.sec () != 0 || tv.usec () != 1000)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("(%P|%t) unexpected value after converting ")
+ ACE_TEXT ("std::chrono::milliseconds (1) to an ACE_Time_Value. ")
+ ACE_TEXT ("<sec=0,usec=1000> - got <sec=%d,usec=%d>\n"),
+ tv.sec (), tv.usec ()));
+ ++errors;
+ }
+
+ tv = ACE_Time_Value { std::chrono::milliseconds {10005} };
+ if (tv.sec () != 10 || tv.usec () != 5000)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("(%P|%t) unexpected value after converting ")
+ ACE_TEXT ("std::chrono::milliseconds (10005) to an ACE_Time_Value. ")
+ ACE_TEXT ("<sec=10,usec=5000> - got <sec=%d,usec=%d>\n"),
+ tv.sec (), tv.usec ()));
+ ++errors;
+ }
+
+ tv = ACE_Time_Value { std::chrono::seconds {1} };
+ if (tv.sec () != 1 || tv.usec () != 0)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("(%P|%t) unexpected value after converting ")
+ ACE_TEXT ("std::chrono::seconds (1) to an ACE_Time_Value. ")
+ ACE_TEXT ("<sec=1,usec=0> - got <sec=%d,usec=%d>\n"),
+ tv.sec (), tv.usec ()));
+ ++errors;
+ }
+
+ tv = ACE_Time_Value { std::chrono::seconds {10005} };
+ if (tv.sec () != 10005 || tv.usec () != 0)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("(%P|%t) unexpected value after converting ")
+ ACE_TEXT ("std::chrono::seconds (10005) to an ACE_Time_Value. ")
+ ACE_TEXT ("<sec=10005,usec=0> - got <sec=%d,usec=%d>\n"),
+ tv.sec (), tv.usec ()));
+ ++errors;
+ }
+
+ tv = ACE_Time_Value { std::chrono::hours {1} };
+ if (tv.sec () != 3600 || tv.usec () != 0)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("(%P|%t) unexpected value after converting ")
+ ACE_TEXT ("std::chrono::hours (1) to an ACE_Time_Value. ")
+ ACE_TEXT ("<sec=3600,usec=0> - got <sec=%d,usec=%d>\n"),
+ tv.sec (), tv.usec ()));
+ ++errors;
+ }
+
+ tv = ACE_Time_Value { std::chrono::hours {10005} };
+ if (tv.sec () != 3600*10005 || tv.usec () != 0)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("(%P|%t) unexpected value after converting ")
+ ACE_TEXT ("std::chrono::hours (10005) to an ACE_Time_Value. ")
+ ACE_TEXT ("<sec=%d,usec=0> - got <sec=%d,usec=%d>\n"),
+ 3600*10005, tv.sec (), tv.usec ()));
+ ++errors;
+ }
+
+ // Two times half a day, 3 hours, 24 minutes, 54 seconds, 238 milliseconds,
+ // 754 microseconds and 342 nanoseconds.
+ std::chrono::duration<double, std::ratio<(24*3600)>> half_day {0.5};
+ std::chrono::microseconds const usec {
+ 2 * (
+ std::chrono::duration_cast<std::chrono::microseconds> (
+ half_day +
+ std::chrono::hours {3} + std::chrono::minutes {24} +
+ std::chrono::seconds {54} + std::chrono::milliseconds {238} +
+ std::chrono::microseconds {754} + std::chrono::nanoseconds {342}))
+ };
+
+
+ tv = ACE_Time_Value {usec};
+
+ // half a day 3 hours 24 minutes 54 seconds
+ time_t expected_sec = { ((12*3600) + (3*3600) + (24*60) + 54 ) * 2 };
+ // 238 milli usec 342 nano
+ suseconds_t expected_usec = { ((238*1000) + 754 + 0) * 2 };
+
+ if (tv.sec () != expected_sec || tv.usec () != expected_usec)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("(%P|%t) unexpected value after converting ")
+ ACE_TEXT ("two times half a day, 3 hours, 24 minutes, 54 seconds, ")
+ ACE_TEXT ("238 milliseconds, 754 microseconds and 342 nanoseconds ")
+ ACE_TEXT ("to an ACE_Time_Value. Expected <sec=%d,usec=%d> - ")
+ ACE_TEXT ("got <sec=%d,usec=%d>\n"),
+ expected_sec, expected_usec, tv.sec (), tv.usec ()));
+ ++errors;
+ }
+
+ tv.set (std::chrono::milliseconds {1120});
+ if (tv.sec () != 1 || tv.usec () != 120 * std::kilo::num)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("(%P|%t) unexpected value after converting ")
+ ACE_TEXT ("a std::chrono::milliseconds of 1120 to an ACE_Time_Value ")
+ ACE_TEXT ("Expected <sec=1,usec=120000> - got <sec=%d,usec=%d>\n"),
+ tv.sec (), tv.usec ()));
+ ++errors;
+ }
+
+ return errors;
+}
+
+int
+test_streamers ()
+{
+ int errors {};
+
+ // Three days, 13 hours, 54 seconds, 25 milliseconds and 132 microseconds
+ constexpr int nr_hours { (3*24) + 13 };
+
+ std::chrono::hours day_test_h {nr_hours};
+ std::chrono::seconds day_test_s {54};
+ std::chrono::milliseconds day_test_ms {25};
+ std::chrono::microseconds day_test_us {132};
+
+ std::chrono::seconds day_test_ts { day_test_h+day_test_s };
+ std::chrono::microseconds day_test_tus { day_test_ms+day_test_us };
+ ACE_Time_Value const test_day {
+ ACE_Time_Value { day_test_ts.count (), day_test_tus.count () }};
+
+ constexpr int expected_min {nr_hours * 60};
+ constexpr int64_t expected_sec { expected_min * 60 + 54 };
+ constexpr int64_t expected_msec { (expected_sec * std::kilo::num) + 25 };
+ constexpr int64_t expected_usec { (expected_msec * std::kilo::num) + 132 };
+ constexpr int64_t expected_nsec { (expected_usec * std::kilo::num) };
+
+ std::chrono::hours h;
+ h << test_day;
+ if (h.count () != nr_hours)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("(%P|%t) unexpected value after streaming an ")
+ ACE_TEXT ("ACE_Time_Value <sec=%d,usec=%d> into ")
+ ACE_TEXT ("std::chrono::hours. Expected <%d> - got <%q>.\n"),
+ test_day.sec (), test_day.usec (), nr_hours, h.count ()));
+ ++errors;
+ }
+
+ std::chrono::minutes m;
+ m << test_day;
+ if (m.count () != expected_min)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("(%P|%t) unexpected value after streaming an ")
+ ACE_TEXT ("ACE_Time_Value <sec=%d,usec=%d> into ")
+ ACE_TEXT ("std::chrono::minutes. Expected <%d> - got <%q>.\n"),
+ test_day.sec (), test_day.usec (), expected_min, m.count ()));
+ ++errors;
+ }
+
+ std::chrono::seconds s;
+ s << test_day;
+ if (s.count () != expected_sec)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("(%P|%t) unexpected value after streaming an ")
+ ACE_TEXT ("ACE_Time_Value <sec=%d,usec=%d> into ")
+ ACE_TEXT ("std::chrono::seconds. Expected <%q> - got <%q>.\n"),
+ test_day.sec (), test_day.usec (), expected_sec, s.count ()));
+ ++errors;
+ }
+
+ std::chrono::milliseconds ms;
+ ms << test_day;
+ if (ms.count () != expected_msec)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("(%P|%t) unexpected value after streaming an ")
+ ACE_TEXT ("ACE_Time_Value <sec=%d,usec=%d> into ")
+ ACE_TEXT ("std::chrono::milliseconds. Expected <%q> - got <%q>.\n"),
+ test_day.sec (), test_day.usec (), expected_msec, ms.count ()));
+ ++errors;
+ }
+
+ std::chrono::microseconds us;
+ us << test_day;
+ if (us.count () != expected_usec)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("(%P|%t) unexpected value after streaming an ")
+ ACE_TEXT ("ACE_Time_Value <sec=%d,usec=%d> into ")
+ ACE_TEXT ("std::chrono::microseconds. Expected <%q> - got <%q>.\n"),
+ test_day.sec (), test_day.usec (), expected_usec, us.count ()));
+ ++errors;
+ }
+
+ std::chrono::nanoseconds ns;
+ ns << test_day;
+ if (ns.count () != expected_nsec)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("(%P|%t) unexpected value after streaming an ")
+ ACE_TEXT ("ACE_Time_Value <sec=%d,usec=%d> into ")
+ ACE_TEXT ("std::chrono::nanoseconds. Expected <%q> - got <%q>.\n"),
+ test_day.sec (), test_day.usec (), expected_nsec, ns.count ()));
+ ++errors;
+ }
+
+
+
+ ACE_Time_Value const test_sec {12, 132};
+ // Seconds
+ s << test_sec;
+ if (s.count () != 12)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("(%P|%t) unexpected value after streaming an ")
+ ACE_TEXT ("ACE_Time_Value <sec=%d,usec=%d> into ")
+ ACE_TEXT ("std::chrono::seconds. Expected <%d> - got <%q>.\n"),
+ test_sec.sec (), test_sec.usec (), test_sec.sec (), s.count ()));
+ ++errors;
+ }
+
+ ACE_Time_Value const test_sec2 { ACE_Time_Value {12, 6 * std::mega::num} };
+ std::chrono::seconds s2;
+ s2 << test_sec2;
+ if (s2.count () != 18)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("(%P|%t) unexpected value after streaming an ")
+ ACE_TEXT ("ACE_Time_Value <sec=%d,usec=%d> into ")
+ ACE_TEXT ("std::chrono::seconds. Expected <%d> - got <%q>.\n"),
+ test_sec2.sec (), test_sec2.usec (), test_sec2.sec (), s2.count ()));
+ ++errors;
+ }
+
+ // Milliseconds
+ ms << test_sec;
+ if (ms.count () != 12 * std::kilo::num)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("(%P|%t) unexpected value after streaming an ")
+ ACE_TEXT ("ACE_Time_Value <sec=%d,usec=%d> into ")
+ ACE_TEXT ("std::chrono::milliseconds. Expected <%d> - got <%q>.\n"),
+ test_sec.sec (), test_sec.usec (), 12000, ms.count ()));
+ ++errors;
+ }
+
+ std::chrono::milliseconds ms2;
+ ms2 << test_sec2;
+ if (ms2.count () != 18 * std::kilo::num)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("(%P|%t) unexpected value after streaming an ")
+ ACE_TEXT ("ACE_Time_Value <sec=%d,usec=%d> into ")
+ ACE_TEXT ("std::chrono::milliseconds. Expected <%d> - got <%q>.\n"),
+ test_sec2.sec (), test_sec2.usec (), 18000, ms2.count ()));
+ ++errors;
+ }
+
+ // Microseconds
+ us << test_sec;
+ if (us.count () != (12 * std::mega::num) + 132)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("(%P|%t) unexpected value after streaming an ")
+ ACE_TEXT ("ACE_Time_Value <sec=%d,usec=%d> into ")
+ ACE_TEXT ("std::chrono::microseconds. Expected <%d> - got <%q>.\n"),
+ test_sec.sec (), test_sec.usec (), test_sec.sec (), us.count ()));
+ ++errors;
+ }
+
+ std::chrono::microseconds us2;
+ us2 << test_sec2;
+ if (us2.count () != 18 * std::mega::num)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("(%P|%t) unexpected value after streaming an ")
+ ACE_TEXT ("ACE_Time_Value <sec=%d,usec=%d> into ")
+ ACE_TEXT ("std::chrono::microseconds. Expected <%d> - got <%q>.\n"),
+ test_sec2.sec (), test_sec2.usec (), test_sec2.sec (), us2.count ()));
+ ++errors;
+ }
+
+ return errors;
+}
+
+int
+test_ace_time_value_operators ()
+{
+ int errors {};
+
+ std::chrono::seconds const sec {2};
+ std::chrono::microseconds const usec {3000};
+
+ std::chrono::milliseconds const msec {
+ std::chrono::duration_cast<std::chrono::milliseconds>(sec) +
+ std::chrono::duration_cast<std::chrono::milliseconds>(usec) };
+
+
+ ACE_Time_Value tv;
+ tv = msec;
+ tv += std::chrono::milliseconds {300};
+ if (tv.sec () != 2 || tv.usec () != 303 * std::kilo::num)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("(%P|%t) unexpected value after adding a duration ")
+ ACE_TEXT ("of 300 ms. Expected <sec=2,usec=3300> - got <sec=%d,")
+ ACE_TEXT ("usec=%d>.\n"),
+ tv.sec (), tv.usec ()));
+ ++errors;
+ }
+ tv -= std::chrono::microseconds {400};
+ if (tv.sec () != 2 || tv.usec () != 302600)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("(%P|%t) unexpected value after substracting a duration ")
+ ACE_TEXT ("of 400 us. Expected <sec=2,usec=3300> - got <sec=%d,")
+ ACE_TEXT ("usec=%d>.\n"),
+ tv.sec (), tv.usec ()));
+ ++errors;
+ }
+ return errors;
+}
+
+int
+test_chrono_operators ()
+{
+ int errors {};
+
+ std::chrono::hours hr {1};
+ ACE_Time_Value const tv_hr {3645, 0};
+ hr += tv_hr;
+ if (hr.count () != 2)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("(%P|%t) unexpected value after adding an ACE_Time_Value ")
+ ACE_TEXT ("of <sec=%d,usec=%d> to a std::chrono::hours of 1. ")
+ ACE_TEXT ("Expected <2> - got <%d>.\n"),
+ tv_hr.sec (), tv_hr.usec (), hr.count ()));
+ ++errors;
+ }
+
+ hr -= tv_hr;
+ if (hr.count () != 1)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("(%P|%t) unexpected value after substracting an ACE_Time_Value ")
+ ACE_TEXT ("of <sec=%d,usec=%d> to a std::chrono::hours of 2. ")
+ ACE_TEXT ("Expected <1> - got <%d>.\n"),
+ tv_hr.sec (), tv_hr.usec (), hr.count ()));
+ ++errors;
+ }
+
+
+ std::chrono::minutes mn {1};
+ ACE_Time_Value const tv_min {75, 0};
+ mn += tv_min;
+ if (mn.count () != 2)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("(%P|%t) unexpected value after adding an ACE_Time_Value ")
+ ACE_TEXT ("of <sec=%d,usec=%d> to a std::chrono::minutes of 1. ")
+ ACE_TEXT ("Expected <2> - got <%d>.\n"),
+ tv_min.sec (), tv_min.usec (), mn.count ()));
+ ++errors;
+ }
+
+ mn -= tv_min;
+ if (mn.count () != 1)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("(%P|%t) unexpected value after substracting an ACE_Time_Value ")
+ ACE_TEXT ("of <sec=%d,usec=%d> to a std::chrono::minutes of 2. ")
+ ACE_TEXT ("Expected <1> - got <%d>.\n"),
+ tv_min.sec (), tv_min.usec (), mn.count ()));
+ ++errors;
+ }
+
+ std::chrono::seconds sec {1};
+ ACE_Time_Value const tv_sec {1, std::mega::num};
+ sec += tv_sec;
+ if (sec.count () != 3)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("(%P|%t) unexpected value after adding an ACE_Time_Value ")
+ ACE_TEXT ("of <sec=%d,usec=%d> to a std::chrono::seconds of 1. ")
+ ACE_TEXT ("Expected <3> - got <%d>.\n"),
+ tv_sec.sec (), tv_sec.usec (), sec.count ()));
+ ++errors;
+ }
+
+ sec -= tv_sec;
+ if (sec.count () != 1)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("(%P|%t) unexpected value after substracting an ACE_Time_Value ")
+ ACE_TEXT ("of <sec=%d,usec=%d> to a std::chrono::seconds of 3. ")
+ ACE_TEXT ("Expected <1> - got <%d>.\n"),
+ tv_sec.sec (), tv_sec.usec (), sec.count ()));
+ ++errors;
+ }
+
+ std::chrono::milliseconds msec {400};
+ ACE_Time_Value const tv_msec {1, 3000};
+ msec += tv_msec;
+ if (msec.count () != 1403)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("(%P|%t) unexpected value after adding an ACE_Time_Value ")
+ ACE_TEXT ("of <sec=%d,usec=%d> to a std::chrono::milliseconds of 400. ")
+ ACE_TEXT ("Expected <1403> - got <%d>.\n"),
+ tv_msec.sec (), tv_msec.usec (), msec.count ()));
+ ++errors;
+ }
+
+ msec -= tv_msec;
+ if (msec.count () != 400)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("(%P|%t) unexpected value after substracting an ACE_Time_Value ")
+ ACE_TEXT ("of <sec=%d,usec=%d> to a std::chrono::milliseconds of 1403. ")
+ ACE_TEXT ("Expected <400> - got <%d>.\n"),
+ tv_msec.sec (), tv_msec.usec (), msec.count ()));
+ ++errors;
+ }
+
+ std::chrono::microseconds usec {400};
+ ACE_Time_Value const tv_usec {0, 3000};
+ usec += tv_usec;
+ if (usec.count () != 3400)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("(%P|%t) unexpected value after adding an ACE_Time_Value ")
+ ACE_TEXT ("of <sec=%d,usec=%d> to a std::chrono::microseconds of 400. ")
+ ACE_TEXT ("Expected <3400> - got <%d>.\n"),
+ tv_usec.sec (), tv_usec.usec (), usec.count ()));
+ ++errors;
+ }
+
+ usec -= tv_usec;
+ if (usec.count () != 400)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("(%P|%t) unexpected value after substracting an ACE_Time_Value ")
+ ACE_TEXT ("of <sec=%d,usec=%d> to a std::chrono::microseconds of 3400. ")
+ ACE_TEXT ("Expected <400> - got <%d>.\n"),
+ tv_usec.sec (), tv_usec.usec (), usec.count ()));
+ ++errors;
+ }
+
+ std::chrono::nanoseconds nsec {4000};
+ nsec += tv_usec;
+ if (nsec.count () != 3004 * std::kilo::num)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("(%P|%t) unexpected value after adding an ACE_Time_Value ")
+ ACE_TEXT ("of <sec=%d,usec=%d> to a std::chrono::nanoseconds of 4000. ")
+ ACE_TEXT ("Expected <3004000> - got <%d>.\n"),
+ tv_usec.sec (), tv_usec.usec (), nsec.count ()));
+ ++errors;
+ }
+
+ nsec -= tv_usec;
+ if (nsec.count () != 4000)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("(%P|%t) unexpected value after substracting an ACE_Time_Value ")
+ ACE_TEXT ("of <sec=%d,usec=%d> to a std::chrono::nanoseconds of 3004000. ")
+ ACE_TEXT ("Expected <4000> - got <%d>.\n"),
+ tv_usec.sec (), tv_usec.usec (), nsec.count ()));
+ ++errors;
+ }
+
+ return errors;
+}
+
+int
+test_chrono ()
+{
+ int errors = test_assignments ();
+ errors += test_streamers ();
+ errors += test_ace_time_value_operators ();
+ errors += test_chrono_operators ();
+ return errors;
+}
+
+int
+run_main (int, ACE_TCHAR *[])
+{
+ ACE_START_TEST (ACE_TEXT ("Chrono_Test"));
+
+ int errors = test_chrono ();
+
+ ACE_END_TEST;
+ return errors;
+}
+
+#else
+
+int
+run_main (int, ACE_TCHAR *[])
+{
+ ACE_START_TEST (ACE_TEXT ("Chrono_Test"));
+
+ ACE_ERROR ((LM_INFO, ACE_TEXT ("std::chrono is not supported on this platform\n")));
+
+ ACE_END_TEST;
+ return 0;
+}
+
+#endif /* ACE_HAS_CPP11 */
diff --git a/ACE/tests/run_test.lst b/ACE/tests/run_test.lst
index 3a376fe34c5..8e4bb4a230d 100644
--- a/ACE/tests/run_test.lst
+++ b/ACE/tests/run_test.lst
@@ -70,6 +70,7 @@ Bug_4189_Regression_Test: !ST
CDR_Array_Test: !ACE_FOR_TAO
CDR_File_Test: !ACE_FOR_TAO
CDR_Test
+Chrono_Test
Cache_Map_Manager_Test
Cached_Accept_Conn_Test: !ACE_FOR_TAO !LabVIEW_RT
Cached_Allocator_Test: !ACE_FOR_TAO
diff --git a/ACE/tests/tests.mpc b/ACE/tests/tests.mpc
index e45e143ccc4..adb95592aa6 100644
--- a/ACE/tests/tests.mpc
+++ b/ACE/tests/tests.mpc
@@ -544,6 +544,13 @@ project(CDR Test) : acetest {
}
}
+project(Chrono Test) : acetest {
+ exename = Chrono_Test
+ Source_Files {
+ Chrono_Test.cpp
+ }
+}
+
project(Collection Test) : acetest {
exename = Collection_Test
Source_Files {
diff --git a/TAO/tao/PortableServer/PortableServer_Functions.cpp b/TAO/tao/PortableServer/PortableServer_Functions.cpp
index 853bd2b7ea2..fe9c1f5f45a 100644
--- a/TAO/tao/PortableServer/PortableServer_Functions.cpp
+++ b/TAO/tao/PortableServer/PortableServer_Functions.cpp
@@ -9,6 +9,13 @@ namespace PortableServer
PortableServer::ObjectId *
string_to_ObjectId (const char *string)
{
+ // Passing in a nil pointer is illegal so throw an exception to
+ // indicate that
+ if (string == 0)
+ {
+ throw ::CORBA::BAD_PARAM ();
+ }
+
// Size of string
//
// We DO NOT include the zero terminator, as this is simply an