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

View as plain text