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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/bin/eventhandler_macos.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #ifndef PLATFORM_SIGNAL_BLOCKER_H_ 5 #ifndef PLATFORM_SIGNAL_BLOCKER_H_
6 #define PLATFORM_SIGNAL_BLOCKER_H_ 6 #define PLATFORM_SIGNAL_BLOCKER_H_
7 7
8 #include "platform/globals.h" 8 #include "platform/globals.h"
9 9
10 #if defined(TARGET_OS_WINDOWS) 10 #if defined(TARGET_OS_WINDOWS)
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 // This macro can be used to insert checks that a call is made, that 72 // This macro can be used to insert checks that a call is made, that
73 // was expected to not return EINTR, but did it anyway. 73 // was expected to not return EINTR, but did it anyway.
74 #define NO_RETRY_EXPECTED(expression) \ 74 #define NO_RETRY_EXPECTED(expression) \
75 ({ intptr_t __result = (expression); \ 75 ({ intptr_t __result = (expression); \
76 ASSERT(__result != -1L || errno != EINTR); \ 76 ASSERT(__result != -1L || errno != EINTR); \
77 __result; }) 77 __result; })
78 78
79 #define VOID_NO_RETRY_EXPECTED(expression) \ 79 #define VOID_NO_RETRY_EXPECTED(expression) \
80 (static_cast<void>(NO_RETRY_EXPECTED(expression))) 80 (static_cast<void>(NO_RETRY_EXPECTED(expression)))
81 81
82 // Define to check in debug mode, if a signal is currently being blocked.
83 #define CHECK_IS_BLOCKING(signal) \
84 ({ sigset_t signal_mask; \
85 int __r = pthread_sigmask(SIG_BLOCK, NULL, &signal_mask); \
86 USE(__r); \
87 ASSERT(__r == 0); \
88 sigismember(&signal_mask, signal); }) \
89
90
91 // Versions of the above, that does not enter a signal blocking scope. Use only
92 // when a signal blocking scope is entered manually.
93 #define TEMP_FAILURE_RETRY_NO_SIGNAL_BLOCKER(expression) \
94 ({ intptr_t __result; \
95 ASSERT(CHECK_IS_BLOCKING(SIGPROF)); \
96 do { \
97 __result = (expression); \
98 } while ((__result == -1L) && (errno == EINTR)); \
99 __result; })
100
101 #define VOID_TEMP_FAILURE_RETRY_NO_SIGNAL_BLOCKER(expression) \
102 (static_cast<void>(TEMP_FAILURE_RETRY_NO_SIGNAL_BLOCKER(expression)))
103
82 } // namespace dart 104 } // namespace dart
83 105
84 #endif // PLATFORM_SIGNAL_BLOCKER_H_ 106 #endif // PLATFORM_SIGNAL_BLOCKER_H_
OLDNEW
« 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