Changes to attempt to silence bcc64x
[ACE_TAO.git] / ACE / ace / OS_NS_math.h
blobede8de33bd1caf46f70eeb43ce7153e17f138331
1 // -*- C++ -*-
3 //=============================================================================
4 /**
5 * @file OS_NS_math.h
7 * @author Douglas C. Schmidt <d.schmidt@vanderbilt.edu>
8 * @author Jesper S. M|ller<stophph@diku.dk>
9 * @author and a cast of thousands...
11 //=============================================================================
13 #ifndef ACE_OS_NS_MATH_H
14 # define ACE_OS_NS_MATH_H
16 # include /**/ "ace/pre.h"
18 # include "ace/config-all.h"
20 # if !defined (ACE_LACKS_PRAGMA_ONCE)
21 # pragma once
22 # endif /* ACE_LACKS_PRAGMA_ONCE */
24 #include "ace/os_include/os_math.h"
25 #include <cmath>
27 #include /**/ "ace/ACE_export.h"
29 #if defined (ACE_EXPORT_MACRO)
30 # undef ACE_EXPORT_MACRO
31 #endif
32 #define ACE_EXPORT_MACRO ACE_Export
36 * We inline and undef some functions that may be implemented
37 * as macros on some platforms. This way macro definitions will
38 * be usable later as there is no way to save the macro definition
39 * using the pre-processor.
41 inline double ace_log2_helper (double x)
43 #if defined (log2)
44 return log2 (x);
45 #undef log2
46 #else
47 # if !defined (ACE_LACKS_LOG2)
48 return std::log2 (x);
49 # else
51 ==================================================================
53 log (x)
55 log (x) = -------
56 b log (b)
59 meaning the binary logarithm of x using the natural logarithm, for
60 example, is:
63 log (x)
65 log (x) = -------
66 2 log (2)
69 ==================================================================
72 // Precomputed value of 1/log(2.0). Saves an expensive division and
73 // computing log(2.0) in each call.
74 double const _1_ln2 = 1.442695040888963407359924681002;
76 return log (x) * _1_ln2;
77 # endif /* !ACE_LACKS_LOG2 */
78 #endif /* defined (log2) */
82 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
84 namespace ACE_OS
86 /// This method computes the largest integral value not greater than x.
87 template <typename T>
88 inline
89 T floor (T x)
91 return std::floor (x);
94 /// This method computes the smallest integral value not less than x.
95 template <typename T>
96 inline
97 T ceil (T x)
99 return std::ceil (x);
102 /// This method computes the base-2 logarithm of x.
103 ACE_NAMESPACE_INLINE_FUNCTION
104 double log2 (double x);
105 } /* namespace ACE_OS */
107 ACE_END_VERSIONED_NAMESPACE_DECL
109 # if defined (ACE_HAS_INLINED_OSCALLS)
110 # if defined (ACE_INLINE)
111 # undef ACE_INLINE
112 # endif /* ACE_INLINE */
113 # define ACE_INLINE inline
114 # include "ace/OS_NS_math.inl"
115 # endif /* ACE_HAS_INLINED_OSCALLS */
117 # include /**/ "ace/post.h"
118 #endif /* ACE_OS_NS_MATH_H */