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

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

Issue 10357003: Beginnings of a debugger wire protocol (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 7 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
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 <errno.h> 5 #include <errno.h>
6 #include <fcntl.h> 6 #include <fcntl.h>
7 #include <unistd.h> 7 #include <unistd.h>
8 #include <sys/ioctl.h> 8 #include <sys/ioctl.h>
9 9
10 #include "bin/fdutils.h" 10 #include "bin/fdutils.h"
11 11
12 12
13 bool FDUtils::SetNonBlocking(intptr_t fd) { 13 bool FDUtils::SetNonBlocking(intptr_t fd) {
14 intptr_t status; 14 intptr_t status;
15 status = TEMP_FAILURE_RETRY(fcntl(fd, F_GETFL)); 15 status = TEMP_FAILURE_RETRY(fcntl(fd, F_GETFL));
16 if (status < 0) { 16 if (status < 0) {
17 perror("fcntl F_GETFL failed"); 17 perror("fcntl F_GETFL failed");
18 return false; 18 return false;
19 } 19 }
20 status = (status | O_NONBLOCK); 20 status = (status | O_NONBLOCK);
21 if (TEMP_FAILURE_RETRY(fcntl(fd, F_SETFL, status)) < 0) { 21 if (TEMP_FAILURE_RETRY(fcntl(fd, F_SETFL, status)) < 0) {
22 perror("fcntl F_SETFL failed"); 22 perror("fcntl F_SETFL failed");
23 return false; 23 return false;
24 } 24 }
25 return true; 25 return true;
26 } 26 }
27 27
28 28
29 bool FDUtils::SetBlocking(intptr_t fd) {
30 intptr_t status;
31 status = TEMP_FAILURE_RETRY(fcntl(fd, F_GETFL));
32 if (status < 0) {
33 perror("fcntl F_GETFL failed");
34 return false;
35 }
36 status = (status & ~O_NONBLOCK);
37 if (TEMP_FAILURE_RETRY(fcntl(fd, F_SETFL, status)) < 0) {
38 perror("fcntl F_SETFL failed");
39 return false;
40 }
41 return true;
siva 2012/05/03 22:52:08 The code in SetNonBlocking and SetBlocking can be
hausner 2012/05/03 23:52:00 Not quite. The bit operation is | in one case and
42 }
43
44
29 bool FDUtils::IsBlocking(intptr_t fd, bool* is_blocking) { 45 bool FDUtils::IsBlocking(intptr_t fd, bool* is_blocking) {
30 intptr_t status; 46 intptr_t status;
31 status = TEMP_FAILURE_RETRY(fcntl(fd, F_GETFL)); 47 status = TEMP_FAILURE_RETRY(fcntl(fd, F_GETFL));
32 if (status < 0) { 48 if (status < 0) {
33 perror("fcntl F_GETFL failed"); 49 perror("fcntl F_GETFL failed");
34 return false; 50 return false;
35 } 51 }
36 *is_blocking = (status & O_NONBLOCK) == 0; 52 *is_blocking = (status & O_NONBLOCK) == 0;
37 return true; 53 return true;
38 } 54 }
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 ASSERT(errno != EWOULDBLOCK); 115 ASSERT(errno != EWOULDBLOCK);
100 return -1; 116 return -1;
101 } else { 117 } else {
102 ASSERT(bytes_written > 0); 118 ASSERT(bytes_written > 0);
103 remaining -= bytes_written; 119 remaining -= bytes_written;
104 buffer_pos += bytes_written; 120 buffer_pos += bytes_written;
105 } 121 }
106 } 122 }
107 return count; 123 return count;
108 } 124 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698