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

Side by Side Diff: runtime/bin/signal_blocker.h

Issue 109803002: Profiler Take 2 (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years 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/process.cc ('k') | runtime/bin/socket.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 #ifndef BIN_SIGNAL_BLOCKER_H_
6 #define BIN_SIGNAL_BLOCKER_H_
7
8 #include "platform/globals.h"
9
10 #if defined(TARGET_OS_WINDOWS)
11 #error Do not include this file on Windows.
12 #endif
13
14 #include <signal.h> // NOLINT
15
16 namespace dart {
17 namespace bin {
18
19 class ThreadSignalBlocker {
20 public:
21 explicit ThreadSignalBlocker(int sig) {
22 sigset_t signal_mask;
23 sigemptyset(&signal_mask);
24 sigaddset(&signal_mask, sig);
25 // Add sig to signal mask.
26 int r = pthread_sigmask(SIG_BLOCK, &signal_mask, &old);
27 ASSERT(r == 0);
28 }
29
30 ~ThreadSignalBlocker() {
31 // Restore signal mask.
32 int r = pthread_sigmask(SIG_SETMASK, &old, NULL);
33 ASSERT(r == 0);
34 }
35
36 private:
37 sigset_t old;
38 };
39
40
41 #define TEMP_FAILURE_RETRY_BLOCK_SIGNALS(expression) \
42 ({ ThreadSignalBlocker tsb(SIGPROF); \
43 int64_t __result; \
44 do { \
45 __result = static_cast<int64_t>(expression); \
46 } while (__result == -1L && errno == EINTR); \
47 __result; })
48
49 #define VOID_TEMP_FAILURE_RETRY_BLOCK_SIGNALS(expression) \
50 (static_cast<void>(TEMP_FAILURE_RETRY_BLOCK_SIGNALS(expression)))
51
52 } // namespace bin
53 } // namespace dart
54
55 #endif // BIN_SIGNAL_BLOCKER_H_
OLDNEW
« no previous file with comments | « runtime/bin/process.cc ('k') | runtime/bin/socket.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698