...
Run Format

Source file src/syscall/types_linux.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 _LARGEFILE_SOURCE
    18  #define _LARGEFILE64_SOURCE
    19  #define _FILE_OFFSET_BITS 64
    20  #define _GNU_SOURCE
    21  
    22  #include <dirent.h>
    23  #include <fcntl.h>
    24  #include <netinet/in.h>
    25  #include <netinet/tcp.h>
    26  #include <netpacket/packet.h>
    27  #include <signal.h>
    28  #include <stdio.h>
    29  #include <sys/epoll.h>
    30  #include <sys/inotify.h>
    31  #include <sys/mman.h>
    32  #include <sys/mount.h>
    33  #include <sys/param.h>
    34  #include <sys/ptrace.h>
    35  #include <sys/resource.h>
    36  #include <sys/select.h>
    37  #include <sys/signal.h>
    38  #include <sys/stat.h>
    39  #include <sys/statfs.h>
    40  #include <sys/sysinfo.h>
    41  #include <sys/time.h>
    42  #include <sys/times.h>
    43  #include <sys/timex.h>
    44  #include <sys/types.h>
    45  #include <sys/un.h>
    46  #include <sys/user.h>
    47  #include <sys/utsname.h>
    48  #include <sys/wait.h>
    49  #include <linux/filter.h>
    50  #include <linux/netlink.h>
    51  #include <linux/rtnetlink.h>
    52  #include <linux/icmpv6.h>
    53  #include <termios.h>
    54  #include <time.h>
    55  #include <unistd.h>
    56  #include <utime.h>
    57  
    58  enum {
    59  	sizeofPtr = sizeof(void*),
    60  };
    61  
    62  union sockaddr_all {
    63  	struct sockaddr s1;	// this one gets used for fields
    64  	struct sockaddr_in s2;	// these pad it out
    65  	struct sockaddr_in6 s3;
    66  	struct sockaddr_un s4;
    67  	struct sockaddr_ll s5;
    68  	struct sockaddr_nl s6;
    69  };
    70  
    71  struct sockaddr_any {
    72  	struct sockaddr addr;
    73  	char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)];
    74  };
    75  
    76  // copied from /usr/include/linux/un.h
    77  struct my_sockaddr_un {
    78  	sa_family_t sun_family;
    79  #if defined(__ARM_EABI__) || defined(__powerpc64__) || defined(__s390x__)
    80  	// on ARM, PPC and s390x char is by default unsigned
    81  	signed char sun_path[108];
    82  #else
    83  	char sun_path[108];
    84  #endif
    85  };
    86  
    87  #ifdef __ARM_EABI__
    88  typedef struct user_regs PtraceRegs;
    89  #elif defined(__aarch64__)
    90  typedef struct user_pt_regs PtraceRegs;
    91  #elif defined(__powerpc64__)
    92  typedef struct pt_regs PtraceRegs;
    93  #elif defined(__mips__)
    94  typedef struct user PtraceRegs;
    95  #elif defined(__s390x__)
    96  typedef struct _user_regs_struct PtraceRegs;
    97  #else
    98  typedef struct user_regs_struct PtraceRegs;
    99  #endif
   100  
   101  #if defined(__s390x__)
   102  typedef struct _user_psw_struct ptracePsw;
   103  typedef struct _user_fpregs_struct ptraceFpregs;
   104  typedef struct _user_per_struct ptracePer;
   105  #else
   106  typedef struct {} ptracePsw;
   107  typedef struct {} ptraceFpregs;
   108  typedef struct {} ptracePer;
   109  #endif
   110  
   111  // The real epoll_event is a union, and godefs doesn't handle it well.
   112  struct my_epoll_event {
   113  	uint32_t events;
   114  #if defined(__ARM_EABI__) || (defined(__mips__) && _MIPS_SIM == _ABIO32)
   115  	// padding is not specified in linux/eventpoll.h but added to conform to the
   116  	// alignment requirements of EABI
   117  	int32_t padFd;
   118  #endif
   119  #if defined(__powerpc64__) || defined(__s390x__)
   120  	int32_t _padFd;
   121  #endif
   122  	int32_t fd;
   123  	int32_t pad;
   124  };
   125  
   126  // ustat is deprecated and glibc 2.28 removed ustat.h. Provide the type here for
   127  // backwards compatibility. Copied from /usr/include/bits/ustat.h
   128  struct ustat {
   129  	__daddr_t f_tfree;
   130  	__ino_t f_tinode;
   131  	char f_fname[6];
   132  	char f_fpack[6];
   133  };
   134  
   135  */
   136  import "C"
   137  
   138  // Machine characteristics; for internal use.
   139  
   140  const (
   141  	sizeofPtr      = C.sizeofPtr
   142  	sizeofShort    = C.sizeof_short
   143  	sizeofInt      = C.sizeof_int
   144  	sizeofLong     = C.sizeof_long
   145  	sizeofLongLong = C.sizeof_longlong
   146  	PathMax        = C.PATH_MAX
   147  )
   148  
   149  // Basic types
   150  
   151  type (
   152  	_C_short     C.short
   153  	_C_int       C.int
   154  	_C_long      C.long
   155  	_C_long_long C.longlong
   156  )
   157  
   158  // Time
   159  
   160  type Timespec C.struct_timespec
   161  
   162  type Timeval C.struct_timeval
   163  
   164  type Timex C.struct_timex
   165  
   166  type Time_t C.time_t
   167  
   168  type Tms C.struct_tms
   169  
   170  type Utimbuf C.struct_utimbuf
   171  
   172  // Processes
   173  
   174  type Rusage C.struct_rusage
   175  
   176  type Rlimit C.struct_rlimit
   177  
   178  type _Gid_t C.gid_t
   179  
   180  // Files
   181  
   182  type Stat_t C.struct_stat
   183  
   184  type Statfs_t C.struct_statfs
   185  
   186  type Dirent C.struct_dirent
   187  
   188  type Fsid C.fsid_t
   189  
   190  type Flock_t C.struct_flock
   191  
   192  // Sockets
   193  
   194  type RawSockaddrInet4 C.struct_sockaddr_in
   195  
   196  type RawSockaddrInet6 C.struct_sockaddr_in6
   197  
   198  type RawSockaddrUnix C.struct_my_sockaddr_un
   199  
   200  type RawSockaddrLinklayer C.struct_sockaddr_ll
   201  
   202  type RawSockaddrNetlink C.struct_sockaddr_nl
   203  
   204  type RawSockaddr C.struct_sockaddr
   205  
   206  type RawSockaddrAny C.struct_sockaddr_any
   207  
   208  type _Socklen C.socklen_t
   209  
   210  type Linger C.struct_linger
   211  
   212  type Iovec C.struct_iovec
   213  
   214  type IPMreq C.struct_ip_mreq
   215  
   216  type IPMreqn C.struct_ip_mreqn
   217  
   218  type IPv6Mreq C.struct_ipv6_mreq
   219  
   220  type Msghdr C.struct_msghdr
   221  
   222  type Cmsghdr C.struct_cmsghdr
   223  
   224  type Inet4Pktinfo C.struct_in_pktinfo
   225  
   226  type Inet6Pktinfo C.struct_in6_pktinfo
   227  
   228  type IPv6MTUInfo C.struct_ip6_mtuinfo
   229  
   230  type ICMPv6Filter C.struct_icmp6_filter
   231  
   232  type Ucred C.struct_ucred
   233  
   234  type TCPInfo C.struct_tcp_info
   235  
   236  const (
   237  	SizeofSockaddrInet4     = C.sizeof_struct_sockaddr_in
   238  	SizeofSockaddrInet6     = C.sizeof_struct_sockaddr_in6
   239  	SizeofSockaddrAny       = C.sizeof_struct_sockaddr_any
   240  	SizeofSockaddrUnix      = C.sizeof_struct_sockaddr_un
   241  	SizeofSockaddrLinklayer = C.sizeof_struct_sockaddr_ll
   242  	SizeofSockaddrNetlink   = C.sizeof_struct_sockaddr_nl
   243  	SizeofLinger            = C.sizeof_struct_linger
   244  	SizeofIPMreq            = C.sizeof_struct_ip_mreq
   245  	SizeofIPMreqn           = C.sizeof_struct_ip_mreqn
   246  	SizeofIPv6Mreq          = C.sizeof_struct_ipv6_mreq
   247  	SizeofMsghdr            = C.sizeof_struct_msghdr
   248  	SizeofCmsghdr           = C.sizeof_struct_cmsghdr
   249  	SizeofInet4Pktinfo      = C.sizeof_struct_in_pktinfo
   250  	SizeofInet6Pktinfo      = C.sizeof_struct_in6_pktinfo
   251  	SizeofIPv6MTUInfo       = C.sizeof_struct_ip6_mtuinfo
   252  	SizeofICMPv6Filter      = C.sizeof_struct_icmp6_filter
   253  	SizeofUcred             = C.sizeof_struct_ucred
   254  	SizeofTCPInfo           = C.sizeof_struct_tcp_info
   255  )
   256  
   257  // Netlink routing and interface messages
   258  
   259  const (
   260  	IFA_UNSPEC          = C.IFA_UNSPEC
   261  	IFA_ADDRESS         = C.IFA_ADDRESS
   262  	IFA_LOCAL           = C.IFA_LOCAL
   263  	IFA_LABEL           = C.IFA_LABEL
   264  	IFA_BROADCAST       = C.IFA_BROADCAST
   265  	IFA_ANYCAST         = C.IFA_ANYCAST
   266  	IFA_CACHEINFO       = C.IFA_CACHEINFO
   267  	IFA_MULTICAST       = C.IFA_MULTICAST
   268  	IFLA_UNSPEC         = C.IFLA_UNSPEC
   269  	IFLA_ADDRESS        = C.IFLA_ADDRESS
   270  	IFLA_BROADCAST      = C.IFLA_BROADCAST
   271  	IFLA_IFNAME         = C.IFLA_IFNAME
   272  	IFLA_MTU            = C.IFLA_MTU
   273  	IFLA_LINK           = C.IFLA_LINK
   274  	IFLA_QDISC          = C.IFLA_QDISC
   275  	IFLA_STATS          = C.IFLA_STATS
   276  	IFLA_COST           = C.IFLA_COST
   277  	IFLA_PRIORITY       = C.IFLA_PRIORITY
   278  	IFLA_MASTER         = C.IFLA_MASTER
   279  	IFLA_WIRELESS       = C.IFLA_WIRELESS
   280  	IFLA_PROTINFO       = C.IFLA_PROTINFO
   281  	IFLA_TXQLEN         = C.IFLA_TXQLEN
   282  	IFLA_MAP            = C.IFLA_MAP
   283  	IFLA_WEIGHT         = C.IFLA_WEIGHT
   284  	IFLA_OPERSTATE      = C.IFLA_OPERSTATE
   285  	IFLA_LINKMODE       = C.IFLA_LINKMODE
   286  	IFLA_LINKINFO       = C.IFLA_LINKINFO
   287  	IFLA_NET_NS_PID     = C.IFLA_NET_NS_PID
   288  	IFLA_IFALIAS        = C.IFLA_IFALIAS
   289  	IFLA_MAX            = C.IFLA_MAX
   290  	RT_SCOPE_UNIVERSE   = C.RT_SCOPE_UNIVERSE
   291  	RT_SCOPE_SITE       = C.RT_SCOPE_SITE
   292  	RT_SCOPE_LINK       = C.RT_SCOPE_LINK
   293  	RT_SCOPE_HOST       = C.RT_SCOPE_HOST
   294  	RT_SCOPE_NOWHERE    = C.RT_SCOPE_NOWHERE
   295  	RT_TABLE_UNSPEC     = C.RT_TABLE_UNSPEC
   296  	RT_TABLE_COMPAT     = C.RT_TABLE_COMPAT
   297  	RT_TABLE_DEFAULT    = C.RT_TABLE_DEFAULT
   298  	RT_TABLE_MAIN       = C.RT_TABLE_MAIN
   299  	RT_TABLE_LOCAL      = C.RT_TABLE_LOCAL
   300  	RT_TABLE_MAX        = C.RT_TABLE_MAX
   301  	RTA_UNSPEC          = C.RTA_UNSPEC
   302  	RTA_DST             = C.RTA_DST
   303  	RTA_SRC             = C.RTA_SRC
   304  	RTA_IIF             = C.RTA_IIF
   305  	RTA_OIF             = C.RTA_OIF
   306  	RTA_GATEWAY         = C.RTA_GATEWAY
   307  	RTA_PRIORITY        = C.RTA_PRIORITY
   308  	RTA_PREFSRC         = C.RTA_PREFSRC
   309  	RTA_METRICS         = C.RTA_METRICS
   310  	RTA_MULTIPATH       = C.RTA_MULTIPATH
   311  	RTA_FLOW            = C.RTA_FLOW
   312  	RTA_CACHEINFO       = C.RTA_CACHEINFO
   313  	RTA_TABLE           = C.RTA_TABLE
   314  	RTN_UNSPEC          = C.RTN_UNSPEC
   315  	RTN_UNICAST         = C.RTN_UNICAST
   316  	RTN_LOCAL           = C.RTN_LOCAL
   317  	RTN_BROADCAST       = C.RTN_BROADCAST
   318  	RTN_ANYCAST         = C.RTN_ANYCAST
   319  	RTN_MULTICAST       = C.RTN_MULTICAST
   320  	RTN_BLACKHOLE       = C.RTN_BLACKHOLE
   321  	RTN_UNREACHABLE     = C.RTN_UNREACHABLE
   322  	RTN_PROHIBIT        = C.RTN_PROHIBIT
   323  	RTN_THROW           = C.RTN_THROW
   324  	RTN_NAT             = C.RTN_NAT
   325  	RTN_XRESOLVE        = C.RTN_XRESOLVE
   326  	RTNLGRP_NONE        = C.RTNLGRP_NONE
   327  	RTNLGRP_LINK        = C.RTNLGRP_LINK
   328  	RTNLGRP_NOTIFY      = C.RTNLGRP_NOTIFY
   329  	RTNLGRP_NEIGH       = C.RTNLGRP_NEIGH
   330  	RTNLGRP_TC          = C.RTNLGRP_TC
   331  	RTNLGRP_IPV4_IFADDR = C.RTNLGRP_IPV4_IFADDR
   332  	RTNLGRP_IPV4_MROUTE = C.RTNLGRP_IPV4_MROUTE
   333  	RTNLGRP_IPV4_ROUTE  = C.RTNLGRP_IPV4_ROUTE
   334  	RTNLGRP_IPV4_RULE   = C.RTNLGRP_IPV4_RULE
   335  	RTNLGRP_IPV6_IFADDR = C.RTNLGRP_IPV6_IFADDR
   336  	RTNLGRP_IPV6_MROUTE = C.RTNLGRP_IPV6_MROUTE
   337  	RTNLGRP_IPV6_ROUTE  = C.RTNLGRP_IPV6_ROUTE
   338  	RTNLGRP_IPV6_IFINFO = C.RTNLGRP_IPV6_IFINFO
   339  	RTNLGRP_IPV6_PREFIX = C.RTNLGRP_IPV6_PREFIX
   340  	RTNLGRP_IPV6_RULE   = C.RTNLGRP_IPV6_RULE
   341  	RTNLGRP_ND_USEROPT  = C.RTNLGRP_ND_USEROPT
   342  	SizeofNlMsghdr      = C.sizeof_struct_nlmsghdr
   343  	SizeofNlMsgerr      = C.sizeof_struct_nlmsgerr
   344  	SizeofRtGenmsg      = C.sizeof_struct_rtgenmsg
   345  	SizeofNlAttr        = C.sizeof_struct_nlattr
   346  	SizeofRtAttr        = C.sizeof_struct_rtattr
   347  	SizeofIfInfomsg     = C.sizeof_struct_ifinfomsg
   348  	SizeofIfAddrmsg     = C.sizeof_struct_ifaddrmsg
   349  	SizeofRtMsg         = C.sizeof_struct_rtmsg
   350  	SizeofRtNexthop     = C.sizeof_struct_rtnexthop
   351  )
   352  
   353  type NlMsghdr C.struct_nlmsghdr
   354  
   355  type NlMsgerr C.struct_nlmsgerr
   356  
   357  type RtGenmsg C.struct_rtgenmsg
   358  
   359  type NlAttr C.struct_nlattr
   360  
   361  type RtAttr C.struct_rtattr
   362  
   363  type IfInfomsg C.struct_ifinfomsg
   364  
   365  type IfAddrmsg C.struct_ifaddrmsg
   366  
   367  type RtMsg C.struct_rtmsg
   368  
   369  type RtNexthop C.struct_rtnexthop
   370  
   371  // Linux socket filter
   372  
   373  const (
   374  	SizeofSockFilter = C.sizeof_struct_sock_filter
   375  	SizeofSockFprog  = C.sizeof_struct_sock_fprog
   376  )
   377  
   378  type SockFilter C.struct_sock_filter
   379  
   380  type SockFprog C.struct_sock_fprog
   381  
   382  // Inotify
   383  
   384  type InotifyEvent C.struct_inotify_event
   385  
   386  const SizeofInotifyEvent = C.sizeof_struct_inotify_event
   387  
   388  // Ptrace
   389  
   390  // Register structures
   391  type PtraceRegs C.PtraceRegs
   392  
   393  // Structures contained in PtraceRegs on s390x (exported by post.go)
   394  type ptracePsw C.ptracePsw
   395  
   396  type ptraceFpregs C.ptraceFpregs
   397  
   398  type ptracePer C.ptracePer
   399  
   400  // Misc
   401  
   402  type FdSet C.fd_set
   403  
   404  type Sysinfo_t C.struct_sysinfo
   405  
   406  type Utsname C.struct_utsname
   407  
   408  type Ustat_t C.struct_ustat
   409  
   410  type EpollEvent C.struct_my_epoll_event
   411  
   412  const (
   413  	_AT_FDCWD            = C.AT_FDCWD
   414  	_AT_REMOVEDIR        = C.AT_REMOVEDIR
   415  	_AT_SYMLINK_NOFOLLOW = C.AT_SYMLINK_NOFOLLOW
   416  	_AT_EACCESS          = C.AT_EACCESS
   417  )
   418  
   419  // Terminal handling
   420  
   421  type Termios C.struct_termios
   422  
   423  const (
   424  	IUCLC  = C.IUCLC
   425  	OLCUC  = C.OLCUC
   426  	TCGETS = C.TCGETS
   427  	TCSETS = C.TCSETS
   428  	XCASE  = C.XCASE
   429  )
   430  

View as plain text