# HG changeset patch # User Alpar Juttner # Date 1430237227 -7200 # Node ID f70f688d9ef9a2d36c71268d6f9487ac825fe381 # Parent 043a787c3ceed658694f3ef5a446f0a91d36db6e Replace #define WIN32 (#595) diff -r 043a787c3cee -r f70f688d9ef9 CMakeLists.txt --- a/CMakeLists.txt Thu Apr 02 14:07:38 2015 +0200 +++ b/CMakeLists.txt Tue Apr 28 18:07:07 2015 +0200 @@ -66,6 +66,10 @@ FIND_PACKAGE(Doxygen) FIND_PACKAGE(Ghostscript) +IF(WIN32) + SET(LEMON_WIN32 TRUE) +ENDIF(WIN32) + SET(LEMON_ENABLE_GLPK YES CACHE STRING "Enable GLPK solver backend.") SET(LEMON_ENABLE_ILOG YES CACHE STRING "Enable ILOG (CPLEX) solver backend.") SET(LEMON_ENABLE_COIN YES CACHE STRING "Enable COIN solver backend.") diff -r 043a787c3cee -r f70f688d9ef9 lemon/bits/windows.cc --- a/lemon/bits/windows.cc Thu Apr 02 14:07:38 2015 +0200 +++ b/lemon/bits/windows.cc Tue Apr 28 18:07:07 2015 +0200 @@ -21,7 +21,7 @@ #include -#ifdef WIN32 +#ifdef LEMON_WIN32 #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif @@ -40,7 +40,7 @@ #else #include #include -#ifndef WIN32 +#ifndef LEMON_WIN32 #include #endif #include @@ -55,7 +55,7 @@ double &utime, double &stime, double &cutime, double &cstime) { -#ifdef WIN32 +#ifdef LEMON_WIN32 static const double ch = 4294967296.0e-7; static const double cl = 1.0e-7; @@ -94,11 +94,11 @@ std::string getWinFormattedDate() { std::ostringstream os; -#ifdef WIN32 +#ifdef LEMON_WIN32 SYSTEMTIME time; GetSystemTime(&time); char buf1[11], buf2[9], buf3[5]; - if (GetDateFormat(MY_LOCALE, 0, &time, + if (GetDateFormat(MY_LOCALE, 0, &time, ("ddd MMM dd"), buf1, 11) && GetTimeFormat(MY_LOCALE, 0, &time, ("HH':'mm':'ss"), buf2, 9) && @@ -120,7 +120,7 @@ int getWinRndSeed() { -#ifdef WIN32 +#ifdef LEMON_WIN32 FILETIME time; GetSystemTimeAsFileTime(&time); return GetCurrentProcessId() + time.dwHighDateTime + time.dwLowDateTime; @@ -132,7 +132,7 @@ } WinLock::WinLock() { -#ifdef WIN32 +#ifdef LEMON_WIN32 CRITICAL_SECTION *lock = new CRITICAL_SECTION; InitializeCriticalSection(lock); _repr = lock; @@ -142,7 +142,7 @@ } WinLock::~WinLock() { -#ifdef WIN32 +#ifdef LEMON_WIN32 CRITICAL_SECTION *lock = static_cast(_repr); DeleteCriticalSection(lock); delete lock; @@ -150,14 +150,14 @@ } void WinLock::lock() { -#ifdef WIN32 +#ifdef LEMON_WIN32 CRITICAL_SECTION *lock = static_cast(_repr); EnterCriticalSection(lock); #endif } void WinLock::unlock() { -#ifdef WIN32 +#ifdef LEMON_WIN32 CRITICAL_SECTION *lock = static_cast(_repr); LeaveCriticalSection(lock); #endif diff -r 043a787c3cee -r f70f688d9ef9 lemon/bits/windows.h --- a/lemon/bits/windows.h Thu Apr 02 14:07:38 2015 +0200 +++ b/lemon/bits/windows.h Tue Apr 28 18:07:07 2015 +0200 @@ -19,6 +19,7 @@ #ifndef LEMON_BITS_WINDOWS_H #define LEMON_BITS_WINDOWS_H +#include #include namespace lemon { @@ -34,7 +35,7 @@ WinLock(); ~WinLock(); void lock(); - void unlock(); + void unlock();\ private: void *_repr; }; diff -r 043a787c3cee -r f70f688d9ef9 lemon/config.h.in --- a/lemon/config.h.in Thu Apr 02 14:07:38 2015 +0200 +++ b/lemon/config.h.in Tue Apr 28 18:07:07 2015 +0200 @@ -1,6 +1,11 @@ +#ifndef LEMON_CONFIG_H +#define LEMON_CONFIG_H + #define LEMON_VERSION "@PROJECT_VERSION@" #cmakedefine LEMON_HAVE_LONG_LONG 1 +#cmakedefine LEMON_WIN32 1 + #cmakedefine LEMON_HAVE_LP 1 #cmakedefine LEMON_HAVE_MIP 1 #cmakedefine LEMON_HAVE_GLPK 1 @@ -9,14 +14,16 @@ #cmakedefine LEMON_HAVE_CLP 1 #cmakedefine LEMON_HAVE_CBC 1 -#define _LEMON_CPLEX 1 -#define _LEMON_CLP 2 -#define _LEMON_GLPK 3 -#define _LEMON_SOPLEX 4 -#define _LEMON_CBC 5 +#define LEMON_CPLEX_ 1 +#define LEMON_CLP_ 2 +#define LEMON_GLPK_ 3 +#define LEMON_SOPLEX_ 4 +#define LEMON_CBC_ 5 -#cmakedefine LEMON_DEFAULT_LP _LEMON_@LEMON_DEFAULT_LP@ -#cmakedefine LEMON_DEFAULT_MIP _LEMON_@LEMON_DEFAULT_MIP@ +#cmakedefine LEMON_DEFAULT_LP LEMON_@LEMON_DEFAULT_LP@_ +#cmakedefine LEMON_DEFAULT_MIP LEMON_@LEMON_DEFAULT_MIP@_ #cmakedefine LEMON_USE_PTHREAD 1 #cmakedefine LEMON_USE_WIN32_THREADS 1 + +#endif diff -r 043a787c3cee -r f70f688d9ef9 lemon/graph_to_eps.h --- a/lemon/graph_to_eps.h Thu Apr 02 14:07:38 2015 +0200 +++ b/lemon/graph_to_eps.h Tue Apr 28 18:07:07 2015 +0200 @@ -25,7 +25,7 @@ #include #include -#ifndef WIN32 +#ifndef LEMON_WIN32 #include #include #else @@ -674,7 +674,7 @@ { os << "%%CreationDate: "; -#ifndef WIN32 +#ifndef LEMON_WIN32 timeval tv; gettimeofday(&tv, 0); diff -r 043a787c3cee -r f70f688d9ef9 lemon/lp.h --- a/lemon/lp.h Thu Apr 02 14:07:38 2015 +0200 +++ b/lemon/lp.h Tue Apr 28 18:07:07 2015 +0200 @@ -22,19 +22,19 @@ #include -#if LEMON_DEFAULT_LP == _LEMON_GLPK || LEMON_DEFAULT_MIP == _LEMON_GLPK +#if LEMON_DEFAULT_LP == LEMON_GLPK_ || LEMON_DEFAULT_MIP == LEMON_GLPK_ #include #endif -#if LEMON_DEFAULT_LP == _LEMON_CPLEX || LEMON_DEFAULT_MIP == _LEMON_CPLEX +#if LEMON_DEFAULT_LP == LEMON_CPLEX_ || LEMON_DEFAULT_MIP == LEMON_CPLEX_ #include #endif -#if LEMON_DEFAULT_LP == _LEMON_SOPLEX +#if LEMON_DEFAULT_LP == LEMON_SOPLEX_ #include #endif -#if LEMON_DEFAULT_LP == _LEMON_CLP +#if LEMON_DEFAULT_LP == LEMON_CLP_ #include #endif -#if LEMON_DEFAULT_MIP == _LEMON_CBC +#if LEMON_DEFAULT_MIP == LEMON_CBC_ #include #endif @@ -49,8 +49,8 @@ ///The default LP solver identifier. ///\ingroup lp_group /// - ///Currently, the possible values are \c _LEMON_GLPK, \c LEMON__CPLEX, - ///\c _LEMON_SOPLEX or \c LEMON__CLP + ///Currently, the possible values are \c LEMON_GLPK_, \c LEMON_CPLEX_, + ///\c LEMON_SOPLEX_ or \c LEMON_CLP_ #define LEMON_DEFAULT_LP SOLVER ///The default LP solver @@ -65,8 +65,8 @@ ///The default MIP solver identifier. ///\ingroup lp_group /// - ///Currently, the possible values are \c _LEMON_GLPK, \c LEMON__CPLEX - ///or \c _LEMON_CBC + ///Currently, the possible values are \c LEMON_GLPK_, \c LEMON_CPLEX_ + ///or \c LEMON_CBC_ #define LEMON_DEFAULT_MIP SOLVER ///The default MIP solver. @@ -76,20 +76,20 @@ ///Currently, it is either \c GlpkMip, \c CplexMip , \c CbcMip typedef GlpkMip Mip; #else -#if LEMON_DEFAULT_LP == _LEMON_GLPK +#if LEMON_DEFAULT_LP == LEMON_GLPK_ typedef GlpkLp Lp; -#elif LEMON_DEFAULT_LP == _LEMON_CPLEX +#elif LEMON_DEFAULT_LP == LEMON_CPLEX_ typedef CplexLp Lp; -#elif LEMON_DEFAULT_LP == _LEMON_SOPLEX +#elif LEMON_DEFAULT_LP == LEMON_SOPLEX_ typedef SoplexLp Lp; -#elif LEMON_DEFAULT_LP == _LEMON_CLP +#elif LEMON_DEFAULT_LP == LEMON_CLP_ typedef ClpLp Lp; #endif -#if LEMON_DEFAULT_MIP == _LEMON_GLPK +#if LEMON_DEFAULT_MIP == LEMON_GLPK_ typedef GlpkMip Mip; -#elif LEMON_DEFAULT_MIP == _LEMON_CPLEX +#elif LEMON_DEFAULT_MIP == LEMON_CPLEX_ typedef CplexMip Mip; -#elif LEMON_DEFAULT_MIP == _LEMON_CBC +#elif LEMON_DEFAULT_MIP == LEMON_CBC_ typedef CbcMip Mip; #endif #endif diff -r 043a787c3cee -r f70f688d9ef9 lemon/random.h --- a/lemon/random.h Thu Apr 02 14:07:38 2015 +0200 +++ b/lemon/random.h Tue Apr 28 18:07:07 2015 +0200 @@ -62,6 +62,8 @@ #ifndef LEMON_RANDOM_H #define LEMON_RANDOM_H +#include + #include #include #include @@ -71,7 +73,7 @@ #include #include -#ifndef WIN32 +#ifndef LEMON_WIN32 #include #include #include @@ -605,7 +607,7 @@ /// it uses the \c seedFromTime(). /// \return Currently always \c true. bool seed() { -#ifndef WIN32 +#ifndef LEMON_WIN32 if (seedFromFile("/dev/urandom", 0)) return true; #endif if (seedFromTime()) return true; @@ -625,7 +627,7 @@ /// \param file The source file /// \param offset The offset, from the file read. /// \return \c true when the seeding successes. -#ifndef WIN32 +#ifndef LEMON_WIN32 bool seedFromFile(const std::string& file = "/dev/urandom", int offset = 0) #else bool seedFromFile(const std::string& file = "", int offset = 0) @@ -647,7 +649,7 @@ /// random sequence. /// \return Currently always \c true. bool seedFromTime() { -#ifndef WIN32 +#ifndef LEMON_WIN32 timeval tv; gettimeofday(&tv, 0); seed(getpid() + tv.tv_sec + tv.tv_usec); diff -r 043a787c3cee -r f70f688d9ef9 lemon/time_measure.h --- a/lemon/time_measure.h Thu Apr 02 14:07:38 2015 +0200 +++ b/lemon/time_measure.h Tue Apr 28 18:07:07 2015 +0200 @@ -23,7 +23,9 @@ ///\file ///\brief Tools for measuring cpu usage -#ifdef WIN32 +#include + +#ifdef LEMON_WIN32 #include #else #include @@ -102,7 +104,7 @@ ///Read the current time values of the process void stamp() { -#ifndef WIN32 +#ifndef LEMON_WIN32 timeval tv; gettimeofday(&tv, 0); rtime=tv.tv_sec+double(tv.tv_usec)/1e6;