@@ -83,7 +83,7 @@ func (q *chanQueue) push(node *channelOp) {
8383// waiting (for example, when they're part of a select operation) will be
8484// skipped.
8585// This function must be called with interrupts disabled.
86- func (q * chanQueue ) pop (chanOp uint64 ) * channelOp {
86+ func (q * chanQueue ) pop (chanOp uint32 ) * channelOp {
8787 for {
8888 if q .first == nil {
8989 return nil
@@ -96,11 +96,11 @@ func (q *chanQueue) pop(chanOp uint64) *channelOp {
9696 // The new value for the 'data' field will be a combination of the
9797 // channel operation and the select index. (The select index is 0 for
9898 // non-select channel operations).
99- newDataValue := chanOp | uint64 ( popped .index << 2 )
99+ newDataValue := chanOp | popped .index << 2
100100
101101 // Try to be the first to proceed with this goroutine.
102- if popped .task .Data == chanOperationWaiting {
103- popped .task .Data = newDataValue
102+ if popped .task .DataUint32 () == chanOperationWaiting {
103+ popped .task .SetDataUint32 ( newDataValue )
104104 return popped
105105 }
106106 }
@@ -123,7 +123,7 @@ func (q *chanQueue) remove(remove *channelOp) {
123123type channelOp struct {
124124 next * channelOp
125125 task * task.Task
126- index uintptr // select index, 0 for non-select operation
126+ index uint32 // select index, 0 for non-select operation
127127 value unsafe.Pointer // if this is a sender, this is the value to send
128128}
129129
@@ -239,7 +239,7 @@ func chanSend(ch *channel, value unsafe.Pointer, op *channelOp) {
239239
240240 // Can't proceed. Add us to the list of senders and wait until we're awoken.
241241 t := task .Current ()
242- t .Data = chanOperationWaiting
242+ t .SetDataUint32 ( chanOperationWaiting )
243243 op .task = t
244244 op .index = 0
245245 op .value = value
@@ -251,7 +251,7 @@ func chanSend(ch *channel, value unsafe.Pointer, op *channelOp) {
251251
252252 // Check whether the sent happened normally (not because the channel was
253253 // closed while sending).
254- if t .Data == chanOperationClosed {
254+ if t .DataUint32 () == chanOperationClosed {
255255 // Oops, this channel was closed while sending!
256256 runtimePanic ("send on closed channel" )
257257 }
@@ -313,7 +313,7 @@ func chanRecv(ch *channel, value unsafe.Pointer, op *channelOp) bool {
313313 // until we're awoken.
314314 t := task .Current ()
315315 t .Ptr = value
316- t .Data = chanOperationWaiting
316+ t .SetDataUint32 ( chanOperationWaiting )
317317 op .task = t
318318 op .index = 0
319319 ch .receivers .push (op )
@@ -323,7 +323,7 @@ func chanRecv(ch *channel, value unsafe.Pointer, op *channelOp) bool {
323323 task .Pause ()
324324
325325 // Return whether the receive happened from a closed channel.
326- return t .Data != chanOperationClosed
326+ return t .DataUint32 () != chanOperationClosed
327327}
328328
329329// chanClose closes the given channel. If this channel has a receiver or is
@@ -375,10 +375,10 @@ func chanClose(ch *channel) {
375375
376376// chanSelect implements blocking or non-blocking select operations.
377377// The 'ops' slice must be set if (and only if) this is a blocking select.
378- func chanSelect (recvbuf unsafe.Pointer , states []chanSelectState , ops []channelOp ) (uintptr , bool ) {
378+ func chanSelect (recvbuf unsafe.Pointer , states []chanSelectState , ops []channelOp ) (uint32 , bool ) {
379379 mask := interrupt .Disable ()
380380
381- const selectNoIndex = ^ uintptr (0 )
381+ const selectNoIndex = ^ uint32 (0 )
382382 selectIndex := selectNoIndex
383383 selectOk := true
384384
@@ -393,13 +393,13 @@ func chanSelect(recvbuf unsafe.Pointer, states []chanSelectState, ops []channelO
393393
394394 if state .value == nil { // chan receive
395395 if received , ok := state .ch .tryRecv (recvbuf ); received {
396- selectIndex = uintptr (i )
396+ selectIndex = uint32 (i )
397397 selectOk = ok
398398 break
399399 }
400400 } else { // chan send
401401 if state .ch .trySend (state .value ) {
402- selectIndex = uintptr (i )
402+ selectIndex = uint32 (i )
403403 break
404404 }
405405 }
@@ -421,14 +421,14 @@ func chanSelect(recvbuf unsafe.Pointer, states []chanSelectState, ops []channelO
421421 // will be able to "take" this select operation.
422422 t := task .Current ()
423423 t .Ptr = recvbuf
424- t .Data = chanOperationWaiting
424+ t .SetDataUint32 ( chanOperationWaiting )
425425 for i , state := range states {
426426 if state .ch == nil {
427427 continue
428428 }
429429 op := & ops [i ]
430430 op .task = t
431- op .index = uintptr (i )
431+ op .index = uint32 (i )
432432 if state .value == nil { // chan receive
433433 state .ch .receivers .push (op )
434434 } else { // chan send
@@ -460,8 +460,8 @@ func chanSelect(recvbuf unsafe.Pointer, states []chanSelectState, ops []channelO
460460 }
461461
462462 // Pull the return values out of t.Data (which contains two bitfields).
463- selectIndex = uintptr ( t . Data ) >> 2
464- selectOk = t .Data & chanOperationMask != chanOperationClosed
463+ selectIndex = t . DataUint32 ( ) >> 2
464+ selectOk = t .DataUint32 () & chanOperationMask != chanOperationClosed
465465
466466 return selectIndex , selectOk
467467}
0 commit comments