[Lemon-commits] Alpar Juttner: Replace #define WIN32 (#595)

Lemon HG hg at lemon.cs.elte.hu
Tue Apr 28 18:14:01 CEST 2015


details:   http://lemon.cs.elte.hu/hg/lemon/rev/f70f688d9ef9
changeset: 1340:f70f688d9ef9
user:      Alpar Juttner <alpar [at] cs.elte.hu>
date:      Tue Apr 28 18:07:07 2015 +0200
description:
	Replace #define WIN32 (#595)

diffstat:

 CMakeLists.txt        |   4 ++++
 lemon/bits/windows.cc |  20 ++++++++++----------
 lemon/bits/windows.h  |   3 ++-
 lemon/config.h.in     |  21 ++++++++++++++-------
 lemon/graph_to_eps.h  |   4 ++--
 lemon/lp.h            |  32 ++++++++++++++++----------------
 lemon/random.h        |  10 ++++++----
 lemon/time_measure.h  |   6 ++++--
 8 files changed, 58 insertions(+), 42 deletions(-)

diffs (truncated from 331 to 300 lines):

diff --git a/CMakeLists.txt b/CMakeLists.txt
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -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 --git a/lemon/bits/windows.cc b/lemon/bits/windows.cc
--- a/lemon/bits/windows.cc
+++ b/lemon/bits/windows.cc
@@ -21,7 +21,7 @@
 
 #include<lemon/bits/windows.h>
 
-#ifdef WIN32
+#ifdef LEMON_WIN32
 #ifndef WIN32_LEAN_AND_MEAN
 #define WIN32_LEAN_AND_MEAN
 #endif
@@ -40,7 +40,7 @@
 #else
 #include <unistd.h>
 #include <ctime>
-#ifndef WIN32
+#ifndef LEMON_WIN32
 #include <sys/times.h>
 #endif
 #include <sys/time.h>
@@ -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<CRITICAL_SECTION*>(_repr);
       DeleteCriticalSection(lock);
       delete lock;
@@ -150,14 +150,14 @@
     }
 
     void WinLock::lock() {
-#ifdef WIN32
+#ifdef LEMON_WIN32
       CRITICAL_SECTION *lock = static_cast<CRITICAL_SECTION*>(_repr);
       EnterCriticalSection(lock);
 #endif
     }
 
     void WinLock::unlock() {
-#ifdef WIN32
+#ifdef LEMON_WIN32
       CRITICAL_SECTION *lock = static_cast<CRITICAL_SECTION*>(_repr);
       LeaveCriticalSection(lock);
 #endif
diff --git a/lemon/bits/windows.h b/lemon/bits/windows.h
--- a/lemon/bits/windows.h
+++ b/lemon/bits/windows.h
@@ -19,6 +19,7 @@
 #ifndef LEMON_BITS_WINDOWS_H
 #define LEMON_BITS_WINDOWS_H
 
+#include <lemon/config.h>
 #include <string>
 
 namespace lemon {
@@ -34,7 +35,7 @@
       WinLock();
       ~WinLock();
       void lock();
-      void unlock();
+      void unlock();\
     private:
       void *_repr;
     };
diff --git a/lemon/config.h.in b/lemon/config.h.in
--- a/lemon/config.h.in
+++ b/lemon/config.h.in
@@ -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_ at LEMON_DEFAULT_LP@
-#cmakedefine LEMON_DEFAULT_MIP _LEMON_ at LEMON_DEFAULT_MIP@
+#cmakedefine LEMON_DEFAULT_LP LEMON_ at LEMON_DEFAULT_LP@_
+#cmakedefine LEMON_DEFAULT_MIP LEMON_ at LEMON_DEFAULT_MIP@_
 
 #cmakedefine LEMON_USE_PTHREAD 1
 #cmakedefine LEMON_USE_WIN32_THREADS 1
+
+#endif
diff --git a/lemon/graph_to_eps.h b/lemon/graph_to_eps.h
--- a/lemon/graph_to_eps.h
+++ b/lemon/graph_to_eps.h
@@ -25,7 +25,7 @@
 #include<algorithm>
 #include<vector>
 
-#ifndef WIN32
+#ifndef LEMON_WIN32
 #include<sys/time.h>
 #include<ctime>
 #else
@@ -674,7 +674,7 @@
 
     {
       os << "%%CreationDate: ";
-#ifndef WIN32
+#ifndef LEMON_WIN32
       timeval tv;
       gettimeofday(&tv, 0);
 
diff --git a/lemon/lp.h b/lemon/lp.h
--- a/lemon/lp.h
+++ b/lemon/lp.h
@@ -22,19 +22,19 @@
 #include<lemon/config.h>
 
 
-#if LEMON_DEFAULT_LP == _LEMON_GLPK || LEMON_DEFAULT_MIP == _LEMON_GLPK
+#if LEMON_DEFAULT_LP == LEMON_GLPK_ || LEMON_DEFAULT_MIP == LEMON_GLPK_
 #include <lemon/glpk.h>
 #endif
-#if LEMON_DEFAULT_LP == _LEMON_CPLEX || LEMON_DEFAULT_MIP == _LEMON_CPLEX 
+#if LEMON_DEFAULT_LP == LEMON_CPLEX_ || LEMON_DEFAULT_MIP == LEMON_CPLEX_
 #include <lemon/cplex.h>
 #endif
-#if LEMON_DEFAULT_LP == _LEMON_SOPLEX
+#if LEMON_DEFAULT_LP == LEMON_SOPLEX_
 #include <lemon/soplex.h>
 #endif
-#if LEMON_DEFAULT_LP == _LEMON_CLP
+#if LEMON_DEFAULT_LP == LEMON_CLP_
 #include <lemon/clp.h>
 #endif
-#if LEMON_DEFAULT_MIP == _LEMON_CBC
+#if LEMON_DEFAULT_MIP == LEMON_CBC_
 #include <lemon/cbc.h>
 #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 --git a/lemon/random.h b/lemon/random.h
--- a/lemon/random.h
+++ b/lemon/random.h
@@ -62,6 +62,8 @@
 #ifndef LEMON_RANDOM_H
 #define LEMON_RANDOM_H
 
+#include <lemon/config.h>
+
 #include <algorithm>
 #include <iterator>
 #include <vector>
@@ -71,7 +73,7 @@
 #include <lemon/math.h>
 #include <lemon/dim2.h>
 
-#ifndef WIN32
+#ifndef LEMON_WIN32
 #include <sys/time.h>
 #include <ctime>
 #include <sys/types.h>
@@ -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 @@


More information about the Lemon-commits mailing list