Changeset 6ed6c4a for lib/trace.c


Ignore:
Timestamp:
01/17/07 16:51:08 (15 years ago)
Author:
Brendon Jones <brendonj@…>
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:
d5a27e8
Parents:
8d504c1
Message:

Windows portability fixes.

Windows doesn't have a gettimeofday function, provided an alternate
path that uses _ftime with _timeb structs. This only provides
millisecond resolution rather than microsecond.

Added a few checks to make sure headers that aren't present in
Windows don't get included.

Added new files to the Visual Studio project/solution.

Modified the windows config file to include a few more #defines that
were needed to make pcap support build properly.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/trace.c

    re1868fb r6ed6c4a  
    5050#include <sys/stat.h>
    5151#include <sys/types.h>
     52#ifndef WIN32
    5253#include <sys/socket.h>
     54#endif
    5355#include <stdarg.h>
    5456
     
    8284
    8385#include <time.h>
     86#ifdef WIN32
     87#include <sys/timeb.h>
     88#endif
    8489
    8590#include "libtrace.h"
     
    14271432        static libtrace_t *deadtrace=NULL;
    14281433        libtrace_pcapfile_pkt_hdr_t hdr;
     1434#ifdef WIN32
     1435        struct _timeb tstruct;
     1436#else
    14291437        struct timeval tv;
    1430         if (NULL == deadtrace) deadtrace=trace_create_dead("pcapfile");
     1438#endif
     1439
     1440        if (NULL == deadtrace)
     1441                deadtrace=trace_create_dead("pcapfile");
     1442
     1443#ifdef WIN32
     1444        _ftime(&tstruct);
     1445        hdr.ts_sec=tstruct.time;
     1446        hdr.ts_usec=tstruct.millitm * 1000;
     1447#else
    14311448        gettimeofday(&tv,NULL);
    14321449        hdr.ts_sec=tv.tv_sec;
    14331450        hdr.ts_usec=tv.tv_usec;
     1451#endif
     1452
    14341453        hdr.caplen=len;
    14351454        hdr.wirelen=len;
Note: See TracChangeset for help on using the changeset viewer.