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

Side by Side Diff: runtime/bin/sync_socket_macos.cc

Issue 2974233002: VM: Re-format to use at most one newline between functions (Closed)
Patch Set: Rebase and merge Created 3 years, 5 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 | « runtime/bin/sync_socket_linux.cc ('k') | runtime/bin/sync_socket_unsupported.cc » ('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) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #if !defined(DART_IO_DISABLED) 5 #if !defined(DART_IO_DISABLED)
6 6
7 #include "platform/globals.h" 7 #include "platform/globals.h"
8 #if defined(HOST_OS_MACOS) 8 #if defined(HOST_OS_MACOS)
9 9
10 #include "bin/sync_socket.h" 10 #include "bin/sync_socket.h"
11 11
12 #include <errno.h> // NOLINT 12 #include <errno.h> // NOLINT
13 13
14 #include "bin/fdutils.h" 14 #include "bin/fdutils.h"
15 #include "bin/socket_base.h" 15 #include "bin/socket_base.h"
16 #include "platform/signal_blocker.h" 16 #include "platform/signal_blocker.h"
17 17
18 namespace dart { 18 namespace dart {
19 namespace bin { 19 namespace bin {
20 20
21 bool SynchronousSocket::Initialize() { 21 bool SynchronousSocket::Initialize() {
22 // Nothing to do on Linux. 22 // Nothing to do on Linux.
23 return true; 23 return true;
24 } 24 }
25 25
26
27 static intptr_t Create(const RawAddr& addr) { 26 static intptr_t Create(const RawAddr& addr) {
28 intptr_t fd; 27 intptr_t fd;
29 fd = NO_RETRY_EXPECTED(socket(addr.ss.ss_family, SOCK_STREAM, 0)); 28 fd = NO_RETRY_EXPECTED(socket(addr.ss.ss_family, SOCK_STREAM, 0));
30 if (fd < 0) { 29 if (fd < 0) {
31 return -1; 30 return -1;
32 } 31 }
33 if (!FDUtils::SetCloseOnExec(fd)) { 32 if (!FDUtils::SetCloseOnExec(fd)) {
34 FDUtils::SaveErrorAndClose(fd); 33 FDUtils::SaveErrorAndClose(fd);
35 return -1; 34 return -1;
36 } 35 }
37 return fd; 36 return fd;
38 } 37 }
39 38
40
41 static intptr_t Connect(intptr_t fd, const RawAddr& addr) { 39 static intptr_t Connect(intptr_t fd, const RawAddr& addr) {
42 intptr_t result = TEMP_FAILURE_RETRY( 40 intptr_t result = TEMP_FAILURE_RETRY(
43 connect(fd, &addr.addr, SocketAddress::GetAddrLength(addr))); 41 connect(fd, &addr.addr, SocketAddress::GetAddrLength(addr)));
44 if (result == 0) { 42 if (result == 0) {
45 return fd; 43 return fd;
46 } 44 }
47 ASSERT(errno != EINPROGRESS); 45 ASSERT(errno != EINPROGRESS);
48 FDUtils::FDUtils::SaveErrorAndClose(fd); 46 FDUtils::FDUtils::SaveErrorAndClose(fd);
49 return -1; 47 return -1;
50 } 48 }
51 49
52
53 intptr_t SynchronousSocket::CreateConnect(const RawAddr& addr) { 50 intptr_t SynchronousSocket::CreateConnect(const RawAddr& addr) {
54 intptr_t fd = Create(addr); 51 intptr_t fd = Create(addr);
55 if (fd < 0) { 52 if (fd < 0) {
56 return fd; 53 return fd;
57 } 54 }
58 return Connect(fd, addr); 55 return Connect(fd, addr);
59 } 56 }
60 57
61
62 intptr_t SynchronousSocket::Available(intptr_t fd) { 58 intptr_t SynchronousSocket::Available(intptr_t fd) {
63 return SocketBase::Available(fd); 59 return SocketBase::Available(fd);
64 } 60 }
65 61
66
67 intptr_t SynchronousSocket::GetPort(intptr_t fd) { 62 intptr_t SynchronousSocket::GetPort(intptr_t fd) {
68 return SocketBase::GetPort(fd); 63 return SocketBase::GetPort(fd);
69 } 64 }
70 65
71
72 SocketAddress* SynchronousSocket::GetRemotePeer(intptr_t fd, intptr_t* port) { 66 SocketAddress* SynchronousSocket::GetRemotePeer(intptr_t fd, intptr_t* port) {
73 return SocketBase::GetRemotePeer(fd, port); 67 return SocketBase::GetRemotePeer(fd, port);
74 } 68 }
75 69
76
77 intptr_t SynchronousSocket::Read(intptr_t fd, 70 intptr_t SynchronousSocket::Read(intptr_t fd,
78 void* buffer, 71 void* buffer,
79 intptr_t num_bytes) { 72 intptr_t num_bytes) {
80 return SocketBase::Read(fd, buffer, num_bytes, SocketBase::kSync); 73 return SocketBase::Read(fd, buffer, num_bytes, SocketBase::kSync);
81 } 74 }
82 75
83
84 intptr_t SynchronousSocket::Write(intptr_t fd, 76 intptr_t SynchronousSocket::Write(intptr_t fd,
85 const void* buffer, 77 const void* buffer,
86 intptr_t num_bytes) { 78 intptr_t num_bytes) {
87 return SocketBase::Write(fd, buffer, num_bytes, SocketBase::kSync); 79 return SocketBase::Write(fd, buffer, num_bytes, SocketBase::kSync);
88 } 80 }
89 81
90
91 void SynchronousSocket::ShutdownRead(intptr_t fd) { 82 void SynchronousSocket::ShutdownRead(intptr_t fd) {
92 VOID_NO_RETRY_EXPECTED(shutdown(fd, SHUT_RD)); 83 VOID_NO_RETRY_EXPECTED(shutdown(fd, SHUT_RD));
93 } 84 }
94 85
95
96 void SynchronousSocket::ShutdownWrite(intptr_t fd) { 86 void SynchronousSocket::ShutdownWrite(intptr_t fd) {
97 VOID_NO_RETRY_EXPECTED(shutdown(fd, SHUT_WR)); 87 VOID_NO_RETRY_EXPECTED(shutdown(fd, SHUT_WR));
98 } 88 }
99 89
100
101 void SynchronousSocket::Close(intptr_t fd) { 90 void SynchronousSocket::Close(intptr_t fd) {
102 return SocketBase::Close(fd); 91 return SocketBase::Close(fd);
103 } 92 }
104 93
105 } // namespace bin 94 } // namespace bin
106 } // namespace dart 95 } // namespace dart
107 96
108 #endif // defined(HOST_OS_MACOS) 97 #endif // defined(HOST_OS_MACOS)
109 98
110 #endif // !defined(DART_IO_DISABLED) 99 #endif // !defined(DART_IO_DISABLED)
OLDNEW
« no previous file with comments | « runtime/bin/sync_socket_linux.cc ('k') | runtime/bin/sync_socket_unsupported.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698