// Copyright 2018 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.

package net

import (
	
	
)

// spliceFrom transfers data from r to c using the splice system call to minimize
// copies from and to userspace. c must be a TCP connection.
// Currently, spliceFrom is only enabled if r is a TCP or a stream-oriented Unix connection.
//
// If spliceFrom returns handled == false, it has performed no work.
func spliceFrom( *netFD,  io.Reader) ( int64,  error,  bool) {
	var  int64 = 1<<63 - 1 // by default, copy until EOF
	,  := .(*io.LimitedReader)
	if  {
		,  = .N, .R
		if  <= 0 {
			return 0, nil, true
		}
	}

	var  *netFD
	switch v := .(type) {
	case *TCPConn:
		 = .fd
	case tcpConnWithoutWriteTo:
		 = .fd
	case *UnixConn:
		if .fd.net != "unix" {
			return 0, nil, false
		}
		 = .fd
	default:
		return 0, nil, false
	}

	, , ,  := poll.Splice(&.pfd, &.pfd, )
	if  != nil {
		.N -= 
	}
	return , wrapSyscallError(, ), 
}

// spliceTo transfers data from c to w using the splice system call to minimize
// copies from and to userspace. c must be a TCP connection.
// Currently, spliceTo is only enabled if w is a stream-oriented Unix connection.
//
// If spliceTo returns handled == false, it has performed no work.
func spliceTo( io.Writer,  *netFD) ( int64,  error,  bool) {
	,  := .(*UnixConn)
	if ! || .fd.net != "unix" {
		return
	}

	, , ,  := poll.Splice(&.fd.pfd, &.pfd, 1<<63-1)
	return , wrapSyscallError(, ), 
}