Changeset 11041eb for lib/trace.c


Ignore:
Timestamp:
07/02/13 14:19:40 (8 years ago)
Author:
Shane Alcock <salcock@…>
Branches:
4.0.1-hotfixes, cachetimestamps, develop, dpdk-ndag, etsilive, getfragoff, help, libtrace4, master, ndag_format, pfring, rc-4.0.1, rc-4.0.2, rc-4.0.3, rc-4.0.4, ringdecrementfix, ringperformance, ringtimestampfixes
Children:
da46c9d
Parents:
fdb5e98
Message:
  • Changed all BYTE_ORDER checks to be consistent and use the same macros
  • Ensure that BYTE_ORDER is defined for *all* systems -- stupid BSDs
  • Be careful about writing values from timevals into our pcap header -- 64 bit timevals could cause some issues here
File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/trace.c

    ra464de7 r11041eb  
    4848#endif
    4949#include <stdarg.h>
     50#include <sys/param.h>
    5051
    5152#ifdef HAVE_LIMITS_H
     
    923924#if __BYTE_ORDER == __BIG_ENDIAN
    924925                tv.tv_sec = ts & 0xFFFFFFFF;
     926                tv.tv_usec = ((ts >> 32) * 1000000) & 0xFFFFFFFF;
    925927#elif __BYTE_ORDER == __LITTLE_ENDIAN
    926928                tv.tv_sec = ts >> 32;
     929                tv.tv_usec = ((ts&0xFFFFFFFF)*1000000)>>32;
    927930#else
    928931#error "What on earth are you running this on?"
    929932#endif
    930                 tv.tv_usec = ((ts&0xFFFFFFFF)*1000000)>>32;
    931933                if (tv.tv_usec >= 1000000) {
    932934                        tv.tv_usec -= 1000000;
     
    961963#if __BYTE_ORDER == __BIG_ENDIAN
    962964                ts.tv_sec = erfts & 0xFFFFFFFF;
     965                tv.tv_nsec = ((ts >> 32) * 1000000000) & 0xFFFFFFFF;
    963966#elif __BYTE_ORDER == __LITTLE_ENDIAN
    964967                ts.tv_sec = erfts >> 32;
     968                ts.tv_nsec = ((erfts&0xFFFFFFFF)*1000000000)>>32;
    965969#else
    966970#error "What on earth are you running this on?"
    967971#endif
    968                 ts.tv_nsec = ((erfts&0xFFFFFFFF)*1000000000)>>32;
    969972                if (ts.tv_nsec >= 1000000000) {
    970973                        ts.tv_nsec -= 1000000000;
     
    16361639#if __BYTE_ORDER == __BIG_ENDIAN
    16371640                        tv.tv_sec = ts & 0xFFFFFFFF;
     1641                        tv.tv_usec = ((ts >> 32) * 1000000) & 0xFFFFFFFF;
    16381642#elif __BYTE_ORDER == __LITTLE_ENDIAN
    16391643                        tv.tv_sec = ts >> 32;
     1644                        tv.tv_usec = ((ts&0xFFFFFFFF)*1000000)>>32;
    16401645#else
    16411646#error "What on earth are you running this on?"
    16421647#endif
    1643                         tv.tv_usec = ((ts&0xFFFFFFFF)*1000000)>>32;
    16441648                        if (tv.tv_usec >= 1000000) {
    16451649                                tv.tv_usec -= 1000000;
Note: See TracChangeset for help on using the changeset viewer.