예제 #1
0
func cgoNameinfoPTR(b []byte, sa *syscall.RawSockaddr, salen syscall.Socklen_t) (int, error) {
	syscall.Entersyscall()
	gerrno := libc_getnameinfo(sa, salen, &b[0], syscall.Size_t(len(b)), nil, 0, syscall.NI_NAMEREQD)
	syscall.Exitsyscall()
	var err error
	if gerrno == syscall.EAI_SYSTEM {
		errno := syscall.GetErrno()
		if errno != 0 {
			err = errno
		}
	}
	return gerrno, err
}
예제 #2
0
파일: lookup_unix.go 프로젝트: kraj/gcc
func (k bufferKind) initialSize() syscall.Size_t {
	sz, _ := syscall.Sysconf(int(k))
	if sz == -1 {
		// DragonFly and FreeBSD do not have _SC_GETPW_R_SIZE_MAX.
		// Additionally, not all Linux systems have it, either. For
		// example, the musl libc returns -1.
		return 1024
	}
	if !isSizeReasonable(int64(sz)) {
		// Truncate.  If this truly isn't enough, retryWithBuffer will error on the first run.
		return maxBufferSize
	}
	return syscall.Size_t(sz)
}