Author: adrian.chadd
Date: Wed Jul  8 15:28:20 2009
New Revision: 14160

Modified:
    branches/LUSCA_HEAD/libcore/tools.c
    branches/LUSCA_HEAD/libcore/tools.h
    branches/LUSCA_HEAD/src/tools.c

Log:
Begin addressing issue 39. Migrate the percent() and dpercent() calls
out of src/tools and into libcore/tools.c; write a 64 bit unsigned
percent function.



Modified: branches/LUSCA_HEAD/libcore/tools.c
==============================================================================
--- branches/LUSCA_HEAD/libcore/tools.c (original)
+++ branches/LUSCA_HEAD/libcore/tools.c Wed Jul  8 15:28:20 2009
@@ -137,3 +137,20 @@
  #endif /* _SQUID_SOLARIS_ */
  }

+int
+percent(int a, int b)
+{
+    return b ? ((int) (100.0 * a / b + 0.5)) : 0;
+}
+
+double
+dpercent(double a, double b)
+{
+    return b ? (100.0 * a / b) : 0.0;
+}
+
+uint64_t
+uint64_percent(uint64_t a, uint64_t b)
+{
+    return b ? ((uint64_t) (100.0 * a / b + 0.5)) : 0;
+}

Modified: branches/LUSCA_HEAD/libcore/tools.h
==============================================================================
--- branches/LUSCA_HEAD/libcore/tools.h (original)
+++ branches/LUSCA_HEAD/libcore/tools.h Wed Jul  8 15:28:20 2009
@@ -94,4 +94,8 @@
  #define MAXPATHLEN SQUID_MAXPATHLEN
  #endif

+extern int percent(int, int);
+extern double dpercent(double, double);
+extern uint64_t uint64_percent(uint64_t, uint64_t);
+
  #endif

Modified: branches/LUSCA_HEAD/src/tools.c
==============================================================================
--- branches/LUSCA_HEAD/src/tools.c     (original)
+++ branches/LUSCA_HEAD/src/tools.c     Wed Jul  8 15:28:20 2009
@@ -825,18 +825,6 @@
  #endif /* RLIMIT_VMEM */
  }

-int
-percent(int a, int b)
-{
-    return b ? ((int) (100.0 * a / b + 0.5)) : 0;
-}
-
-double
-dpercent(double a, double b)
-{
-    return b ? (100.0 * a / b) : 0.0;
-}
-
  struct in_addr
  inaddrFromHostent(const struct hostent *hp)
  {

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"lusca-commit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/lusca-commit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to