// WriteLE16 writes 16 bits in native format to the RWops as little-endian data.
// (https://wiki.libsdl.org/SDL_WriteLE16)
354549
func (rwops *RWops) WriteLE16(value uint16) uint {
	if rwops == nil {
		return 0
	}
	return uint(C.SDL_WriteLE16(rwops.cptr(), C.Uint16(value)))
}
284777
func PutUint16(b []byte, v uint16) {
	if l := len(b); l != 2 {
		panic(fmt.Sprintf("PutUint16: unexpected byte slice length: %d", l))
	}

	*(*uint16)(unsafe.Pointer(&b[0])) = v
}
442499
func (vb *packer) WriteUint16(num uint16) (int, error) {
	binary.BigEndian.PutUint16(vb.tempBuffer[:2], num)
	vb.Write(vb.tempBuffer[:2])
	return 2, nil
}
740817
func (cmd *baseCommand) WriteUint16(num uint16) (int, error) {
	binary.BigEndian.PutUint16(cmd.dataBuffer[cmd.dataOffset:cmd.dataOffset+2], num)
	cmd.dataOffset += 2
	return 2, nil
}
1220731
func (e Encoder) AppendUints16(dst []byte, vals []uint16) []byte {
	major := majorTypeArray
	l := len(vals)
	if l == 0 {
		return e.AppendArrayEnd(e.AppendArrayStart(dst))
	}
	if l <= additionalMax {
		lb := byte(l)
		dst = append(dst, byte(major|lb))
	} else {
		dst = appendCborTypePrefix(dst, major, uint64(l))
	}
	for _, v := range vals {
		dst = e.AppendUint16(dst, v)
	}
	return dst
}
99353
func (b *BitWriter) WriteBit(bit Bit) error {

	if bit {
		b.b[0] |= 1 << (b.count - 1)
	}

	b.count--

	if b.count == 0 {
		if n, err := b.w.Write(b.b[:]); n != 1 || err != nil {
			return err
		}
		b.b[0] = 0
		b.count = 8
	}

	return nil
}
880844
func (ed *eventData) writeUint16(value uint16) {
	binary.Write(&ed.buffer, binary.LittleEndian, value)
}
1122751
func (d *RabinKarp64) Write(data []byte) (int, error) {
	l := len(data)
	if l == 0 {
		return 0, nil
	}
	// Re-arrange the window so that the leftmost element is at index 0
	n := len(d.window)
	if d.oldest != 0 {
		tmp := make([]byte, d.oldest)
		copy(tmp, d.window[:d.oldest])
		copy(d.window, d.window[d.oldest:])
		copy(d.window[n-d.oldest:], tmp)
		d.oldest = 0
	}
	d.window = append(d.window, data...)

	d.value = 0
	for _, b := range d.window {
		d.value <<= 8
		d.value |= Pol(b)
		d.value = d.value.Mod(d.pol)
	}

	d.updateTables()

	return len(data), nil
}
156245
func Uint64SliceToByteSlice(in []uint64) ([]byte, error) {
	buffer := bytes.NewBuffer(make([]byte, 0, len(in)*8))
	err := binary.Write(buffer, STORE_ENDIAN, in)
	if err != nil {
		return nil, err
	}

	return buffer.Bytes(), nil
}
1036951
func (rwops *RWops) Write2(buf []byte, size, num uint) (n int, err error) {
	if rwops == nil || buf == nil {
		return 0, ErrInvalidParameters
	}

	header := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
	_data := unsafe.Pointer(header.Data)

	n = int(C.RWwrite(rwops.cptr(), _data, C.size_t(size), C.size_t(num)))
	if n < int(num) {
		err = GetError()
	}
	return
}
378865
func uint16ToNetwork(u uint16) uint16 {
	var b [2]byte
	binary.BigEndian.PutUint16(b[:], u)
	return *(*uint16)(unsafe.Pointer(&b))
}
1275673
func (smb SMBus) Write_word_data(cmd byte, value uint16) error {
	smb.Set_addr(smb.addr)
	_, err := C.i2c_smbus_write_word_data(C.int(smb.bus.Fd()), C.__u8(cmd), C.__u16(value))
	return err
}
1259585
func (b *BitWriter) WriteBits(u uint64, nbits int) error {
	u <<= (64 - uint(nbits))
	for nbits >= 8 {
		byt := byte(u >> 56)
		err := b.WriteByte(byt)
		if err != nil {
			return err
		}
		u <<= 8
		nbits -= 8
	}

	for nbits > 0 {
		err := b.WriteBit((u >> 63) == 1)
		if err != nil {
			return err
		}
		u <<= 1
		nbits--
	}

	return nil
}
1103151
func WriteUInt32(w io.Writer, v uint) error {
	a := byte(v >> 24)
	b := byte(v >> 16)
	c := byte(v >> 8)
	d := byte(v)
	_, err := w.Write([]byte{a, b, c, d})
	if err != nil {
		return err
	}
	return nil
}
253949
func (rwops *RWops) WriteBE32(value uint32) uint {
	if rwops == nil {
		return 0
	}
	return uint(C.SDL_WriteBE32(rwops.cptr(), C.Uint32(value)))
}
812489
func (enc *Encoder) WriteInt16(val int16) error {
	return enc.WriteInt(int(val))
}
617277
func Uint16(v uint16) *uint16 {
	p := new(uint16)
	*p = v
	return p
}