github.com/Andyfoo/golang/x/sys@v0.0.0-20190901054642-57c1bf301704/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  // +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
    19  #define _DARWIN_USE_64_BIT_INODE
    20  #include <dirent.h>
    21  #include <fcntl.h>
    22  #include <poll.h>
    23  #include <signal.h>
    24  #include <termios.h>
    25  #include <unistd.h>
    26  #include <mach/mach.h>
    27  #include <mach/message.h>
    28  #include <sys/event.h>
    29  #include <sys/mman.h>
    30  #include <sys/mount.h>
    31  #include <sys/param.h>
    32  #include <sys/ptrace.h>
    33  #include <sys/resource.h>
    34  #include <sys/select.h>
    35  #include <sys/signal.h>
    36  #include <sys/socket.h>
    37  #include <sys/stat.h>
    38  #include <sys/time.h>
    39  #include <sys/types.h>
    40  #include <sys/uio.h>
    41  #include <sys/un.h>
    42  #include <sys/utsname.h>
    43  #include <sys/wait.h>
    44  #include <net/bpf.h>
    45  #include <net/if.h>
    46  #include <net/if_dl.h>
    47  #include <net/if_var.h>
    48  #include <net/route.h>
    49  #include <netinet/in.h>
    50  #include <netinet/icmp6.h>
    51  #include <netinet/tcp.h>
    52  
    53  enum {
    54  	sizeofPtr = sizeof(void*),
    55  };
    56  
    57  union sockaddr_all {
    58  	struct sockaddr s1;	// this one gets used for fields
    59  	struct sockaddr_in s2;	// these pad it out
    60  	struct sockaddr_in6 s3;
    61  	struct sockaddr_un s4;
    62  	struct sockaddr_dl s5;
    63  };
    64  
    65  struct sockaddr_any {
    66  	struct sockaddr addr;
    67  	char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)];
    68  };
    69  
    70  */
    71  import "C"
    72  
    73  // Machine characteristics
    74  
    75  const (
    76  	SizeofPtr      = C.sizeofPtr
    77  	SizeofShort    = C.sizeof_short
    78  	SizeofInt      = C.sizeof_int
    79  	SizeofLong     = C.sizeof_long
    80  	SizeofLongLong = C.sizeof_longlong
    81  )
    82  
    83  // Basic types
    84  
    85  type (
    86  	_C_short     C.short
    87  	_C_int       C.int
    88  	_C_long      C.long
    89  	_C_long_long C.longlong
    90  )
    91  
    92  // Time
    93  
    94  type Timespec C.struct_timespec
    95  
    96  type Timeval C.struct_timeval
    97  
    98  type Timeval32 C.struct_timeval32
    99  
   100  // Processes
   101  
   102  type Rusage C.struct_rusage
   103  
   104  type Rlimit C.struct_rlimit
   105  
   106  type _Gid_t C.gid_t
   107  
   108  // Files
   109  
   110  type Stat_t C.struct_stat64
   111  
   112  type Statfs_t C.struct_statfs64
   113  
   114  type Flock_t C.struct_flock
   115  
   116  type Fstore_t C.struct_fstore
   117  
   118  type Radvisory_t C.struct_radvisory
   119  
   120  type Fbootstraptransfer_t C.struct_fbootstraptransfer
   121  
   122  type Log2phys_t C.struct_log2phys
   123  
   124  type Fsid C.struct_fsid
   125  
   126  type Dirent C.struct_dirent
   127  
   128  // Sockets
   129  
   130  type RawSockaddrInet4 C.struct_sockaddr_in
   131  
   132  type RawSockaddrInet6 C.struct_sockaddr_in6
   133  
   134  type RawSockaddrUnix C.struct_sockaddr_un
   135  
   136  type RawSockaddrDatalink C.struct_sockaddr_dl
   137  
   138  type RawSockaddr C.struct_sockaddr
   139  
   140  type RawSockaddrAny C.struct_sockaddr_any
   141  
   142  type _Socklen C.socklen_t
   143  
   144  type Linger C.struct_linger
   145  
   146  type Iovec C.struct_iovec
   147  
   148  type IPMreq C.struct_ip_mreq
   149  
   150  type IPv6Mreq C.struct_ipv6_mreq
   151  
   152  type Msghdr C.struct_msghdr
   153  
   154  type Cmsghdr C.struct_cmsghdr
   155  
   156  type Inet4Pktinfo C.struct_in_pktinfo
   157  
   158  type Inet6Pktinfo C.struct_in6_pktinfo
   159  
   160  type IPv6MTUInfo C.struct_ip6_mtuinfo
   161  
   162  type ICMPv6Filter C.struct_icmp6_filter
   163  
   164  const (
   165  	SizeofSockaddrInet4    = C.sizeof_struct_sockaddr_in
   166  	SizeofSockaddrInet6    = C.sizeof_struct_sockaddr_in6
   167  	SizeofSockaddrAny      = C.sizeof_struct_sockaddr_any
   168  	SizeofSockaddrUnix     = C.sizeof_struct_sockaddr_un
   169  	SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl
   170  	SizeofLinger           = C.sizeof_struct_linger
   171  	SizeofIPMreq           = C.sizeof_struct_ip_mreq
   172  	SizeofIPv6Mreq         = C.sizeof_struct_ipv6_mreq
   173  	SizeofMsghdr           = C.sizeof_struct_msghdr
   174  	SizeofCmsghdr          = C.sizeof_struct_cmsghdr
   175  	SizeofInet4Pktinfo     = C.sizeof_struct_in_pktinfo
   176  	SizeofInet6Pktinfo     = C.sizeof_struct_in6_pktinfo
   177  	SizeofIPv6MTUInfo      = C.sizeof_struct_ip6_mtuinfo
   178  	SizeofICMPv6Filter     = C.sizeof_struct_icmp6_filter
   179  )
   180  
   181  // Ptrace requests
   182  
   183  const (
   184  	PTRACE_TRACEME = C.PT_TRACE_ME
   185  	PTRACE_CONT    = C.PT_CONTINUE
   186  	PTRACE_KILL    = C.PT_KILL
   187  )
   188  
   189  // Events (kqueue, kevent)
   190  
   191  type Kevent_t C.struct_kevent
   192  
   193  // Select
   194  
   195  type FdSet C.fd_set
   196  
   197  // Routing and interface messages
   198  
   199  const (
   200  	SizeofIfMsghdr    = C.sizeof_struct_if_msghdr
   201  	SizeofIfData      = C.sizeof_struct_if_data
   202  	SizeofIfaMsghdr   = C.sizeof_struct_ifa_msghdr
   203  	SizeofIfmaMsghdr  = C.sizeof_struct_ifma_msghdr
   204  	SizeofIfmaMsghdr2 = C.sizeof_struct_ifma_msghdr2
   205  	SizeofRtMsghdr    = C.sizeof_struct_rt_msghdr
   206  	SizeofRtMetrics   = C.sizeof_struct_rt_metrics
   207  )
   208  
   209  type IfMsghdr C.struct_if_msghdr
   210  
   211  type IfData C.struct_if_data
   212  
   213  type IfaMsghdr C.struct_ifa_msghdr
   214  
   215  type IfmaMsghdr C.struct_ifma_msghdr
   216  
   217  type IfmaMsghdr2 C.struct_ifma_msghdr2
   218  
   219  type RtMsghdr C.struct_rt_msghdr
   220  
   221  type RtMetrics C.struct_rt_metrics
   222  
   223  // Berkeley packet filter
   224  
   225  const (
   226  	SizeofBpfVersion = C.sizeof_struct_bpf_version
   227  	SizeofBpfStat    = C.sizeof_struct_bpf_stat
   228  	SizeofBpfProgram = C.sizeof_struct_bpf_program
   229  	SizeofBpfInsn    = C.sizeof_struct_bpf_insn
   230  	SizeofBpfHdr     = C.sizeof_struct_bpf_hdr
   231  )
   232  
   233  type BpfVersion C.struct_bpf_version
   234  
   235  type BpfStat C.struct_bpf_stat
   236  
   237  type BpfProgram C.struct_bpf_program
   238  
   239  type BpfInsn C.struct_bpf_insn
   240  
   241  type BpfHdr C.struct_bpf_hdr
   242  
   243  // Terminal handling
   244  
   245  type Termios C.struct_termios
   246  
   247  type Winsize C.struct_winsize
   248  
   249  // fchmodat-like syscalls.
   250  
   251  const (
   252  	AT_FDCWD            = C.AT_FDCWD
   253  	AT_REMOVEDIR        = C.AT_REMOVEDIR
   254  	AT_SYMLINK_FOLLOW   = C.AT_SYMLINK_FOLLOW
   255  	AT_SYMLINK_NOFOLLOW = C.AT_SYMLINK_NOFOLLOW
   256  )
   257  
   258  // poll
   259  
   260  type PollFd C.struct_pollfd
   261  
   262  const (
   263  	POLLERR    = C.POLLERR
   264  	POLLHUP    = C.POLLHUP
   265  	POLLIN     = C.POLLIN
   266  	POLLNVAL   = C.POLLNVAL
   267  	POLLOUT    = C.POLLOUT
   268  	POLLPRI    = C.POLLPRI
   269  	POLLRDBAND = C.POLLRDBAND
   270  	POLLRDNORM = C.POLLRDNORM
   271  	POLLWRBAND = C.POLLWRBAND
   272  	POLLWRNORM = C.POLLWRNORM
   273  )
   274  
   275  // uname
   276  
   277  type Utsname C.struct_utsname
   278  
   279  // Clockinfo
   280  
   281  const SizeofClockinfo = C.sizeof_struct_clockinfo
   282  
   283  type Clockinfo C.struct_clockinfo