# HG changeset patch # User deba # Date 1143809504 0 # Node ID d0e8a86a1ff2682e59eb839f37ac7568d67e2423 # Parent 119db4e6ab2c059b7c71685aa44b5cc6b26f3824 MinGW32 compatibility diff -r 119db4e6ab2c -r d0e8a86a1ff2 lemon/bits/mingw32_time.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lemon/bits/mingw32_time.h Fri Mar 31 12:51:44 2006 +0000 @@ -0,0 +1,137 @@ +/* -*- C++ -*- + * + * This file is a part of LEMON, a generic C++ optimization library + * + * Copyright (C) 2003-2006 + * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport + * (Egervary Research Group on Combinatorial Optimization, EGRES). + * + * Permission to use, modify and distribute this software is granted + * provided that this copyright notice appears in all copies. For + * precise terms see the accompanying LICENSE file. + * + * This software is provided "AS IS" with no warranty of any kind, + * express or implied, and with no claim as to its suitability for any + * purpose. + * + */ + +#ifndef LEMON_BITS_MINGW32_TIME_H +#define LEMON_BITS_MINGW32_TIME_H + +#ifdef WIN32 + +#include +#include +#include "dos.h" + +static const char days[] = +"Sun Mon Tue Wed Thu Fri Sat "; +static const char months[] = +"Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec "; + +inline void num2str(char *c,int i) { + c[0]=i/10+'0'; + c[1]=i%10+'0'; +} + +inline char *asctime_r(const struct tm *t, char *buf) { + /* "Wed Jun 30 21:49:08 1993\n" */ + *(int*)buf=*(int*)(days+(t->tm_wday<<2)); + *(int*)(buf+4)=*(int*)(months+(t->tm_mon<<2)); + num2str(buf+8,t->tm_mday); + if (buf[8]=='0') buf[8]=' '; + buf[10]=' '; + num2str(buf+11,t->tm_hour); + buf[13]=':'; + num2str(buf+14,t->tm_min); + buf[16]=':'; + num2str(buf+17,t->tm_sec); + buf[19]=' '; + num2str(buf+20,(t->tm_year+1900)/100); + num2str(buf+22,(t->tm_year+1900)%100); + buf[24]='\n'; buf[25]='\0'; + return buf; +} + +inline struct tm * localtime_r (const time_t *t, struct tm *tm) { + struct tm *tmp; + + if ((tmp = localtime(t)) && tm) + *tm = *tmp; + else + return 0; + + return tm; +} + +inline char *ctime_r(const time_t * tim_p , char * result) { + struct tm tm; + return asctime_r (localtime_r (tim_p, &tm), result); +} + + +inline int gettimeofday(struct timeval * tp, struct timezone *) { + SYSTEMTIME systime; + + if (tp) { + struct tm tmrec; + time_t theTime = time(NULL); + + + tmrec = *localtime(&theTime); + tp->tv_sec = mktime(&tmrec); + GetLocalTime(&systime); /* system time */ + + tp->tv_usec = systime.wMilliseconds * 1000; + } + return 0; +} + + +struct tms { + long tms_utime; + long tms_stime; + long tms_cutime; + long tms_cstime; +}; + +inline long filetime_to_clock(FILETIME *ft) +{ + __int64 qw = ft->dwHighDateTime; + qw <<= 32; + qw |= ft->dwLowDateTime; + qw /= 10000; /* File time ticks at 0.1uS, clock at 1mS */ + return (long) qw; + +} + +inline int times(struct tms *tmbuf) +{ + FILETIME create, exit, kernel, user; + if (GetProcessTimes(GetCurrentProcess(),&create, &exit, &kernel, &user)) { + tmbuf->tms_utime = filetime_to_clock(&user); + tmbuf->tms_stime = filetime_to_clock(&kernel); + tmbuf->tms_cutime = 0; + tmbuf->tms_cstime = 0; + } + else { + tmbuf->tms_utime = clock(); + tmbuf->tms_stime = 0; + tmbuf->tms_cutime = 0; + tmbuf->tms_cstime = 0; + } + return 0; +} + +#define _SC_CLK_TCK 1 + +inline int sysconf(int) +{ + return 1; +} + +#endif + + +#endif diff -r 119db4e6ab2c -r d0e8a86a1ff2 lemon/graph_to_eps.h --- a/lemon/graph_to_eps.h Fri Mar 31 12:12:06 2006 +0000 +++ b/lemon/graph_to_eps.h Fri Mar 31 12:51:44 2006 +0000 @@ -21,6 +21,10 @@ #include +#ifdef WIN32 +#include +#endif + #include #include #include diff -r 119db4e6ab2c -r d0e8a86a1ff2 lemon/time_measure.h --- a/lemon/time_measure.h Fri Mar 31 12:12:06 2006 +0000 +++ b/lemon/time_measure.h Fri Mar 31 12:51:44 2006 +0000 @@ -25,73 +25,7 @@ #ifdef WIN32 - -#include -#include -#include "dos.h" - -int gettimeofday(struct timeval * tp, struct timezone *) { - SYSTEMTIME systime; - - if (tp) { - - struct tm tmrec; - time_t theTime = time(NULL); - - tmrec = *localtime(&theTime); - tp->tv_sec = mktime(&tmrec); - GetLocalTime(&systime); /* system time */ - - tp->tv_usec = systime.wMilliseconds * 1000; - - } - - return 0; - -} - -struct tms { - long tms_utime; - long tms_stime; - long tms_cutime; - long tms_cstime; -}; - -static long filetime_to_clock(FILETIME *ft) -{ - __int64 qw = ft->dwHighDateTime; - qw <<= 32; - qw |= ft->dwLowDateTime; - qw /= 10000; /* File time ticks at 0.1uS, clock at 1mS */ - return (long) qw; - -} - -int times(struct tms *tmbuf) -{ - FILETIME create, exit, kernel, user; - if (GetProcessTimes(GetCurrentProcess(),&create, &exit, &kernel, &user)) { - tmbuf->tms_utime = filetime_to_clock(&user); - tmbuf->tms_stime = filetime_to_clock(&kernel); - tmbuf->tms_cutime = 0; - tmbuf->tms_cstime = 0; - } - else { - tmbuf->tms_utime = clock(); - tmbuf->tms_stime = 0; - tmbuf->tms_cutime = 0; - tmbuf->tms_cstime = 0; - } - return 0; -} - -#define _SC_CLK_TCK 1 - -int sysconf(int) -{ - return 1; -} - +#include #else #include #endif @@ -141,8 +75,10 @@ rtms &getTms() {return ts;} const rtms &getTms() const {return ts;} - void _reset() - { ts.tms_utime=ts.tms_stime=ts.tms_cutime=ts.tms_cstime=0; real_time=0;} + void _reset() { + ts.tms_utime = ts.tms_stime = ts.tms_cutime = ts.tms_cstime = 0; + real_time = 0; + } public: