53 namespace bits { |
53 namespace bits { |
54 void getWinProcTimes(double &rtime, |
54 void getWinProcTimes(double &rtime, |
55 double &utime, double &stime, |
55 double &utime, double &stime, |
56 double &cutime, double &cstime) |
56 double &cutime, double &cstime) |
57 { |
57 { |
58 #ifdef WIN32 |
58 #ifdef LEMON_WIN32 |
59 static const double ch = 4294967296.0e-7; |
59 static const double ch = 4294967296.0e-7; |
60 static const double cl = 1.0e-7; |
60 static const double cl = 1.0e-7; |
61 |
61 |
62 FILETIME system; |
62 FILETIME system; |
63 GetSystemTimeAsFileTime(&system); |
63 GetSystemTimeAsFileTime(&system); |
92 } |
92 } |
93 |
93 |
94 std::string getWinFormattedDate() |
94 std::string getWinFormattedDate() |
95 { |
95 { |
96 std::ostringstream os; |
96 std::ostringstream os; |
97 #ifdef WIN32 |
97 #ifdef LEMON_WIN32 |
98 SYSTEMTIME time; |
98 SYSTEMTIME time; |
99 GetSystemTime(&time); |
99 GetSystemTime(&time); |
100 char buf1[11], buf2[9], buf3[5]; |
100 char buf1[11], buf2[9], buf3[5]; |
101 if (GetDateFormat(MY_LOCALE, 0, &time, |
101 if (GetDateFormat(MY_LOCALE, 0, &time, |
102 ("ddd MMM dd"), buf1, 11) && |
102 ("ddd MMM dd"), buf1, 11) && |
103 GetTimeFormat(MY_LOCALE, 0, &time, |
103 GetTimeFormat(MY_LOCALE, 0, &time, |
104 ("HH':'mm':'ss"), buf2, 9) && |
104 ("HH':'mm':'ss"), buf2, 9) && |
105 GetDateFormat(MY_LOCALE, 0, &time, |
105 GetDateFormat(MY_LOCALE, 0, &time, |
106 ("yyyy"), buf3, 5)) { |
106 ("yyyy"), buf3, 5)) { |
130 return getpid() + tv.tv_sec + tv.tv_usec; |
130 return getpid() + tv.tv_sec + tv.tv_usec; |
131 #endif |
131 #endif |
132 } |
132 } |
133 |
133 |
134 WinLock::WinLock() { |
134 WinLock::WinLock() { |
135 #ifdef WIN32 |
135 #ifdef LEMON_WIN32 |
136 CRITICAL_SECTION *lock = new CRITICAL_SECTION; |
136 CRITICAL_SECTION *lock = new CRITICAL_SECTION; |
137 InitializeCriticalSection(lock); |
137 InitializeCriticalSection(lock); |
138 _repr = lock; |
138 _repr = lock; |
139 #else |
139 #else |
140 _repr = 0; //Just to avoid 'unused variable' warning with clang |
140 _repr = 0; //Just to avoid 'unused variable' warning with clang |
141 #endif |
141 #endif |
142 } |
142 } |
143 |
143 |
144 WinLock::~WinLock() { |
144 WinLock::~WinLock() { |
145 #ifdef WIN32 |
145 #ifdef LEMON_WIN32 |
146 CRITICAL_SECTION *lock = static_cast<CRITICAL_SECTION*>(_repr); |
146 CRITICAL_SECTION *lock = static_cast<CRITICAL_SECTION*>(_repr); |
147 DeleteCriticalSection(lock); |
147 DeleteCriticalSection(lock); |
148 delete lock; |
148 delete lock; |
149 #endif |
149 #endif |
150 } |
150 } |
151 |
151 |
152 void WinLock::lock() { |
152 void WinLock::lock() { |
153 #ifdef WIN32 |
153 #ifdef LEMON_WIN32 |
154 CRITICAL_SECTION *lock = static_cast<CRITICAL_SECTION*>(_repr); |
154 CRITICAL_SECTION *lock = static_cast<CRITICAL_SECTION*>(_repr); |
155 EnterCriticalSection(lock); |
155 EnterCriticalSection(lock); |
156 #endif |
156 #endif |
157 } |
157 } |
158 |
158 |
159 void WinLock::unlock() { |
159 void WinLock::unlock() { |
160 #ifdef WIN32 |
160 #ifdef LEMON_WIN32 |
161 CRITICAL_SECTION *lock = static_cast<CRITICAL_SECTION*>(_repr); |
161 CRITICAL_SECTION *lock = static_cast<CRITICAL_SECTION*>(_repr); |
162 LeaveCriticalSection(lock); |
162 LeaveCriticalSection(lock); |
163 #endif |
163 #endif |
164 } |
164 } |
165 } |
165 } |