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