@@ -83,7 +83,7 @@ func (q *chanQueue) push(node *channelOp) {
83
83
// waiting (for example, when they're part of a select operation) will be
84
84
// skipped.
85
85
// This function must be called with interrupts disabled.
86
- func (q * chanQueue ) pop (chanOp uint64 ) * channelOp {
86
+ func (q * chanQueue ) pop (chanOp uint32 ) * channelOp {
87
87
for {
88
88
if q .first == nil {
89
89
return nil
@@ -96,11 +96,11 @@ func (q *chanQueue) pop(chanOp uint64) *channelOp {
96
96
// The new value for the 'data' field will be a combination of the
97
97
// channel operation and the select index. (The select index is 0 for
98
98
// non-select channel operations).
99
- newDataValue := chanOp | uint64 ( popped .index << 2 )
99
+ newDataValue := chanOp | popped .index << 2
100
100
101
101
// 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 )
104
104
return popped
105
105
}
106
106
}
@@ -123,7 +123,7 @@ func (q *chanQueue) remove(remove *channelOp) {
123
123
type channelOp struct {
124
124
next * channelOp
125
125
task * task.Task
126
- index uintptr // select index, 0 for non-select operation
126
+ index uint32 // select index, 0 for non-select operation
127
127
value unsafe.Pointer // if this is a sender, this is the value to send
128
128
}
129
129
@@ -239,7 +239,7 @@ func chanSend(ch *channel, value unsafe.Pointer, op *channelOp) {
239
239
240
240
// Can't proceed. Add us to the list of senders and wait until we're awoken.
241
241
t := task .Current ()
242
- t .Data = chanOperationWaiting
242
+ t .SetDataUint32 ( chanOperationWaiting )
243
243
op .task = t
244
244
op .index = 0
245
245
op .value = value
@@ -251,7 +251,7 @@ func chanSend(ch *channel, value unsafe.Pointer, op *channelOp) {
251
251
252
252
// Check whether the sent happened normally (not because the channel was
253
253
// closed while sending).
254
- if t .Data == chanOperationClosed {
254
+ if t .DataUint32 () == chanOperationClosed {
255
255
// Oops, this channel was closed while sending!
256
256
runtimePanic ("send on closed channel" )
257
257
}
@@ -313,7 +313,7 @@ func chanRecv(ch *channel, value unsafe.Pointer, op *channelOp) bool {
313
313
// until we're awoken.
314
314
t := task .Current ()
315
315
t .Ptr = value
316
- t .Data = chanOperationWaiting
316
+ t .SetDataUint32 ( chanOperationWaiting )
317
317
op .task = t
318
318
op .index = 0
319
319
ch .receivers .push (op )
@@ -323,7 +323,7 @@ func chanRecv(ch *channel, value unsafe.Pointer, op *channelOp) bool {
323
323
task .Pause ()
324
324
325
325
// Return whether the receive happened from a closed channel.
326
- return t .Data != chanOperationClosed
326
+ return t .DataUint32 () != chanOperationClosed
327
327
}
328
328
329
329
// chanClose closes the given channel. If this channel has a receiver or is
@@ -375,10 +375,10 @@ func chanClose(ch *channel) {
375
375
376
376
// chanSelect implements blocking or non-blocking select operations.
377
377
// 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 ) {
379
379
mask := interrupt .Disable ()
380
380
381
- const selectNoIndex = ^ uintptr (0 )
381
+ const selectNoIndex = ^ uint32 (0 )
382
382
selectIndex := selectNoIndex
383
383
selectOk := true
384
384
@@ -393,13 +393,13 @@ func chanSelect(recvbuf unsafe.Pointer, states []chanSelectState, ops []channelO
393
393
394
394
if state .value == nil { // chan receive
395
395
if received , ok := state .ch .tryRecv (recvbuf ); received {
396
- selectIndex = uintptr (i )
396
+ selectIndex = uint32 (i )
397
397
selectOk = ok
398
398
break
399
399
}
400
400
} else { // chan send
401
401
if state .ch .trySend (state .value ) {
402
- selectIndex = uintptr (i )
402
+ selectIndex = uint32 (i )
403
403
break
404
404
}
405
405
}
@@ -421,14 +421,14 @@ func chanSelect(recvbuf unsafe.Pointer, states []chanSelectState, ops []channelO
421
421
// will be able to "take" this select operation.
422
422
t := task .Current ()
423
423
t .Ptr = recvbuf
424
- t .Data = chanOperationWaiting
424
+ t .SetDataUint32 ( chanOperationWaiting )
425
425
for i , state := range states {
426
426
if state .ch == nil {
427
427
continue
428
428
}
429
429
op := & ops [i ]
430
430
op .task = t
431
- op .index = uintptr (i )
431
+ op .index = uint32 (i )
432
432
if state .value == nil { // chan receive
433
433
state .ch .receivers .push (op )
434
434
} else { // chan send
@@ -460,8 +460,8 @@ func chanSelect(recvbuf unsafe.Pointer, states []chanSelectState, ops []channelO
460
460
}
461
461
462
462
// 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
465
465
466
466
return selectIndex , selectOk
467
467
}
0 commit comments