aboutsummaryrefslogtreecommitdiff
path: root/src/internal/syscall/unix/writev_illumos.go
blob: f60949f662b58a7710acf27540740d56b7d8a20c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Copyright 2020 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build illumos
// +build illumos

package unix

import (
	"syscall"
	"unsafe"
)

//go:cgo_import_dynamic libc_writev writev "libc.so"

//go:linkname procwritev libc_writev

var procwritev uintptr

func Writev(fd int, iovs []syscall.Iovec) (uintptr, error) {
	var p *syscall.Iovec
	if len(iovs) > 0 {
		p = &iovs[0]
	}
	n, _, errno := syscall6(uintptr(unsafe.Pointer(&procwritev)), 3, uintptr(fd), uintptr(unsafe.Pointer(p)), uintptr(len(iovs)), 0, 0, 0)
	if errno != 0 {
		return 0, errno
	}
	return n, nil
}