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

Side by Side Diff: base/mac/close_nocancel.cc

Issue 1036123003: Add #include of <unistd.h> to close_nocancel.cc. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reword comments Created 5 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
« no previous file with comments | « no previous file | 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 // http://crbug.com/269623 5 // http://crbug.com/269623
6 // http://openradar.appspot.com/14999594 6 // http://openradar.appspot.com/14999594
7 // 7 //
8 // When the default version of close used on Mac OS X fails with EINTR, the 8 // When the default version of close used on Mac OS X fails with EINTR, the
9 // file descriptor is not in a deterministic state. It may have been closed, 9 // file descriptor is not in a deterministic state. It may have been closed,
10 // or it may not have been. This makes it impossible to gracefully recover 10 // or it may not have been. This makes it impossible to gracefully recover
(...skipping 10 matching lines...) Expand all
21 // 21 //
22 // The $NOCANCEL variants of various system calls are activated by compiling 22 // The $NOCANCEL variants of various system calls are activated by compiling
23 // with __DARWIN_NON_CANCELABLE, which prevents them from being pthread 23 // with __DARWIN_NON_CANCELABLE, which prevents them from being pthread
24 // cancellation points. Rather than taking such a heavy-handed approach, this 24 // cancellation points. Rather than taking such a heavy-handed approach, this
25 // file implements an alternative: to use the $NOCANCEL variant of close (thus 25 // file implements an alternative: to use the $NOCANCEL variant of close (thus
26 // preventing it from being a pthread cancellation point) without affecting 26 // preventing it from being a pthread cancellation point) without affecting
27 // any other system calls. 27 // any other system calls.
28 // 28 //
29 // This file operates by providing a close function with the non-$NOCANCEL 29 // This file operates by providing a close function with the non-$NOCANCEL
30 // symbol name expected for the compilation environment as set by <unistd.h> 30 // symbol name expected for the compilation environment as set by <unistd.h>
31 // and <sys/cdefs.h> (the DARWIN_ALIAS_C macro). That function calls the 31 // and <sys/cdefs.h> (the DARWIN_ALIAS_C macro). That name is set by an asm
32 // $NOCANCEL variant, which is resolved from libsyscall. By linking with this 32 // label on the declaration of the close function, so the definition of that
33 // version of close prior to the libsyscall version, close's implementation is 33 // function receives that name. The function calls the $NOCANCEL variant, which
34 // overridden. 34 // is resolved from libsyscall. By linking with this version of close prior to
35 // the libsyscall version, close's implementation is overridden.
35 36
36 #include <sys/cdefs.h> 37 #include <sys/cdefs.h>
38 #include <unistd.h>
37 39
38 // If the non-cancelable variants of all system calls have already been 40 // If the non-cancelable variants of all system calls have already been
39 // chosen, do nothing. 41 // chosen, do nothing.
40 #if !__DARWIN_NON_CANCELABLE 42 #if !__DARWIN_NON_CANCELABLE
41 43
42 extern "C" { 44 extern "C" {
43 45
44 #if __DARWIN_UNIX03 && !__DARWIN_ONLY_UNIX_CONFORMANCE 46 #if !__DARWIN_ONLY_UNIX_CONFORMANCE
45 47
46 // When there's a choice between UNIX2003 and pre-UNIX2003 and UNIX2003 has 48 // When there's a choice between UNIX2003 and pre-UNIX2003. There's no
47 // been chosen: 49 // close$NOCANCEL symbol in this case, so use close$NOCANCEL$UNIX2003 as the
48 #define close_interface close$UNIX2003 50 // implementation. It does the same thing that close$NOCANCEL would do.
49 #define close_implementation close$NOCANCEL$UNIX2003
50
51 #elif !__DARWIN_UNIX03 && !__DARWIN_ONLY_UNIX_CONFORMANCE
52
53 // When there's a choice between UNIX2003 and pre-UNIX2003 and pre-UNIX2003
54 // has been chosen. There's no close$NOCANCEL symbol in this case, so use
55 // close$NOCANCEL$UNIX2003 as the implementation. It does the same thing
56 // that close$NOCANCEL would do.
57 #define close_interface close
58 #define close_implementation close$NOCANCEL$UNIX2003 51 #define close_implementation close$NOCANCEL$UNIX2003
59 52
60 #else // __DARWIN_ONLY_UNIX_CONFORMANCE 53 #else // __DARWIN_ONLY_UNIX_CONFORMANCE
61 54
62 // When only UNIX2003 is supported: 55 // When only UNIX2003 is supported:
63 #define close_interface close
64 #define close_implementation close$NOCANCEL 56 #define close_implementation close$NOCANCEL
65 57
66 #endif 58 #endif
67 59
68 int close_implementation(int fd); 60 int close_implementation(int fd);
69 61
70 int close_interface(int fd) { 62 int close(int fd) {
71 return close_implementation(fd); 63 return close_implementation(fd);
72 } 64 }
73 65
74 #undef close_interface
75 #undef close_implementation 66 #undef close_implementation
76 67
77 } // extern "C" 68 } // extern "C"
78 69
79 #endif // !__DARWIN_NON_CANCELABLE 70 #endif // !__DARWIN_NON_CANCELABLE
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698