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

Side by Side Diff: base/posix/eintr_wrapper.h

Issue 683963002: Replace a few typeofs with delctype. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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
« no previous file with comments | « no previous file | chrome/browser/password_manager/native_backend_gnome_x.h » ('j') | 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) 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 // This provides a wrapper around system calls which may be interrupted by a 5 // This provides a wrapper around system calls which may be interrupted by a
6 // signal and return EINTR. See man 7 signal. 6 // signal and return EINTR. See man 7 signal.
7 // To prevent long-lasting loops (which would likely be a bug, such as a signal 7 // To prevent long-lasting loops (which would likely be a bug, such as a signal
8 // that should be masked) to go unnoticed, there is a limit after which the 8 // that should be masked) to go unnoticed, there is a limit after which the
9 // caller will nonetheless see an EINTR in Debug builds. 9 // caller will nonetheless see an EINTR in Debug builds.
10 // 10 //
11 // On Windows, this wrapper macro does nothing. 11 // On Windows, this wrapper macro does nothing.
12 // 12 //
13 // Don't wrap close calls in HANDLE_EINTR. Use IGNORE_EINTR if the return 13 // Don't wrap close calls in HANDLE_EINTR. Use IGNORE_EINTR if the return
14 // value of close is significant. See http://crbug.com/269623. 14 // value of close is significant. See http://crbug.com/269623.
15 15
16 #ifndef BASE_POSIX_EINTR_WRAPPER_H_ 16 #ifndef BASE_POSIX_EINTR_WRAPPER_H_
17 #define BASE_POSIX_EINTR_WRAPPER_H_ 17 #define BASE_POSIX_EINTR_WRAPPER_H_
18 18
19 #include "build/build_config.h" 19 #include "build/build_config.h"
20 20
21 #if defined(OS_POSIX) 21 #if defined(OS_POSIX)
22 22
23 #include <errno.h> 23 #include <errno.h>
24 24
25 #if defined(NDEBUG) 25 #if defined(NDEBUG)
26 26
27 #define HANDLE_EINTR(x) ({ \ 27 #define HANDLE_EINTR(x) ({ \
28 typeof(x) eintr_wrapper_result; \ 28 decltype(x) eintr_wrapper_result; \
29 do { \ 29 do { \
30 eintr_wrapper_result = (x); \ 30 eintr_wrapper_result = (x); \
31 } while (eintr_wrapper_result == -1 && errno == EINTR); \ 31 } while (eintr_wrapper_result == -1 && errno == EINTR); \
32 eintr_wrapper_result; \ 32 eintr_wrapper_result; \
33 }) 33 })
34 34
35 #else 35 #else
36 36
37 #define HANDLE_EINTR(x) ({ \ 37 #define HANDLE_EINTR(x) ({ \
38 int eintr_wrapper_counter = 0; \ 38 int eintr_wrapper_counter = 0; \
39 typeof(x) eintr_wrapper_result; \ 39 decltype(x) eintr_wrapper_result; \
40 do { \ 40 do { \
41 eintr_wrapper_result = (x); \ 41 eintr_wrapper_result = (x); \
42 } while (eintr_wrapper_result == -1 && errno == EINTR && \ 42 } while (eintr_wrapper_result == -1 && errno == EINTR && \
43 eintr_wrapper_counter++ < 100); \ 43 eintr_wrapper_counter++ < 100); \
44 eintr_wrapper_result; \ 44 eintr_wrapper_result; \
45 }) 45 })
46 46
47 #endif // NDEBUG 47 #endif // NDEBUG
48 48
49 #define IGNORE_EINTR(x) ({ \ 49 #define IGNORE_EINTR(x) ({ \
50 typeof(x) eintr_wrapper_result; \ 50 decltype(x) eintr_wrapper_result; \
51 do { \ 51 do { \
52 eintr_wrapper_result = (x); \ 52 eintr_wrapper_result = (x); \
53 if (eintr_wrapper_result == -1 && errno == EINTR) { \ 53 if (eintr_wrapper_result == -1 && errno == EINTR) { \
54 eintr_wrapper_result = 0; \ 54 eintr_wrapper_result = 0; \
55 } \ 55 } \
56 } while (0); \ 56 } while (0); \
57 eintr_wrapper_result; \ 57 eintr_wrapper_result; \
58 }) 58 })
59 59
60 #else 60 #else
61 61
62 #define HANDLE_EINTR(x) (x) 62 #define HANDLE_EINTR(x) (x)
63 #define IGNORE_EINTR(x) (x) 63 #define IGNORE_EINTR(x) (x)
64 64
65 #endif // OS_POSIX 65 #endif // OS_POSIX
66 66
67 #endif // BASE_POSIX_EINTR_WRAPPER_H_ 67 #endif // BASE_POSIX_EINTR_WRAPPER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/password_manager/native_backend_gnome_x.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698