diff options
author | Olli Savia <ops@iki.fi> | 2007-05-22 11:12:07 +0000 |
---|---|---|
committer | Olli Savia <ops@iki.fi> | 2007-05-22 11:12:07 +0000 |
commit | c430a8b7ff4158aedf021b153b1ae03bab8381e7 (patch) | |
tree | 3943915e5a14afc001dffe491407d208dd6f14c0 | |
parent | b303aaf662b4b0b7616acfd343a58ae6c784bf9c (diff) | |
download | ATCD-c430a8b7ff4158aedf021b153b1ae03bab8381e7.tar.gz |
ChangeLogTag: Tue May 22 11:10:30 UTC 2007 Olli Savia <ops@iki.fi>
-rw-r--r-- | ACE/ChangeLog | 11 | ||||
-rw-r--r-- | ACE/ace/OS_NS_math.h | 6 | ||||
-rw-r--r-- | ACE/ace/OS_NS_math.inl | 2 | ||||
-rw-r--r-- | ACE/tests/OS_Test.cpp | 6 |
4 files changed, 12 insertions, 13 deletions
diff --git a/ACE/ChangeLog b/ACE/ChangeLog index 7203b266811..af74da327eb 100644 --- a/ACE/ChangeLog +++ b/ACE/ChangeLog @@ -1,8 +1,17 @@ +Tue May 22 11:10:30 UTC 2007 Olli Savia <ops@iki.fi> + + * ace/OS_NS_math.h: + * ace/OS_NS_math.inl: + Added log2() emulation. + + * tests/OS_Test.cpp: + Simplified log2 test. + Tue May 22 10:03:26 UTC 2007 Olli Savia <ops@iki.fi> * ace/config-sunos5.10.h: It seems that Solaris 10 supports log2 so we can undefine - ACE_LACKS_LOG2. + ACE_LACKS_LOG2. Tue May 22 09:56:40 UTC 2007 Olli Savia <ops@iki.fi> diff --git a/ACE/ace/OS_NS_math.h b/ACE/ace/OS_NS_math.h index e6be2b46391..aa438d212f3 100644 --- a/ACE/ace/OS_NS_math.h +++ b/ACE/ace/OS_NS_math.h @@ -51,9 +51,7 @@ inline double ace_log2_helper (double x) # if !defined (ACE_LACKS_LOG2) return ACE_STD_NAMESPACE::log2 (x); # else - ACE_UNUSED_ARG (x); - unsigned long const ACE_NaN[2]= { 0xffffffff, 0x7fffffff }; - return *reinterpret_cast<double const *> (ACE_NaN); + return log (x) / log (2.0); # endif /* !ACE_LACKS_LOG2 */ #endif /* defined (log2) */ } @@ -70,11 +68,9 @@ namespace ACE_OS ACE_NAMESPACE_INLINE_FUNCTION double ceil (double x); -#if !defined (ACE_LACKS_LOG2) /// This method computes base-2 logarithm of x ACE_NAMESPACE_INLINE_FUNCTION double log2 (double x); -#endif /* !ACE_LACKS_LOG2 */ } /* namespace ACE_OS */ diff --git a/ACE/ace/OS_NS_math.inl b/ACE/ace/OS_NS_math.inl index 4f4f6779788..3cc3e37a5b5 100644 --- a/ACE/ace/OS_NS_math.inl +++ b/ACE/ace/OS_NS_math.inl @@ -30,13 +30,11 @@ namespace ACE_OS { return static_cast<long> (x) + 1; } -#if !defined (ACE_LACKS_LOG2) ACE_INLINE double log2 (double x) { return ace_log2_helper (x); } -#endif /* !ACE_LACKS_LOG2 */ } // ACE_OS namespace diff --git a/ACE/tests/OS_Test.cpp b/ACE/tests/OS_Test.cpp index 4de87205b34..33bc2eefafb 100644 --- a/ACE/tests/OS_Test.cpp +++ b/ACE/tests/OS_Test.cpp @@ -917,7 +917,6 @@ pagesize_test (void) return 0; } -#if !defined (ACE_LACKS_LOG2) int log2_test (void) { @@ -931,7 +930,7 @@ log2_test (void) for (size_t i = 0 ; i < sizeof (values) / sizeof (double) ; i++) { - result = static_cast<int> (ACE_OS::floor (ACE_OS::log2 (values [i]))); + result = static_cast<int> (ACE_OS::log2 (values [i]) + 0.5); if (result != results [i]) { ACE_ERROR ((LM_ERROR, ACE_TEXT ("Log2 error: input %.1F, output %d, expected %d\n"), values [i], result, results [i])); @@ -941,7 +940,6 @@ log2_test (void) return error_count; } -#endif /* !ACE_LACKS_LOG2 */ int run_main (int, ACE_TCHAR *[]) @@ -977,10 +975,8 @@ run_main (int, ACE_TCHAR *[]) if ((result = pagesize_test ()) != 0) status = result; -#if !defined (ACE_LACKS_LOG2) if ((result = log2_test ()) != 0) status = result; -#endif /* !ACE_LACKS_LOG2 */ ACE_END_TEST; return status; |