...
Run Format

Source file src/syscall/types_freebsd.go

Documentation: syscall

     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 also mkerrors.sh and mkall.sh
     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 syscall
    15  
    16  /*
    17  #define KERNEL
    18  #include <dirent.h>
    19  #include <fcntl.h>
    20  #include <signal.h>
    21  #include <termios.h>
    22  #include <stdio.h>
    23  #include <unistd.h>
    24  #include <sys/event.h>
    25  #include <sys/mman.h>
    26  #include <sys/mount.h>
    27  #include <sys/param.h>
    28  #include <sys/ptrace.h>
    29  #include <sys/resource.h>
    30  #include <sys/select.h>
    31  #include <sys/signal.h>
    32  #include <sys/socket.h>
    33  #include <sys/stat.h>
    34  #include <sys/time.h>
    35  #include <sys/types.h>
    36  #include <sys/un.h>
    37  #include <sys/wait.h>
    38  #include <net/bpf.h>
    39  #include <net/if.h>
    40  #include <net/if_dl.h>
    41  #include <net/route.h>
    42  #include <netinet/in.h>
    43  #include <netinet/icmp6.h>
    44  #include <netinet/tcp.h>
    45  
    46  enum {
    47  	sizeofPtr = sizeof(void*),
    48  };
    49  
    50  union sockaddr_all {
    51  	struct sockaddr s1;	// this one gets used for fields
    52  	struct sockaddr_in s2;	// these pad it out
    53  	struct sockaddr_in6 s3;
    54  	struct sockaddr_un s4;
    55  	struct sockaddr_dl s5;
    56  };
    57  
    58  struct sockaddr_any {
    59  	struct sockaddr addr;
    60  	char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)];
    61  };
    62  
    63  // This structure is a duplicate of stat on FreeBSD 8-STABLE.
    64  // See /usr/include/sys/stat.h.
    65  struct stat8 {
    66  #undef st_atimespec	st_atim
    67  #undef st_mtimespec	st_mtim
    68  #undef st_ctimespec	st_ctim
    69  #undef st_birthtimespec	st_birthtim
    70  	__dev_t   st_dev;
    71  	ino_t     st_ino;
    72  	mode_t    st_mode;
    73  	nlink_t   st_nlink;
    74  	uid_t     st_uid;
    75  	gid_t     st_gid;
    76  	__dev_t   st_rdev;
    77  #if __BSD_VISIBLE
    78  	struct  timespec st_atimespec;
    79  	struct  timespec st_mtimespec;
    80  	struct  timespec st_ctimespec;
    81  #else
    82  	time_t    st_atime;
    83  	long      __st_atimensec;
    84  	time_t    st_mtime;
    85  	long      __st_mtimensec;
    86  	time_t    st_ctime;
    87  	long      __st_ctimensec;
    88  #endif
    89  	off_t     st_size;
    90  	blkcnt_t st_blocks;
    91  	blksize_t st_blksize;
    92  	fflags_t  st_flags;
    93  	__uint32_t st_gen;
    94  	__int32_t st_lspare;
    95  #if __BSD_VISIBLE
    96  	struct timespec st_birthtimespec;
    97  	unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec));
    98  	unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec));
    99  #else
   100  	time_t    st_birthtime;
   101  	long      st_birthtimensec;
   102  	unsigned int :(8 / 2) * (16 - (int)sizeof(struct __timespec));
   103  	unsigned int :(8 / 2) * (16 - (int)sizeof(struct __timespec));
   104  #endif
   105  };
   106  
   107  // This structure is a duplicate of if_data on FreeBSD 8-STABLE.
   108  // See /usr/include/net/if.h.
   109  struct if_data8 {
   110  	u_char  ifi_type;
   111  	u_char  ifi_physical;
   112  	u_char  ifi_addrlen;
   113  	u_char  ifi_hdrlen;
   114  	u_char  ifi_link_state;
   115  	u_char  ifi_spare_char1;
   116  	u_char  ifi_spare_char2;
   117  	u_char  ifi_datalen;
   118  	u_long  ifi_mtu;
   119  	u_long  ifi_metric;
   120  	u_long  ifi_baudrate;
   121  	u_long  ifi_ipackets;
   122  	u_long  ifi_ierrors;
   123  	u_long  ifi_opackets;
   124  	u_long  ifi_oerrors;
   125  	u_long  ifi_collisions;
   126  	u_long  ifi_ibytes;
   127  	u_long  ifi_obytes;
   128  	u_long  ifi_imcasts;
   129  	u_long  ifi_omcasts;
   130  	u_long  ifi_iqdrops;
   131  	u_long  ifi_noproto;
   132  	u_long  ifi_hwassist;
   133  	time_t  ifi_epoch;
   134  	struct  timeval ifi_lastchange;
   135  };
   136  
   137  // This structure is a duplicate of if_msghdr on FreeBSD 8-STABLE.
   138  // See /usr/include/net/if.h.
   139  struct if_msghdr8 {
   140  	u_short ifm_msglen;
   141  	u_char  ifm_version;
   142  	u_char  ifm_type;
   143  	int     ifm_addrs;
   144  	int     ifm_flags;
   145  	u_short ifm_index;
   146  	struct  if_data8 ifm_data;
   147  };
   148  */
   149  import "C"
   150  
   151  // Machine characteristics; for internal use.
   152  
   153  const (
   154  	sizeofPtr      = C.sizeofPtr
   155  	sizeofShort    = C.sizeof_short
   156  	sizeofInt      = C.sizeof_int
   157  	sizeofLong     = C.sizeof_long
   158  	sizeofLongLong = C.sizeof_longlong
   159  )
   160  
   161  // Basic types
   162  
   163  type (
   164  	_C_short     C.short
   165  	_C_int       C.int
   166  	_C_long      C.long
   167  	_C_long_long C.longlong
   168  )
   169  
   170  // Time
   171  
   172  type Timespec C.struct_timespec
   173  
   174  type Timeval C.struct_timeval
   175  
   176  // Processes
   177  
   178  type Rusage C.struct_rusage
   179  
   180  type Rlimit C.struct_rlimit
   181  
   182  type _Gid_t C.gid_t
   183  
   184  // Files
   185  
   186  const ( // Directory mode bits
   187  	S_IFMT   = C.S_IFMT
   188  	S_IFIFO  = C.S_IFIFO
   189  	S_IFCHR  = C.S_IFCHR
   190  	S_IFDIR  = C.S_IFDIR
   191  	S_IFBLK  = C.S_IFBLK
   192  	S_IFREG  = C.S_IFREG
   193  	S_IFLNK  = C.S_IFLNK
   194  	S_IFSOCK = C.S_IFSOCK
   195  	S_ISUID  = C.S_ISUID
   196  	S_ISGID  = C.S_ISGID
   197  	S_ISVTX  = C.S_ISVTX
   198  	S_IRUSR  = C.S_IRUSR
   199  	S_IWUSR  = C.S_IWUSR
   200  	S_IXUSR  = C.S_IXUSR
   201  )
   202  
   203  type Stat_t C.struct_stat8
   204  
   205  type Statfs_t C.struct_statfs
   206  
   207  type Flock_t C.struct_flock
   208  
   209  type Dirent C.struct_dirent
   210  
   211  type Fsid C.struct_fsid
   212  
   213  // File system limits
   214  
   215  const (
   216  	pathMax = C.PATH_MAX
   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  // Misc
   347  
   348  const (
   349  	_AT_FDCWD = C.AT_FDCWD
   350  )
   351  
   352  // Terminal handling
   353  
   354  type Termios C.struct_termios
   355  

View as plain text