MCPcopy
hub / github.com/google/gvisor / Write

Method Write

pkg/eventfd/eventfd.go:79–98  ·  view source on GitHub ↗

Write writes a specific value to the eventfd.

(val uint64)

Source from the content-addressed store, hash-verified

77
78// Write writes a specific value to the eventfd.
79func (ev Eventfd) Write(val uint64) error {
80 var buf [sizeofUint64]byte
81 hostarch.ByteOrder.PutUint64(buf[:], val)
82 if ev.mmioAddr != 0 && ev.mmioCtrl.Enabled() {
83 if _, err := safecopy.CopyOut(ev.mmioPtr(), buf[:]); err == nil {
84 return nil
85 }
86 // Fall back to using a syscall.
87 }
88 for {
89 n, err := nonBlockingWrite(ev.fd, buf[:])
90 if err == unix.EINTR {
91 continue
92 }
93 if err != nil || n != sizeofUint64 {
94 panic(fmt.Sprintf("bad write to eventfd: got %d bytes, wanted %d with error %v", n, sizeofUint64, err))
95 }
96 return err
97 }
98}
99
100// MMIOWrite is equivalent to Write, but returns an error if the write cannot be
101// implemented by writing to the address set by EnableMMIO. This is primarily

Callers 1

NotifyMethod · 0.95

Calls 4

mmioPtrMethod · 0.95
CopyOutFunction · 0.92
nonBlockingWriteFunction · 0.85
EnabledMethod · 0.65

Tested by

no test coverage detected