1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
5 typedef struct WaitQ WaitQ
;
6 typedef struct SudoG SudoG
;
7 typedef struct Select Select
;
8 typedef struct Scase Scase
;
10 typedef struct __go_type_descriptor Type
;
11 typedef struct __go_channel_type ChanType
;
19 byte
* elem
; // data element
28 // The garbage collector is assuming that Hchan can only contain pointers into the stack
29 // and cannot contain pointers into the heap.
32 uintgo qcount
; // total data in the q
33 uintgo dataqsiz
; // size of the circular q
35 uint16 pad
; // ensures proper alignment of the buffer that follows Hchan in memory
37 const Type
* elemtype
; // element type
38 uintgo sendx
; // send index
39 uintgo recvx
; // receive index
40 WaitQ recvq
; // list of recv waiters
41 WaitQ sendq
; // list of send waiters
45 // Buffer follows Hchan immediately in memory.
46 // chanbuf(c, i) is pointer to the i'th slot in the buffer.
47 #define chanbuf(c, i) ((byte*)((c)+1)+(uintptr)(c)->elemsize*(i))
61 SudoG sg
; // must be first member (cast to Scase)
64 uint16 index
; // index to return
65 bool* receivedp
; // pointer to received bool (recv2)
70 uint16 tcase
; // total count of scase[]
71 uint16 ncase
; // currently filled scase[]
72 uint16
* pollorder
; // case poll order
73 Hchan
** lockorder
; // channel lock order
74 Scase scase
[1]; // one per case (in order of appearance)