COIN-OR::LEMON - Graph Library

Changeset 2028:d0e8a86a1ff2 in lemon-0.x for lemon/time_measure.h


Ignore:
Timestamp:
03/31/06 14:51:44 (18 years ago)
Author:
Balazs Dezso
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2667
Message:

MinGW32 compatibility

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lemon/time_measure.h

    r2027 r2028  
    2626
    2727#ifdef WIN32
    28 
    29 #include <windows.h>
    30 #include <time.h>
    31 #include "dos.h"
    32 
    33 int gettimeofday(struct timeval * tp, struct timezone *) {
    34   SYSTEMTIME      systime;
    35 
    36   if (tp) {
    37 
    38     struct tm tmrec;
    39     time_t theTime = time(NULL);
    40 
    41     tmrec = *localtime(&theTime);
    42     tp->tv_sec = mktime(&tmrec);
    43     GetLocalTime(&systime); /* system time */
    44 
    45     tp->tv_usec = systime.wMilliseconds * 1000;
    46 
    47   }
    48 
    49   return 0;
    50 
    51 }
    52 
    53 struct tms {
    54   long  tms_utime;
    55   long  tms_stime;
    56   long  tms_cutime;
    57   long  tms_cstime;
    58 };
    59 
    60 static long filetime_to_clock(FILETIME *ft)
    61 {
    62   __int64 qw = ft->dwHighDateTime;
    63   qw <<= 32;
    64   qw |= ft->dwLowDateTime;
    65   qw /= 10000;  /* File time ticks at 0.1uS, clock at 1mS */
    66   return (long) qw;
    67 
    68 }
    69 
    70 int times(struct tms *tmbuf)
    71 {
    72   FILETIME create, exit, kernel, user;
    73   if (GetProcessTimes(GetCurrentProcess(),&create, &exit, &kernel, &user)) {
    74     tmbuf->tms_utime = filetime_to_clock(&user);
    75     tmbuf->tms_stime = filetime_to_clock(&kernel);
    76     tmbuf->tms_cutime = 0;
    77     tmbuf->tms_cstime = 0;
    78   }
    79   else {
    80     tmbuf->tms_utime = clock();
    81     tmbuf->tms_stime = 0;
    82     tmbuf->tms_cutime = 0;
    83     tmbuf->tms_cstime = 0;
    84   }
    85   return 0;
    86 }
    87 
    88 #define _SC_CLK_TCK 1
    89 
    90 int sysconf(int)
    91 {
    92   return 1;
    93 }
    94 
     28#include <lemon/bits/mingw32_time.h>
    9529#else
    9630#include <sys/times.h>
     
    14276    const rtms &getTms() const {return ts;}
    14377
    144     void _reset()
    145     { ts.tms_utime=ts.tms_stime=ts.tms_cutime=ts.tms_cstime=0; real_time=0;}
     78    void _reset() {
     79      ts.tms_utime = ts.tms_stime = ts.tms_cutime = ts.tms_cstime = 0;
     80      real_time = 0;
     81    }
    14682
    14783  public:
Note: See TracChangeset for help on using the changeset viewer.