diff options
author | Johnny Willemsen <jwillemsen@remedy.nl> | 2019-11-06 15:04:05 +0100 |
---|---|---|
committer | Johnny Willemsen <jwillemsen@remedy.nl> | 2019-11-06 15:04:05 +0100 |
commit | ea79999156f6175ed974fa09673c5a61d58bddae (patch) | |
tree | 84eb9e1ada0e7be5498ce34a27bce2a113df08ec | |
parent | d9abaa91f7eba82e4310704298815a3b57c665b3 (diff) | |
parent | 2f4f63116b20f0659eeaea301b00bd592791272d (diff) | |
download | ATCD-ea79999156f6175ed974fa09673c5a61d58bddae.tar.gz |
Merge branch 'master' of https://github.com/DOCGroup/ACE_TAO
-rw-r--r-- | .github/workflows/ccpp.yml | 47 | ||||
-rw-r--r-- | ACE/NEWS | 7 | ||||
-rw-r--r-- | ACE/ace/Condition_Attributes.inl | 2 | ||||
-rw-r--r-- | ACE/ace/Configuration.cpp | 20 | ||||
-rw-r--r-- | ACE/ace/Configuration.h | 22 | ||||
-rw-r--r-- | ACE/ace/Monotonic_Time_Policy.h | 4 | ||||
-rw-r--r-- | ACE/ace/Monotonic_Time_Policy.inl | 10 | ||||
-rw-r--r-- | ACE/ace/OS_NS_Thread.inl | 35 | ||||
-rw-r--r-- | ACE/ace/OS_NS_time.inl | 12 | ||||
-rw-r--r-- | ACE/ace/config-hpux-11.00.h | 1 | ||||
-rw-r--r-- | ACE/ace/config-macros.h | 18 | ||||
-rw-r--r-- | ACE/ace/config-posix.h | 20 | ||||
-rw-r--r-- | ACE/ace/config-win32-common.h | 2 | ||||
-rw-r--r-- | ACE/docs/ACE-monotonic-timer.html | 46 | ||||
-rw-r--r-- | ACE/tests/.gitignore | 1 | ||||
-rw-r--r-- | ACE/tests/Bug_4055_Regression_Test.cpp | 36 | ||||
-rw-r--r-- | ACE/tests/Monotonic_Manual_Event_Test.cpp | 40 | ||||
-rw-r--r-- | ACE/tests/Monotonic_Message_Queue_Test.cpp | 31 | ||||
-rw-r--r-- | ACE/tests/Monotonic_Task_Test.cpp | 27 |
19 files changed, 231 insertions, 150 deletions
diff --git a/.github/workflows/ccpp.yml b/.github/workflows/ccpp.yml new file mode 100644 index 00000000000..e0c57bfce46 --- /dev/null +++ b/.github/workflows/ccpp.yml @@ -0,0 +1,47 @@ +name: C/C++ CI + +on: [push, pull_request] + +jobs: + build: + runs-on: ubuntu-latest + env: + ACE_ROOT: ${{ github.workspace }}/ACE + TAO_ROOT: ${{ github.workspace }}/TAO + MPC_ROOT: ${{ github.workspace }}/../MPC + + steps: + - name: checkout ACE/TAO + uses: actions/checkout@v1 + - name: checkout MPC + uses: actions/checkout@v1 + with: + repository: DOCGroup/MPC + ref: master + fetch-depth: 1 + - name: create $ACE_ROOT/ace/config.h + run: | + echo ${env:ACE_ROOT} + echo ${env:GITHUB_WORKSPACE} + '#include "ace/config-linux.h"' > ${env:ACE_ROOT}/ace/config.h + shell: pwsh + - name: create $ACE_ROOT/include/makeinclude/platform_macros.GNU + run: | + 'include $(ACE_ROOT)/include/makeinclude/platform_linux.GNU' > ${env:ACE_ROOT}/include/makeinclude/platform_macros.GNU + shell: pwsh + - name: Run mwc.pl on $(TAO_ROOT)/TAO_ACE.mwc + run: | + perl ${env:ACE_ROOT}/bin/mwc.pl -type gnuace ${env:TAO_ROOT}/TAO_ACE.mwc -workers 4 + shell: pwsh + - name: Run mwc.pl on $(ACE_ROOT)/tests/tests.mwc + run: | + perl ${env:ACE_ROOT}/bin/mwc.pl -type gnuace ${env:ACE_ROOT}/tests/tests.mwc -workers 4 + shell: pwsh + - name: Build TAO_ACE project + run: | + make -j 6 -C ${env:TAO_ROOT} + shell: pwsh + - name: Build ACE/tests project + run: | + make -j 6 -C ${env:ACE_ROOT}/tests + shell: pwsh @@ -6,6 +6,13 @@ USER VISIBLE CHANGES BETWEEN ACE-6.5.6 and ACE-6.5.7 . gnuace makefiles: Updated handling of generated files and use requires/avoids to make postbuild steps conditional +. Removed references to the ACE_LACKS_MONOTONIC_TIME preprocessor macro because + it was equivalent to ACE_LACKS_CLOCK_MONOTONIC. + +. Exposed support status of monotonic times features using these preprocessor + macros. See "Testing for Monotonic Time Support" in + docs/ACE-monotonic-timer.html. + USER VISIBLE CHANGES BETWEEN ACE-6.5.5 and ACE-6.5.6 ==================================================== diff --git a/ACE/ace/Condition_Attributes.inl b/ACE/ace/Condition_Attributes.inl index 7fecc4aafd2..f63106ad4e0 100644 --- a/ACE/ace/Condition_Attributes.inl +++ b/ACE/ace/Condition_Attributes.inl @@ -24,7 +24,7 @@ ACE_INLINE ACE_Condition_Attributes_T<ACE_Monotonic_Time_Policy>::ACE_Condition_Attributes_T (int type) : ACE_Condition_Attributes (type) { -#if (defined (_POSIX_MONOTONIC_CLOCK) && !defined (ACE_LACKS_MONOTONIC_TIME)) || defined (ACE_HAS_CLOCK_GETTIME_MONOTONIC) +#if defined (ACE_HAS_POSIX_MONOTONIC_CONDITIONS) (void) ACE_OS::condattr_setclock (this->attributes_, CLOCK_MONOTONIC); #endif } diff --git a/ACE/ace/Configuration.cpp b/ACE/ace/Configuration.cpp index 19628107866..10b0ad2b05b 100644 --- a/ACE/ace/Configuration.cpp +++ b/ACE/ace/Configuration.cpp @@ -107,7 +107,7 @@ int ACE_Configuration::expand_path (const ACE_Configuration_Section_Key& key, const ACE_TString& path_in, ACE_Configuration_Section_Key& key_out, - int create) + bool create) { // Make a copy of key ACE_Configuration_Section_Key current_section = key; @@ -458,7 +458,8 @@ ACE_Configuration_Win32Registry::operator!= (const ACE_Configuration_Win32Regist return true; } -ACE_Configuration_Win32Registry::ACE_Configuration_Win32Registry (HKEY hKey) +ACE_Configuration_Win32Registry::ACE_Configuration_Win32Registry (HKEY hKey, u_long security_access) + : security_access_ (security_access) { ACE_Section_Key_Win32 *temp = 0; @@ -475,7 +476,7 @@ ACE_Configuration_Win32Registry::~ACE_Configuration_Win32Registry (void) int ACE_Configuration_Win32Registry::open_section (const ACE_Configuration_Section_Key& base, const ACE_TCHAR* sub_section, - int create, + bool create, ACE_Configuration_Section_Key& result) { if (validate_name (sub_section, 1)) @@ -490,7 +491,7 @@ ACE_Configuration_Win32Registry::open_section (const ACE_Configuration_Section_K if ((errnum = ACE_TEXT_RegOpenKeyEx (base_key, sub_section, 0, - KEY_ALL_ACCESS, + security_access_, &result_key)) != ERROR_SUCCESS) { if (!create) @@ -504,7 +505,7 @@ ACE_Configuration_Win32Registry::open_section (const ACE_Configuration_Section_K 0, 0, REG_OPTION_NON_VOLATILE, - KEY_ALL_ACCESS, + security_access_, 0, &result_key, (PDWORD) 0 @@ -979,7 +980,8 @@ ACE_Configuration_Win32Registry::load_key (const ACE_Configuration_Section_Key& HKEY ACE_Configuration_Win32Registry::resolve_key (HKEY hKey, const ACE_TCHAR* path, - int create) + bool create, + u_long security_access) { HKEY result = 0; // Make a copy of hKey @@ -1030,7 +1032,7 @@ ACE_Configuration_Win32Registry::resolve_key (HKEY hKey, 0, 0, 0, - KEY_ALL_ACCESS, + security_access, 0, &subkey, (PDWORD) 0 @@ -1522,7 +1524,7 @@ ACE_Configuration_Heap::section_open_helper (size_t hash_table_size, int ACE_Configuration_Heap::open_section (const ACE_Configuration_Section_Key& base, const ACE_TCHAR* sub_section, - int create, + bool create, ACE_Configuration_Section_Key& result) { ACE_ASSERT (this->allocator_); @@ -1549,7 +1551,7 @@ ACE_Configuration_Heap::open_section (const ACE_Configuration_Section_Key& base, int ACE_Configuration_Heap::open_simple_section (const ACE_Configuration_Section_Key& base, const ACE_TCHAR* sub_section, - int create, + bool create, ACE_Configuration_Section_Key& result) { ACE_TString section (0, 0, false); diff --git a/ACE/ace/Configuration.h b/ACE/ace/Configuration.h index aa69ea49e65..0179236a6f4 100644 --- a/ACE/ace/Configuration.h +++ b/ACE/ace/Configuration.h @@ -158,7 +158,7 @@ public: * * @param base Existing section in which to open the named section. * @param sub_section Name of the section to open. - * @param create If zero, the named section must exist. If non-zero, + * @param create If false, the named section must exist, otherwise * the named section will be created if it does not exist. * @param result Reference; receives the section key for the new * section. @@ -168,7 +168,7 @@ public: */ virtual int open_section (const ACE_Configuration_Section_Key &base, const ACE_TCHAR *sub_section, - int create, + bool create, ACE_Configuration_Section_Key& result) = 0; /// Removes a named section. @@ -355,7 +355,7 @@ public: int expand_path (const ACE_Configuration_Section_Key& key, const ACE_TString& path_in, ACE_Configuration_Section_Key& key_out, - int create = 1); + bool create = true); /** * Determine if the contents of this object is the same as the @@ -453,14 +453,15 @@ public: * base registry key to attach to. This class takes ownership of * hKey, it will invoke <RegCloseKey> on it upon destruction. */ - explicit ACE_Configuration_Win32Registry (HKEY hKey); + explicit ACE_Configuration_Win32Registry (HKEY hKey, + u_long security_access = KEY_ALL_ACCESS); /// Destructor virtual ~ACE_Configuration_Win32Registry (void); virtual int open_section (const ACE_Configuration_Section_Key& base, const ACE_TCHAR* sub_section, - int create, + bool create, ACE_Configuration_Section_Key& result); virtual int remove_section (const ACE_Configuration_Section_Key& key, @@ -520,7 +521,8 @@ public: */ static HKEY resolve_key (HKEY hKey, const ACE_TCHAR* path, - int create = 1); + bool create = true, + u_long security_access = KEY_ALL_ACCESS); virtual bool operator== (const ACE_Configuration_Win32Registry &rhs) const; virtual bool operator!= (const ACE_Configuration_Win32Registry &rhs) const; @@ -533,6 +535,8 @@ protected: ACE_Configuration_Win32Registry (void); ACE_Configuration_Win32Registry (const ACE_Configuration_Win32Registry& rhs); ACE_Configuration_Win32Registry& operator= (const ACE_Configuration_Win32Registry& rhs); + + const u_long security_access_; }; #endif /* ACE_WIN32 && !ACE_LACKS_WIN32_REGISTRY */ @@ -808,7 +812,7 @@ public: virtual int open_section (const ACE_Configuration_Section_Key& base, const ACE_TCHAR* sub_section, - int create, ACE_Configuration_Section_Key& result); + bool create, ACE_Configuration_Section_Key& result); virtual int remove_section (const ACE_Configuration_Section_Key& key, const ACE_TCHAR* sub_section, @@ -860,8 +864,8 @@ public: private: /// @a sub_section may not contain path separators int open_simple_section (const ACE_Configuration_Section_Key &base, - const ACE_TCHAR *sub_section, - int create, ACE_Configuration_Section_Key &result); + const ACE_TCHAR *sub_section, + bool create, ACE_Configuration_Section_Key &result); /// Adds a new section int add_section (const ACE_Configuration_Section_Key &base, const ACE_TCHAR *sub_section, diff --git a/ACE/ace/Monotonic_Time_Policy.h b/ACE/ace/Monotonic_Time_Policy.h index 77e822e6a3d..9ec9f8d9f8e 100644 --- a/ACE/ace/Monotonic_Time_Policy.h +++ b/ACE/ace/Monotonic_Time_Policy.h @@ -25,8 +25,8 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL * * This class implements support for returning monotonic time values * on platforms that support that. - * If a platform does not support monotonic time the policy returns - * ACE_Time_Value::zero. + * If a platform does not support monotonic time ACE_HAS_MONOTONIC_TIME_POLICY + * isn't defined and the policy returns ACE_Time_Value::zero. */ class ACE_Export ACE_Monotonic_Time_Policy { diff --git a/ACE/ace/Monotonic_Time_Policy.inl b/ACE/ace/Monotonic_Time_Policy.inl index bef06a049da..c295e0e50d1 100644 --- a/ACE/ace/Monotonic_Time_Policy.inl +++ b/ACE/ace/Monotonic_Time_Policy.inl @@ -7,16 +7,20 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE ACE_Time_Value_T<ACE_Monotonic_Time_Policy> ACE_Monotonic_Time_Policy::operator()() const { -# if defined (ACE_WIN32) +#if defined (ACE_HAS_MONOTONIC_TIME_POLICY) +# if defined (ACE_WIN32) return ACE_Time_Value_T<ACE_Monotonic_Time_Policy> (ACE_High_Res_Timer::gettimeofday_hr ()); -#elif (defined (_POSIX_MONOTONIC_CLOCK) && !defined (ACE_LACKS_MONOTONIC_TIME)) || defined (ACE_HAS_CLOCK_GETTIME_MONOTONIC) +# elif defined (ACE_HAS_CLOCK_GETTIME_MONOTONIC) struct timespec ts; if (ACE_OS::clock_gettime (CLOCK_MONOTONIC, &ts) == 0) return ACE_Time_Value_T<ACE_Monotonic_Time_Policy>(ts); else return ACE_Time_Value_T<ACE_Monotonic_Time_Policy> (ACE_Time_Value::zero); -#else +# else +# error "ACE_HAS_MONOTONIC_TIME_POLICY is defined, but no implementation is valid" +# endif /* ACE_WIN32 */ +#else /* !ACE_HAS_MONOTONIC_TIME_POLICY */ return ACE_Time_Value_T<ACE_Monotonic_Time_Policy> (ACE_Time_Value::zero); #endif } diff --git a/ACE/ace/OS_NS_Thread.inl b/ACE/ace/OS_NS_Thread.inl index 65a7fba0482..8e1e1e94204 100644 --- a/ACE/ace/OS_NS_Thread.inl +++ b/ACE/ace/OS_NS_Thread.inl @@ -143,24 +143,24 @@ ACE_OS::condattr_init (ACE_condattr_t &attributes, int type) # if defined (ACE_HAS_PTHREADS) int result = -1; -# if !defined (ACE_LACKS_CONDATTR) -# if defined (ACE_PTHREAD_CONDATTR_T_INITIALIZE) +# if !defined (ACE_LACKS_CONDATTR) +# if defined (ACE_PTHREAD_CONDATTR_T_INITIALIZE) /* Tests show that VxWorks 6.x pthread lib does not only * require zeroing of mutex/condition objects to function correctly * but also of the attribute objects. */ ACE_OS::memset (&attributes, 0, sizeof (attributes)); -# endif +# endif if ( ACE_ADAPT_RETVAL (pthread_condattr_init (&attributes), result) == 0 -# if defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_CONDATTR_PSHARED) +# if defined (_POSIX_THREAD_PROCESS_SHARED) && !defined (ACE_LACKS_CONDATTR_PSHARED) && ACE_ADAPT_RETVAL (pthread_condattr_setpshared (&attributes, type), result) == 0 -# endif /* _POSIX_THREAD_PROCESS_SHARED && ! ACE_LACKS_CONDATTR_PSHARED */ +# endif /* _POSIX_THREAD_PROCESS_SHARED && ! ACE_LACKS_CONDATTR_PSHARED */ ) -# else +# else if (type == USYNC_THREAD) -# endif /* !ACE_LACKS_CONDATTR */ +# endif /* !ACE_LACKS_CONDATTR */ result = 0; else { @@ -218,31 +218,18 @@ ACE_OS::condattr_synctype (ACE_condattr_t &attributes, int& type) ACE_INLINE int ACE_OS::condattr_setclock (ACE_condattr_t &attributes, clockid_t clock_id) { -# if defined (ACE_HAS_THREADS) -# if defined (ACE_HAS_PTHREADS) && !defined (ACE_LACKS_CONDATTR) +#if defined (ACE_HAS_CONDATTR_SETCLOCK) && !defined (ACE_LACKS_CONDATTR_SETCLOCK) && \ + !defined (ACE_LACKS_CONDATTR_SETCLOCK) int result = -1; - -# if defined (_POSIX_CLOCK_SELECTION) && !defined (ACE_LACKS_CONDATTR_SETCLOCK) ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (pthread_condattr_setclock (&attributes, clock_id), result), int, -1); -# else - ACE_UNUSED_ARG (clock_id); - ACE_UNUSED_ARG (attributes); -# endif /* _POSIX_CLOCK_SELECTION) && !ACE_LACKS_CONDATTR_SETCLOCK */ - return result; -# else - ACE_UNUSED_ARG (clock_id); - ACE_UNUSED_ARG (attributes); - ACE_NOTSUP_RETURN (-1); -# endif /* ACE_HAS_PTHREADS && !ACE_LACKS_CONDATTR */ - -# else +#else ACE_UNUSED_ARG (clock_id); ACE_UNUSED_ARG (attributes); ACE_NOTSUP_RETURN (-1); -# endif /* ACE_HAS_THREADS */ +#endif } #if !defined (ACE_LACKS_COND_T) diff --git a/ACE/ace/OS_NS_time.inl b/ACE/ace/OS_NS_time.inl index bc81f93a844..0249ead4b18 100644 --- a/ACE/ace/OS_NS_time.inl +++ b/ACE/ace/OS_NS_time.inl @@ -317,9 +317,9 @@ ACE_OS::gethrtime (const ACE_HRTimer_Op op) u_long most; u_long least; -#if defined (ghs) +# if defined (ghs) ACE_OS::readPPCTimeBase (most, least); -#else +# else u_long scratch; do { @@ -328,7 +328,7 @@ ACE_OS::gethrtime (const ACE_HRTimer_Op op) "mftbu %2" : "=r" (most), "=r" (least), "=r" (scratch)); } while (most != scratch); -#endif +# endif return 0x100000000llu * most + least; @@ -338,11 +338,11 @@ ACE_OS::gethrtime (const ACE_HRTimer_Op op) struct timespec ts; ACE_OS::clock_gettime ( -#if defined (ACE_HAS_CLOCK_GETTIME_MONOTONIC) +# if defined (ACE_HAS_CLOCK_GETTIME_MONOTONIC) CLOCK_MONOTONIC, -#else +# else CLOCK_REALTIME, -#endif /* !ACE_HAS_CLOCK_GETTIME_MONOTONIC */ +# endif /* !ACE_HAS_CLOCK_GETTIME_MONOTONIC */ &ts); // Carefully create the return value to avoid arithmetic overflow diff --git a/ACE/ace/config-hpux-11.00.h b/ACE/ace/config-hpux-11.00.h index 995bfd9878b..48829300ee3 100644 --- a/ACE/ace/config-hpux-11.00.h +++ b/ACE/ace/config-hpux-11.00.h @@ -162,7 +162,6 @@ #define ACE_HAS_CLOCK_SETTIME #define ACE_LACKS_CLOCK_MONOTONIC -#define ACE_LACKS_MONOTONIC_TIME #define ACE_LACKS_PTHREAD_SCOPE_PROCESS diff --git a/ACE/ace/config-macros.h b/ACE/ace/config-macros.h index dc292523ffb..ae5c0b0621b 100644 --- a/ACE/ace/config-macros.h +++ b/ACE/ace/config-macros.h @@ -700,4 +700,22 @@ extern "C" u_long CLS##_Export _get_dll_unload_policy (void) \ # define ACE_LACKS_CONDATTR_PSHARED #endif +#ifdef ACE_LACKS_CONDATTR_SETCLOCK +# ifdef ACE_HAS_CONDATTR_SETCLOCK +# undef ACE_HAS_CONDATTR_SETCLOCK +# endif +# ifdef ACE_HAS_POSIX_MONOTONIC_CONDITIONS +# undef ACE_HAS_POSIX_MONOTONIC_CONDITIONS +# endif +# ifdef ACE_HAS_MONOTONIC_CONDITIONS +# undef ACE_HAS_MONOTONIC_CONDITIONS +# endif +#endif + +#if defined (ACE_HAS_CLOCK_GETTIME_MONOTONIC) && !defined (ACE_LACKS_CLOCK_MONOTONIC) +# ifndef ACE_HAS_MONOTONIC_TIME_POLICY +# define ACE_HAS_MONOTONIC_TIME_POLICY +# endif +#endif + #endif /* ACE_CONFIG_MACROS_H */ diff --git a/ACE/ace/config-posix.h b/ACE/ace/config-posix.h index 781b7a8daa8..35fa4f8ca5e 100644 --- a/ACE/ace/config-posix.h +++ b/ACE/ace/config-posix.h @@ -58,6 +58,11 @@ # define ACE_HAS_PTHREADS # endif /* ACE_HAS_PTHREADS */ +# if defined (_POSIX_CLOCK_SELECTION) && (_POSIX_POSIX_CLOCK_SELECTION-0 != -1) +# if !defined (ACE_HAS_CONDATTR_SETCLOCK) && !defined (ACE_LACKS_CONDATTR_SETCLOCK) +# define ACE_HAS_CONDATTR_SETCLOCK +# endif +# endif # endif /* _POSIX_THREADS */ # endif /* ACE_HAS_THREADS */ #endif /* !ACE_MT_SAFE */ @@ -68,4 +73,19 @@ # endif /* ACE_HAS_POSIX_MESSAGE_PASSING */ #endif /* _POSIX_MESSAGE_PASSING */ +#if defined (_POSIX_MONOTONIC_CLOCK) && (_POSIX_MONOTONIC_CLOCK-0 != -1) +# if !defined (ACE_HAS_CLOCK_GETTIME_MONOTONIC) && !defined (ACE_LACKS_CLOCK_MONOTONIC) +# define ACE_HAS_CLOCK_GETTIME_MONOTONIC +# endif +#endif + +#if defined (ACE_HAS_CONDATTR_SETCLOCK) && defined (ACE_HAS_CLOCK_GETTIME_MONOTONIC) +# if !defined (ACE_HAS_POSIX_MONOTONIC_CONDITIONS) +# define ACE_HAS_POSIX_MONOTONIC_CONDITIONS +# endif +# if !defined (ACE_HAS_MONOTONIC_CONDITIONS) +# define ACE_HAS_MONOTONIC_CONDITIONS +# endif +#endif + #endif /* ACE_CONFIG_POSIX_H */ diff --git a/ACE/ace/config-win32-common.h b/ACE/ace/config-win32-common.h index 56567eead08..c9a4cf6abb2 100644 --- a/ACE/ace/config-win32-common.h +++ b/ACE/ace/config-win32-common.h @@ -253,6 +253,8 @@ #define ACE_LACKS_CLOCKID_T #define ACE_LACKS_CLOCK_REALTIME #define ACE_LACKS_CLOCK_MONOTONIC +#define ACE_HAS_MONOTONIC_TIME_POLICY +#define ACE_HAS_MONOTONIC_CONDITIONS /* LACKS gid/pid/sid/uid facilities */ #define ACE_LACKS_GETPGID diff --git a/ACE/docs/ACE-monotonic-timer.html b/ACE/docs/ACE-monotonic-timer.html index d50535adb30..afdfb359c4d 100644 --- a/ACE/docs/ACE-monotonic-timer.html +++ b/ACE/docs/ACE-monotonic-timer.html @@ -24,7 +24,7 @@ H3 { margin-bottom: 0.08in } H3.western { font-family: "Liberation Sans", sans-serif; font-size: 13pt } H3.cjk { font-family: "Droid Sans Fallback" } - PRE { margin-left: 0.49in; border-top: none; border-bottom: none; border-left: 1.05pt solid #808080; border-right: none; padding-top: 0in; padding-bottom: 0in; padding-left: 0.02in; padding-right: 0in } + PRE { margin-left: 0.20in; margin-bottom: 0.20in; border-top: none; border-bottom: none; border-left: 1.05pt solid #808080; border-right: none; padding-top: 0in; padding-bottom: 0in; padding-left: 0.02in; padding-right: 0in } PRE.cjk { font-family: "Droid Sans Fallback", monospace } --> </STYLE> @@ -42,7 +42,7 @@ which provide support to use monotonic timers for condition and event variables to solve the problem of system timeshift vulnerability of the ACE Condition and Event variable timeout functionality.</P> -<H3 CLASS="western">Background</H3> +<H2 CLASS="western">Background</H2> <P>ACE Condition and Event variables implement an API to wait for the condition or event to be signalled with a maximum wait timeout value. This timeout value must be specified as <B>absolute time</B><SPAN STYLE="font-weight: normal"> @@ -77,11 +77,11 @@ values which are correct relative to previously returned time values (at least within the lifetime of a single running process).</P> <P STYLE="font-weight: normal">The customer encountered this problem while making use of the ACE_Message_Queue classes in the -implementation of their application. The enqueu/dequeue functionality +implementation of their application. The enqueue/dequeue functionality of the message queues makes heavy use of the ACE Condition variable timed wait support. The customer also used ACE_Event derived classes which suffer from the same vulnerability.</P> -<H3 CLASS="western">Requirements</H3> +<H2 CLASS="western">Requirements</H2> <P STYLE="font-weight: normal">Prerequisites for the solution are:</P> <UL> <LI><P STYLE="font-weight: normal">maintain backward compatibility @@ -115,10 +115,7 @@ values.</P> it is now possible to set up message queues that support monotonic time values for timed wait methods in a portable way as will be shown in the following section.</P> -<H3 CLASS="western"><BR><BR> -</H3> -<H3 CLASS="western" STYLE="page-break-before: always"><B>User Code -Changes</B></H3> +<H2 CLASS="western" STYLE="page-break-before: always">User Code Changes</H2> <P STYLE="font-weight: normal">The following are examples of user code changes required to update an application to support monotonic timed message queues.</P> @@ -130,11 +127,9 @@ values the new ACE_Monotonic_Time_Policy should be used. <P STYLE="font-weight: normal">So, where an existing application declared a Message_Queue as:</P> <PRE CLASS="western" STYLE="font-weight: normal">ACE_Message_Queue<ACE_MT_SYNCH> msg_queue_;</PRE><P STYLE="font-weight: normal"> -<BR><BR> </P> <P STYLE="font-weight: normal">this would need to change to:</P> <PRE CLASS="western" STYLE="font-weight: normal">ACE_Message_Queue<ACE_MT_SYNCH, ACE_Monotonic_Time_Policy> msg_queue_;</PRE><P STYLE="font-weight: normal"> -<BR><BR> </P> <P STYLE="font-weight: normal">The changes for task are similar:</P> <PRE CLASS="western" STYLE="font-weight: normal">class MyTask : public ACE_Task<ACE_MT_SYNCH> @@ -146,7 +141,6 @@ should change to:</P> { … };</PRE><P STYLE="font-weight: normal"> -<BR><BR> </P> <P STYLE="font-weight: normal">To specify timeout values to these message queues on the enqueue/dequeue operations you would have to @@ -154,7 +148,6 @@ use time values that are Time_Policy aware. To that end a templated derivative of ACE_Time_Value has been implemented allowing one to declare a time value as:</P> <PRE CLASS="western" STYLE="font-weight: normal">ACE_Time_Value_T<ACE_Monotonic_Time_Policy> timeout_;</PRE><P STYLE="font-weight: normal"> -<BR><BR> </P> <P STYLE="font-weight: normal">The updated Message_Queue and Task classes provide a convenience method to initialize such a time value @@ -164,28 +157,25 @@ with the time policy based time of day as follows:</P> <B>// or</B> ACE_Time_Value_T<ACE_Monotonic_Time_Policy> timeout_; timeout_ = msg_queue_.gettimeofday ();</PRE><P STYLE="font-weight: normal"> -<BR><BR> </P> <P STYLE="font-weight: normal">The return type of this method is a time policy specific time value as follows:</P> -<PRE CLASS="western" STYLE="font-weight: normal">tempate <ACE_SYNCH_DECL, class TIME_POLICY> +<PRE CLASS="western" STYLE="font-weight: normal">template <ACE_SYNCH_DECL, class TIME_POLICY> class ACE_Message_Queue : public ACE_Message_Queue_Base { … ACE_Time_Value_T<TIME_POLICY> gettimeofday () const; … };</PRE><P STYLE="font-weight: normal"> -<BR><BR> </P> <P STYLE="font-weight: normal">To define a wait timeout of 5 sec and -execute an enqueu operation the following would apply:</P> +execute an enqueue operation the following would apply:</P> <PRE CLASS="western" STYLE="font-weight: normal">... ACE_Time_Value_T<ACE_Monotonic_Time_Policy> timeout_; timeout_ = msg_queue_.gettimeofday (); timeout_ += ACE_Time_Value (5,0); msg_queue_.enqueue (msg_block, &timeout_); …</PRE><P STYLE="font-weight: normal"> -<BR><BR> </P> <P STYLE="font-weight: normal">Similar changes apply to the refactored ACE_Event classes. In addition to the added support for time policies also a new base class is introduced to allow @@ -210,7 +200,6 @@ evt.wait (&timeout_); ACE_Time_Value_T<ACE_Monotonic_Time_Policy> timeout_ (5,0); evt.wait (&timeout_, 0); </PRE><P STYLE="font-weight: normal"> -<BR><BR> </P> <P><B>NOTE:</B><SPAN STYLE="font-weight: normal"> To function properly the ACE_Time_Value pointer passed to the timed wait methods @@ -248,7 +237,6 @@ ACE_Time_Value_T<ACE_Monotonic_Time_Policy> tv; // now () returns an ACE_Time_Value representing current time according // to the active time policy of tv tv = tv.now () + tdiff;</PRE><P STYLE="font-style: normal; font-weight: normal"> -<BR><BR> </P> <P STYLE="font-style: normal; font-weight: normal">More examples code can be found in the following regression tests</P> @@ -258,6 +246,26 @@ can be found in the following regression tests</P> <LI><P STYLE="font-style: normal; font-weight: normal">$ACE_ROOT/tests/Monotonic_Message_Queue_Test</P> <LI><P STYLE="font-style: normal; font-weight: normal">$ACE_ROOT/tests/Monotonic_Manual_Event_Test</P> </UL> + +<h2 class="western">Testing for Monotonic Time Support</h2> + +<p>Support for monotonic time in ACE can be determined by testing for the +existence of these two preprocessor macros that would be defined by ACE +platform headers:</p> + +<ul> +<li><p> + The <code>ACE_HAS_MONOTONIC_TIME_POLICY</code> preprocessor macro is defined + when <code>ACE_Monotonic_Time_Policy</code> by itself should be supported. +</p></li> +<li><p> + The <code>ACE_HAS_MONOTONIC_CONDITIONS</code> preprocessor macro is defined + when <code>ACE_Condition</code>s should support waiting for a monotonic point + in time using + <code>ACE_Condition_Attributes<ACE_Monotonic_Time_Policy></code>. +</p></li> +</ul> + <DIV TYPE=FOOTER> <P STYLE="margin-top: 0.2in; margin-bottom: 0in"><BR> </P> diff --git a/ACE/tests/.gitignore b/ACE/tests/.gitignore index 8da5ea9d5fd..91d8a0c9947 100644 --- a/ACE/tests/.gitignore +++ b/ACE/tests/.gitignore @@ -261,6 +261,7 @@ /TSS_Test /Unbounded_Set_Test /Unbounded_Set_Test_Ex +/UNIX_Addr_Test /UnloadLibACE /Upgradable_RW_Test /UPIPE_SAP_Test diff --git a/ACE/tests/Bug_4055_Regression_Test.cpp b/ACE/tests/Bug_4055_Regression_Test.cpp index c1e3e4ff5db..4aa1d30a3c3 100644 --- a/ACE/tests/Bug_4055_Regression_Test.cpp +++ b/ACE/tests/Bug_4055_Regression_Test.cpp @@ -22,15 +22,13 @@ #include "ace/Task_T.h" #include "ace/Truncate.h" -# if defined (ACE_WIN32) || \ - (defined (_POSIX_MONOTONIC_CLOCK) && !defined (ACE_LACKS_MONOTONIC_TIME)) || \ - defined (ACE_HAS_CLOCK_GETTIME_MONOTONIC) +#if defined (ACE_HAS_MONOTONIC_TIME_POLICY) && defined (ACE_HAS_MONOTONIC_CONDITIONS) -# if defined (ACE_HAS_THREADS) +# if defined (ACE_HAS_THREADS) -# if defined (ACE_WIN32) -# include "ace/Date_Time.h" -# endif +# if defined (ACE_WIN32) +# include "ace/Date_Time.h" +# endif // Create timer queue with hr support ACE_Timer_Queue * @@ -59,10 +57,10 @@ public: int start (int num_threads); int stop (void); ACE_Reactor* get_reactor (); - int create_reactor (void); + int create_reactor (void); private: - int delete_reactor (void); + int delete_reactor (void); ACE_SYNCH_RECURSIVE_MUTEX lock_; ACE_Reactor *my_reactor_; @@ -230,7 +228,7 @@ bool test_timer (ACE_Condition_Thread_Mutex& condition_, ACE_Time_Value& waittim // reset system clock 4 seconds backwards ACE_Time_Value curtime = ACE_OS::gettimeofday (); curtime -= ACE_Time_Value (4, 0); -# if defined (ACE_WIN32) +# if defined (ACE_WIN32) ACE_Date_Time curdt (curtime); SYSTEMTIME sys_time; sys_time.wDay = ACE_Utils::truncate_cast <WORD> (curdt.day ()); @@ -241,11 +239,11 @@ bool test_timer (ACE_Condition_Thread_Mutex& condition_, ACE_Time_Value& waittim sys_time.wSecond = ACE_Utils::truncate_cast <WORD> (curdt.second ()); sys_time.wMilliseconds = ACE_Utils::truncate_cast <WORD> (curdt.microsec () / 1000); if (!::SetLocalTime (&sys_time)) -# else +# else timespec_t curts; curts = curtime; if (ACE_OS::clock_settime (CLOCK_REALTIME, &curts) != 0) -# endif +# endif { ACE_DEBUG((LM_INFO, "(%P|%t) Unable to reset OS time. Insufficient privileges or not supported.\n")); @@ -290,7 +288,7 @@ bool test_timer (ACE_Condition_Thread_Mutex& condition_, ACE_Time_Value& waittim // reset system clock to correct time curtime = ACE_OS::gettimeofday (); curtime += ACE_Time_Value (4, 0); -# if defined (ACE_WIN32) +# if defined (ACE_WIN32) curdt.update (curtime); SYSTEMTIME sys_time; sys_time.wDay = ACE_Utils::truncate_cast <WORD> (curdt.day ()); @@ -301,10 +299,10 @@ bool test_timer (ACE_Condition_Thread_Mutex& condition_, ACE_Time_Value& waittim sys_time.wSecond = ACE_Utils::truncate_cast <WORD> (curdt.second ()); sys_time.wMilliseconds = ACE_Utils::truncate_cast <WORD> (curdt.microsec () / 1000); if (!::SetLocalTime (&sys_time)) -# else +# else curts = curtime; if (ACE_OS::clock_settime (CLOCK_REALTIME, &curts) != 0) -# endif +# endif { ACE_DEBUG((LM_INFO, "(%P|%t) Unable to reset OS time. Insufficient privileges or not supported.\n")); @@ -319,13 +317,13 @@ bool test_timer (ACE_Condition_Thread_Mutex& condition_, ACE_Time_Value& waittim return status; } -# endif +# endif int run_main (int , ACE_TCHAR *[]) { ACE_START_TEST (ACE_TEXT ("Bug_4055_Regression_Test")); -# if defined (ACE_HAS_THREADS) +# if defined (ACE_HAS_THREADS) int status = 1; ACE_Thread_Mutex mutex_; @@ -349,9 +347,9 @@ run_main (int , ACE_TCHAR *[]) status = 0; } } -# else +# else int status = 0; -# endif +# endif ACE_END_TEST; return status; } diff --git a/ACE/tests/Monotonic_Manual_Event_Test.cpp b/ACE/tests/Monotonic_Manual_Event_Test.cpp index 1979e7f3d8f..f38def4bafb 100644 --- a/ACE/tests/Monotonic_Manual_Event_Test.cpp +++ b/ACE/tests/Monotonic_Manual_Event_Test.cpp @@ -21,23 +21,17 @@ #include "ace/OS_NS_unistd.h" #include "ace/Atomic_Op.h" -#if defined (ACE_WIN32) || \ - (defined (ACE_HAS_CLOCK_GETTIME) && \ - !defined (ACE_LACKS_MONOTONIC_TIME) && \ - !defined (ACE_LACKS_CONDATTR) && \ - (defined (_POSIX_MONOTONIC_CLOCK) || defined (ACE_HAS_CLOCK_GETTIME_MONOTONIC)) && \ - defined (_POSIX_CLOCK_SELECTION) && !defined (ACE_LACKS_CONDATTR_SETCLOCK)) - -# include "ace/Monotonic_Time_Policy.h" -# if defined (ACE_WIN32) -# include "ace/Date_Time.h" -# include "ace/Truncate.h" -# endif +#if defined (ACE_HAS_MONOTONIC_TIME_POLICY) && defined (ACE_HAS_MONOTONIC_CONDITIONS) +# include "ace/Monotonic_Time_Policy.h" +# if defined (ACE_WIN32) +# include "ace/Date_Time.h" +# include "ace/Truncate.h" +# endif // Test results, 'success' is 0 static int test_result = 0; -#if defined (ACE_HAS_THREADS) +# if defined (ACE_HAS_THREADS) // Event used in the tests. Start it "unsignalled" (i.e., its initial // state is 0). @@ -53,13 +47,13 @@ static long n_workers = 10; static ACE_Time_Value *initial_timeout; // Number of wakeups. -#if defined (ACE_HAS_BUILTIN_ATOMIC_OP) +# if defined (ACE_HAS_BUILTIN_ATOMIC_OP) static ACE_Atomic_Op<ACE_Thread_Mutex, long> n_awoken; static ACE_Atomic_Op<ACE_Thread_Mutex, long> n_awoken2; -#else +# else static long n_awoken; static long n_awoken2; -#endif +# endif // Explain usage and exit. static void @@ -94,7 +88,7 @@ parse_args (int argc, ACE_TCHAR *argv[]) void set_system_time(const ACE_Time_Value& tv) { -# if defined (ACE_WIN32) +# if defined (ACE_WIN32) ACE_Date_Time curdt (tv); SYSTEMTIME sys_time; sys_time.wDay = ACE_Utils::truncate_cast <WORD> (curdt.day ()); @@ -105,11 +99,11 @@ void set_system_time(const ACE_Time_Value& tv) sys_time.wSecond = ACE_Utils::truncate_cast <WORD> (curdt.second ()); sys_time.wMilliseconds = ACE_Utils::truncate_cast <WORD> (curdt.microsec () / 1000); if (!::SetLocalTime (&sys_time)) -# else +# else timespec_t curts; curts = tv; if (ACE_OS::clock_settime (CLOCK_REALTIME, &curts) != 0) -# endif +# endif { ACE_DEBUG((LM_INFO, "(%P|%t) Unable to reset OS time. Insufficient privileges or not supported.\n")); @@ -218,7 +212,7 @@ worker (void *) return 0; } -#endif /* ACE_HAS_THREADS */ +# endif /* ACE_HAS_THREADS */ // Test event functionality. @@ -226,7 +220,7 @@ int run_main (int argc, ACE_TCHAR *argv[]) { ACE_START_TEST (ACE_TEXT ("Monotonic_Manual_Event_Test")); -#if defined (ACE_HAS_THREADS) +# if defined (ACE_HAS_THREADS) ACE_Manual_Event_T<ACE_Monotonic_Time_Policy> monotonic_event (0); ACE_Manual_Event systime_event (0); ACE_Time_Value_T<ACE_Monotonic_Time_Policy> tm_mono; @@ -304,12 +298,12 @@ int run_main (int argc, ACE_TCHAR *argv[]) 1); ACE_Thread_Manager::instance ()->wait (); -#else +# else ACE_UNUSED_ARG (argc); ACE_UNUSED_ARG (argv); ACE_ERROR ((LM_INFO, ACE_TEXT ("Threads not supported on this platform\n"))); -#endif /* ACE_HAS_THREADS */ +# endif /* ACE_HAS_THREADS */ ACE_END_TEST; return test_result; } diff --git a/ACE/tests/Monotonic_Message_Queue_Test.cpp b/ACE/tests/Monotonic_Message_Queue_Test.cpp index 9ffdc691143..bbe1f5f594f 100644 --- a/ACE/tests/Monotonic_Message_Queue_Test.cpp +++ b/ACE/tests/Monotonic_Message_Queue_Test.cpp @@ -32,18 +32,13 @@ #include "ace/OS_NS_time.h" #include "ace/OS_NS_unistd.h" -#if defined (ACE_WIN32) || \ - (defined (ACE_HAS_CLOCK_GETTIME) && \ - !defined (ACE_LACKS_MONOTONIC_TIME) && \ - !defined (ACE_LACKS_CONDATTR) && \ - (defined (_POSIX_MONOTONIC_CLOCK) || defined (ACE_HAS_CLOCK_GETTIME_MONOTONIC)) && \ - defined (_POSIX_CLOCK_SELECTION) && !defined (ACE_LACKS_CONDATTR_SETCLOCK)) - -# if defined (ACE_WIN32) -# include "ace/Date_Time.h" -# endif - -# if defined (ACE_HAS_THREADS) +#if defined (ACE_HAS_MONOTONIC_TIME_POLICY) && defined (ACE_HAS_MONOTONIC_CONDITIONS) + +# if defined (ACE_WIN32) +# include "ace/Date_Time.h" +# endif + +# if defined (ACE_HAS_THREADS) typedef ACE_Message_Queue<ACE_MT_SYNCH, ACE_Monotonic_Time_Policy> SYNCH_QUEUE; // Create timer queue with hr support @@ -226,7 +221,7 @@ bool TestHandler::trigger_in(const ACE_Time_Value &delay) void set_system_time(const ACE_Time_Value& tv) { -# if defined (ACE_WIN32) +# if defined (ACE_WIN32) ACE_Date_Time curdt (tv); SYSTEMTIME sys_time; sys_time.wDay = ACE_Utils::truncate_cast <WORD> (curdt.day ()); @@ -237,11 +232,11 @@ void set_system_time(const ACE_Time_Value& tv) sys_time.wSecond = ACE_Utils::truncate_cast <WORD> (curdt.second ()); sys_time.wMilliseconds = ACE_Utils::truncate_cast <WORD> (curdt.microsec () / 1000); if (!::SetLocalTime (&sys_time)) -# else +# else timespec_t curts; curts = tv; if (ACE_OS::clock_settime (CLOCK_REALTIME, &curts) != 0) -# endif +# endif { ACE_DEBUG((LM_INFO, "(%P|%t) Unable to reset OS time. Insufficient privileges or not supported.\n")); @@ -340,7 +335,7 @@ timeout_test (void) return status; } -# endif /* ACE_HAS_THREADS */ +# endif /* ACE_HAS_THREADS */ int run_main (int , ACE_TCHAR *[]) @@ -349,7 +344,7 @@ run_main (int , ACE_TCHAR *[]) int status = 0; -# if defined (ACE_HAS_THREADS) +# if defined (ACE_HAS_THREADS) if (!timeout_test ()) { ACE_ERROR ((LM_ERROR, @@ -357,7 +352,7 @@ run_main (int , ACE_TCHAR *[]) ACE_TEXT ("test failed"))); status = 1; } -# endif /* ACE_HAS_THREADS */ +# endif /* ACE_HAS_THREADS */ ACE_END_TEST; return status; diff --git a/ACE/tests/Monotonic_Task_Test.cpp b/ACE/tests/Monotonic_Task_Test.cpp index 7c4c0db3843..755207ab16a 100644 --- a/ACE/tests/Monotonic_Task_Test.cpp +++ b/ACE/tests/Monotonic_Task_Test.cpp @@ -35,22 +35,17 @@ #include "ace/OS_NS_time.h" #include "ace/OS_NS_unistd.h" -#if defined (ACE_WIN32) || \ - (defined (ACE_HAS_CLOCK_GETTIME) && \ - !defined (ACE_LACKS_MONOTONIC_TIME) && \ - !defined (ACE_LACKS_CONDATTR) && \ - (defined (_POSIX_MONOTONIC_CLOCK) || defined (ACE_HAS_CLOCK_GETTIME_MONOTONIC)) && \ - defined (_POSIX_CLOCK_SELECTION) && !defined (ACE_LACKS_CONDATTR_SETCLOCK)) +#if defined (ACE_HAS_MONOTONIC_TIME_POLICY) && defined (ACE_HAS_MONOTONIC_CONDITIONS) -# if defined (ACE_WIN32) -# include "ace/Date_Time.h" -# endif +# if defined (ACE_WIN32) +# include "ace/Date_Time.h" +# endif -# if defined (ACE_HAS_THREADS) +# if defined (ACE_HAS_THREADS) void set_system_time(const ACE_Time_Value& tv) { -# if defined (ACE_WIN32) +# if defined (ACE_WIN32) ACE_Date_Time curdt (tv); SYSTEMTIME sys_time; sys_time.wDay = ACE_Utils::truncate_cast <WORD> (curdt.day ()); @@ -61,11 +56,11 @@ void set_system_time(const ACE_Time_Value& tv) sys_time.wSecond = ACE_Utils::truncate_cast <WORD> (curdt.second ()); sys_time.wMilliseconds = ACE_Utils::truncate_cast <WORD> (curdt.microsec () / 1000); if (!::SetLocalTime (&sys_time)) -# else +# else timespec_t curts; curts = tv; if (ACE_OS::clock_settime (CLOCK_REALTIME, &curts) != 0) -# endif +# endif { ACE_DEBUG((LM_INFO, "(%P|%t) Unable to reset OS time. Insufficient privileges or not supported.\n")); @@ -263,7 +258,7 @@ MyTask::svc (void) return 0; } -# endif /* ACE_HAS_THREADS */ +# endif /* ACE_HAS_THREADS */ int run_main (int , ACE_TCHAR *[]) @@ -272,7 +267,7 @@ run_main (int , ACE_TCHAR *[]) int status = 0; -# if defined (ACE_HAS_THREADS) +# if defined (ACE_HAS_THREADS) MyTask my_task; if (my_task.start () == 0) @@ -325,7 +320,7 @@ run_main (int , ACE_TCHAR *[]) else status = 1; -# endif /* ACE_HAS_THREADS */ +# endif /* ACE_HAS_THREADS */ ACE_END_TEST; return status; |