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
29 // The garbage collector is assuming that Hchan can only contain pointers into the stack
30 // and cannot contain pointers into the heap.
33 uintgo qcount
; // total data in the q
34 uintgo dataqsiz
; // size of the circular q
36 uint16 pad
; // ensures proper alignment of the buffer that follows Hchan in memory
38 const Type
* elemtype
; // element type
39 uintgo sendx
; // send index
40 uintgo recvx
; // receive index
41 WaitQ recvq
; // list of recv waiters
42 WaitQ sendq
; // list of send waiters
46 // Buffer follows Hchan immediately in memory.
47 // chanbuf(c, i) is pointer to the i'th slot in the buffer.
48 #define chanbuf(c, i) ((byte*)((c)+1)+(uintptr)(c)->elemsize*(i))
62 SudoG sg
; // must be first member (cast to Scase)
65 uint16 index
; // index to return
66 bool* receivedp
; // pointer to received bool (recv2)
71 uint16 tcase
; // total count of scase[]
72 uint16 ncase
; // currently filled scase[]
73 uint16
* pollorder
; // case poll order
74 Hchan
** lockorder
; // channel lock order
75 Scase scase
[1]; // one per case (in order of appearance)