vendor/golang.org/x/sys/unix/types_freebsd.go
changeset 251 1c52a0eeb952
parent 250 c040f992052f
child 252 8399cd48111b
equal deleted inserted replaced
250:c040f992052f 251:1c52a0eeb952
     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 type Stat_t C.struct_stat8
       
   193 
       
   194 type Statfs_t C.struct_statfs
       
   195 
       
   196 type Flock_t C.struct_flock
       
   197 
       
   198 type Dirent C.struct_dirent
       
   199 
       
   200 type Fsid C.struct_fsid
       
   201 
       
   202 // File system limits
       
   203 
       
   204 const (
       
   205 	PathMax = C.PATH_MAX
       
   206 )
       
   207 
       
   208 // Advice to Fadvise
       
   209 
       
   210 const (
       
   211 	FADV_NORMAL     = C.POSIX_FADV_NORMAL
       
   212 	FADV_RANDOM     = C.POSIX_FADV_RANDOM
       
   213 	FADV_SEQUENTIAL = C.POSIX_FADV_SEQUENTIAL
       
   214 	FADV_WILLNEED   = C.POSIX_FADV_WILLNEED
       
   215 	FADV_DONTNEED   = C.POSIX_FADV_DONTNEED
       
   216 	FADV_NOREUSE    = C.POSIX_FADV_NOREUSE
       
   217 )
       
   218 
       
   219 // Sockets
       
   220 
       
   221 type RawSockaddrInet4 C.struct_sockaddr_in
       
   222 
       
   223 type RawSockaddrInet6 C.struct_sockaddr_in6
       
   224 
       
   225 type RawSockaddrUnix C.struct_sockaddr_un
       
   226 
       
   227 type RawSockaddrDatalink C.struct_sockaddr_dl
       
   228 
       
   229 type RawSockaddr C.struct_sockaddr
       
   230 
       
   231 type RawSockaddrAny C.struct_sockaddr_any
       
   232 
       
   233 type _Socklen C.socklen_t
       
   234 
       
   235 type Linger C.struct_linger
       
   236 
       
   237 type Iovec C.struct_iovec
       
   238 
       
   239 type IPMreq C.struct_ip_mreq
       
   240 
       
   241 type IPMreqn C.struct_ip_mreqn
       
   242 
       
   243 type IPv6Mreq C.struct_ipv6_mreq
       
   244 
       
   245 type Msghdr C.struct_msghdr
       
   246 
       
   247 type Cmsghdr C.struct_cmsghdr
       
   248 
       
   249 type Inet6Pktinfo C.struct_in6_pktinfo
       
   250 
       
   251 type IPv6MTUInfo C.struct_ip6_mtuinfo
       
   252 
       
   253 type ICMPv6Filter C.struct_icmp6_filter
       
   254 
       
   255 const (
       
   256 	SizeofSockaddrInet4    = C.sizeof_struct_sockaddr_in
       
   257 	SizeofSockaddrInet6    = C.sizeof_struct_sockaddr_in6
       
   258 	SizeofSockaddrAny      = C.sizeof_struct_sockaddr_any
       
   259 	SizeofSockaddrUnix     = C.sizeof_struct_sockaddr_un
       
   260 	SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl
       
   261 	SizeofLinger           = C.sizeof_struct_linger
       
   262 	SizeofIPMreq           = C.sizeof_struct_ip_mreq
       
   263 	SizeofIPMreqn          = C.sizeof_struct_ip_mreqn
       
   264 	SizeofIPv6Mreq         = C.sizeof_struct_ipv6_mreq
       
   265 	SizeofMsghdr           = C.sizeof_struct_msghdr
       
   266 	SizeofCmsghdr          = C.sizeof_struct_cmsghdr
       
   267 	SizeofInet6Pktinfo     = C.sizeof_struct_in6_pktinfo
       
   268 	SizeofIPv6MTUInfo      = C.sizeof_struct_ip6_mtuinfo
       
   269 	SizeofICMPv6Filter     = C.sizeof_struct_icmp6_filter
       
   270 )
       
   271 
       
   272 // Ptrace requests
       
   273 
       
   274 const (
       
   275 	PTRACE_TRACEME = C.PT_TRACE_ME
       
   276 	PTRACE_CONT    = C.PT_CONTINUE
       
   277 	PTRACE_KILL    = C.PT_KILL
       
   278 )
       
   279 
       
   280 // Events (kqueue, kevent)
       
   281 
       
   282 type Kevent_t C.struct_kevent
       
   283 
       
   284 // Select
       
   285 
       
   286 type FdSet C.fd_set
       
   287 
       
   288 // Routing and interface messages
       
   289 
       
   290 const (
       
   291 	sizeofIfMsghdr         = C.sizeof_struct_if_msghdr
       
   292 	SizeofIfMsghdr         = C.sizeof_struct_if_msghdr8
       
   293 	sizeofIfData           = C.sizeof_struct_if_data
       
   294 	SizeofIfData           = C.sizeof_struct_if_data8
       
   295 	SizeofIfaMsghdr        = C.sizeof_struct_ifa_msghdr
       
   296 	SizeofIfmaMsghdr       = C.sizeof_struct_ifma_msghdr
       
   297 	SizeofIfAnnounceMsghdr = C.sizeof_struct_if_announcemsghdr
       
   298 	SizeofRtMsghdr         = C.sizeof_struct_rt_msghdr
       
   299 	SizeofRtMetrics        = C.sizeof_struct_rt_metrics
       
   300 )
       
   301 
       
   302 type ifMsghdr C.struct_if_msghdr
       
   303 
       
   304 type IfMsghdr C.struct_if_msghdr8
       
   305 
       
   306 type ifData C.struct_if_data
       
   307 
       
   308 type IfData C.struct_if_data8
       
   309 
       
   310 type IfaMsghdr C.struct_ifa_msghdr
       
   311 
       
   312 type IfmaMsghdr C.struct_ifma_msghdr
       
   313 
       
   314 type IfAnnounceMsghdr C.struct_if_announcemsghdr
       
   315 
       
   316 type RtMsghdr C.struct_rt_msghdr
       
   317 
       
   318 type RtMetrics C.struct_rt_metrics
       
   319 
       
   320 // Berkeley packet filter
       
   321 
       
   322 const (
       
   323 	SizeofBpfVersion    = C.sizeof_struct_bpf_version
       
   324 	SizeofBpfStat       = C.sizeof_struct_bpf_stat
       
   325 	SizeofBpfZbuf       = C.sizeof_struct_bpf_zbuf
       
   326 	SizeofBpfProgram    = C.sizeof_struct_bpf_program
       
   327 	SizeofBpfInsn       = C.sizeof_struct_bpf_insn
       
   328 	SizeofBpfHdr        = C.sizeof_struct_bpf_hdr
       
   329 	SizeofBpfZbufHeader = C.sizeof_struct_bpf_zbuf_header
       
   330 )
       
   331 
       
   332 type BpfVersion C.struct_bpf_version
       
   333 
       
   334 type BpfStat C.struct_bpf_stat
       
   335 
       
   336 type BpfZbuf C.struct_bpf_zbuf
       
   337 
       
   338 type BpfProgram C.struct_bpf_program
       
   339 
       
   340 type BpfInsn C.struct_bpf_insn
       
   341 
       
   342 type BpfHdr C.struct_bpf_hdr
       
   343 
       
   344 type BpfZbufHeader C.struct_bpf_zbuf_header
       
   345 
       
   346 // Terminal handling
       
   347 
       
   348 type Termios C.struct_termios
       
   349 
       
   350 type Winsize C.struct_winsize
       
   351 
       
   352 // fchmodat-like syscalls.
       
   353 
       
   354 const (
       
   355 	AT_FDCWD            = C.AT_FDCWD
       
   356 	AT_REMOVEDIR        = C.AT_REMOVEDIR
       
   357 	AT_SYMLINK_FOLLOW   = C.AT_SYMLINK_FOLLOW
       
   358 	AT_SYMLINK_NOFOLLOW = C.AT_SYMLINK_NOFOLLOW
       
   359 )
       
   360 
       
   361 // poll
       
   362 
       
   363 type PollFd C.struct_pollfd
       
   364 
       
   365 const (
       
   366 	POLLERR      = C.POLLERR
       
   367 	POLLHUP      = C.POLLHUP
       
   368 	POLLIN       = C.POLLIN
       
   369 	POLLINIGNEOF = C.POLLINIGNEOF
       
   370 	POLLNVAL     = C.POLLNVAL
       
   371 	POLLOUT      = C.POLLOUT
       
   372 	POLLPRI      = C.POLLPRI
       
   373 	POLLRDBAND   = C.POLLRDBAND
       
   374 	POLLRDNORM   = C.POLLRDNORM
       
   375 	POLLWRBAND   = C.POLLWRBAND
       
   376 	POLLWRNORM   = C.POLLWRNORM
       
   377 )
       
   378 
       
   379 // Capabilities
       
   380 
       
   381 type CapRights C.struct_cap_rights
       
   382 
       
   383 // Uname
       
   384 
       
   385 type Utsname C.struct_utsname