Browse Source

prevent stack copy

Darien Raymond 7 years ago
parent
commit
bd7bc63fac
2 changed files with 4 additions and 0 deletions
  1. 1 0
      common/protocol/address.go
  2. 3 0
      common/serial/serial.go

+ 1 - 0
common/protocol/address.go

@@ -226,6 +226,7 @@ func (p *addressParser) readAddress(b *buf.Buffer, reader io.Reader) (net.Addres
 	}
 }
 
+//go:nosplit
 func (p *addressParser) writeAddress(writer io.Writer, address net.Address) error {
 	tb := p.addrByteMap[address.Family()]
 	if tb == afInvalid {

+ 3 - 0
common/serial/serial.go

@@ -9,6 +9,7 @@ import (
 )
 
 // ReadUint16 reads first two bytes from the reader, and then coverts them to an uint16 value.
+//go:nosplit
 func ReadUint16(reader io.Reader) (uint16, error) {
 	var b stack.TwoBytes
 	s := b[:]
@@ -22,6 +23,7 @@ func ReadUint16(reader io.Reader) (uint16, error) {
 }
 
 // WriteUint16 writes an uint16 value into writer.
+//go:nosplit
 func WriteUint16(writer io.Writer, value uint16) (int, error) {
 	var b stack.TwoBytes
 	s := b[:]
@@ -33,6 +35,7 @@ func WriteUint16(writer io.Writer, value uint16) (int, error) {
 }
 
 // WriteUint64 writes an uint64 value into writer.
+//go:nosplit
 func WriteUint64(writer io.Writer, value uint64) (int, error) {
 	var b stack.EightBytes
 	s := b[:]