dasher r3646 - in trunk: . Src/DasherCore



Author: pwelche
Date: Tue Mar  3 18:01:54 2009
New Revision: 3646
URL: http://svn.gnome.org/viewvc/dasher?rev=3646&view=rev

Log:
Visual studio 2005 thinks that long long int is 64 bit. The difference between
"myint" and int64_t is that if _DEBUG is defined, a Cint64 class is used
with some asserts in the operator definitions. I think long long int is safe.


Modified:
   trunk/ChangeLog
   trunk/Src/DasherCore/DasherViewSquare.cpp
   trunk/configure.in

Modified: trunk/Src/DasherCore/DasherViewSquare.cpp
==============================================================================
--- trunk/Src/DasherCore/DasherViewSquare.cpp	(original)
+++ trunk/Src/DasherCore/DasherViewSquare.cpp	Tue Mar  3 18:01:54 2009
@@ -804,27 +804,33 @@
 
 inline myint CDasherViewSquare::CustomIDiv(myint iNumerator, myint iDenominator) { 
   // Integer division rounding away from zero
-  
-#ifdef _WIN32
-  myint quot = iNumerator / iDenominator;
-  myint rem = (int64)iNumerator % (int64)iDenominator;
 
-  if(rem < 0)
-    return quot - 1;
-  else if (rem > 0)
-    return quot + 1;
-  else
-    return quot;
+  long long int num, denom, quot, rem;
+  myint res;
+
+  num   = iNumerator;
+  denom = iDenominator;
+
+  DASHER_ASSERT(denom != 0);
+
+#ifdef HAVE_LLDIV
+  lldiv_t ans = ::lldiv(num, denom);
+
+  quot = ans.quot;
+  rem  = ans.rem;
 #else
-  lldiv_t res = ::lldiv(iNumerator, iDenominator);
+  quot = num / denom;
+  rem  = num % denom;
+#endif
   
-  if(res.rem < 0)
-    return res.quot - 1;
-  else if (res.rem > 0)
-    return res.quot + 1;
+  if (rem < 0)
+    res = quot - 1;
+  else if (rem > 0)
+    res = quot + 1;
   else
-    return res.quot;
-#endif
+    res = quot;
+
+  return res;
 
   // return (iNumerator + iDenominator - 1) / iDenominator;
 }

Modified: trunk/configure.in
==============================================================================
--- trunk/configure.in	(original)
+++ trunk/configure.in	Tue Mar  3 18:01:54 2009
@@ -33,7 +33,10 @@
 PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.4)
 
 AC_CHECK_LIB(expat, XML_Parse,, AC_MSG_ERROR([Expat library not found.]))
+AC_LANG_PUSH(C++)
+AC_CHECK_FUNCS(lldiv)
 AC_CHECK_FUNC(socket,,[AC_CHECK_LIB(socket,socket)])
+AC_LANG_POP(C++)
 
 AC_ARG_ENABLE(debug,
 	AC_HELP_STRING([--enable-debug],[build with additional debugging checks (default is NO)]),



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]