Write writes a specific value to the eventfd.
(val uint64)
| 77 | |
| 78 | // Write writes a specific value to the eventfd. |
| 79 | func (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 |
no test coverage detected