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 // Common helper functions/classes used both in the host and device forwarder. | 5 // Common helper functions/classes used both in the host and device forwarder. |
6 | 6 |
7 #ifndef TOOLS_ANDROID_FORWARDER2_COMMON_H_ | 7 #ifndef TOOLS_ANDROID_FORWARDER2_COMMON_H_ |
8 #define TOOLS_ANDROID_FORWARDER2_COMMON_H_ | 8 #define TOOLS_ANDROID_FORWARDER2_COMMON_H_ |
9 | 9 |
| 10 #include <errno.h> |
10 #include <stdarg.h> | 11 #include <stdarg.h> |
11 #include <stdio.h> | 12 #include <stdio.h> |
12 #include <errno.h> | |
13 | 13 |
14 #include "base/basictypes.h" | |
15 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
16 #include "base/logging.h" | 15 #include "base/logging.h" |
| 16 #include "base/macros.h" |
17 #include "base/posix/eintr_wrapper.h" | 17 #include "base/posix/eintr_wrapper.h" |
18 | 18 |
19 // Preserving errno for Close() is important because the function is very often | 19 // Preserving errno for Close() is important because the function is very often |
20 // used in cleanup code, after an error occurred, and it is very easy to pass an | 20 // used in cleanup code, after an error occurred, and it is very easy to pass an |
21 // invalid file descriptor to close() in this context, or more rarely, a | 21 // invalid file descriptor to close() in this context, or more rarely, a |
22 // spurious signal might make close() return -1 + setting errno to EINTR, | 22 // spurious signal might make close() return -1 + setting errno to EINTR, |
23 // masking the real reason for the original error. This leads to very unpleasant | 23 // masking the real reason for the original error. This leads to very unpleasant |
24 // debugging sessions. | 24 // debugging sessions. |
25 #define PRESERVE_ERRNO_HANDLE_EINTR(Func) \ | 25 #define PRESERVE_ERRNO_HANDLE_EINTR(Func) \ |
26 do { \ | 26 do { \ |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 char* write_ptr_; | 80 char* write_ptr_; |
81 char buffer_[BufferSize]; | 81 char buffer_[BufferSize]; |
82 | 82 |
83 static_assert(BufferSize >= 1, "size of buffer must be at least one"); | 83 static_assert(BufferSize >= 1, "size of buffer must be at least one"); |
84 DISALLOW_COPY_AND_ASSIGN(FixedSizeStringBuilder); | 84 DISALLOW_COPY_AND_ASSIGN(FixedSizeStringBuilder); |
85 }; | 85 }; |
86 | 86 |
87 } // namespace forwarder2 | 87 } // namespace forwarder2 |
88 | 88 |
89 #endif // TOOLS_ANDROID_FORWARDER2_COMMON_H_ | 89 #endif // TOOLS_ANDROID_FORWARDER2_COMMON_H_ |
OLD | NEW |