github.com/binkynet/BinkyNet@v1.12.1-0.20240421190447-da4e34c20be0/proto_vendor/golang.org/x/net/internal/socket/sys.go (about)

     1  // Copyright 2017 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  package socket
     6  
     7  import (
     8  	"encoding/binary"
     9  	"unsafe"
    10  )
    11  
    12  var (
    13  	// NativeEndian is the machine native endian implementation of
    14  	// ByteOrder.
    15  	NativeEndian binary.ByteOrder
    16  
    17  	kernelAlign int
    18  )
    19  
    20  func init() {
    21  	i := uint32(1)
    22  	b := (*[4]byte)(unsafe.Pointer(&i))
    23  	if b[0] == 1 {
    24  		NativeEndian = binary.LittleEndian
    25  	} else {
    26  		NativeEndian = binary.BigEndian
    27  	}
    28  	kernelAlign = probeProtocolStack()
    29  }
    30  
    31  func roundup(l int) int {
    32  	return (l + kernelAlign - 1) &^ (kernelAlign - 1)
    33  }