golang.org/x/sys@v0.20.1-0.20240517151509-673e0f94c16d/unix/types_darwin.go (about)

     1  // Copyright 2009 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 ignore
     6  
     7  /*
     8  Input to cgo -godefs.  See README.md
     9  */
    10  
    11  // +godefs map struct_in_addr [4]byte /* in_addr */
    12  // +godefs map struct_in6_addr [16]byte /* in6_addr */
    13  
    14  package unix
    15  
    16  /*
    17  #define __DARWIN_UNIX03 0
    18  #define KERNEL 1
    19  #define _DARWIN_USE_64_BIT_INODE
    20  #include <dirent.h>
    21  #include <fcntl.h>
    22  #include <poll.h>
    23  #include <stdint.h>
    24  #include <signal.h>
    25  #include <termios.h>
    26  #include <unistd.h>
    27  #include <mach/mach.h>
    28  #include <mach/message.h>
    29  #include <sys/event.h>
    30  #include <sys/ipc.h>
    31  #include <sys/kern_control.h>
    32  #include <sys/mman.h>
    33  #include <sys/mount.h>
    34  #include <sys/param.h>
    35  #include <sys/ptrace.h>
    36  #include <sys/resource.h>
    37  #include <sys/select.h>
    38  #include <sys/shm.h>
    39  #include <sys/signal.h>
    40  #include <sys/socket.h>
    41  #include <sys/stat.h>
    42  #include <sys/sysctl.h>
    43  #include <sys/time.h>
    44  #include <sys/types.h>
    45  #include <sys/ucred.h>
    46  #include <sys/uio.h>
    47  #include <sys/un.h>
    48  #include <sys/utsname.h>
    49  #include <sys/wait.h>
    50  #include <sys/vsock.h>
    51  #include <net/bpf.h>
    52  #include <net/if.h>
    53  #include <net/if_dl.h>
    54  #include <net/if_var.h>
    55  #include <net/route.h>
    56  #include <netinet/in.h>
    57  #include <netinet/icmp6.h>
    58  #include <netinet/tcp.h>
    59  
    60  enum {
    61  	sizeofPtr = sizeof(void*),
    62  };
    63  
    64  union sockaddr_all {
    65  	struct sockaddr s1;	// this one gets used for fields
    66  	struct sockaddr_in s2;	// these pad it out
    67  	struct sockaddr_in6 s3;
    68  	struct sockaddr_un s4;
    69  	struct sockaddr_dl s5;
    70  };
    71  
    72  struct sockaddr_any {
    73  	struct sockaddr addr;
    74  	char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)];
    75  };
    76  
    77  #if defined(__x86_64__)
    78  typedef struct stat64 stat_t;
    79  typedef struct statfs64 statfs_t;
    80  #else // __arm__
    81  typedef struct stat stat_t;
    82  typedef struct statfs statfs_t;
    83  #endif
    84  */
    85  import "C"
    86  
    87  // Machine characteristics
    88  
    89  const (
    90  	SizeofPtr      = C.sizeofPtr
    91  	SizeofShort    = C.sizeof_short
    92  	SizeofInt      = C.sizeof_int
    93  	SizeofLong     = C.sizeof_long
    94  	SizeofLongLong = C.sizeof_longlong
    95  )
    96  
    97  // Basic types
    98  
    99  type (
   100  	_C_short     C.short
   101  	_C_int       C.int
   102  	_C_long      C.long
   103  	_C_long_long C.longlong
   104  )
   105  
   106  // Time
   107  
   108  type Timespec C.struct_timespec
   109  
   110  type Timeval C.struct_timeval
   111  
   112  type Timeval32 C.struct_timeval32
   113  
   114  // Processes
   115  
   116  type Rusage C.struct_rusage
   117  
   118  type Rlimit C.struct_rlimit
   119  
   120  type _Gid_t C.gid_t
   121  
   122  // Files
   123  
   124  type Stat_t C.stat_t
   125  
   126  type Statfs_t C.statfs_t
   127  
   128  type Flock_t C.struct_flock
   129  
   130  type Fstore_t C.struct_fstore
   131  
   132  type Radvisory_t C.struct_radvisory
   133  
   134  type Fbootstraptransfer_t C.struct_fbootstraptransfer
   135  
   136  type Log2phys_t C.struct_log2phys
   137  
   138  type Fsid C.struct_fsid
   139  
   140  type Dirent C.struct_dirent
   141  
   142  type Attrlist C.struct_attrlist
   143  
   144  // File system limits
   145  
   146  const (
   147  	PathMax = C.PATH_MAX
   148  )
   149  
   150  // Sockets
   151  
   152  type RawSockaddrInet4 C.struct_sockaddr_in
   153  
   154  type RawSockaddrInet6 C.struct_sockaddr_in6
   155  
   156  type RawSockaddrUnix C.struct_sockaddr_un
   157  
   158  type RawSockaddrDatalink C.struct_sockaddr_dl
   159  
   160  type RawSockaddr C.struct_sockaddr
   161  
   162  type RawSockaddrAny C.struct_sockaddr_any
   163  
   164  type RawSockaddrCtl C.struct_sockaddr_ctl
   165  
   166  type RawSockaddrVM C.struct_sockaddr_vm
   167  
   168  type XVSockPCB C.struct_xvsockpcb
   169  
   170  type XSocket C.struct_xsocket
   171  
   172  type XSocket64 C.struct_xsocket64
   173  
   174  type XSockbuf C.struct_xsockbuf
   175  
   176  type XVSockPgen C.struct_xvsockpgen
   177  
   178  type _Socklen C.socklen_t
   179  
   180  type Xucred C.struct_xucred
   181  
   182  type Linger C.struct_linger
   183  
   184  type Iovec C.struct_iovec
   185  
   186  type IPMreq C.struct_ip_mreq
   187  
   188  type IPMreqn C.struct_ip_mreqn
   189  
   190  type IPv6Mreq C.struct_ipv6_mreq
   191  
   192  type Msghdr C.struct_msghdr
   193  
   194  type Cmsghdr C.struct_cmsghdr
   195  
   196  type Inet4Pktinfo C.struct_in_pktinfo
   197  
   198  type Inet6Pktinfo C.struct_in6_pktinfo
   199  
   200  type IPv6MTUInfo C.struct_ip6_mtuinfo
   201  
   202  type ICMPv6Filter C.struct_icmp6_filter
   203  
   204  type TCPConnectionInfo C.struct_tcp_connection_info
   205  
   206  const (
   207  	SizeofSockaddrInet4     = C.sizeof_struct_sockaddr_in
   208  	SizeofSockaddrInet6     = C.sizeof_struct_sockaddr_in6
   209  	SizeofSockaddrAny       = C.sizeof_struct_sockaddr_any
   210  	SizeofSockaddrUnix      = C.sizeof_struct_sockaddr_un
   211  	SizeofSockaddrDatalink  = C.sizeof_struct_sockaddr_dl
   212  	SizeofSockaddrCtl       = C.sizeof_struct_sockaddr_ctl
   213  	SizeofSockaddrVM        = C.sizeof_struct_sockaddr_vm
   214  	SizeofXvsockpcb         = C.sizeof_struct_xvsockpcb
   215  	SizeofXSocket           = C.sizeof_struct_xsocket
   216  	SizeofXSockbuf          = C.sizeof_struct_xsockbuf
   217  	SizeofXVSockPgen        = C.sizeof_struct_xvsockpgen
   218  	SizeofXucred            = C.sizeof_struct_xucred
   219  	SizeofLinger            = C.sizeof_struct_linger
   220  	SizeofIovec             = C.sizeof_struct_iovec
   221  	SizeofIPMreq            = C.sizeof_struct_ip_mreq
   222  	SizeofIPMreqn           = C.sizeof_struct_ip_mreqn
   223  	SizeofIPv6Mreq          = C.sizeof_struct_ipv6_mreq
   224  	SizeofMsghdr            = C.sizeof_struct_msghdr
   225  	SizeofCmsghdr           = C.sizeof_struct_cmsghdr
   226  	SizeofInet4Pktinfo      = C.sizeof_struct_in_pktinfo
   227  	SizeofInet6Pktinfo      = C.sizeof_struct_in6_pktinfo
   228  	SizeofIPv6MTUInfo       = C.sizeof_struct_ip6_mtuinfo
   229  	SizeofICMPv6Filter      = C.sizeof_struct_icmp6_filter
   230  	SizeofTCPConnectionInfo = C.sizeof_struct_tcp_connection_info
   231  )
   232  
   233  // Ptrace requests
   234  
   235  const (
   236  	PTRACE_TRACEME = C.PT_TRACE_ME
   237  	PTRACE_CONT    = C.PT_CONTINUE
   238  	PTRACE_KILL    = C.PT_KILL
   239  )
   240  
   241  // Events (kqueue, kevent)
   242  
   243  type Kevent_t C.struct_kevent
   244  
   245  // Select
   246  
   247  type FdSet C.fd_set
   248  
   249  // Routing and interface messages
   250  
   251  const (
   252  	SizeofIfMsghdr    = C.sizeof_struct_if_msghdr
   253  	SizeofIfData      = C.sizeof_struct_if_data
   254  	SizeofIfaMsghdr   = C.sizeof_struct_ifa_msghdr
   255  	SizeofIfmaMsghdr  = C.sizeof_struct_ifma_msghdr
   256  	SizeofIfmaMsghdr2 = C.sizeof_struct_ifma_msghdr2
   257  	SizeofRtMsghdr    = C.sizeof_struct_rt_msghdr
   258  	SizeofRtMetrics   = C.sizeof_struct_rt_metrics
   259  )
   260  
   261  type IfMsghdr C.struct_if_msghdr
   262  
   263  type IfData C.struct_if_data
   264  
   265  type IfaMsghdr C.struct_ifa_msghdr
   266  
   267  type IfmaMsghdr C.struct_ifma_msghdr
   268  
   269  type IfmaMsghdr2 C.struct_ifma_msghdr2
   270  
   271  type RtMsghdr C.struct_rt_msghdr
   272  
   273  type RtMetrics C.struct_rt_metrics
   274  
   275  // Berkeley packet filter
   276  
   277  const (
   278  	SizeofBpfVersion = C.sizeof_struct_bpf_version
   279  	SizeofBpfStat    = C.sizeof_struct_bpf_stat
   280  	SizeofBpfProgram = C.sizeof_struct_bpf_program
   281  	SizeofBpfInsn    = C.sizeof_struct_bpf_insn
   282  	SizeofBpfHdr     = C.sizeof_struct_bpf_hdr
   283  )
   284  
   285  type BpfVersion C.struct_bpf_version
   286  
   287  type BpfStat C.struct_bpf_stat
   288  
   289  type BpfProgram C.struct_bpf_program
   290  
   291  type BpfInsn C.struct_bpf_insn
   292  
   293  type BpfHdr C.struct_bpf_hdr
   294  
   295  // Terminal handling
   296  
   297  type Termios C.struct_termios
   298  
   299  type Winsize C.struct_winsize
   300  
   301  // fchmodat-like syscalls.
   302  
   303  const (
   304  	AT_FDCWD            = C.AT_FDCWD
   305  	AT_REMOVEDIR        = C.AT_REMOVEDIR
   306  	AT_SYMLINK_FOLLOW   = C.AT_SYMLINK_FOLLOW
   307  	AT_SYMLINK_NOFOLLOW = C.AT_SYMLINK_NOFOLLOW
   308  	AT_EACCESS          = C.AT_EACCESS
   309  )
   310  
   311  // poll
   312  
   313  type PollFd C.struct_pollfd
   314  
   315  const (
   316  	POLLERR    = C.POLLERR
   317  	POLLHUP    = C.POLLHUP
   318  	POLLIN     = C.POLLIN
   319  	POLLNVAL   = C.POLLNVAL
   320  	POLLOUT    = C.POLLOUT
   321  	POLLPRI    = C.POLLPRI
   322  	POLLRDBAND = C.POLLRDBAND
   323  	POLLRDNORM = C.POLLRDNORM
   324  	POLLWRBAND = C.POLLWRBAND
   325  	POLLWRNORM = C.POLLWRNORM
   326  )
   327  
   328  // uname
   329  
   330  type Utsname C.struct_utsname
   331  
   332  // Clockinfo
   333  
   334  const SizeofClockinfo = C.sizeof_struct_clockinfo
   335  
   336  type Clockinfo C.struct_clockinfo
   337  
   338  // ctl_info
   339  
   340  type CtlInfo C.struct_ctl_info
   341  
   342  // KinfoProc
   343  
   344  const SizeofKinfoProc = C.sizeof_struct_kinfo_proc
   345  
   346  type Eproc C.struct_eproc
   347  
   348  type ExternProc C.struct_extern_proc
   349  
   350  type Itimerval C.struct_itimerval
   351  
   352  type KinfoProc C.struct_kinfo_proc
   353  
   354  type Vmspace C.struct_vmspace
   355  
   356  type Pcred C.struct__pcred
   357  
   358  type Ucred C.struct__ucred
   359  
   360  // shm
   361  
   362  type SysvIpcPerm C.struct_ipc_perm
   363  type SysvShmDesc C.struct_shmid_ds
   364  
   365  const (
   366  	IPC_CREAT   = C.IPC_CREAT
   367  	IPC_EXCL    = C.IPC_EXCL
   368  	IPC_NOWAIT  = C.IPC_NOWAIT
   369  	IPC_PRIVATE = C.IPC_PRIVATE
   370  )
   371  
   372  const (
   373  	IPC_RMID = C.IPC_RMID
   374  	IPC_SET  = C.IPC_SET
   375  	IPC_STAT = C.IPC_STAT
   376  )
   377  
   378  const (
   379  	SHM_RDONLY = C.SHM_RDONLY
   380  	SHM_RND    = C.SHM_RND
   381  )