[PATCH] D38599: Remove warnings for dynamic_cast fallback.

2017-10-16 Thread Howard Hinnant via Phabricator via cfe-commits
howard.hinnant added a comment.

Fwiw, I wrote this code.  All of that "fallback" stuff was written to make 
customer code that was incorrect, but working on OS X 
-version-that-used-libsupc++ continue to work.  I.e. to be a crutch for 
incorrect code.  It should all be removed if you no longer want to provide such 
a crutch.


https://reviews.llvm.org/D38599



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38599: Remove warnings for dynamic_cast fallback.

2017-10-16 Thread Howard Hinnant via Phabricator via cfe-commits
howard.hinnant added a comment.

Ok.  Well that's why it is under a #define:  to make it easier to include or 
not, depending on the needs of the platform.


https://reviews.llvm.org/D38599



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D27429: [Chrono][Darwin] On Darwin use CLOCK_UPTIME_RAW instead of CLOCK_MONOTONIC

2017-01-04 Thread Howard Hinnant via Phabricator via cfe-commits
howard.hinnant added inline comments.



Comment at: src/chrono.cpp:218
+#error "Never use CLOCK_MONOTONIC for steady_clock::now on Apple platforms"
+#endif
+

Nice, thanks!


https://reviews.llvm.org/D27429



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D27429: [Chrono][Darwin] On Darwin use CLOCK_UPTIME_RAW instead of CLOCK_MONOTONIC

2016-12-09 Thread Howard Hinnant via Phabricator via cfe-commits
howard.hinnant added a comment.

I would like to offer two thoughts:

1. Timing with `steady_clock` is often used to time very short events.  It 
should be respected as the "high_resolution_clock".  This means that two 
consecutive calls to `steady_clock::now()` should return nanoseconds resolution 
and should not be equal unless the implementation is actually able to complete 
a call to `steady_clock::now()` in less than 1ns.

2. Here's test of thought 1:



  #include 
  #include 
  #include 
  #include 
  
  std::chrono::milliseconds
  uptime()
  {
  using namespace std::chrono;
  timeval ts;
  auto ts_len = sizeof(ts);
  int mib[2] = { CTL_KERN, KERN_BOOTTIME };
  auto constexpr mib_len = sizeof(mib)/sizeof(mib[0]);
  if (sysctl(mib, mib_len, &ts, &ts_len, nullptr, 0) == 0)
  {
  system_clock::time_point boot{seconds{ts.tv_sec} + 
microseconds{ts.tv_usec}};
  return duration_cast(system_clock::now() - boot);
  }
  return 0ms;
  }
  
  std::chrono::nanoseconds
  get_uptime_raw()
  {
  using namespace std::chrono;
  struct timespec tp;
  clock_gettime(CLOCK_UPTIME_RAW, &tp);
  return seconds(tp.tv_sec) + nanoseconds(tp.tv_nsec);
  }
  
  std::chrono::nanoseconds
  get_monotonic()
  {
  using namespace std::chrono;
  struct timespec tp;
  clock_gettime(CLOCK_MONOTONIC, &tp);
  return seconds(tp.tv_sec) + nanoseconds(tp.tv_nsec);
  }
  
  #include "date.h"
  #include 
  
  template 
  void
  display(Duration time)
  {
  using namespace date;
  auto d = floor(time);
  time -= d;
  std::cout << d.count() << " days " << make_time(time) << '\n';
  }
  
  int
  main()
  {
  using namespace std::chrono;
  for (int i = 0; i < 4; ++i)
  {
  std::cout << i << '\n';
  {
  auto t0 = uptime();
  auto t1 = uptime();
  std::cout << "boot time : ";  display(t0);
  std::cout << "boot time : ";  display(t1);
  std::cout << "delta boot time   : " << nanoseconds{t1 
- t0}.count() << "ns\n";
  }
  {
  auto t0 = get_uptime_raw();
  auto t1 = get_uptime_raw();
  std::cout << "CLOCK_UPTIME_RAW  : "; display(t0);
  std::cout << "CLOCK_UPTIME_RAW  : "; display(t1);
  std::cout << "delta CLOCK_UPTIME_RAW time   : " << nanoseconds{t1 
- t0}.count() << "ns\n";
  }
  {
  auto t0 = get_monotonic();
  auto t1 = get_monotonic();
  std::cout << "CLOCK_MONOTONIC   : "; display(t0);
  std::cout << "CLOCK_MONOTONIC   : "; display(t1);
  std::cout << "delta CLOCK_MONOTONIC time: " << nanoseconds{t1 
- t0}.count() << "ns\n";
  }
  {
  auto t0 = std::chrono::steady_clock::now().time_since_epoch();
  auto t1 = std::chrono::steady_clock::now().time_since_epoch();
  std::cout << "mach_absolute_time: "; display(t0);
  std::cout << "mach_absolute_time: "; display(t1);
  std::cout << "delta mach_absolute_time time : " << nanoseconds{t1 
- t0}.count() << "ns\n";
  }
  std::cout << '\n';
  }
  }

Sorry, it requires "date.h" from https://github.com/HowardHinnant/date .  It is 
header-only and portable.  It's just used for matting purposes if it really 
stresses you out.

For me this outputs (at -O3):

  Jade:~/Development/cljunk> a.out
  0
  boot time : 11 days 22:30:42.827
  boot time : 11 days 22:30:42.827
  delta boot time   : 0ns
  CLOCK_UPTIME_RAW  : 11 days 22:22:28.960672112
  CLOCK_UPTIME_RAW  : 11 days 22:22:28.960672266
  delta CLOCK_UPTIME_RAW time   : 154ns
  CLOCK_MONOTONIC   : 11 days 22:30:42.827318000
  CLOCK_MONOTONIC   : 11 days 22:30:42.827318000
  delta CLOCK_MONOTONIC time: 0ns
  mach_absolute_time: 11 days 22:22:28.960714394
  mach_absolute_time: 11 days 22:22:28.960714504
  delta mach_absolute_time time : 110ns
  
  1
  boot time : 11 days 22:30:42.827
  boot time : 11 days 22:30:42.827
  delta boot time   : 0ns
  CLOCK_UPTIME_RAW  : 11 days 22:22:28.960761867
  CLOCK_UPTIME_RAW  : 11 days 22:22:28.960761932
  delta CLOCK_UPTIME_RAW time   : 65ns
  CLOCK_MONOTONIC   : 11 days 22:30:42.827402000
  CLOCK_MONOTONIC   : 11 days 22:30:42.827402000
  delta CLOCK_MONOTONIC time: 0ns
  mach_absolute_time: 11 days 22:22:28.960793667
  mach_absolute_time: 11 days 22:22:28.960793747
  delta mach_absolute_time time : 80ns
  
  2
  boot time : 11 days 22:30:42.827
  boot time : 11 days 22:30:42.827
 

[PATCH] D27429: [Chrono][Darwin] On Darwin use CLOCK_UPTIME_RAW instead of CLOCK_MONOTONIC

2016-12-11 Thread Howard Hinnant via Phabricator via cfe-commits
howard.hinnant added a comment.

One more comment:  `steady_clock::now()` is not allowed to throw an exception 
because it shall satisfy the requirements of `TrivialClock` ([time.clock]/p1).  
And [time.clock.req]/p4/b4 says that a `TrivialClock::now()` does not throw 
exceptions.


https://reviews.llvm.org/D27429



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D27429: [Chrono][Darwin] On Darwin use CLOCK_UPTIME_RAW instead of CLOCK_MONOTONIC

2016-12-11 Thread Howard Hinnant via Phabricator via cfe-commits
howard.hinnant added a comment.

Thanks Eric.

Fwiw `CLOCK_MONOTONIC` won't meet the requirements of the standard either.  The 
standard appears to require `steady_clock` to be a perfect clock and there is 
no such thing. The wording used to only require monotonic, but the committee 
got a little too enthusiastic.   :-)


https://reviews.llvm.org/D27429



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits