00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef __portability_h__
00014 #define __portability_h__
00015
00016 #include <algorithm>
00017 #include <numeric>
00018 #include <cmath>
00019
00020
00021 namespace portability {
00022 #if !defined(_MSC_VER)||defined(__ICL)
00023 template <class Type>
00024 Type min(const Type& x, const Type& y)
00025 {
00026 Type min_;
00027 min_ = (x>y)? y:x;
00028 return min_;
00029 }
00030 template <class Type>
00031 Type max(const Type& x, const Type& y)
00032 {
00033 Type max_;
00034 max_ = (x<y)? y:x;
00035 return max_;
00036 }
00037 #endif
00038 template <class T>
00039 T abs(const T& x) { return (x>0?x:-(x));}
00040 }
00041
00042
00043 #ifdef __GNUG__
00044 #define MIN(A,B) std::min(A,B)
00045 #define MAX(A,B) std::max(A,B)
00046 #define ABS(A) std::abs(A)
00047 #define RESTRICT __restrict__
00048 #endif
00049
00050 #if defined(_MSC_VER)
00051 #define ABS(A) portability::abs(A)
00052 #ifdef __ICL
00053 #define MIN(A,B) portability::min(A,B)
00054 #define MAX(A,B) portability::max(A,B)
00055 #define RESTRICT restrict
00056 #else
00057 #define MIN(A,B) min(A,B)
00058 #define MAX(A,B) max(A,B)
00059 #define RESTRICT
00060 #endif
00061 #endif
00062
00063
00064
00065 #endif