Browse code

Compile on macOS, but hdf5 path hard-coded

Steffen Neumann authored on 29/01/2017 21:44:03
Showing 5 changed files

... ...
@@ -111,7 +111,7 @@ ARCH_OBJS=./boost/libs/thread/src/pthread/once.o \
111 111
 endif
112 112
 
113 113
 NC_CFLAGS=`nc-config --cflags || /bin/true`
114
-NC_LIBS=`nc-config --libs || echo " -lnetcdf "`
114
+NC_LIBS=-L/opt/lib/hdf5-18/lib/ `nc-config --libs || echo " -lnetcdf "`
115 115
 
116 116
 MZROBJECTS=cramp.o ramp_base64.o ramp.o RcppRamp.o RcppRampModule.o rnetCDF.o RcppPwiz.o RcppPwizModule.o RcppIdent.o RcppIdentModule.o
117 117
 
118 118
new file mode 100644
... ...
@@ -0,0 +1,20 @@
1
+/*
2
+ (c) 2014 Glen Joseph Fernandes
3
+ glenjofe at gmail dot com
4
+
5
+ Distributed under the Boost Software
6
+ License, Version 1.0.
7
+ http://boost.org/LICENSE_1_0.txt
8
+*/
9
+#ifndef BOOST_ALIGN_DETAIL_ALIGN_CXX11_HPP
10
+#define BOOST_ALIGN_DETAIL_ALIGN_CXX11_HPP
11
+
12
+#include <memory>
13
+
14
+namespace boost {
15
+    namespace alignment {
16
+        using std::align;
17
+    }
18
+}
19
+
20
+#endif
0 21
new file mode 100644
... ...
@@ -0,0 +1,241 @@
1
+//  mac/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
+//----------------------------------------------------------------------------//
11
+//                                 Mac                                        //
12
+//----------------------------------------------------------------------------//
13
+
14
+#include <sys/time.h> //for gettimeofday and timeval
15
+#include <mach/mach_time.h>  // mach_absolute_time, mach_timebase_info_data_t
16
+
17
+namespace boost
18
+{
19
+namespace chrono
20
+{
21
+
22
+// system_clock
23
+
24
+// gettimeofday is the most precise "system time" available on this platform.
25
+// It returns the number of microseconds since New Years 1970 in a struct called timeval
26
+// which has a field for seconds and a field for microseconds.
27
+//    Fill in the timeval and then convert that to the time_point
28
+system_clock::time_point
29
+system_clock::now() BOOST_NOEXCEPT
30
+{
31
+    timeval tv;
32
+    gettimeofday(&tv, 0);
33
+    return time_point(seconds(tv.tv_sec) + microseconds(tv.tv_usec));
34
+}
35
+
36
+#if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
37
+system_clock::time_point
38
+system_clock::now(system::error_code & ec)
39
+{
40
+    timeval tv;
41
+    gettimeofday(&tv, 0);
42
+    if (!BOOST_CHRONO_IS_THROWS(ec)) 
43
+    {
44
+        ec.clear();
45
+    }
46
+    return time_point(seconds(tv.tv_sec) + microseconds(tv.tv_usec));
47
+}
48
+#endif
49
+// Take advantage of the fact that on this platform time_t is nothing but
50
+//    an integral count of seconds since New Years 1970 (same epoch as timeval).
51
+//    Just get the duration out of the time_point and truncate it to seconds.
52
+time_t
53
+system_clock::to_time_t(const time_point& t) BOOST_NOEXCEPT
54
+{
55
+    return time_t(duration_cast<seconds>(t.time_since_epoch()).count());
56
+}
57
+
58
+// Just turn the time_t into a count of seconds and construct a time_point with it.
59
+system_clock::time_point
60
+system_clock::from_time_t(time_t t) BOOST_NOEXCEPT
61
+{
62
+    return system_clock::time_point(seconds(t));
63
+}
64
+
65
+namespace chrono_detail
66
+{
67
+
68
+// steady_clock
69
+
70
+// Note, in this implementation steady_clock and high_resolution_clock
71
+//   are the same clock.  They are both based on mach_absolute_time().
72
+//   mach_absolute_time() * MachInfo.numer / MachInfo.denom is the number of
73
+//   nanoseconds since the computer booted up.  MachInfo.numer and MachInfo.denom
74
+//   are run time constants supplied by the OS.  This clock has no relationship
75
+//   to the Gregorian calendar.  It's main use is as a high resolution timer.
76
+
77
+// MachInfo.numer / MachInfo.denom is often 1 on the latest equipment.  Specialize
78
+//   for that case as an optimization.
79
+BOOST_CHRONO_STATIC
80
+steady_clock::rep
81
+steady_simplified()
82
+{
83
+    return mach_absolute_time();
84
+}
85
+
86
+#if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
87
+BOOST_CHRONO_STATIC
88
+steady_clock::rep
89
+steady_simplified_ec(system::error_code & ec)
90
+{
91
+    if (!BOOST_CHRONO_IS_THROWS(ec)) 
92
+    {
93
+        ec.clear();
94
+    }
95
+    return mach_absolute_time();
96
+}
97
+#endif
98
+
99
+BOOST_CHRONO_STATIC
100
+double
101
+compute_steady_factor(kern_return_t& err)
102
+{
103
+    mach_timebase_info_data_t MachInfo;
104
+    err = mach_timebase_info(&MachInfo);
105
+    if ( err != 0  ) {
106
+        return 0;
107
+    }
108
+    return static_cast<double>(MachInfo.numer) / MachInfo.denom;
109
+}
110
+
111
+BOOST_CHRONO_STATIC
112
+steady_clock::rep
113
+steady_full()
114
+{
115
+    static kern_return_t err;
116
+    static const double factor = chrono_detail::compute_steady_factor(err);
117
+    if (err != 0) 
118
+    {
119
+      BOOST_ASSERT(0 && "Boost::Chrono - Internal Error");
120
+    }
121
+    return static_cast<steady_clock::rep>(mach_absolute_time() * factor);
122
+}
123
+
124
+#if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
125
+BOOST_CHRONO_STATIC
126
+steady_clock::rep
127
+steady_full_ec(system::error_code & ec)
128
+{
129
+    static kern_return_t err;
130
+    static const double factor = chrono_detail::compute_steady_factor(err);
131
+    if (err != 0) 
132
+    {
133
+        if (BOOST_CHRONO_IS_THROWS(ec))
134
+        {
135
+            boost::throw_exception(
136
+                    system::system_error( 
137
+                            err, 
138
+                            BOOST_CHRONO_SYSTEM_CATEGORY, 
139
+                            "chrono::steady_clock" ));
140
+        } 
141
+        else
142
+        {
143
+            ec.assign( errno, BOOST_CHRONO_SYSTEM_CATEGORY );
144
+            return steady_clock::rep();
145
+        }
146
+    }
147
+    if (!BOOST_CHRONO_IS_THROWS(ec)) 
148
+    {
149
+        ec.clear();
150
+    }
151
+    return static_cast<steady_clock::rep>(mach_absolute_time() * factor);
152
+}
153
+#endif
154
+
155
+typedef steady_clock::rep (*FP)();
156
+#if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
157
+typedef steady_clock::rep (*FP_ec)(system::error_code &);
158
+#endif
159
+
160
+BOOST_CHRONO_STATIC
161
+FP
162
+init_steady_clock(kern_return_t & err)
163
+{
164
+    mach_timebase_info_data_t MachInfo;
165
+    err = mach_timebase_info(&MachInfo);
166
+    if ( err != 0  ) 
167
+    {
168
+        return 0;
169
+    }
170
+
171
+    if (MachInfo.numer == MachInfo.denom)
172
+    {
173
+        return &chrono_detail::steady_simplified;
174
+    }
175
+    return &chrono_detail::steady_full;
176
+}
177
+
178
+#if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
179
+BOOST_CHRONO_STATIC
180
+FP_ec
181
+init_steady_clock_ec(kern_return_t & err)
182
+{
183
+    mach_timebase_info_data_t MachInfo;
184
+    err = mach_timebase_info(&MachInfo);
185
+    if ( err != 0  ) 
186
+    {
187
+        return 0;
188
+    }
189
+
190
+    if (MachInfo.numer == MachInfo.denom) 
191
+    {
192
+        return &chrono_detail::steady_simplified_ec;
193
+    }
194
+    return &chrono_detail::steady_full_ec;
195
+}
196
+#endif
197
+}
198
+
199
+steady_clock::time_point
200
+steady_clock::now() BOOST_NOEXCEPT
201
+{
202
+    static kern_return_t err;
203
+    static chrono_detail::FP fp = chrono_detail::init_steady_clock(err);
204
+    if ( err != 0  ) 
205
+    {     
206
+      BOOST_ASSERT(0 && "Boost::Chrono - Internal Error");
207
+    }
208
+    return time_point(duration(fp()));
209
+}
210
+
211
+#if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
212
+steady_clock::time_point
213
+steady_clock::now(system::error_code & ec)
214
+{
215
+    static kern_return_t err;
216
+    static chrono_detail::FP_ec fp = chrono_detail::init_steady_clock_ec(err);
217
+    if ( err != 0  ) 
218
+    {
219
+        if (BOOST_CHRONO_IS_THROWS(ec))
220
+        {
221
+            boost::throw_exception(
222
+                    system::system_error( 
223
+                            err, 
224
+                            BOOST_CHRONO_SYSTEM_CATEGORY, 
225
+                            "chrono::steady_clock" ));
226
+        }
227
+        else
228
+        {
229
+            ec.assign( err, BOOST_CHRONO_SYSTEM_CATEGORY );
230
+            return time_point();
231
+        }
232
+    }
233
+    if (!BOOST_CHRONO_IS_THROWS(ec)) 
234
+    {
235
+        ec.clear();
236
+    }
237
+    return time_point(duration(fp(ec)));
238
+}
239
+#endif
240
+}  // namespace chrono
241
+}  // namespace boost
0 242
new file mode 100644
... ...
@@ -0,0 +1,356 @@
1
+//  boost process_cpu_clocks.cpp  -----------------------------------------------------------//
2
+
3
+//  Copyright Beman Dawes 1994, 2006, 2008
4
+//  Copyright Vicente J. Botet Escriba 2009
5
+
6
+//  Distributed under the Boost Software License, Version 1.0.
7
+//  See http://www.boost.org/LICENSE_1_0.txt
8
+
9
+//  See http://www.boost.org/libs/chrono for documentation.
10
+
11
+//--------------------------------------------------------------------------------------//
12
+
13
+#include <boost/chrono/config.hpp>
14
+#include <boost/chrono/process_cpu_clocks.hpp>
15
+#include <boost/assert.hpp>
16
+
17
+#include <sys/time.h> //for gettimeofday and timeval
18
+#include <sys/times.h> //for times
19
+# include <unistd.h>
20
+
21
+namespace boost
22
+{
23
+  namespace chrono
24
+  {
25
+    namespace chrono_detail
26
+    {
27
+
28
+      inline long tick_factor() // multiplier to convert ticks
29
+      //  to nanoseconds; -1 if unknown
30
+      {
31
+        static long factor = 0;
32
+        if (!factor)
33
+        {
34
+          if ((factor = ::sysconf(_SC_CLK_TCK)) <= 0)
35
+            factor = -1;
36
+          else
37
+          {
38
+            BOOST_ASSERT(factor <= 1000000000l); // doesn't handle large ticks
39
+            factor = 1000000000l / factor; // compute factor
40
+            if (!factor)
41
+              factor = -1;
42
+          }
43
+        }
44
+        return factor;
45
+      }
46
+    }
47
+
48
+
49
+    process_real_cpu_clock::time_point process_real_cpu_clock::now() BOOST_NOEXCEPT
50
+    {
51
+#if 1
52
+      tms tm;
53
+      clock_t c = ::times(&tm);
54
+      if (c == clock_t(-1)) // error
55
+      {
56
+        BOOST_ASSERT(0 && "Boost::Chrono - Internal Error");
57
+      } else
58
+      {
59
+        long factor = chrono_detail::tick_factor();
60
+        if (factor != -1)
61
+        {
62
+          return time_point(nanoseconds(c * factor));
63
+        } else
64
+        {
65
+          BOOST_ASSERT(0 && "Boost::Chrono - Internal Error");
66
+        }
67
+      }
68
+      return time_point();
69
+#else
70
+      clock_t c = ::clock();
71
+      if (c == clock_t(-1)) // error
72
+      {
73
+        BOOST_ASSERT(0 && "Boost::Chrono - Internal Error");
74
+      } else
75
+      {
76
+        long factor = chrono_detail::tick_factor();
77
+        if (factor != -1)
78
+        {
79
+          return time_point(nanoseconds(c * factor));
80
+        } else
81
+        {
82
+          BOOST_ASSERT(0 && "Boost::Chrono - Internal Error");
83
+        }
84
+      }
85
+      return time_point();
86
+#endif
87
+    }
88
+
89
+#if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
90
+    process_real_cpu_clock::time_point process_real_cpu_clock::now(system::error_code & ec)
91
+    {
92
+
93
+#if 1
94
+      tms tm;
95
+      clock_t c = ::times(&tm);
96
+      if (c == clock_t(-1)) // error
97
+      {
98
+        if (BOOST_CHRONO_IS_THROWS(ec))
99
+        {
100
+          boost::throw_exception(system::system_error(errno, BOOST_CHRONO_SYSTEM_CATEGORY, "chrono::process_real_cpu_clock"));
101
+        } else
102
+        {
103
+          ec.assign(errno, BOOST_CHRONO_SYSTEM_CATEGORY);
104
+          return time_point();
105
+        }
106
+      } else
107
+      {
108
+        long factor = chrono_detail::tick_factor();
109
+        if (factor != -1)
110
+        {
111
+          if (!BOOST_CHRONO_IS_THROWS(ec))
112
+          {
113
+            ec.clear();
114
+          }
115
+          return time_point(nanoseconds(c * factor));
116
+        } else
117
+        {
118
+          if (BOOST_CHRONO_IS_THROWS(ec))
119
+          {
120
+            boost::throw_exception(system::system_error(errno, BOOST_CHRONO_SYSTEM_CATEGORY, "chrono::process_real_cpu_clock"));
121
+          } else
122
+          {
123
+            ec.assign(errno, BOOST_CHRONO_SYSTEM_CATEGORY);
124
+            return time_point();
125
+          }
126
+        }
127
+      }
128
+#else
129
+      clock_t c = ::clock();
130
+      if (c == clock_t(-1)) // error
131
+      {
132
+        if (BOOST_CHRONO_IS_THROWS(ec))
133
+        {
134
+          boost::throw_exception(system::system_error(errno, BOOST_CHRONO_SYSTEM_CATEGORY, "chrono::process_real_cpu_clock"));
135
+        } else
136
+        {
137
+          ec.assign(errno, BOOST_CHRONO_SYSTEM_CATEGORY);
138
+          return time_point();
139
+        }
140
+      } else
141
+      {
142
+        long factor = chrono_detail::tick_factor();
143
+        if (factor != -1)
144
+        {
145
+          if (!BOOST_CHRONO_IS_THROWS(ec))
146
+          {
147
+            ec.clear();
148
+          }
149
+          return time_point(nanoseconds(c * factor));
150
+        } else
151
+        {
152
+          if (BOOST_CHRONO_IS_THROWS(ec))
153
+          {
154
+            boost::throw_exception(system::system_error(errno, BOOST_CHRONO_SYSTEM_CATEGORY, "chrono::process_real_cpu_clock"));
155
+          } else
156
+          {
157
+            ec.assign(errno, BOOST_CHRONO_SYSTEM_CATEGORY);
158
+            return time_point();
159
+          }
160
+        }
161
+      }
162
+#endif
163
+
164
+    }
165
+#endif
166
+
167
+#if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
168
+    process_user_cpu_clock::time_point process_user_cpu_clock::now(system::error_code & ec)
169
+    {
170
+      tms tm;
171
+      clock_t c = ::times(&tm);
172
+      if (c == clock_t(-1)) // error
173
+      {
174
+        if (BOOST_CHRONO_IS_THROWS(ec))
175
+        {
176
+          boost::throw_exception(system::system_error(errno, BOOST_CHRONO_SYSTEM_CATEGORY, "chrono::process_user_cpu_clock"));
177
+        } else
178
+        {
179
+          ec.assign(errno, BOOST_CHRONO_SYSTEM_CATEGORY);
180
+          return time_point();
181
+        }
182
+      } else
183
+      {
184
+        long factor = chrono_detail::tick_factor();
185
+        if (factor != -1)
186
+        {
187
+          if (!BOOST_CHRONO_IS_THROWS(ec))
188
+          {
189
+            ec.clear();
190
+          }
191
+          return time_point(nanoseconds((tm.tms_utime + tm.tms_cutime) * factor));
192
+        } else
193
+        {
194
+          if (BOOST_CHRONO_IS_THROWS(ec))
195
+          {
196
+            boost::throw_exception(system::system_error(errno, BOOST_CHRONO_SYSTEM_CATEGORY, "chrono::process_user_cpu_clock"));
197
+          } else
198
+          {
199
+            ec.assign(errno, BOOST_CHRONO_SYSTEM_CATEGORY);
200
+            return time_point();
201
+          }
202
+        }
203
+      }
204
+    }
205
+#endif
206
+
207
+    process_user_cpu_clock::time_point process_user_cpu_clock::now() BOOST_NOEXCEPT
208
+    {
209
+      tms tm;
210
+      clock_t c = ::times(&tm);
211
+      if (c == clock_t(-1)) // error
212
+      {
213
+        BOOST_ASSERT(0 && "Boost::Chrono - Internal Error");
214
+      } else
215
+      {
216
+        long factor = chrono_detail::tick_factor();
217
+        if (factor != -1)
218
+        {
219
+          return time_point(nanoseconds((tm.tms_utime + tm.tms_cutime)
220
+              * factor));
221
+        } else
222
+        {
223
+          BOOST_ASSERT(0 && "Boost::Chrono - Internal Error");
224
+        }
225
+      }
226
+      return time_point();
227
+    }
228
+    process_system_cpu_clock::time_point process_system_cpu_clock::now() BOOST_NOEXCEPT
229
+    {
230
+      tms tm;
231
+      clock_t c = ::times(&tm);
232
+      if (c == clock_t(-1)) // error
233
+      {
234
+        BOOST_ASSERT(0 && "Boost::Chrono - Internal Error");
235
+      } else
236
+      {
237
+        long factor = chrono_detail::tick_factor();
238
+        if (factor != -1)
239
+        {
240
+          return time_point(nanoseconds((tm.tms_stime + tm.tms_cstime)
241
+              * factor));
242
+        } else
243
+        {
244
+          BOOST_ASSERT(0 && "Boost::Chrono - Internal Error");
245
+        }
246
+      }
247
+      return time_point();
248
+    }
249
+
250
+#if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
251
+    process_system_cpu_clock::time_point process_system_cpu_clock::now(system::error_code & ec)
252
+    {
253
+      tms tm;
254
+      clock_t c = ::times(&tm);
255
+      if (c == clock_t(-1)) // error
256
+      {
257
+        if (BOOST_CHRONO_IS_THROWS(ec))
258
+        {
259
+          boost::throw_exception(system::system_error(errno, BOOST_CHRONO_SYSTEM_CATEGORY, "chrono::process_system_cpu_clock"));
260
+        } else
261
+        {
262
+          ec.assign(errno, BOOST_CHRONO_SYSTEM_CATEGORY);
263
+          return time_point();
264
+        }
265
+      } else
266
+      {
267
+        long factor = chrono_detail::tick_factor();
268
+        if (factor != -1)
269
+        {
270
+          if (!BOOST_CHRONO_IS_THROWS(ec))
271
+          {
272
+            ec.clear();
273
+          }
274
+          return time_point(nanoseconds((tm.tms_stime + tm.tms_cstime) * factor));
275
+        } else
276
+        {
277
+          if (BOOST_CHRONO_IS_THROWS(ec))
278
+          {
279
+            boost::throw_exception(system::system_error(errno, BOOST_CHRONO_SYSTEM_CATEGORY, "chrono::process_system_cpu_clock"));
280
+          } else
281
+          {
282
+            ec.assign(errno, BOOST_CHRONO_SYSTEM_CATEGORY);
283
+            return time_point();
284
+          }
285
+        }
286
+      }
287
+    }
288
+#endif
289
+
290
+    process_cpu_clock::time_point process_cpu_clock::now() BOOST_NOEXCEPT
291
+    {
292
+      tms tm;
293
+      clock_t c = ::times(&tm);
294
+      if (c == clock_t(-1)) // error
295
+      {
296
+        BOOST_ASSERT(0 && "Boost::Chrono - Internal Error");
297
+      } else
298
+      {
299
+        long factor = chrono_detail::tick_factor();
300
+        if (factor != -1)
301
+        {
302
+          time_point::rep
303
+              r(c * factor, (tm.tms_utime + tm.tms_cutime) * factor, (tm.tms_stime
304
+                  + tm.tms_cstime) * factor);
305
+          return time_point(duration(r));
306
+        } else
307
+        {
308
+          BOOST_ASSERT(0 && "Boost::Chrono - Internal Error");
309
+        }
310
+      }
311
+      return time_point();
312
+    }
313
+
314
+#if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
315
+    process_cpu_clock::time_point process_cpu_clock::now(system::error_code & ec)
316
+    {
317
+
318
+      tms tm;
319
+      clock_t c = ::times(&tm);
320
+      if (c == clock_t(-1)) // error
321
+      {
322
+        if (BOOST_CHRONO_IS_THROWS(ec))
323
+        {
324
+          boost::throw_exception(system::system_error(errno, BOOST_CHRONO_SYSTEM_CATEGORY, "chrono::process_clock"));
325
+        } else
326
+        {
327
+          ec.assign(errno, BOOST_CHRONO_SYSTEM_CATEGORY);
328
+          return time_point();
329
+        }
330
+      } else
331
+      {
332
+        long factor = chrono_detail::tick_factor();
333
+        if (factor != -1)
334
+        {
335
+          time_point::rep
336
+              r(c * factor, (tm.tms_utime + tm.tms_cutime) * factor, (tm.tms_stime
337
+                  + tm.tms_cstime) * factor);
338
+          return time_point(duration(r));
339
+        } else
340
+        {
341
+          if (BOOST_CHRONO_IS_THROWS(ec))
342
+          {
343
+            boost::throw_exception(system::system_error(errno, BOOST_CHRONO_SYSTEM_CATEGORY, "chrono::process_clock"));
344
+          } else
345
+          {
346
+            ec.assign(errno, BOOST_CHRONO_SYSTEM_CATEGORY);
347
+            return time_point();
348
+          }
349
+        }
350
+      }
351
+
352
+    }
353
+#endif
354
+
355
+  }
356
+}
0 357
new file mode 100644
... ...
@@ -0,0 +1,91 @@
1
+//  boost thread_clock.cpp  -----------------------------------------------------------//
2
+
3
+//  Copyright Beman Dawes 1994, 2006, 2008
4
+//  Copyright Vicente J. Botet Escriba 2009-2011
5
+//  Copyright Christopher Brown 2013
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
+
14
+#include <boost/chrono/config.hpp>
15
+#include <boost/chrono/thread_clock.hpp>
16
+#include <cassert>
17
+
18
+# include <pthread.h>
19
+# include <mach/thread_act.h>
20
+
21
+namespace boost { namespace chrono {
22
+
23
+    thread_clock::time_point thread_clock::now( ) BOOST_NOEXCEPT
24
+    {
25
+        // get the thread port (borrowing pthread's reference)
26
+        mach_port_t port = pthread_mach_thread_np(pthread_self());
27
+
28
+        // get the thread info
29
+        thread_basic_info_data_t info;
30
+        mach_msg_type_number_t count = THREAD_BASIC_INFO_COUNT;
31
+        if ( thread_info(port, THREAD_BASIC_INFO, (thread_info_t)&info, &count) != KERN_SUCCESS )
32
+        {
33
+            BOOST_ASSERT(0 && "Boost::Chrono - Internal Error");
34
+            return time_point();
35
+        }
36
+
37
+        // convert to nanoseconds
38
+        duration user = duration(
39
+                static_cast<thread_clock::rep>( info.user_time.seconds ) * 1000000000
40
+                        + static_cast<thread_clock::rep>(info.user_time.microseconds ) * 1000);
41
+
42
+        duration system = duration(
43
+                static_cast<thread_clock::rep>( info.system_time.seconds ) * 1000000000
44
+                        + static_cast<thread_clock::rep>( info.system_time.microseconds ) * 1000);
45
+
46
+        return time_point( user + system );
47
+    }
48
+
49
+#if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
50
+    thread_clock::time_point thread_clock::now( system::error_code & ec )
51
+    {
52
+        // get the thread port (borrowing pthread's reference)
53
+        mach_port_t port = pthread_mach_thread_np(pthread_self());
54
+
55
+        // get the thread info
56
+        thread_basic_info_data_t info;
57
+        mach_msg_type_number_t count = THREAD_BASIC_INFO_COUNT;
58
+        if ( thread_info(port, THREAD_BASIC_INFO, (thread_info_t)&info, &count) != KERN_SUCCESS )
59
+        {
60
+            if (BOOST_CHRONO_IS_THROWS(ec))
61
+            {
62
+                boost::throw_exception(
63
+                        system::system_error(
64
+                                EINVAL,
65
+                                BOOST_CHRONO_SYSTEM_CATEGORY,
66
+                                "chrono::thread_clock" ));
67
+            }
68
+            else
69
+            {
70
+                ec.assign( errno, BOOST_CHRONO_SYSTEM_CATEGORY );
71
+                return time_point();
72
+            }
73
+        }
74
+        if (!BOOST_CHRONO_IS_THROWS(ec))
75
+        {
76
+            ec.clear();
77
+        }
78
+
79
+        // convert to nanoseconds
80
+        duration user = duration(
81
+                static_cast<thread_clock::rep>( info.user_time.seconds ) * 1000000000
82
+                        + static_cast<thread_clock::rep>(info.user_time.microseconds ) * 1000);
83
+
84
+        duration system = duration(
85
+                static_cast<thread_clock::rep>( info.system_time.seconds ) * 1000000000
86
+                        + static_cast<thread_clock::rep>( info.system_time.microseconds ) * 1000);
87
+
88
+        return time_point( user + system );
89
+    }
90
+#endif
91
+} }