github.com/cilium/ebpf@v0.15.1-0.20240517100537-8079b37aa138/internal/unix/types_other.go (about)

     1  //go:build !linux
     2  
     3  package unix
     4  
     5  import (
     6  	"fmt"
     7  	"runtime"
     8  	"syscall"
     9  )
    10  
    11  var errNonLinux = fmt.Errorf("unsupported platform %s/%s", runtime.GOOS, runtime.GOARCH)
    12  
    13  // Errnos are distinct and non-zero.
    14  const (
    15  	ENOENT syscall.Errno = iota + 1
    16  	EEXIST
    17  	EAGAIN
    18  	ENOSPC
    19  	EINVAL
    20  	EINTR
    21  	EPERM
    22  	ESRCH
    23  	ENODEV
    24  	EBADF
    25  	E2BIG
    26  	EFAULT
    27  	EACCES
    28  	EILSEQ
    29  	EOPNOTSUPP
    30  	ESTALE
    31  )
    32  
    33  // Constants are distinct to avoid breaking switch statements.
    34  const (
    35  	BPF_F_NO_PREALLOC = iota
    36  	BPF_F_NUMA_NODE
    37  	BPF_F_RDONLY
    38  	BPF_F_WRONLY
    39  	BPF_F_RDONLY_PROG
    40  	BPF_F_WRONLY_PROG
    41  	BPF_F_SLEEPABLE
    42  	BPF_F_MMAPABLE
    43  	BPF_F_INNER_MAP
    44  	BPF_F_KPROBE_MULTI_RETURN
    45  	BPF_F_UPROBE_MULTI_RETURN
    46  	BPF_F_XDP_HAS_FRAGS
    47  	BPF_OBJ_NAME_LEN
    48  	BPF_TAG_SIZE
    49  	BPF_RINGBUF_BUSY_BIT
    50  	BPF_RINGBUF_DISCARD_BIT
    51  	BPF_RINGBUF_HDR_SZ
    52  	SYS_BPF
    53  	F_DUPFD_CLOEXEC
    54  	EPOLLIN
    55  	EPOLL_CTL_ADD
    56  	EPOLL_CLOEXEC
    57  	O_CLOEXEC
    58  	O_NONBLOCK
    59  	PROT_NONE
    60  	PROT_READ
    61  	PROT_WRITE
    62  	MAP_ANON
    63  	MAP_SHARED
    64  	MAP_PRIVATE
    65  	PERF_ATTR_SIZE_VER1
    66  	PERF_TYPE_SOFTWARE
    67  	PERF_TYPE_TRACEPOINT
    68  	PERF_COUNT_SW_BPF_OUTPUT
    69  	PERF_EVENT_IOC_DISABLE
    70  	PERF_EVENT_IOC_ENABLE
    71  	PERF_EVENT_IOC_SET_BPF
    72  	PerfBitWatermark
    73  	PerfBitWriteBackward
    74  	PERF_SAMPLE_RAW
    75  	PERF_FLAG_FD_CLOEXEC
    76  	RLIM_INFINITY
    77  	RLIMIT_MEMLOCK
    78  	BPF_STATS_RUN_TIME
    79  	PERF_RECORD_LOST
    80  	PERF_RECORD_SAMPLE
    81  	AT_FDCWD
    82  	RENAME_NOREPLACE
    83  	SO_ATTACH_BPF
    84  	SO_DETACH_BPF
    85  	SOL_SOCKET
    86  	SIGPROF
    87  	SIG_BLOCK
    88  	SIG_UNBLOCK
    89  	EM_NONE
    90  	EM_BPF
    91  	BPF_FS_MAGIC
    92  	TRACEFS_MAGIC
    93  	DEBUGFS_MAGIC
    94  	BPF_RB_NO_WAKEUP
    95  	BPF_RB_FORCE_WAKEUP
    96  	BPF_F_LOCK
    97  )
    98  
    99  type Statfs_t struct {
   100  	Type    int64
   101  	Bsize   int64
   102  	Blocks  uint64
   103  	Bfree   uint64
   104  	Bavail  uint64
   105  	Files   uint64
   106  	Ffree   uint64
   107  	Fsid    [2]int32
   108  	Namelen int64
   109  	Frsize  int64
   110  	Flags   int64
   111  	Spare   [4]int64
   112  }
   113  
   114  type Stat_t struct {
   115  	Dev     uint64
   116  	Ino     uint64
   117  	Nlink   uint64
   118  	Mode    uint32
   119  	Uid     uint32
   120  	Gid     uint32
   121  	_       int32
   122  	Rdev    uint64
   123  	Size    int64
   124  	Blksize int64
   125  	Blocks  int64
   126  }
   127  
   128  type Rlimit struct {
   129  	Cur uint64
   130  	Max uint64
   131  }
   132  
   133  type Signal int
   134  
   135  type Sigset_t struct {
   136  	Val [4]uint64
   137  }
   138  
   139  func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) {
   140  	return 0, 0, syscall.ENOTSUP
   141  }
   142  
   143  func PthreadSigmask(how int, set, oldset *Sigset_t) error {
   144  	return errNonLinux
   145  }
   146  
   147  func FcntlInt(fd uintptr, cmd, arg int) (int, error) {
   148  	return -1, errNonLinux
   149  }
   150  
   151  func IoctlSetInt(fd int, req uint, value int) error {
   152  	return errNonLinux
   153  }
   154  
   155  func Statfs(path string, buf *Statfs_t) error {
   156  	return errNonLinux
   157  }
   158  
   159  func Close(fd int) (err error) {
   160  	return errNonLinux
   161  }
   162  
   163  type EpollEvent struct {
   164  	Events uint32
   165  	Fd     int32
   166  	Pad    int32
   167  }
   168  
   169  func EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) {
   170  	return 0, errNonLinux
   171  }
   172  
   173  func EpollCtl(epfd int, op int, fd int, event *EpollEvent) (err error) {
   174  	return errNonLinux
   175  }
   176  
   177  func Eventfd(initval uint, flags int) (fd int, err error) {
   178  	return 0, errNonLinux
   179  }
   180  
   181  func Write(fd int, p []byte) (n int, err error) {
   182  	return 0, errNonLinux
   183  }
   184  
   185  func EpollCreate1(flag int) (fd int, err error) {
   186  	return 0, errNonLinux
   187  }
   188  
   189  type PerfEventMmapPage struct {
   190  	Version        uint32
   191  	Compat_version uint32
   192  	Lock           uint32
   193  	Index          uint32
   194  	Offset         int64
   195  	Time_enabled   uint64
   196  	Time_running   uint64
   197  	Capabilities   uint64
   198  	Pmc_width      uint16
   199  	Time_shift     uint16
   200  	Time_mult      uint32
   201  	Time_offset    uint64
   202  	Time_zero      uint64
   203  	Size           uint32
   204  
   205  	Data_head   uint64
   206  	Data_tail   uint64
   207  	Data_offset uint64
   208  	Data_size   uint64
   209  	Aux_head    uint64
   210  	Aux_tail    uint64
   211  	Aux_offset  uint64
   212  	Aux_size    uint64
   213  }
   214  
   215  func SetNonblock(fd int, nonblocking bool) (err error) {
   216  	return errNonLinux
   217  }
   218  
   219  func Mmap(fd int, offset int64, length int, prot int, flags int) (data []byte, err error) {
   220  	return []byte{}, errNonLinux
   221  }
   222  
   223  func Munmap(b []byte) (err error) {
   224  	return errNonLinux
   225  }
   226  
   227  type PerfEventAttr struct {
   228  	Type               uint32
   229  	Size               uint32
   230  	Config             uint64
   231  	Sample             uint64
   232  	Sample_type        uint64
   233  	Read_format        uint64
   234  	Bits               uint64
   235  	Wakeup             uint32
   236  	Bp_type            uint32
   237  	Ext1               uint64
   238  	Ext2               uint64
   239  	Branch_sample_type uint64
   240  	Sample_regs_user   uint64
   241  	Sample_stack_user  uint32
   242  	Clockid            int32
   243  	Sample_regs_intr   uint64
   244  	Aux_watermark      uint32
   245  	Sample_max_stack   uint16
   246  }
   247  
   248  func PerfEventOpen(attr *PerfEventAttr, pid int, cpu int, groupFd int, flags int) (fd int, err error) {
   249  	return 0, errNonLinux
   250  }
   251  
   252  type Utsname struct {
   253  	Release [65]byte
   254  	Version [65]byte
   255  }
   256  
   257  func Uname(buf *Utsname) (err error) {
   258  	return errNonLinux
   259  }
   260  
   261  func Getpid() int {
   262  	return -1
   263  }
   264  
   265  func Gettid() int {
   266  	return -1
   267  }
   268  
   269  func Tgkill(tgid int, tid int, sig syscall.Signal) (err error) {
   270  	return errNonLinux
   271  }
   272  
   273  func BytePtrFromString(s string) (*byte, error) {
   274  	return nil, errNonLinux
   275  }
   276  
   277  func ByteSliceToString(s []byte) string {
   278  	return ""
   279  }
   280  
   281  func Renameat2(olddirfd int, oldpath string, newdirfd int, newpath string, flags uint) error {
   282  	return errNonLinux
   283  }
   284  
   285  func Prlimit(pid, resource int, new, old *Rlimit) error {
   286  	return errNonLinux
   287  }
   288  
   289  func Open(path string, mode int, perm uint32) (int, error) {
   290  	return -1, errNonLinux
   291  }
   292  
   293  func Fstat(fd int, stat *Stat_t) error {
   294  	return errNonLinux
   295  }
   296  
   297  func SetsockoptInt(fd, level, opt, value int) error {
   298  	return errNonLinux
   299  }
   300  
   301  type CPUSet struct{}
   302  
   303  func (*CPUSet) Set(int) {}
   304  
   305  func SchedSetaffinity(pid int, set *CPUSet) error {
   306  	return errNonLinux
   307  }
   308  
   309  func SchedGetaffinity(pid int, set *CPUSet) error {
   310  	return errNonLinux
   311  }