Merge bugfix #595
authorAlpar Juttner <alpar@cs.elte.hu>
Tue, 28 Apr 2015 18:13:42 +0200
changeset 134320f95cd51aba
parent 1339 93d455c647be
parent 1341 c199e9976d93
child 1346 f95b18d99843
Merge bugfix #595
CMakeLists.txt
lemon/config.h.in
lemon/random.h
     1.1 --- a/CMakeLists.txt	Tue Apr 14 16:36:45 2015 +0200
     1.2 +++ b/CMakeLists.txt	Tue Apr 28 18:13:42 2015 +0200
     1.3 @@ -70,6 +70,10 @@
     1.4  FIND_PACKAGE(Doxygen)
     1.5  FIND_PACKAGE(Ghostscript)
     1.6  
     1.7 +IF(WIN32)
     1.8 +  SET(LEMON_WIN32 TRUE)
     1.9 +ENDIF(WIN32)
    1.10 +
    1.11  SET(LEMON_ENABLE_GLPK YES CACHE STRING "Enable GLPK solver backend.")
    1.12  SET(LEMON_ENABLE_ILOG YES CACHE STRING "Enable ILOG (CPLEX) solver backend.")
    1.13  SET(LEMON_ENABLE_COIN YES CACHE STRING "Enable COIN solver backend.")
     2.1 --- a/lemon/bits/windows.cc	Tue Apr 14 16:36:45 2015 +0200
     2.2 +++ b/lemon/bits/windows.cc	Tue Apr 28 18:13:42 2015 +0200
     2.3 @@ -21,7 +21,11 @@
     2.4  
     2.5  #include<lemon/bits/windows.h>
     2.6  
     2.7 -#ifdef WIN32
     2.8 +#if defined(LEMON_WIN32) && defined(__GNUC__)
     2.9 +#pragma GCC diagnostic ignored "-Wold-style-cast"
    2.10 +#endif
    2.11 +
    2.12 +#ifdef LEMON_WIN32
    2.13  #ifndef WIN32_LEAN_AND_MEAN
    2.14  #define WIN32_LEAN_AND_MEAN
    2.15  #endif
    2.16 @@ -40,7 +44,7 @@
    2.17  #else
    2.18  #include <unistd.h>
    2.19  #include <ctime>
    2.20 -#ifndef WIN32
    2.21 +#ifndef LEMON_WIN32
    2.22  #include <sys/times.h>
    2.23  #endif
    2.24  #include <sys/time.h>
    2.25 @@ -55,7 +59,7 @@
    2.26                           double &utime, double &stime,
    2.27                           double &cutime, double &cstime)
    2.28      {
    2.29 -#ifdef WIN32
    2.30 +#ifdef LEMON_WIN32
    2.31        static const double ch = 4294967296.0e-7;
    2.32        static const double cl = 1.0e-7;
    2.33  
    2.34 @@ -94,11 +98,11 @@
    2.35      std::string getWinFormattedDate()
    2.36      {
    2.37        std::ostringstream os;
    2.38 -#ifdef WIN32
    2.39 +#ifdef LEMON_WIN32
    2.40        SYSTEMTIME time;
    2.41        GetSystemTime(&time);
    2.42        char buf1[11], buf2[9], buf3[5];
    2.43 -          if (GetDateFormat(MY_LOCALE, 0, &time,
    2.44 +      if (GetDateFormat(MY_LOCALE, 0, &time,
    2.45                          ("ddd MMM dd"), buf1, 11) &&
    2.46            GetTimeFormat(MY_LOCALE, 0, &time,
    2.47                          ("HH':'mm':'ss"), buf2, 9) &&
    2.48 @@ -120,7 +124,7 @@
    2.49  
    2.50      int getWinRndSeed()
    2.51      {
    2.52 -#ifdef WIN32
    2.53 +#ifdef LEMON_WIN32
    2.54        FILETIME time;
    2.55        GetSystemTimeAsFileTime(&time);
    2.56        return GetCurrentProcessId() + time.dwHighDateTime + time.dwLowDateTime;
    2.57 @@ -132,7 +136,7 @@
    2.58      }
    2.59  
    2.60      WinLock::WinLock() {
    2.61 -#ifdef WIN32
    2.62 +#ifdef LEMON_WIN32
    2.63        CRITICAL_SECTION *lock = new CRITICAL_SECTION;
    2.64        InitializeCriticalSection(lock);
    2.65        _repr = lock;
    2.66 @@ -142,7 +146,7 @@
    2.67      }
    2.68  
    2.69      WinLock::~WinLock() {
    2.70 -#ifdef WIN32
    2.71 +#ifdef LEMON_WIN32
    2.72        CRITICAL_SECTION *lock = static_cast<CRITICAL_SECTION*>(_repr);
    2.73        DeleteCriticalSection(lock);
    2.74        delete lock;
    2.75 @@ -150,14 +154,14 @@
    2.76      }
    2.77  
    2.78      void WinLock::lock() {
    2.79 -#ifdef WIN32
    2.80 +#ifdef LEMON_WIN32
    2.81        CRITICAL_SECTION *lock = static_cast<CRITICAL_SECTION*>(_repr);
    2.82        EnterCriticalSection(lock);
    2.83  #endif
    2.84      }
    2.85  
    2.86      void WinLock::unlock() {
    2.87 -#ifdef WIN32
    2.88 +#ifdef LEMON_WIN32
    2.89        CRITICAL_SECTION *lock = static_cast<CRITICAL_SECTION*>(_repr);
    2.90        LeaveCriticalSection(lock);
    2.91  #endif
     3.1 --- a/lemon/bits/windows.h	Tue Apr 14 16:36:45 2015 +0200
     3.2 +++ b/lemon/bits/windows.h	Tue Apr 28 18:13:42 2015 +0200
     3.3 @@ -19,6 +19,7 @@
     3.4  #ifndef LEMON_BITS_WINDOWS_H
     3.5  #define LEMON_BITS_WINDOWS_H
     3.6  
     3.7 +#include <lemon/config.h>
     3.8  #include <string>
     3.9  
    3.10  namespace lemon {
    3.11 @@ -34,7 +35,7 @@
    3.12        WinLock();
    3.13        ~WinLock();
    3.14        void lock();
    3.15 -      void unlock();
    3.16 +      void unlock();\
    3.17      private:
    3.18        void *_repr;
    3.19      };
     4.1 --- a/lemon/config.h.in	Tue Apr 14 16:36:45 2015 +0200
     4.2 +++ b/lemon/config.h.in	Tue Apr 28 18:13:42 2015 +0200
     4.3 @@ -1,8 +1,13 @@
     4.4 +#ifndef LEMON_CONFIG_H
     4.5 +#define LEMON_CONFIG_H
     4.6 +
     4.7  #define LEMON_VERSION "@PROJECT_VERSION@"
     4.8  #cmakedefine LEMON_HAVE_LONG_LONG 1
     4.9  
    4.10  #cmakedefine LEMON_CXX11 1
    4.11  
    4.12 +#cmakedefine LEMON_WIN32 1
    4.13 +
    4.14  #cmakedefine LEMON_HAVE_LP 1
    4.15  #cmakedefine LEMON_HAVE_MIP 1
    4.16  #cmakedefine LEMON_HAVE_GLPK 1
    4.17 @@ -11,14 +16,16 @@
    4.18  #cmakedefine LEMON_HAVE_CLP 1
    4.19  #cmakedefine LEMON_HAVE_CBC 1
    4.20  
    4.21 -#define _LEMON_CPLEX 1
    4.22 -#define _LEMON_CLP 2
    4.23 -#define _LEMON_GLPK 3
    4.24 -#define _LEMON_SOPLEX 4
    4.25 -#define _LEMON_CBC 5
    4.26 +#define LEMON_CPLEX_ 1
    4.27 +#define LEMON_CLP_ 2
    4.28 +#define LEMON_GLPK_ 3
    4.29 +#define LEMON_SOPLEX_ 4
    4.30 +#define LEMON_CBC_ 5
    4.31  
    4.32 -#cmakedefine LEMON_DEFAULT_LP _LEMON_@LEMON_DEFAULT_LP@
    4.33 -#cmakedefine LEMON_DEFAULT_MIP _LEMON_@LEMON_DEFAULT_MIP@
    4.34 +#cmakedefine LEMON_DEFAULT_LP LEMON_@LEMON_DEFAULT_LP@_
    4.35 +#cmakedefine LEMON_DEFAULT_MIP LEMON_@LEMON_DEFAULT_MIP@_
    4.36  
    4.37  #cmakedefine LEMON_USE_PTHREAD 1
    4.38  #cmakedefine LEMON_USE_WIN32_THREADS 1
    4.39 +
    4.40 +#endif
     5.1 --- a/lemon/core.h	Tue Apr 14 16:36:45 2015 +0200
     5.2 +++ b/lemon/core.h	Tue Apr 28 18:13:42 2015 +0200
     5.3 @@ -19,13 +19,12 @@
     5.4  #ifndef LEMON_CORE_H
     5.5  #define LEMON_CORE_H
     5.6  
     5.7 -#include <vector>
     5.8 -#include <algorithm>
     5.9 -
    5.10 -#include <lemon/config.h>
    5.11 -#include <lemon/bits/enable_if.h>
    5.12 -#include <lemon/bits/traits.h>
    5.13 -#include <lemon/assert.h>
    5.14 +///\file
    5.15 +///\brief LEMON core utilities.
    5.16 +///
    5.17 +///This header file contains core utilities for LEMON.
    5.18 +///It is automatically included by all graph types, therefore it usually
    5.19 +///do not have to be included directly.
    5.20  
    5.21  // Disable the following warnings when compiling with MSVC:
    5.22  // C4250: 'class1' : inherits 'class2::member' via dominance
    5.23 @@ -43,12 +42,15 @@
    5.24  #pragma GCC diagnostic ignored "-Wunused-local-typedefs"
    5.25  #endif
    5.26  
    5.27 -///\file
    5.28 -///\brief LEMON core utilities.
    5.29 -///
    5.30 -///This header file contains core utilities for LEMON.
    5.31 -///It is automatically included by all graph types, therefore it usually
    5.32 -///do not have to be included directly.
    5.33 +#include <vector>
    5.34 +#include <algorithm>
    5.35 +
    5.36 +#include <lemon/config.h>
    5.37 +#include <lemon/bits/enable_if.h>
    5.38 +#include <lemon/bits/traits.h>
    5.39 +#include <lemon/assert.h>
    5.40 +
    5.41 +
    5.42  
    5.43  namespace lemon {
    5.44  
     6.1 --- a/lemon/graph_to_eps.h	Tue Apr 14 16:36:45 2015 +0200
     6.2 +++ b/lemon/graph_to_eps.h	Tue Apr 28 18:13:42 2015 +0200
     6.3 @@ -25,7 +25,7 @@
     6.4  #include<algorithm>
     6.5  #include<vector>
     6.6  
     6.7 -#ifndef WIN32
     6.8 +#ifndef LEMON_WIN32
     6.9  #include<sys/time.h>
    6.10  #include<ctime>
    6.11  #else
    6.12 @@ -674,7 +674,7 @@
    6.13  
    6.14      {
    6.15        os << "%%CreationDate: ";
    6.16 -#ifndef WIN32
    6.17 +#ifndef LEMON_WIN32
    6.18        timeval tv;
    6.19        gettimeofday(&tv, 0);
    6.20  
     7.1 --- a/lemon/lp.h	Tue Apr 14 16:36:45 2015 +0200
     7.2 +++ b/lemon/lp.h	Tue Apr 28 18:13:42 2015 +0200
     7.3 @@ -22,19 +22,19 @@
     7.4  #include<lemon/config.h>
     7.5  
     7.6  
     7.7 -#if LEMON_DEFAULT_LP == _LEMON_GLPK || LEMON_DEFAULT_MIP == _LEMON_GLPK
     7.8 +#if LEMON_DEFAULT_LP == LEMON_GLPK_ || LEMON_DEFAULT_MIP == LEMON_GLPK_
     7.9  #include <lemon/glpk.h>
    7.10  #endif
    7.11 -#if LEMON_DEFAULT_LP == _LEMON_CPLEX || LEMON_DEFAULT_MIP == _LEMON_CPLEX 
    7.12 +#if LEMON_DEFAULT_LP == LEMON_CPLEX_ || LEMON_DEFAULT_MIP == LEMON_CPLEX_
    7.13  #include <lemon/cplex.h>
    7.14  #endif
    7.15 -#if LEMON_DEFAULT_LP == _LEMON_SOPLEX
    7.16 +#if LEMON_DEFAULT_LP == LEMON_SOPLEX_
    7.17  #include <lemon/soplex.h>
    7.18  #endif
    7.19 -#if LEMON_DEFAULT_LP == _LEMON_CLP
    7.20 +#if LEMON_DEFAULT_LP == LEMON_CLP_
    7.21  #include <lemon/clp.h>
    7.22  #endif
    7.23 -#if LEMON_DEFAULT_MIP == _LEMON_CBC
    7.24 +#if LEMON_DEFAULT_MIP == LEMON_CBC_
    7.25  #include <lemon/cbc.h>
    7.26  #endif
    7.27  
    7.28 @@ -49,8 +49,8 @@
    7.29    ///The default LP solver identifier.
    7.30    ///\ingroup lp_group
    7.31    ///
    7.32 -  ///Currently, the possible values are \c _LEMON_GLPK, \c LEMON__CPLEX,
    7.33 -  ///\c _LEMON_SOPLEX or \c LEMON__CLP
    7.34 +  ///Currently, the possible values are \c LEMON_GLPK_, \c LEMON_CPLEX_,
    7.35 +  ///\c LEMON_SOPLEX_ or \c LEMON_CLP_
    7.36  #define LEMON_DEFAULT_LP SOLVER
    7.37    ///The default LP solver
    7.38  
    7.39 @@ -65,8 +65,8 @@
    7.40    ///The default MIP solver identifier.
    7.41    ///\ingroup lp_group
    7.42    ///
    7.43 -  ///Currently, the possible values are \c _LEMON_GLPK, \c LEMON__CPLEX
    7.44 -  ///or \c _LEMON_CBC
    7.45 +  ///Currently, the possible values are \c LEMON_GLPK_, \c LEMON_CPLEX_
    7.46 +  ///or \c LEMON_CBC_
    7.47  #define LEMON_DEFAULT_MIP SOLVER
    7.48    ///The default MIP solver.
    7.49  
    7.50 @@ -76,20 +76,20 @@
    7.51    ///Currently, it is either \c GlpkMip, \c CplexMip , \c CbcMip
    7.52    typedef GlpkMip Mip;
    7.53  #else
    7.54 -#if LEMON_DEFAULT_LP == _LEMON_GLPK
    7.55 +#if LEMON_DEFAULT_LP == LEMON_GLPK_
    7.56    typedef GlpkLp Lp;
    7.57 -#elif LEMON_DEFAULT_LP == _LEMON_CPLEX
    7.58 +#elif LEMON_DEFAULT_LP == LEMON_CPLEX_
    7.59    typedef CplexLp Lp;
    7.60 -#elif LEMON_DEFAULT_LP == _LEMON_SOPLEX
    7.61 +#elif LEMON_DEFAULT_LP == LEMON_SOPLEX_
    7.62    typedef SoplexLp Lp;
    7.63 -#elif LEMON_DEFAULT_LP == _LEMON_CLP
    7.64 +#elif LEMON_DEFAULT_LP == LEMON_CLP_
    7.65    typedef ClpLp Lp;
    7.66  #endif
    7.67 -#if LEMON_DEFAULT_MIP == _LEMON_GLPK
    7.68 +#if LEMON_DEFAULT_MIP == LEMON_GLPK_
    7.69    typedef GlpkMip Mip;
    7.70 -#elif LEMON_DEFAULT_MIP == _LEMON_CPLEX
    7.71 +#elif LEMON_DEFAULT_MIP == LEMON_CPLEX_
    7.72    typedef CplexMip Mip;
    7.73 -#elif LEMON_DEFAULT_MIP == _LEMON_CBC
    7.74 +#elif LEMON_DEFAULT_MIP == LEMON_CBC_
    7.75    typedef CbcMip Mip;
    7.76  #endif
    7.77  #endif
     8.1 --- a/lemon/random.h	Tue Apr 14 16:36:45 2015 +0200
     8.2 +++ b/lemon/random.h	Tue Apr 28 18:13:42 2015 +0200
     8.3 @@ -62,6 +62,8 @@
     8.4  #ifndef LEMON_RANDOM_H
     8.5  #define LEMON_RANDOM_H
     8.6  
     8.7 +#include <lemon/config.h>
     8.8 +
     8.9  #include <algorithm>
    8.10  #include <iterator>
    8.11  #include <vector>
    8.12 @@ -71,7 +73,7 @@
    8.13  #include <lemon/math.h>
    8.14  #include <lemon/dim2.h>
    8.15  
    8.16 -#ifndef WIN32
    8.17 +#ifndef LEMON_WIN32
    8.18  #include <sys/time.h>
    8.19  #include <ctime>
    8.20  #include <sys/types.h>
    8.21 @@ -605,7 +607,7 @@
    8.22      /// it uses the \c seedFromTime().
    8.23      /// \return Currently always \c true.
    8.24      bool seed() {
    8.25 -#ifndef WIN32
    8.26 +#ifndef LEMON_WIN32
    8.27        if (seedFromFile("/dev/urandom", 0)) return true;
    8.28  #endif
    8.29        if (seedFromTime()) return true;
    8.30 @@ -625,7 +627,7 @@
    8.31      /// \param file The source file
    8.32      /// \param offset The offset, from the file read.
    8.33      /// \return \c true when the seeding successes.
    8.34 -#ifndef WIN32
    8.35 +#ifndef LEMON_WIN32
    8.36      bool seedFromFile(const std::string& file = "/dev/urandom", int offset = 0)
    8.37  #else
    8.38      bool seedFromFile(const std::string& file = "", int offset = 0)
    8.39 @@ -647,7 +649,7 @@
    8.40      /// random sequence.
    8.41      /// \return Currently always \c true.
    8.42      bool seedFromTime() {
    8.43 -#ifndef WIN32
    8.44 +#ifndef LEMON_WIN32
    8.45        timeval tv;
    8.46        gettimeofday(&tv, 0);
    8.47        seed(getpid() + tv.tv_sec + tv.tv_usec);
     9.1 --- a/lemon/time_measure.h	Tue Apr 14 16:36:45 2015 +0200
     9.2 +++ b/lemon/time_measure.h	Tue Apr 28 18:13:42 2015 +0200
     9.3 @@ -23,7 +23,9 @@
     9.4  ///\file
     9.5  ///\brief Tools for measuring cpu usage
     9.6  
     9.7 -#ifdef WIN32
     9.8 +#include <lemon/config.h>
     9.9 +
    9.10 +#ifdef LEMON_WIN32
    9.11  #include <lemon/bits/windows.h>
    9.12  #else
    9.13  #include <unistd.h>
    9.14 @@ -102,7 +104,7 @@
    9.15      ///Read the current time values of the process
    9.16      void stamp()
    9.17      {
    9.18 -#ifndef WIN32
    9.19 +#ifndef LEMON_WIN32
    9.20        timeval tv;
    9.21        gettimeofday(&tv, 0);
    9.22        rtime=tv.tv_sec+double(tv.tv_usec)/1e6;
    10.1 --- a/test/radix_sort_test.cc	Tue Apr 14 16:36:45 2015 +0200
    10.2 +++ b/test/radix_sort_test.cc	Tue Apr 28 18:13:42 2015 +0200
    10.3 @@ -16,6 +16,8 @@
    10.4   *
    10.5   */
    10.6  
    10.7 +#include <lemon/core.h>
    10.8 +
    10.9  #include <lemon/time_measure.h>
   10.10  #include <lemon/smart_graph.h>
   10.11  #include <lemon/maps.h>