-
Notifications
You must be signed in to change notification settings - Fork 14.8k
[flang] Fix compile error : on MacOS 11.5.1 (20G80), cmake version 3.21.1 #333
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,10 @@ | |
// overload will have a dummy parameter whose type indicates whether or not it | ||
// should be preferred. Any other parameters required for SFINAE should have | ||
// default values provided. | ||
|
||
// #define invalid_clock_t (-1) | ||
#define INVALID_CLOCK_T (0xFF) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will 0xFF work on machines that have std::clock_t as a signed integer? Will a static cast of -1 to std::clock_t work better? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You definitely don't want 0xFF, as that is a "valid" clock_t value (although it would be very close to January 1st, 1970 :) ). My local patch was to use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Btw, on FreeBSD the situation is 'interesting' in the sense that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you might consider There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
No, you should really use -1. The
On Linux:
I think the Linux man page makes it a bit clearer that you have to cast -1 to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (Having said all that, it's very unlikely that you cannot retrieve the current time.... but still, better safe than sorry :) ) |
||
|
||
namespace { | ||
// Types for the dummy parameter indicating the priority of a given overload. | ||
// We will invoke our helper with an integer literal argument, so the overload | ||
|
@@ -36,7 +40,7 @@ using preferred_implementation = int; | |
// This is the fallback implementation, which should work everywhere. | ||
template <typename Unused = void> double GetCpuTime(fallback_implementation) { | ||
std::clock_t timestamp{std::clock()}; | ||
if (timestamp != std::clock_t{-1}) { | ||
if (timestamp != std::clock_t{INVALID_CLOCK_T}) { | ||
return static_cast<double>(timestamp) / CLOCKS_PER_SEC; | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Remove commented code.