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

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

Issue 13636003: Fix a number of issues with determining the type of stdio (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review comments Created 7 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « runtime/bin/socket_linux.cc ('k') | runtime/bin/stdio_patch.dart » ('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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 #include "platform/globals.h" 5 #include "platform/globals.h"
6 #if defined(TARGET_OS_MACOS) 6 #if defined(TARGET_OS_MACOS)
7 7
8 #include <errno.h> // NOLINT 8 #include <errno.h> // NOLINT
9 #include <stdio.h> // NOLINT 9 #include <stdio.h> // NOLINT
10 #include <stdlib.h> // NOLINT 10 #include <stdlib.h> // NOLINT
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 SOL_SOCKET, 136 SOL_SOCKET,
137 SO_ERROR, 137 SO_ERROR,
138 &errno, 138 &errno,
139 reinterpret_cast<socklen_t*>(&len)); 139 reinterpret_cast<socklen_t*>(&len));
140 os_error->SetCodeAndMessage(OSError::kSystem, errno); 140 os_error->SetCodeAndMessage(OSError::kSystem, errno);
141 } 141 }
142 142
143 143
144 int Socket::GetType(intptr_t fd) { 144 int Socket::GetType(intptr_t fd) {
145 struct stat buf; 145 struct stat buf;
146 if (isatty(fd)) return File::kTerminal;
147 int result = fstat(fd, &buf); 146 int result = fstat(fd, &buf);
148 if (result == -1) return -1; 147 if (result == -1) return -1;
148 if (S_ISCHR(buf.st_mode)) return File::kTerminal;
149 if (S_ISFIFO(buf.st_mode)) return File::kPipe; 149 if (S_ISFIFO(buf.st_mode)) return File::kPipe;
150 if (S_ISREG(buf.st_mode)) return File::kFile; 150 if (S_ISREG(buf.st_mode)) return File::kFile;
151 return File::kOther; 151 return File::kOther;
152 } 152 }
153 153
154 154
155 intptr_t Socket::GetStdioHandle(int num) { 155 intptr_t Socket::GetStdioHandle(int num) {
156 return static_cast<intptr_t>(num); 156 return static_cast<intptr_t>(num);
157 } 157 }
158 158
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 bool Socket::SetNoDelay(intptr_t fd, bool enabled) { 277 bool Socket::SetNoDelay(intptr_t fd, bool enabled) {
278 int on = enabled ? 1 : 0; 278 int on = enabled ? 1 : 0;
279 return TEMP_FAILURE_RETRY(setsockopt(fd, 279 return TEMP_FAILURE_RETRY(setsockopt(fd,
280 IPPROTO_TCP, 280 IPPROTO_TCP,
281 TCP_NODELAY, 281 TCP_NODELAY,
282 reinterpret_cast<char *>(&on), 282 reinterpret_cast<char *>(&on),
283 sizeof(on))) == 0; 283 sizeof(on))) == 0;
284 } 284 }
285 285
286 #endif // defined(TARGET_OS_MACOS) 286 #endif // defined(TARGET_OS_MACOS)
OLDNEW
« no previous file with comments | « runtime/bin/socket_linux.cc ('k') | runtime/bin/stdio_patch.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698