Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(158)

Delta Between Two Patch Sets: src/pkg/runtime/netpoll.goc

Issue 9569043: code review 9569043: runtime: change PollDesc.fd from int32 to uintptr (Closed)
Left Patch Set: Created 10 years, 10 months ago
Right Patch Set: diff -r fab6ba2a2d10 https://go.googlecode.com/hg/ Created 10 years, 10 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « src/pkg/net/fd_poll_runtime.go ('k') | src/pkg/runtime/netpoll_epoll.c » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
1 // Copyright 2013 The Go Authors. All rights reserved. 1 // Copyright 2013 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 // +build darwin linux 5 // +build darwin linux
6 6
7 package net 7 package net
8 8
9 #include "runtime.h" 9 #include "runtime.h"
10 #include "defs_GOOS_GOARCH.h" 10 #include "defs_GOOS_GOARCH.h"
11 #include "arch_GOARCH.h" 11 #include "arch_GOARCH.h"
12 #include "malloc.h" 12 #include "malloc.h"
13 13
14 // Integrated network poller (platform-independent part). 14 // Integrated network poller (platform-independent part).
15 // A particular implementation (epoll/kqueue) must define the following function s: 15 // A particular implementation (epoll/kqueue) must define the following function s:
16 // void runtime·netpollinit(void); // to initialize the pol ler 16 // void runtime·netpollinit(void); // to initialize the pol ler
17 // int32 runtime·netpollopen(int32 fd, PollDesc *pd);» // to arm edge-triggered notifications 17 // int32 runtime·netpollopen(uintptr fd, PollDesc *pd);»// to arm edge-triggered notifications
18 // and associate fd with pd. 18 // and associate fd with pd.
19 // An implementation must call the following function to denote that the pd is r eady. 19 // An implementation must call the following function to denote that the pd is r eady.
20 // void runtime·netpollready(G **gpp, PollDesc *pd, int32 mode); 20 // void runtime·netpollready(G **gpp, PollDesc *pd, int32 mode);
21 21
22 #define READY ((G*)1) 22 #define READY ((G*)1)
23 23
24 struct PollDesc 24 struct PollDesc
25 { 25 {
26 PollDesc* link; // in pollcache, protected by pollcache.Lock 26 PollDesc* link; // in pollcache, protected by pollcache.Lock
27 Lock; // protectes the following fields 27 Lock; // protectes the following fields
28 » int32» fd; 28 » uintptr»fd;
29 bool closing; 29 bool closing;
30 uintptr seq; // protects from stale timers and ready notifications 30 uintptr seq; // protects from stale timers and ready notifications
31 G* rg; // G waiting for read or READY (binary semaphore) 31 G* rg; // G waiting for read or READY (binary semaphore)
32 Timer rt; // read deadline timer (set if rt.fv != nil) 32 Timer rt; // read deadline timer (set if rt.fv != nil)
33 int64 rd; // read deadline 33 int64 rd; // read deadline
34 G* wg; // the same for writes 34 G* wg; // the same for writes
35 Timer wt; 35 Timer wt;
36 int64 wd; 36 int64 wd;
37 }; 37 };
38 38
(...skipping 17 matching lines...) Expand all
56 static intgo checkerr(PollDesc *pd, int32 mode); 56 static intgo checkerr(PollDesc *pd, int32 mode);
57 57
58 static FuncVal deadlineFn = {(void(*)(void))deadline}; 58 static FuncVal deadlineFn = {(void(*)(void))deadline};
59 static FuncVal readDeadlineFn = {(void(*)(void))readDeadline}; 59 static FuncVal readDeadlineFn = {(void(*)(void))readDeadline};
60 static FuncVal writeDeadlineFn = {(void(*)(void))writeDeadline}; 60 static FuncVal writeDeadlineFn = {(void(*)(void))writeDeadline};
61 61
62 func runtime_pollServerInit() { 62 func runtime_pollServerInit() {
63 runtime·netpollinit(); 63 runtime·netpollinit();
64 } 64 }
65 65
66 func runtime_pollOpen(fd int) (pd *PollDesc, errno int) { 66 func runtime_pollOpen(fd uintptr) (pd *PollDesc, errno int) {
67 pd = allocPollDesc(); 67 pd = allocPollDesc();
68 runtime·lock(pd); 68 runtime·lock(pd);
69 if(pd->wg != nil && pd->wg != READY) 69 if(pd->wg != nil && pd->wg != READY)
70 runtime·throw("runtime_pollOpen: blocked write on free descripto r"); 70 runtime·throw("runtime_pollOpen: blocked write on free descripto r");
71 if(pd->rg != nil && pd->rg != READY) 71 if(pd->rg != nil && pd->rg != READY)
72 runtime·throw("runtime_pollOpen: blocked read on free descriptor "); 72 runtime·throw("runtime_pollOpen: blocked read on free descriptor ");
73 pd->fd = fd; 73 pd->fd = fd;
74 pd->closing = false; 74 pd->closing = false;
75 pd->seq++; 75 pd->seq++;
76 pd->rg = nil; 76 pd->rg = nil;
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 for(i = 0; i < n; i++) { 342 for(i = 0; i < n; i++) {
343 pd[i].link = pollcache.first; 343 pd[i].link = pollcache.first;
344 pollcache.first = &pd[i]; 344 pollcache.first = &pd[i];
345 } 345 }
346 } 346 }
347 pd = pollcache.first; 347 pd = pollcache.first;
348 pollcache.first = pd->link; 348 pollcache.first = pd->link;
349 runtime·unlock(&pollcache); 349 runtime·unlock(&pollcache);
350 return pd; 350 return pd;
351 } 351 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b