ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/libstatgrab/src/libstatgrab/network_stats.c
(Generate patch)

Comparing projects/libstatgrab/src/libstatgrab/network_stats.c (file contents):
Revision 1.55 by ats, Tue Mar 9 11:29:46 2004 UTC vs.
Revision 1.58 by tdb, Sun Apr 4 21:54:48 2004 UTC

# Line 66 | Line 66 | typedef __uint64_t u64;
66   #include <net/if.h>
67   #include <net/if_media.h>
68   #include <sys/ioctl.h>
69 + #include <unistd.h>
70   #endif
71  
72   static network_stat_t *network_stats=NULL;
# Line 322 | Line 323 | network_stat_t *get_network_stats(int *entries){
323   }
324  
325   long long transfer_diff(long long new, long long old){
326 < #if defined(SOL7) || defined(LINUX) || defined(FREEBSD) || defined(DFBSD)
327 < #define MAXVAL 0xffffffffLL
326 > #if defined(SOL7) || defined(LINUX) || defined(FREEBSD) || defined(DFBSD) || defined(OPENBSD)
327 >        /* 32-bit quantities, so we must explicitly deal with wraparound. */
328 > #define MAXVAL 0x100000000LL
329 >        if (new >= old) {
330 >                return new - old;
331 >        } else {
332 >                return MAXVAL + new - old;
333 >        }
334   #else
335 < #define MAXVAL 0xffffffffffffffffLL
335 >        /* 64-bit quantities, so plain subtraction works. */
336 >        return new - old;
337   #endif
330        long long result;
331        if(new>=old){
332                result = (new-old);
333        }else{
334                result = (MAXVAL+(new-old));
335        }
336
337        return result;
338
338   }
339  
340   network_stat_t *get_network_stats_diff(int *entries) {
341          static network_stat_t *diff = NULL;
342          static int diff_count = 0;
343 <        network_stat_t *src, *dest;
343 >        network_stat_t *src = NULL, *dest;
344          int i, j, new_count;
345  
346          if (network_stats == NULL) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines