@@ -33,8 +33,8 @@ func newRingBufEventRing(mapFD, size int) (*ringbufEventRing, error) {
33
33
return nil , fmt .Errorf ("can't mmap data pages: %w" , err )
34
34
}
35
35
36
- cons_pos := (* uint64 )(unsafe .Pointer (& cons [0 ]))
37
- prod_pos := (* uint64 )(unsafe .Pointer (& prod [0 ]))
36
+ cons_pos := (* uintptr )(unsafe .Pointer (& cons [0 ]))
37
+ prod_pos := (* uintptr )(unsafe .Pointer (& prod [0 ]))
38
38
39
39
ring := & ringbufEventRing {
40
40
prod : prod ,
@@ -58,17 +58,17 @@ func (ring *ringbufEventRing) Close() {
58
58
59
59
type ringReader struct {
60
60
// These point into mmap'ed memory and must be accessed atomically.
61
- prod_pos , cons_pos * uint64
62
- mask uint64
61
+ prod_pos , cons_pos * uintptr
62
+ mask uintptr
63
63
ring []byte
64
64
}
65
65
66
- func newRingReader (cons_ptr , prod_ptr * uint64 , ring []byte ) * ringReader {
66
+ func newRingReader (cons_ptr , prod_ptr * uintptr , ring []byte ) * ringReader {
67
67
return & ringReader {
68
68
prod_pos : prod_ptr ,
69
69
cons_pos : cons_ptr ,
70
70
// cap is always a power of two
71
- mask : uint64 (cap (ring )/ 2 - 1 ),
71
+ mask : uintptr (cap (ring )/ 2 - 1 ),
72
72
ring : ring ,
73
73
}
74
74
}
@@ -82,15 +82,15 @@ func (rr *ringReader) size() int {
82
82
83
83
// The amount of data available to read in the ring buffer.
84
84
func (rr * ringReader ) AvailableBytes () uint64 {
85
- prod := atomic .LoadUint64 (rr .prod_pos )
86
- cons := atomic .LoadUint64 (rr .cons_pos )
87
- return prod - cons
85
+ prod := atomic .LoadUintptr (rr .prod_pos )
86
+ cons := atomic .LoadUintptr (rr .cons_pos )
87
+ return uint64 ( prod - cons )
88
88
}
89
89
90
90
// Read a record from an event ring.
91
91
func (rr * ringReader ) readRecord (rec * Record ) error {
92
- prod := atomic .LoadUint64 (rr .prod_pos )
93
- cons := atomic .LoadUint64 (rr .cons_pos )
92
+ prod := atomic .LoadUintptr (rr .prod_pos )
93
+ cons := atomic .LoadUintptr (rr .cons_pos )
94
94
95
95
for {
96
96
if remaining := prod - cons ; remaining == 0 {
@@ -117,7 +117,7 @@ func (rr *ringReader) readRecord(rec *Record) error {
117
117
cons += sys .BPF_RINGBUF_HDR_SZ
118
118
119
119
// Data is always padded to 8 byte alignment.
120
- dataLenAligned := uint64 (internal .Align (header .dataLen (), 8 ))
120
+ dataLenAligned := uintptr (internal .Align (header .dataLen (), 8 ))
121
121
if remaining := prod - cons ; remaining < dataLenAligned {
122
122
return fmt .Errorf ("read sample data: %w" , io .ErrUnexpectedEOF )
123
123
}
@@ -129,7 +129,7 @@ func (rr *ringReader) readRecord(rec *Record) error {
129
129
// when the record header indicates that the data should be
130
130
// discarded, we skip it by just updating the consumer position
131
131
// to the next record.
132
- atomic .StoreUint64 (rr .cons_pos , cons )
132
+ atomic .StoreUintptr (rr .cons_pos , cons )
133
133
continue
134
134
}
135
135
@@ -141,7 +141,7 @@ func (rr *ringReader) readRecord(rec *Record) error {
141
141
142
142
copy (rec .RawSample , rr .ring [start :])
143
143
rec .Remaining = int (prod - cons )
144
- atomic .StoreUint64 (rr .cons_pos , cons )
144
+ atomic .StoreUintptr (rr .cons_pos , cons )
145
145
return nil
146
146
}
147
147
}
0 commit comments