gitee.com/ks-custle/core-gm@v0.0.0-20230922171213-b83bdd97b62c/internal/syscall/unix/pipe2_illumos.go (about)

     1  // Copyright 2020 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  //go:build illumos
     6  // +build illumos
     7  
     8  package unix
     9  
    10  import (
    11  	"syscall"
    12  	"unsafe"
    13  )
    14  
    15  //go:cgo_import_dynamic libc_pipe2 pipe2 "libc.so"
    16  
    17  //go:linkname procpipe2 libc_pipe2
    18  
    19  var procpipe2 uintptr
    20  
    21  type _C_int int32
    22  
    23  func Pipe2(p []int, flags int) error {
    24  	if len(p) != 2 {
    25  		return syscall.EINVAL
    26  	}
    27  	var pp [2]_C_int
    28  	_, _, errno := syscall6(uintptr(unsafe.Pointer(&procpipe2)), 2, uintptr(unsafe.Pointer(&pp)), uintptr(flags), 0, 0, 0, 0)
    29  	if errno != 0 {
    30  		return errno
    31  	}
    32  	p[0] = int(pp[0])
    33  	p[1] = int(pp[1])
    34  	return nil
    35  }