summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlevine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1997-12-31 16:10:39 +0000
committerlevine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1997-12-31 16:10:39 +0000
commit7e42f620b7a96c0575a24790b77fbe2e18b19605 (patch)
tree0ce58843441407ab4f158d5c09647d7dbe9087d1
parentbb1e0d64ab646bf2976e8188235613c605c5a4ce (diff)
downloadATCD-7e42f620b7a96c0575a24790b77fbe2e18b19605.tar.gz
only use u_longlong_t on sun. Added operator++ to ACE_U_LongLong, and tweaked calculation in operator/
-rw-r--r--ace/Basic_Types.h20
-rw-r--r--ace/Basic_Types.i22
2 files changed, 34 insertions, 8 deletions
diff --git a/ace/Basic_Types.h b/ace/Basic_Types.h
index eeaed00f34c..60718e42fdc 100644
--- a/ace/Basic_Types.h
+++ b/ace/Basic_Types.h
@@ -142,20 +142,20 @@
# endif /* ULLONG_MAX */
#else /* ! ACE_WIN32 && ! ULLONG_MAX && ! __GNUG__ && ! ULONGLONG_MAX */
# if defined (ACE_HAS_LONGLONG_T)
- // Assume 8-byte longs. It would be better to #define
+ // Assume 8-byte long longs. It would be better to #define
// ACE_HAS_LONGLONG_T to the number of bytes in a long,
// but we'd have to do that consistently in all config files.
# define ACE_SIZEOF_LONG_LONG 8
# if ACE_SIZEOF_INT != 8 && ACE_SIZEOF_LONG != 8
-# if defined (__GNUG__) && !defined (__Lynx__) && \
- (!defined (linux) || defined (__GLIBC__))
- // So that g++ -pedantic doesn't complain about no ANSI C++ long long.
+# if defined (sun)
+ // sun #defines u_longlong_t, maybe other platforms do also.
+ // Use it, at least with g++, so that its -pedantic doesn't
+ // complain about no ANSI C++ long long.
typedef u_longlong_t ACE_UINT64;
# else
- // The g++ that ships with LynxOS 2.5.0 doesn't have u_longlong_t.
- // Same for Linux prior to glibc 2.0.
+ // LynxOS 2.5.0 and Linux don't have u_longlong_t.
typedef unsigned long long ACE_UINT64;
-# endif /* __GNUG__ && !__Lynx__ && (!inux || __GLIBC__) */
+# endif /* __GNUG__ && sun */
# endif /* ACE_SIZEOF_INT != 8 && ACE_SIZEOF_LONG != 8 */
# else /* ! ACE_HAS_LONGLONG_T */
@@ -190,9 +190,15 @@
ACE_U_LongLong operator+ (const ACE_U_LongLong &) const;
ACE_U_LongLong operator- (const ACE_U_LongLong &) const;
+
+ // Note that the following take ACE_UINT32 arguments. These are
+ // typical use cases, and easy to implement. But, they're very
+ // limited in the ranges of values that they can handle.
ACE_UINT32 operator/ (const ACE_UINT32) const;
+ // ACE_UINT32 operator% (const ACE_UINT32) const;
ACE_U_LongLong &operator+= (const ACE_U_LongLong &);
+ ACE_U_LongLong &operator++ ();
ACE_U_LongLong &operator-= (const ACE_U_LongLong &);
// = Helper methods.
diff --git a/ace/Basic_Types.i b/ace/Basic_Types.i
index 4eb872481ab..80f52471444 100644
--- a/ace/Basic_Types.i
+++ b/ace/Basic_Types.i
@@ -115,9 +115,21 @@ ACE_U_LongLong::operator- (const ACE_U_LongLong &ll) const
ACE_INLINE ACE_UINT32
ACE_U_LongLong::operator/ (const ACE_UINT32 ul) const
{
- return hi_ / ul * ULONG_MAX + lo_ / ul;
+ // This assumes integer division, so it's not always very accurate:
+ // Quotient = (hi_ * (ULONG_MAX + 1) + lo_) / ul
+ // = (hi_ * ULONG_MAX + hi_ + lo_) / ul
+ // = hi_ * (ULONG_MAX / ul) + (hi_ + lo_) / ul
+ return hi_ * (ULONG_MAX / ul) + (hi_ + lo_) / ul;
}
+// ACE_INLINE ACE_UINT32
+// ACE_U_LongLong::operator% (const ACE_UINT32 ul) const
+// {
+// // Just return lo_ portion. Because the argument is an ACE_UINT32,
+// // the result can never be bigger than 32 bits.
+// return (*this - (ACE_U_LongLong) (*this / ul * ul)).lo_;
+// }
+
ACE_INLINE ACE_U_LongLong &
ACE_U_LongLong::operator+= (const ACE_U_LongLong &ll)
{
@@ -128,6 +140,14 @@ ACE_U_LongLong::operator+= (const ACE_U_LongLong &ll)
}
ACE_INLINE ACE_U_LongLong &
+ACE_U_LongLong::operator++ ()
+{
+ ++lo_;
+ if (lo_ == 0) /* carry */ ++hi_;
+ return *this;
+}
+
+ACE_INLINE ACE_U_LongLong &
ACE_U_LongLong::operator-= (const ACE_U_LongLong &ll)
{
hi_ -= ll.hi_;