OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef SANDBOX_LINUX_SECCOMP_BPF_DIE_H__ | 5 #ifndef SANDBOX_LINUX_SECCOMP_BPF_DIE_H__ |
6 #define SANDBOX_LINUX_SECCOMP_BPF_DIE_H__ | 6 #define SANDBOX_LINUX_SECCOMP_BPF_DIE_H__ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 | 9 |
10 namespace playground2 { | 10 namespace sandbox { |
11 | 11 |
12 // This is the main API for using this file. Prints a error message and | 12 // This is the main API for using this file. Prints a error message and |
13 // exits with a fatal error. This is not async-signal safe. | 13 // exits with a fatal error. This is not async-signal safe. |
14 #define SANDBOX_DIE(m) playground2::Die::SandboxDie(m, __FILE__, __LINE__) | 14 #define SANDBOX_DIE(m) sandbox::Die::SandboxDie(m, __FILE__, __LINE__) |
15 | 15 |
16 // An async signal safe version of the same API. Won't print the filename | 16 // An async signal safe version of the same API. Won't print the filename |
17 // and line numbers. | 17 // and line numbers. |
18 #define RAW_SANDBOX_DIE(m) playground2::Die::RawSandboxDie(m) | 18 #define RAW_SANDBOX_DIE(m) sandbox::Die::RawSandboxDie(m) |
19 | 19 |
20 // Adds an informational message to the log file or stderr as appropriate. | 20 // Adds an informational message to the log file or stderr as appropriate. |
21 #define SANDBOX_INFO(m) playground2::Die::SandboxInfo(m, __FILE__, __LINE__) | 21 #define SANDBOX_INFO(m) sandbox::Die::SandboxInfo(m, __FILE__, __LINE__) |
22 | 22 |
23 class Die { | 23 class Die { |
24 public: | 24 public: |
25 // Terminate the program, even if the current sandbox policy prevents some | 25 // Terminate the program, even if the current sandbox policy prevents some |
26 // of the more commonly used functions used for exiting. | 26 // of the more commonly used functions used for exiting. |
27 // Most users would want to call SANDBOX_DIE() instead, as it logs extra | 27 // Most users would want to call SANDBOX_DIE() instead, as it logs extra |
28 // information. But calling ExitGroup() is correct and in some rare cases | 28 // information. But calling ExitGroup() is correct and in some rare cases |
29 // preferable. So, we make it part of the public API. | 29 // preferable. So, we make it part of the public API. |
30 static void ExitGroup() __attribute__((noreturn)); | 30 static void ExitGroup() __attribute__((noreturn)); |
31 | 31 |
(...skipping 23 matching lines...) Expand all Loading... |
55 // unittests). | 55 // unittests). |
56 static void SuppressInfoMessages(bool flag) { suppress_info_ = flag; } | 56 static void SuppressInfoMessages(bool flag) { suppress_info_ = flag; } |
57 | 57 |
58 private: | 58 private: |
59 static bool simple_exit_; | 59 static bool simple_exit_; |
60 static bool suppress_info_; | 60 static bool suppress_info_; |
61 | 61 |
62 DISALLOW_IMPLICIT_CONSTRUCTORS(Die); | 62 DISALLOW_IMPLICIT_CONSTRUCTORS(Die); |
63 }; | 63 }; |
64 | 64 |
65 } // namespace | 65 } // namespace sandbox |
66 | 66 |
67 #endif // SANDBOX_LINUX_SECCOMP_BPF_DIE_H__ | 67 #endif // SANDBOX_LINUX_SECCOMP_BPF_DIE_H__ |
OLD | NEW |