Browse code

Adding more win stuff

Steffen Neumann authored on 27/11/2021 10:23:50
Showing 4 changed files

... ...
@@ -52,8 +52,8 @@ jobs:
52 52
       fail-fast: false
53 53
       matrix:
54 54
         config:
55
-          - { os: ubuntu-latest, r: 'devel', bioc: '3.15', cont: "bioconductor/bioconductor_docker:devel", rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest" }
56
-          - { os: macOS-latest, r: 'devel', bioc: '3.15'}
55
+#          - { os: ubuntu-latest, r: 'devel', bioc: '3.15', cont: "bioconductor/bioconductor_docker:devel", rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest" }
56
+#          - { os: macOS-latest, r: 'devel', bioc: '3.15'}
57 57
           - { os: windows-latest, r: 'devel', bioc: '3.15'}
58 58
     env:
59 59
       R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
60 60
new file mode 100755
... ...
@@ -0,0 +1,151 @@
1
+//  win/chrono.cpp  --------------------------------------------------------------//
2
+
3
+//  Copyright Beman Dawes 2008
4
+//  Copyright 2009-2010 Vicente J. Botet Escriba
5
+
6
+//  Distributed under the Boost Software License, Version 1.0.
7
+//  See http://www.boost.org/LICENSE_1_0.txt
8
+
9
+//----------------------------------------------------------------------------//
10
+//                                Windows                                     //
11
+//----------------------------------------------------------------------------//
12
+#ifndef BOOST_CHRONO_DETAIL_INLINED_WIN_CHRONO_HPP
13
+#define BOOST_CHRONO_DETAIL_INLINED_WIN_CHRONO_HPP
14
+
15
+#include <boost/winapi/time.hpp>
16
+#include <boost/winapi/timers.hpp>
17
+#include <boost/winapi/get_last_error.hpp>
18
+#include <boost/winapi/error_codes.hpp>
19
+#include <boost/assert.hpp>
20
+
21
+namespace boost
22
+{
23
+namespace chrono
24
+{
25
+namespace chrono_detail
26
+{
27
+
28
+  BOOST_CHRONO_INLINE double get_nanosecs_per_tic() BOOST_NOEXCEPT
29
+  {
30
+      boost::winapi::LARGE_INTEGER_ freq;
31
+      if ( !boost::winapi::QueryPerformanceFrequency( &freq ) )
32
+          return 0.0L;
33
+      return double(1000000000.0L / freq.QuadPart);
34
+  }
35
+
36
+}
37
+
38
+  steady_clock::time_point steady_clock::now() BOOST_NOEXCEPT
39
+  {
40
+    double nanosecs_per_tic = chrono_detail::get_nanosecs_per_tic();
41
+
42
+    boost::winapi::LARGE_INTEGER_ pcount;
43
+    if ( nanosecs_per_tic <= 0.0L )
44
+    {
45
+      BOOST_ASSERT(0 && "Boost::Chrono - get_nanosecs_per_tic Internal Error");
46
+      return steady_clock::time_point();
47
+    }
48
+    unsigned times=0;
49
+    while ( ! boost::winapi::QueryPerformanceCounter( &pcount ) )
50
+    {
51
+      if ( ++times > 3 )
52
+      {
53
+        BOOST_ASSERT(0 && "Boost::Chrono - QueryPerformanceCounter Internal Error");
54
+        return steady_clock::time_point();
55
+      }
56
+    }
57
+
58
+    return steady_clock::time_point(steady_clock::duration(
59
+      static_cast<steady_clock::rep>((nanosecs_per_tic) * pcount.QuadPart)));
60
+  }
61
+
62
+
63
+#if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
64
+  steady_clock::time_point steady_clock::now( system::error_code & ec )
65
+  {
66
+    double nanosecs_per_tic = chrono_detail::get_nanosecs_per_tic();
67
+
68
+    boost::winapi::LARGE_INTEGER_ pcount;
69
+    if ( (nanosecs_per_tic <= 0.0L)
70
+            || (!boost::winapi::QueryPerformanceCounter( &pcount )) )
71
+    {
72
+        boost::winapi::DWORD_ cause =
73
+            ((nanosecs_per_tic <= 0.0L)
74
+                    ? boost::winapi::ERROR_NOT_SUPPORTED_
75
+                    : boost::winapi::GetLastError());
76
+        if (::boost::chrono::is_throws(ec)) {
77
+            boost::throw_exception(
78
+                    system::system_error(
79
+                            cause,
80
+                            ::boost::system::system_category(),
81
+                            "chrono::steady_clock" ));
82
+        }
83
+        else
84
+        {
85
+            ec.assign( cause, ::boost::system::system_category() );
86
+            return steady_clock::time_point(duration(0));
87
+        }
88
+    }
89
+
90
+    if (!::boost::chrono::is_throws(ec))
91
+    {
92
+        ec.clear();
93
+    }
94
+    return time_point(duration(
95
+      static_cast<steady_clock::rep>(nanosecs_per_tic * pcount.QuadPart)));
96
+  }
97
+#endif
98
+
99
+  BOOST_CHRONO_INLINE
100
+  system_clock::time_point system_clock::now() BOOST_NOEXCEPT
101
+  {
102
+    boost::winapi::FILETIME_ ft;
103
+    boost::winapi::GetSystemTimeAsFileTime( &ft );  // never fails
104
+    return system_clock::time_point(
105
+      system_clock::duration(
106
+        ((static_cast<__int64>( ft.dwHighDateTime ) << 32) | ft.dwLowDateTime)
107
+       - 116444736000000000LL
108
+       //- (134775LL*864000000000LL)
109
+      )
110
+    );
111
+  }
112
+
113
+#if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
114
+  BOOST_CHRONO_INLINE
115
+  system_clock::time_point system_clock::now( system::error_code & ec )
116
+  {
117
+    boost::winapi::FILETIME_ ft;
118
+    boost::winapi::GetSystemTimeAsFileTime( &ft );  // never fails
119
+    if (!::boost::chrono::is_throws(ec))
120
+    {
121
+        ec.clear();
122
+    }
123
+    return system_clock::time_point(
124
+      system_clock::duration(
125
+       ((static_cast<__int64>( ft.dwHighDateTime ) << 32) | ft.dwLowDateTime)
126
+       - 116444736000000000LL
127
+       //- (134775LL*864000000000LL)
128
+       ));
129
+  }
130
+#endif
131
+
132
+  BOOST_CHRONO_INLINE
133
+  std::time_t system_clock::to_time_t(const system_clock::time_point& t) BOOST_NOEXCEPT
134
+  {
135
+      __int64 temp = t.time_since_epoch().count();
136
+      temp /= 10000000;
137
+      return static_cast<std::time_t>( temp );
138
+  }
139
+
140
+  BOOST_CHRONO_INLINE
141
+  system_clock::time_point system_clock::from_time_t(std::time_t t) BOOST_NOEXCEPT
142
+  {
143
+      __int64 temp = t;
144
+      temp *= 10000000;
145
+      return time_point(duration(temp));
146
+  }
147
+
148
+}  // namespace chrono
149
+}  // namespace boost
150
+
151
+#endif
0 152
new file mode 100755
... ...
@@ -0,0 +1,281 @@
1
+//  boost process_timer.cpp  -----------------------------------------------------------//
2
+
3
+//  Copyright Beman Dawes 1994, 2006, 2008
4
+//  Copyright 2009-2010 Vicente J. Botet Escriba
5
+//  Copyright (c) Microsoft Corporation 2014
6
+
7
+//  Distributed under the Boost Software License, Version 1.0.
8
+//  See http://www.boost.org/LICENSE_1_0.txt
9
+
10
+//  See http://www.boost.org/libs/chrono for documentation.
11
+
12
+//--------------------------------------------------------------------------------------//
13
+#ifndef BOOST_CHRONO_DETAIL_INLINED_WIN_PROCESS_CLOCK_HPP
14
+#define BOOST_CHRONO_DETAIL_INLINED_WIN_PROCESS_CLOCK_HPP
15
+
16
+#include <boost/chrono/config.hpp>
17
+#include <boost/chrono/process_cpu_clocks.hpp>
18
+#include <cassert>
19
+#include <time.h>
20
+#include <boost/assert.hpp>
21
+
22
+#include <boost/winapi/get_last_error.hpp>
23
+#include <boost/winapi/get_current_process.hpp>
24
+#if BOOST_PLAT_WINDOWS_DESKTOP
25
+#include <boost/winapi/get_process_times.hpp>
26
+#endif
27
+
28
+namespace boost
29
+{
30
+namespace chrono
31
+{
32
+
33
+process_real_cpu_clock::time_point process_real_cpu_clock::now() BOOST_NOEXCEPT
34
+{
35
+    clock_t c = ::clock();
36
+    if ( c == clock_t(-1) ) // error
37
+    {
38
+      BOOST_ASSERT(0 && "Boost::Chrono - Internal Error");
39
+    }
40
+    typedef ratio_divide<giga, ratio<CLOCKS_PER_SEC> >::type R;
41
+    return time_point(
42
+      duration(static_cast<rep>(c)*R::num/R::den)
43
+    );
44
+}
45
+
46
+#if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
47
+process_real_cpu_clock::time_point process_real_cpu_clock::now(
48
+        system::error_code & ec)
49
+{
50
+    clock_t c = ::clock();
51
+    if ( c == clock_t(-1) ) // error
52
+    {
53
+            boost::throw_exception(
54
+                    system::system_error(
55
+                            errno,
56
+                            ::boost::system::system_category(),
57
+                            "chrono::process_real_cpu_clock" ));
58
+    }
59
+    if (!::boost::chrono::is_throws(ec))
60
+    {
61
+      ec.clear();
62
+    }
63
+    typedef ratio_divide<giga, ratio<CLOCKS_PER_SEC> >::type R;
64
+    return time_point(
65
+      duration(static_cast<rep>(c)*R::num/R::den)
66
+    );
67
+}
68
+#endif
69
+
70
+#if BOOST_PLAT_WINDOWS_DESKTOP
71
+process_user_cpu_clock::time_point process_user_cpu_clock::now() BOOST_NOEXCEPT
72
+{
73
+
74
+    //  note that Windows uses 100 nanosecond ticks for FILETIME
75
+    boost::winapi::FILETIME_ creation, exit, user_time, system_time;
76
+
77
+    if ( boost::winapi::GetProcessTimes(
78
+            boost::winapi::GetCurrentProcess(), &creation, &exit,
79
+            &system_time, &user_time ) )
80
+    {
81
+        return time_point(duration(
82
+                ((static_cast<process_user_cpu_clock::rep>(user_time.dwHighDateTime) << 32)
83
+                  | user_time.dwLowDateTime) * 100
84
+                ));
85
+    }
86
+    else
87
+    {
88
+        BOOST_ASSERT(0 && "Boost::Chrono - Internal Error");
89
+        return time_point();
90
+    }
91
+
92
+}
93
+
94
+#if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
95
+process_user_cpu_clock::time_point process_user_cpu_clock::now(
96
+        system::error_code & ec)
97
+{
98
+
99
+    //  note that Windows uses 100 nanosecond ticks for FILETIME
100
+    boost::winapi::FILETIME_ creation, exit, user_time, system_time;
101
+
102
+    if ( boost::winapi::GetProcessTimes(
103
+            boost::winapi::GetCurrentProcess(), &creation, &exit,
104
+            &system_time, &user_time ) )
105
+    {
106
+        if (!::boost::chrono::is_throws(ec))
107
+        {
108
+            ec.clear();
109
+        }
110
+        return time_point(duration(
111
+                ((static_cast<process_user_cpu_clock::rep>(user_time.dwHighDateTime) << 32)
112
+                  | user_time.dwLowDateTime) * 100
113
+                ));
114
+    }
115
+    else
116
+    {
117
+        boost::winapi::DWORD_ cause = boost::winapi::GetLastError();
118
+        if (::boost::chrono::is_throws(ec))
119
+        {
120
+            boost::throw_exception(
121
+                    system::system_error(
122
+                            cause,
123
+                            ::boost::system::system_category(),
124
+                            "chrono::process_user_cpu_clock" ));
125
+        }
126
+        else
127
+        {
128
+            ec.assign( cause, ::boost::system::system_category() );
129
+            return time_point();
130
+        }
131
+    }
132
+
133
+}
134
+#endif
135
+
136
+process_system_cpu_clock::time_point process_system_cpu_clock::now() BOOST_NOEXCEPT
137
+{
138
+
139
+    //  note that Windows uses 100 nanosecond ticks for FILETIME
140
+    boost::winapi::FILETIME_ creation, exit, user_time, system_time;
141
+
142
+    if ( boost::winapi::GetProcessTimes(
143
+            boost::winapi::GetCurrentProcess(), &creation, &exit,
144
+            &system_time, &user_time ) )
145
+    {
146
+        return time_point(duration(
147
+                ((static_cast<process_system_cpu_clock::rep>(system_time.dwHighDateTime) << 32)
148
+                                    | system_time.dwLowDateTime) * 100
149
+                ));
150
+    }
151
+    else
152
+    {
153
+      BOOST_ASSERT(0 && "Boost::Chrono - Internal Error");
154
+      return time_point();
155
+    }
156
+
157
+}
158
+
159
+#if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
160
+process_system_cpu_clock::time_point process_system_cpu_clock::now(
161
+        system::error_code & ec)
162
+{
163
+
164
+    //  note that Windows uses 100 nanosecond ticks for FILETIME
165
+    boost::winapi::FILETIME_ creation, exit, user_time, system_time;
166
+
167
+    if ( boost::winapi::GetProcessTimes(
168
+            boost::winapi::GetCurrentProcess(), &creation, &exit,
169
+            &system_time, &user_time ) )
170
+    {
171
+        if (!::boost::chrono::is_throws(ec))
172
+        {
173
+            ec.clear();
174
+        }
175
+        return time_point(duration(
176
+                ((static_cast<process_system_cpu_clock::rep>(system_time.dwHighDateTime) << 32)
177
+                                    | system_time.dwLowDateTime) * 100
178
+                ));
179
+    }
180
+    else
181
+    {
182
+        boost::winapi::DWORD_ cause = boost::winapi::GetLastError();
183
+        if (::boost::chrono::is_throws(ec))
184
+        {
185
+            boost::throw_exception(
186
+                    system::system_error(
187
+                            cause,
188
+                            ::boost::system::system_category(),
189
+                            "chrono::process_system_cpu_clock" ));
190
+        }
191
+        else
192
+        {
193
+            ec.assign( cause, ::boost::system::system_category() );
194
+            return time_point();
195
+        }
196
+    }
197
+
198
+}
199
+#endif
200
+
201
+process_cpu_clock::time_point process_cpu_clock::now()  BOOST_NOEXCEPT
202
+{
203
+
204
+    //  note that Windows uses 100 nanosecond ticks for FILETIME
205
+    boost::winapi::FILETIME_ creation, exit, user_time, system_time;
206
+
207
+    if ( boost::winapi::GetProcessTimes(
208
+            boost::winapi::GetCurrentProcess(), &creation, &exit,
209
+            &system_time, &user_time ) )
210
+    {
211
+        time_point::rep r(process_real_cpu_clock::now().time_since_epoch().count()
212
+                            ,
213
+                ((static_cast<process_user_cpu_clock::rep>(user_time.dwHighDateTime) << 32)
214
+                        | user_time.dwLowDateTime
215
+                ) * 100,
216
+                ((static_cast<process_system_cpu_clock::rep>(system_time.dwHighDateTime) << 32)
217
+                        | system_time.dwLowDateTime
218
+                ) * 100
219
+        );
220
+        return time_point(duration(r));
221
+    }
222
+    else
223
+    {
224
+      BOOST_ASSERT(0 && "Boost::Chrono - Internal Error");
225
+      return time_point();
226
+    }
227
+
228
+}
229
+
230
+#if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
231
+process_cpu_clock::time_point process_cpu_clock::now(
232
+        system::error_code & ec )
233
+{
234
+
235
+    //  note that Windows uses 100 nanosecond ticks for FILETIME
236
+    boost::winapi::FILETIME_ creation, exit, user_time, system_time;
237
+
238
+    if ( boost::winapi::GetProcessTimes(
239
+            boost::winapi::GetCurrentProcess(), &creation, &exit,
240
+            &system_time, &user_time ) )
241
+    {
242
+        if (!::boost::chrono::is_throws(ec))
243
+        {
244
+            ec.clear();
245
+        }
246
+        time_point::rep r(process_real_cpu_clock::now().time_since_epoch().count()
247
+                            ,
248
+                ((static_cast<process_user_cpu_clock::rep>(user_time.dwHighDateTime) << 32)
249
+                        | user_time.dwLowDateTime
250
+                ) * 100,
251
+                ((static_cast<process_system_cpu_clock::rep>(system_time.dwHighDateTime) << 32)
252
+                        | system_time.dwLowDateTime
253
+                ) * 100
254
+        );
255
+        return time_point(duration(r));
256
+    }
257
+    else
258
+    {
259
+        boost::winapi::DWORD_ cause = boost::winapi::GetLastError();
260
+        if (::boost::chrono::is_throws(ec))
261
+        {
262
+            boost::throw_exception(
263
+                    system::system_error(
264
+                            cause,
265
+                            ::boost::system::system_category(),
266
+                            "chrono::process_cpu_clock" ));
267
+        }
268
+        else
269
+        {
270
+            ec.assign( cause, ::boost::system::system_category() );
271
+            return time_point();
272
+        }
273
+    }
274
+
275
+}
276
+#endif
277
+#endif
278
+} // namespace chrono
279
+} // namespace boost
280
+
281
+#endif
0 282
new file mode 100755
... ...
@@ -0,0 +1,103 @@
1
+//  boost thread_clock.cpp  -----------------------------------------------------------//
2
+
3
+//  Copyright 2010 Vicente J. Botet Escriba
4
+
5
+//  Distributed under the Boost Software License, Version 1.0.
6
+//  See http://www.boost.org/LICENSE_1_0.txt
7
+
8
+//  See http://www.boost.org/libs/chrono for documentation.
9
+
10
+//--------------------------------------------------------------------------------------//
11
+#ifndef BOOST_CHRONO_DETAIL_INLINED_WIN_THREAD_CLOCK_HPP
12
+#define BOOST_CHRONO_DETAIL_INLINED_WIN_THREAD_CLOCK_HPP
13
+
14
+#include <boost/chrono/config.hpp>
15
+#include <boost/chrono/thread_clock.hpp>
16
+#include <cassert>
17
+#include <boost/assert.hpp>
18
+
19
+#include <boost/winapi/get_last_error.hpp>
20
+#include <boost/winapi/get_current_thread.hpp>
21
+#include <boost/winapi/get_thread_times.hpp>
22
+
23
+namespace boost
24
+{
25
+namespace chrono
26
+{
27
+
28
+#if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
29
+thread_clock::time_point thread_clock::now( system::error_code & ec )
30
+{
31
+    //  note that Windows uses 100 nanosecond ticks for FILETIME
32
+    boost::winapi::FILETIME_ creation, exit, user_time, system_time;
33
+
34
+    if ( boost::winapi::GetThreadTimes(
35
+            boost::winapi::GetCurrentThread (), &creation, &exit,
36
+            &system_time, &user_time ) )
37
+    {
38
+        duration user = duration(
39
+                ((static_cast<duration::rep>(user_time.dwHighDateTime) << 32)
40
+                        | user_time.dwLowDateTime) * 100 );
41
+
42
+        duration system = duration(
43
+                ((static_cast<duration::rep>(system_time.dwHighDateTime) << 32)
44
+                        | system_time.dwLowDateTime) * 100 );
45
+
46
+        if (!::boost::chrono::is_throws(ec))
47
+        {
48
+            ec.clear();
49
+        }
50
+        return time_point(system+user);
51
+
52
+    }
53
+    else
54
+    {
55
+        if (::boost::chrono::is_throws(ec))
56
+        {
57
+            boost::throw_exception(
58
+                    system::system_error(
59
+                            boost::winapi::GetLastError(),
60
+                            ::boost::system::system_category(),
61
+                            "chrono::thread_clock" ));
62
+        }
63
+        else
64
+        {
65
+            ec.assign( boost::winapi::GetLastError(), ::boost::system::system_category() );
66
+            return thread_clock::time_point(duration(0));
67
+        }
68
+    }
69
+}
70
+#endif
71
+
72
+thread_clock::time_point thread_clock::now() BOOST_NOEXCEPT
73
+{
74
+
75
+    //  note that Windows uses 100 nanosecond ticks for FILETIME
76
+    boost::winapi::FILETIME_ creation, exit, user_time, system_time;
77
+
78
+    if ( boost::winapi::GetThreadTimes(
79
+            boost::winapi::GetCurrentThread (), &creation, &exit,
80
+            &system_time, &user_time ) )
81
+    {
82
+        duration user   = duration(
83
+                ((static_cast<duration::rep>(user_time.dwHighDateTime) << 32)
84
+                        | user_time.dwLowDateTime) * 100 );
85
+
86
+        duration system = duration(
87
+                ((static_cast<duration::rep>(system_time.dwHighDateTime) << 32)
88
+                        | system_time.dwLowDateTime) * 100 );
89
+
90
+        return time_point(system+user);
91
+    }
92
+    else
93
+    {
94
+      BOOST_ASSERT(0 && "Boost::Chrono - Internal Error");
95
+      return time_point();
96
+    }
97
+
98
+}
99
+
100
+} // namespace chrono
101
+} // namespace boost
102
+
103
+#endif