Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(775)

Unified Diff: runtime/platform/signal_blocker.h

Issue 209333014: Speed up GetRandomBytes by only entering signal-blocking scope once. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add validation and apply in other scenario. Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/eventhandler_macos.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/platform/signal_blocker.h
diff --git a/runtime/platform/signal_blocker.h b/runtime/platform/signal_blocker.h
index 4bfc2287a6ed4150fc77ef51cfaee82326e05cfa..4ce4b712f6ed9d4f0469098179656186150af460 100644
--- a/runtime/platform/signal_blocker.h
+++ b/runtime/platform/signal_blocker.h
@@ -79,6 +79,28 @@ class ThreadSignalBlocker {
#define VOID_NO_RETRY_EXPECTED(expression) \
(static_cast<void>(NO_RETRY_EXPECTED(expression)))
+// Define to check in debug mode, if a signal is currently being blocked.
+#define CHECK_IS_BLOCKING(signal) \
+ ({ sigset_t signal_mask; \
+ int __r = pthread_sigmask(SIG_BLOCK, NULL, &signal_mask); \
+ USE(__r); \
+ ASSERT(__r == 0); \
+ sigismember(&signal_mask, signal); }) \
+
+
+// Versions of the above, that does not enter a signal blocking scope. Use only
+// when a signal blocking scope is entered manually.
+#define TEMP_FAILURE_RETRY_NO_SIGNAL_BLOCKER(expression) \
+ ({ intptr_t __result; \
+ ASSERT(CHECK_IS_BLOCKING(SIGPROF)); \
+ do { \
+ __result = (expression); \
+ } while ((__result == -1L) && (errno == EINTR)); \
+ __result; })
+
+#define VOID_TEMP_FAILURE_RETRY_NO_SIGNAL_BLOCKER(expression) \
+ (static_cast<void>(TEMP_FAILURE_RETRY_NO_SIGNAL_BLOCKER(expression)))
+
} // namespace dart
#endif // PLATFORM_SIGNAL_BLOCKER_H_
« no previous file with comments | « runtime/bin/eventhandler_macos.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698