github.com/alexis81/domosgo@v0.0.0-20191016125037-5aee90a434af/Domos/src/golang.org/x/sys/unix/types_freebsd.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 KERNEL
    18  #include <dirent.h>
    19  #include <fcntl.h>
    20  #include <poll.h>
    21  #include <signal.h>
    22  #include <termios.h>
    23  #include <stdio.h>
    24  #include <unistd.h>
    25  #include <sys/capability.h>
    26  #include <sys/event.h>
    27  #include <sys/mman.h>
    28  #include <sys/mount.h>
    29  #include <sys/param.h>
    30  #include <sys/ptrace.h>
    31  #include <sys/resource.h>
    32  #include <sys/select.h>
    33  #include <sys/signal.h>
    34  #include <sys/socket.h>
    35  #include <sys/stat.h>
    36  #include <sys/time.h>
    37  #include <sys/types.h>
    38  #include <sys/un.h>
    39  #include <sys/utsname.h>
    40  #include <sys/wait.h>
    41  #include <net/bpf.h>
    42  #include <net/if.h>
    43  #include <net/if_dl.h>
    44  #include <net/route.h>
    45  #include <netinet/in.h>
    46  #include <netinet/icmp6.h>
    47  #include <netinet/tcp.h>
    48  
    49  enum {
    50  	sizeofPtr = sizeof(void*),
    51  };
    52  
    53  union sockaddr_all {
    54  	struct sockaddr s1;	// this one gets used for fields
    55  	struct sockaddr_in s2;	// these pad it out
    56  	struct sockaddr_in6 s3;
    57  	struct sockaddr_un s4;
    58  	struct sockaddr_dl s5;
    59  };
    60  
    61  struct sockaddr_any {
    62  	struct sockaddr addr;
    63  	char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)];
    64  };
    65  
    66  // This structure is a duplicate of stat on FreeBSD 8-STABLE.
    67  // See /usr/include/sys/stat.h.
    68  struct stat8 {
    69  #undef st_atimespec	st_atim
    70  #undef st_mtimespec	st_mtim
    71  #undef st_ctimespec	st_ctim
    72  #undef st_birthtimespec	st_birthtim
    73  	__dev_t   st_dev;
    74  	ino_t     st_ino;
    75  	mode_t    st_mode;
    76  	nlink_t   st_nlink;
    77  	uid_t     st_uid;
    78  	gid_t     st_gid;
    79  	__dev_t   st_rdev;
    80  #if __BSD_VISIBLE
    81  	struct  timespec st_atimespec;
    82  	struct  timespec st_mtimespec;
    83  	struct  timespec st_ctimespec;
    84  #else
    85  	time_t    st_atime;
    86  	long      __st_atimensec;
    87  	time_t    st_mtime;
    88  	long      __st_mtimensec;
    89  	time_t    st_ctime;
    90  	long      __st_ctimensec;
    91  #endif
    92  	off_t     st_size;
    93  	blkcnt_t st_blocks;
    94  	blksize_t st_blksize;
    95  	fflags_t  st_flags;
    96  	__uint32_t st_gen;
    97  	__int32_t st_lspare;
    98  #if __BSD_VISIBLE
    99  	struct timespec st_birthtimespec;
   100  	unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec));
   101  	unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec));
   102  #else
   103  	time_t    st_birthtime;
   104  	long      st_birthtimensec;
   105  	unsigned int :(8 / 2) * (16 - (int)sizeof(struct __timespec));
   106  	unsigned int :(8 / 2) * (16 - (int)sizeof(struct __timespec));
   107  #endif
   108  };
   109  
   110  // This structure is a duplicate of if_data on FreeBSD 8-STABLE.
   111  // See /usr/include/net/if.h.
   112  struct if_data8 {
   113  	u_char  ifi_type;
   114  	u_char  ifi_physical;
   115  	u_char  ifi_addrlen;
   116  	u_char  ifi_hdrlen;
   117  	u_char  ifi_link_state;
   118  	u_char  ifi_spare_char1;
   119  	u_char  ifi_spare_char2;
   120  	u_char  ifi_datalen;
   121  	u_long  ifi_mtu;
   122  	u_long  ifi_metric;
   123  	u_long  ifi_baudrate;
   124  	u_long  ifi_ipackets;
   125  	u_long  ifi_ierrors;
   126  	u_long  ifi_opackets;
   127  	u_long  ifi_oerrors;
   128  	u_long  ifi_collisions;
   129  	u_long  ifi_ibytes;
   130  	u_long  ifi_obytes;
   131  	u_long  ifi_imcasts;
   132  	u_long  ifi_omcasts;
   133  	u_long  ifi_iqdrops;
   134  	u_long  ifi_noproto;
   135  	u_long  ifi_hwassist;
   136  // FIXME: these are now unions, so maybe need to change definitions?
   137  #undef ifi_epoch
   138  	time_t  ifi_epoch;
   139  #undef ifi_lastchange
   140  	struct  timeval ifi_lastchange;
   141  };
   142  
   143  // This structure is a duplicate of if_msghdr on FreeBSD 8-STABLE.
   144  // See /usr/include/net/if.h.
   145  struct if_msghdr8 {
   146  	u_short ifm_msglen;
   147  	u_char  ifm_version;
   148  	u_char  ifm_type;
   149  	int     ifm_addrs;
   150  	int     ifm_flags;
   151  	u_short ifm_index;
   152  	struct  if_data8 ifm_data;
   153  };
   154  */
   155  import "C"
   156  
   157  // Machine characteristics; for internal use.
   158  
   159  const (
   160  	sizeofPtr      = C.sizeofPtr
   161  	sizeofShort    = C.sizeof_short
   162  	sizeofInt      = C.sizeof_int
   163  	sizeofLong     = C.sizeof_long
   164  	sizeofLongLong = C.sizeof_longlong
   165  )
   166  
   167  // Basic types
   168  
   169  type (
   170  	_C_short     C.short
   171  	_C_int       C.int
   172  	_C_long      C.long
   173  	_C_long_long C.longlong
   174  )
   175  
   176  // Time
   177  
   178  type Timespec C.struct_timespec
   179  
   180  type Timeval C.struct_timeval
   181  
   182  // Processes
   183  
   184  type Rusage C.struct_rusage
   185  
   186  type Rlimit C.struct_rlimit
   187  
   188  type _Gid_t C.gid_t
   189  
   190  // Files
   191  
   192  const ( // Directory mode bits
   193  	S_IFMT   = C.S_IFMT
   194  	S_IFIFO  = C.S_IFIFO
   195  	S_IFCHR  = C.S_IFCHR
   196  	S_IFDIR  = C.S_IFDIR
   197  	S_IFBLK  = C.S_IFBLK
   198  	S_IFREG  = C.S_IFREG
   199  	S_IFLNK  = C.S_IFLNK
   200  	S_IFSOCK = C.S_IFSOCK
   201  	S_ISUID  = C.S_ISUID
   202  	S_ISGID  = C.S_ISGID
   203  	S_ISVTX  = C.S_ISVTX
   204  	S_IRUSR  = C.S_IRUSR
   205  	S_IWUSR  = C.S_IWUSR
   206  	S_IXUSR  = C.S_IXUSR
   207  )
   208  
   209  type Stat_t C.struct_stat8
   210  
   211  type Statfs_t C.struct_statfs
   212  
   213  type Flock_t C.struct_flock
   214  
   215  type Dirent C.struct_dirent
   216  
   217  type Fsid C.struct_fsid
   218  
   219  // File system limits
   220  
   221  const (
   222  	PathMax = C.PATH_MAX
   223  )
   224  
   225  // Advice to Fadvise
   226  
   227  const (
   228  	FADV_NORMAL     = C.POSIX_FADV_NORMAL
   229  	FADV_RANDOM     = C.POSIX_FADV_RANDOM
   230  	FADV_SEQUENTIAL = C.POSIX_FADV_SEQUENTIAL
   231  	FADV_WILLNEED   = C.POSIX_FADV_WILLNEED
   232  	FADV_DONTNEED   = C.POSIX_FADV_DONTNEED
   233  	FADV_NOREUSE    = C.POSIX_FADV_NOREUSE
   234  )
   235  
   236  // Sockets
   237  
   238  type RawSockaddrInet4 C.struct_sockaddr_in
   239  
   240  type RawSockaddrInet6 C.struct_sockaddr_in6
   241  
   242  type RawSockaddrUnix C.struct_sockaddr_un
   243  
   244  type RawSockaddrDatalink C.struct_sockaddr_dl
   245  
   246  type RawSockaddr C.struct_sockaddr
   247  
   248  type RawSockaddrAny C.struct_sockaddr_any
   249  
   250  type _Socklen C.socklen_t
   251  
   252  type Linger C.struct_linger
   253  
   254  type Iovec C.struct_iovec
   255  
   256  type IPMreq C.struct_ip_mreq
   257  
   258  type IPMreqn C.struct_ip_mreqn
   259  
   260  type IPv6Mreq C.struct_ipv6_mreq
   261  
   262  type Msghdr C.struct_msghdr
   263  
   264  type Cmsghdr C.struct_cmsghdr
   265  
   266  type Inet6Pktinfo C.struct_in6_pktinfo
   267  
   268  type IPv6MTUInfo C.struct_ip6_mtuinfo
   269  
   270  type ICMPv6Filter C.struct_icmp6_filter
   271  
   272  const (
   273  	SizeofSockaddrInet4    = C.sizeof_struct_sockaddr_in
   274  	SizeofSockaddrInet6    = C.sizeof_struct_sockaddr_in6
   275  	SizeofSockaddrAny      = C.sizeof_struct_sockaddr_any
   276  	SizeofSockaddrUnix     = C.sizeof_struct_sockaddr_un
   277  	SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl
   278  	SizeofLinger           = C.sizeof_struct_linger
   279  	SizeofIPMreq           = C.sizeof_struct_ip_mreq
   280  	SizeofIPMreqn          = C.sizeof_struct_ip_mreqn
   281  	SizeofIPv6Mreq         = C.sizeof_struct_ipv6_mreq
   282  	SizeofMsghdr           = C.sizeof_struct_msghdr
   283  	SizeofCmsghdr          = C.sizeof_struct_cmsghdr
   284  	SizeofInet6Pktinfo     = C.sizeof_struct_in6_pktinfo
   285  	SizeofIPv6MTUInfo      = C.sizeof_struct_ip6_mtuinfo
   286  	SizeofICMPv6Filter     = C.sizeof_struct_icmp6_filter
   287  )
   288  
   289  // Ptrace requests
   290  
   291  const (
   292  	PTRACE_TRACEME = C.PT_TRACE_ME
   293  	PTRACE_CONT    = C.PT_CONTINUE
   294  	PTRACE_KILL    = C.PT_KILL
   295  )
   296  
   297  // Events (kqueue, kevent)
   298  
   299  type Kevent_t C.struct_kevent
   300  
   301  // Select
   302  
   303  type FdSet C.fd_set
   304  
   305  // Routing and interface messages
   306  
   307  const (
   308  	sizeofIfMsghdr         = C.sizeof_struct_if_msghdr
   309  	SizeofIfMsghdr         = C.sizeof_struct_if_msghdr8
   310  	sizeofIfData           = C.sizeof_struct_if_data
   311  	SizeofIfData           = C.sizeof_struct_if_data8
   312  	SizeofIfaMsghdr        = C.sizeof_struct_ifa_msghdr
   313  	SizeofIfmaMsghdr       = C.sizeof_struct_ifma_msghdr
   314  	SizeofIfAnnounceMsghdr = C.sizeof_struct_if_announcemsghdr
   315  	SizeofRtMsghdr         = C.sizeof_struct_rt_msghdr
   316  	SizeofRtMetrics        = C.sizeof_struct_rt_metrics
   317  )
   318  
   319  type ifMsghdr C.struct_if_msghdr
   320  
   321  type IfMsghdr C.struct_if_msghdr8
   322  
   323  type ifData C.struct_if_data
   324  
   325  type IfData C.struct_if_data8
   326  
   327  type IfaMsghdr C.struct_ifa_msghdr
   328  
   329  type IfmaMsghdr C.struct_ifma_msghdr
   330  
   331  type IfAnnounceMsghdr C.struct_if_announcemsghdr
   332  
   333  type RtMsghdr C.struct_rt_msghdr
   334  
   335  type RtMetrics C.struct_rt_metrics
   336  
   337  // Berkeley packet filter
   338  
   339  const (
   340  	SizeofBpfVersion    = C.sizeof_struct_bpf_version
   341  	SizeofBpfStat       = C.sizeof_struct_bpf_stat
   342  	SizeofBpfZbuf       = C.sizeof_struct_bpf_zbuf
   343  	SizeofBpfProgram    = C.sizeof_struct_bpf_program
   344  	SizeofBpfInsn       = C.sizeof_struct_bpf_insn
   345  	SizeofBpfHdr        = C.sizeof_struct_bpf_hdr
   346  	SizeofBpfZbufHeader = C.sizeof_struct_bpf_zbuf_header
   347  )
   348  
   349  type BpfVersion C.struct_bpf_version
   350  
   351  type BpfStat C.struct_bpf_stat
   352  
   353  type BpfZbuf C.struct_bpf_zbuf
   354  
   355  type BpfProgram C.struct_bpf_program
   356  
   357  type BpfInsn C.struct_bpf_insn
   358  
   359  type BpfHdr C.struct_bpf_hdr
   360  
   361  type BpfZbufHeader C.struct_bpf_zbuf_header
   362  
   363  // Terminal handling
   364  
   365  type Termios C.struct_termios
   366  
   367  type Winsize C.struct_winsize
   368  
   369  // fchmodat-like syscalls.
   370  
   371  const (
   372  	AT_FDCWD            = C.AT_FDCWD
   373  	AT_REMOVEDIR        = C.AT_REMOVEDIR
   374  	AT_SYMLINK_FOLLOW   = C.AT_SYMLINK_FOLLOW
   375  	AT_SYMLINK_NOFOLLOW = C.AT_SYMLINK_NOFOLLOW
   376  )
   377  
   378  // poll
   379  
   380  type PollFd C.struct_pollfd
   381  
   382  const (
   383  	POLLERR      = C.POLLERR
   384  	POLLHUP      = C.POLLHUP
   385  	POLLIN       = C.POLLIN
   386  	POLLINIGNEOF = C.POLLINIGNEOF
   387  	POLLNVAL     = C.POLLNVAL
   388  	POLLOUT      = C.POLLOUT
   389  	POLLPRI      = C.POLLPRI
   390  	POLLRDBAND   = C.POLLRDBAND
   391  	POLLRDNORM   = C.POLLRDNORM
   392  	POLLWRBAND   = C.POLLWRBAND
   393  	POLLWRNORM   = C.POLLWRNORM
   394  )
   395  
   396  // Capabilities
   397  
   398  type CapRights C.struct_cap_rights
   399  
   400  // Uname
   401  
   402  type Utsname C.struct_utsname