Home | History | Annotate | only in /external/syzkaller/vendor/golang.org/x/sys/unix
Up to higher level directory
NameDateSize
affinity_linux.go22-Oct-20203.2K
asm_darwin_386.s22-Oct-2020675
asm_darwin_amd64.s22-Oct-2020678
asm_darwin_arm.s22-Oct-2020686
asm_darwin_arm64.s22-Oct-2020691
asm_dragonfly_amd64.s22-Oct-2020681
asm_freebsd_386.s22-Oct-2020676
asm_freebsd_amd64.s22-Oct-2020679
asm_freebsd_arm.s22-Oct-2020666
asm_linux_386.s22-Oct-20201.4K
asm_linux_amd64.s22-Oct-20201.2K
asm_linux_arm.s22-Oct-20201.1K
asm_linux_arm64.s22-Oct-20201.1K
asm_linux_mips64x.s22-Oct-20201.1K
asm_linux_mipsx.s22-Oct-20201.1K
asm_linux_ppc64x.s22-Oct-20201.1K
asm_linux_s390x.s22-Oct-20201.1K
asm_netbsd_386.s22-Oct-2020675
asm_netbsd_amd64.s22-Oct-2020678
asm_netbsd_arm.s22-Oct-2020665
asm_openbsd_386.s22-Oct-2020676
asm_openbsd_amd64.s22-Oct-2020679
asm_openbsd_arm.s22-Oct-2020666
asm_solaris_amd64.s22-Oct-2020426
bluetooth_linux.go22-Oct-2020655
cap_freebsd.go22-Oct-20205K
constants.go22-Oct-2020285
dev_darwin.go22-Oct-2020747
dev_dragonfly.go22-Oct-20201K
dev_freebsd.go22-Oct-20201,013
dev_linux.go22-Oct-20201.5K
dev_netbsd.go22-Oct-2020913
dev_openbsd.go22-Oct-2020918
dirent.go22-Oct-2020620
endian_big.go22-Oct-2020236
endian_little.go22-Oct-2020266
env_unix.go22-Oct-2020612
errors_freebsd_386.go22-Oct-20209.2K
errors_freebsd_amd64.go22-Oct-20209.2K
errors_freebsd_arm.go22-Oct-20208.8K
fcntl.go22-Oct-2020936
fcntl_linux_32bit.go22-Oct-2020388
gccgo.go22-Oct-20201.9K
gccgo_c.c22-Oct-20201K
gccgo_linux_amd64.go22-Oct-2020429
mkall.sh22-Oct-20206.1K
mkerrors.sh22-Oct-202014.7K
mkpost.go22-Oct-20203.1K
mksyscall.pl22-Oct-20208.4K
mksyscall_solaris.pl22-Oct-20206.9K
mksysctl_openbsd.pl22-Oct-20205.2K
mksysnum_darwin.pl22-Oct-2020751
mksysnum_dragonfly.pl22-Oct-20201K
mksysnum_freebsd.pl22-Oct-20201K
mksysnum_netbsd.pl22-Oct-20201.2K
mksysnum_openbsd.pl22-Oct-20201K
openbsd_pledge.go22-Oct-2020891
pagesize_unix.go22-Oct-2020363
race.go22-Oct-2020607
race0.go22-Oct-2020505
README.md22-Oct-20208.1K
sockcmsg_linux.go22-Oct-20201K
sockcmsg_unix.go22-Oct-20202.9K
str.go22-Oct-2020611
syscall.go22-Oct-20202K
syscall_bsd.go22-Oct-202015.6K
syscall_darwin.go22-Oct-202018.4K
syscall_darwin_386.go22-Oct-20201.7K
syscall_darwin_amd64.go22-Oct-20201.6K
syscall_darwin_arm.go22-Oct-20201.7K
syscall_darwin_arm64.go22-Oct-20201.6K
syscall_dragonfly.go22-Oct-202013.3K
syscall_dragonfly_amd64.go22-Oct-20201.2K
syscall_freebsd.go22-Oct-202019.7K
syscall_freebsd_386.go22-Oct-20201.2K
syscall_freebsd_amd64.go22-Oct-20201.2K
syscall_freebsd_arm.go22-Oct-20201.2K
syscall_linux.go22-Oct-202041.5K
syscall_linux_386.go22-Oct-202010.5K
syscall_linux_amd64.go22-Oct-20205.5K
syscall_linux_amd64_gc.go22-Oct-2020297
syscall_linux_arm.go22-Oct-20207.7K
syscall_linux_arm64.go22-Oct-20206.2K
syscall_linux_gc.go22-Oct-2020495
syscall_linux_gc_386.go22-Oct-2020582
syscall_linux_gccgo_386.go22-Oct-2020979
syscall_linux_gccgo_arm.go22-Oct-2020589
syscall_linux_mips64x.go22-Oct-20206.4K
syscall_linux_mipsx.go22-Oct-20207.1K
syscall_linux_ppc64x.go22-Oct-20205.1K
syscall_linux_s390x.go22-Oct-20209.9K
syscall_linux_sparc64.go22-Oct-20205.1K
syscall_netbsd.go22-Oct-202013.6K
syscall_netbsd_386.go22-Oct-2020735
syscall_netbsd_amd64.go22-Oct-2020730
syscall_netbsd_arm.go22-Oct-2020735
syscall_openbsd.go22-Oct-20209.9K
syscall_openbsd_386.go22-Oct-2020735
syscall_openbsd_amd64.go22-Oct-2020905
syscall_openbsd_arm.go22-Oct-2020735
syscall_solaris.go22-Oct-202020.6K
syscall_solaris_amd64.go22-Oct-2020509
syscall_unix.go22-Oct-20209.6K
syscall_unix_gc.go22-Oct-2020606
timestruct.go22-Oct-20202.5K
types_darwin.go22-Oct-20205.5K
types_dragonfly.go22-Oct-20205.5K
types_freebsd.go22-Oct-20208.5K
types_netbsd.go22-Oct-20205.5K
types_openbsd.go22-Oct-20205.5K
types_solaris.go22-Oct-20205.7K
zerrors_darwin_386.go22-Oct-202072.8K
zerrors_darwin_amd64.go22-Oct-202072.8K
zerrors_darwin_arm.go22-Oct-202072.8K
zerrors_darwin_arm64.go22-Oct-202072.8K
zerrors_dragonfly_amd64.go22-Oct-202064.3K
zerrors_freebsd_386.go22-Oct-202068.7K
zerrors_freebsd_amd64.go22-Oct-202068.8K
zerrors_freebsd_arm.go22-Oct-202069K
zerrors_linux_386.go22-Oct-2020113.4K
zerrors_linux_amd64.go22-Oct-2020113.4K
zerrors_linux_arm.go22-Oct-2020113.6K
zerrors_linux_arm64.go22-Oct-2020113K
zerrors_linux_mips.go22-Oct-2020113.9K
zerrors_linux_mips64.go22-Oct-2020113.9K
zerrors_linux_mips64le.go22-Oct-2020113.9K
zerrors_linux_mipsle.go22-Oct-2020113.9K
zerrors_linux_ppc64.go22-Oct-2020116.3K
zerrors_linux_ppc64le.go22-Oct-2020116.3K
zerrors_linux_s390x.go22-Oct-2020116.1K
zerrors_linux_sparc64.go22-Oct-202083.9K
zerrors_netbsd_386.go22-Oct-202070.6K
zerrors_netbsd_amd64.go22-Oct-202070.2K
zerrors_netbsd_arm.go22-Oct-202069.7K
zerrors_openbsd_386.go22-Oct-202065.5K
zerrors_openbsd_amd64.go22-Oct-202069.9K
zerrors_openbsd_arm.go22-Oct-202065.5K
zerrors_solaris_amd64.go22-Oct-202056.7K
zptrace386_linux.go22-Oct-20201.8K
zptracearm_linux.go22-Oct-20201.2K
zptracemips_linux.go22-Oct-20201.4K
zptracemipsle_linux.go22-Oct-20201.4K
zsyscall_darwin_386.go22-Oct-202040K
zsyscall_darwin_amd64.go22-Oct-202039.8K
zsyscall_darwin_arm.go22-Oct-202040K
zsyscall_darwin_arm64.go22-Oct-202039.8K
zsyscall_dragonfly_amd64.go22-Oct-202035K
zsyscall_freebsd_386.go22-Oct-202046K
zsyscall_freebsd_amd64.go22-Oct-202045.8K
zsyscall_freebsd_arm.go22-Oct-202046K
zsyscall_linux_386.go22-Oct-202047.7K
zsyscall_linux_amd64.go22-Oct-202052.1K
zsyscall_linux_arm.go22-Oct-202050.8K
zsyscall_linux_arm64.go22-Oct-202048.5K
zsyscall_linux_mips.go22-Oct-202052.4K
zsyscall_linux_mips64.go22-Oct-202051.7K
zsyscall_linux_mips64le.go22-Oct-202051.8K
zsyscall_linux_mipsle.go22-Oct-202052.4K
zsyscall_linux_ppc64.go22-Oct-202053.2K
zsyscall_linux_ppc64le.go22-Oct-202053.3K
zsyscall_linux_s390x.go22-Oct-202047K
zsyscall_linux_sparc64.go22-Oct-202052.1K
zsyscall_netbsd_386.go22-Oct-202033.5K
zsyscall_netbsd_amd64.go22-Oct-202033.3K
zsyscall_netbsd_arm.go22-Oct-202033.5K
zsyscall_openbsd_386.go22-Oct-202035K
zsyscall_openbsd_amd64.go22-Oct-202034.8K
zsyscall_openbsd_arm.go22-Oct-202035K
zsyscall_solaris_amd64.go22-Oct-202045.5K
zsysctl_openbsd_386.go22-Oct-202011.7K
zsysctl_openbsd_amd64.go22-Oct-202011.1K
zsysctl_openbsd_arm.go22-Oct-202011.7K
zsysnum_darwin_386.go22-Oct-202017.7K
zsysnum_darwin_amd64.go22-Oct-202017.7K
zsysnum_darwin_arm.go22-Oct-202017.7K
zsysnum_darwin_arm64.go22-Oct-202017.7K
zsysnum_dragonfly_amd64.go22-Oct-202023.6K
zsysnum_freebsd_386.go22-Oct-202025K
zsysnum_freebsd_amd64.go22-Oct-202025K
zsysnum_freebsd_arm.go22-Oct-202025K
zsysnum_linux_386.go22-Oct-202012.7K
zsysnum_linux_amd64.go22-Oct-202011.1K
zsysnum_linux_arm.go22-Oct-202011.8K
zsysnum_linux_arm64.go22-Oct-20209.3K
zsysnum_linux_mips.go22-Oct-202012.7K
zsysnum_linux_mips64.go22-Oct-202011.3K
zsysnum_linux_mips64le.go22-Oct-202011.3K
zsysnum_linux_mipsle.go22-Oct-202012.7K
zsysnum_linux_ppc64.go22-Oct-202012.2K
zsysnum_linux_ppc64le.go22-Oct-202012.2K
zsysnum_linux_s390x.go22-Oct-202011K
zsysnum_linux_sparc64.go22-Oct-202011.4K
zsysnum_netbsd_386.go22-Oct-202025.6K
zsysnum_netbsd_amd64.go22-Oct-202025.6K
zsysnum_netbsd_arm.go22-Oct-202025.6K
zsysnum_openbsd_386.go22-Oct-202014K
zsysnum_openbsd_amd64.go22-Oct-202014.8K
zsysnum_openbsd_arm.go22-Oct-202014.5K
ztypes_darwin_386.go22-Oct-20207.2K
ztypes_darwin_amd64.go22-Oct-20207.3K
ztypes_darwin_arm.go22-Oct-20207.2K
ztypes_darwin_arm64.go22-Oct-20207.3K
ztypes_dragonfly_amd64.go22-Oct-20207.1K
ztypes_freebsd_386.go22-Oct-20208.6K
ztypes_freebsd_amd64.go22-Oct-20208.7K
ztypes_freebsd_arm.go22-Oct-20208.7K
ztypes_linux_386.go22-Oct-202046K
ztypes_linux_amd64.go22-Oct-202046.3K
ztypes_linux_arm.go22-Oct-202045.8K
ztypes_linux_arm64.go22-Oct-202046K
ztypes_linux_mips.go22-Oct-202045.9K
ztypes_linux_mips64.go22-Oct-202046K
ztypes_linux_mips64le.go22-Oct-202046K
ztypes_linux_mipsle.go22-Oct-202045.9K
ztypes_linux_ppc64.go22-Oct-202046.2K
ztypes_linux_ppc64le.go22-Oct-202046.2K
ztypes_linux_s390x.go22-Oct-202046.6K
ztypes_linux_sparc64.go22-Oct-202012K
ztypes_netbsd_386.go22-Oct-20206.6K
ztypes_netbsd_amd64.go22-Oct-20206.8K
ztypes_netbsd_arm.go22-Oct-20206.8K
ztypes_openbsd_386.go22-Oct-20207.2K
ztypes_openbsd_amd64.go22-Oct-20207.1K
ztypes_openbsd_arm.go22-Oct-20207.1K
ztypes_solaris_amd64.go22-Oct-20206.6K

README.md

      1 # Building `sys/unix`
      2 
      3 The sys/unix package provides access to the raw system call interface of the
      4 underlying operating system. See: https://godoc.org/golang.org/x/sys/unix
      5 
      6 Porting Go to a new architecture/OS combination or adding syscalls, types, or
      7 constants to an existing architecture/OS pair requires some manual effort;
      8 however, there are tools that automate much of the process.
      9 
     10 ## Build Systems
     11 
     12 There are currently two ways we generate the necessary files. We are currently
     13 migrating the build system to use containers so the builds are reproducible.
     14 This is being done on an OS-by-OS basis. Please update this documentation as
     15 components of the build system change.
     16 
     17 ### Old Build System (currently for `GOOS != "Linux" || GOARCH == "sparc64"`)
     18 
     19 The old build system generates the Go files based on the C header files
     20 present on your system. This means that files
     21 for a given GOOS/GOARCH pair must be generated on a system with that OS and
     22 architecture. This also means that the generated code can differ from system
     23 to system, based on differences in the header files.
     24 
     25 To avoid this, if you are using the old build system, only generate the Go
     26 files on an installation with unmodified header files. It is also important to
     27 keep track of which version of the OS the files were generated from (ex.
     28 Darwin 14 vs Darwin 15). This makes it easier to track the progress of changes
     29 and have each OS upgrade correspond to a single change.
     30 
     31 To build the files for your current OS and architecture, make sure GOOS and
     32 GOARCH are set correctly and run `mkall.sh`. This will generate the files for
     33 your specific system. Running `mkall.sh -n` shows the commands that will be run.
     34 
     35 Requirements: bash, perl, go
     36 
     37 ### New Build System (currently for `GOOS == "Linux" && GOARCH != "sparc64"`)
     38 
     39 The new build system uses a Docker container to generate the go files directly
     40 from source checkouts of the kernel and various system libraries. This means
     41 that on any platform that supports Docker, all the files using the new build
     42 system can be generated at once, and generated files will not change based on
     43 what the person running the scripts has installed on their computer.
     44 
     45 The OS specific files for the new build system are located in the `${GOOS}`
     46 directory, and the build is coordinated by the `${GOOS}/mkall.go` program. When
     47 the kernel or system library updates, modify the Dockerfile at
     48 `${GOOS}/Dockerfile` to checkout the new release of the source.
     49 
     50 To build all the files under the new build system, you must be on an amd64/Linux
     51 system and have your GOOS and GOARCH set accordingly. Running `mkall.sh` will
     52 then generate all of the files for all of the GOOS/GOARCH pairs in the new build
     53 system. Running `mkall.sh -n` shows the commands that will be run.
     54 
     55 Requirements: bash, perl, go, docker
     56 
     57 ## Component files
     58 
     59 This section describes the various files used in the code generation process.
     60 It also contains instructions on how to modify these files to add a new
     61 architecture/OS or to add additional syscalls, types, or constants. Note that
     62 if you are using the new build system, the scripts cannot be called normally.
     63 They must be called from within the docker container.
     64 
     65 ### asm files
     66 
     67 The hand-written assembly file at `asm_${GOOS}_${GOARCH}.s` implements system
     68 call dispatch. There are three entry points:
     69 ```
     70   func Syscall(trap, a1, a2, a3 uintptr) (r1, r2, err uintptr)
     71   func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr)
     72   func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2, err uintptr)
     73 ```
     74 The first and second are the standard ones; they differ only in how many
     75 arguments can be passed to the kernel. The third is for low-level use by the
     76 ForkExec wrapper. Unlike the first two, it does not call into the scheduler to
     77 let it know that a system call is running.
     78 
     79 When porting Go to an new architecture/OS, this file must be implemented for
     80 each GOOS/GOARCH pair.
     81 
     82 ### mksysnum
     83 
     84 Mksysnum is a script located at `${GOOS}/mksysnum.pl` (or `mksysnum_${GOOS}.pl`
     85 for the old system). This script takes in a list of header files containing the
     86 syscall number declarations and parses them to produce the corresponding list of
     87 Go numeric constants. See `zsysnum_${GOOS}_${GOARCH}.go` for the generated
     88 constants.
     89 
     90 Adding new syscall numbers is mostly done by running the build on a sufficiently
     91 new installation of the target OS (or updating the source checkouts for the
     92 new build system). However, depending on the OS, you make need to update the
     93 parsing in mksysnum.
     94 
     95 ### mksyscall.pl
     96 
     97 The `syscall.go`, `syscall_${GOOS}.go`, `syscall_${GOOS}_${GOARCH}.go` are
     98 hand-written Go files which implement system calls (for unix, the specific OS,
     99 or the specific OS/Architecture pair respectively) that need special handling
    100 and list `//sys` comments giving prototypes for ones that can be generated.
    101 
    102 The mksyscall.pl script takes the `//sys` and `//sysnb` comments and converts
    103 them into syscalls. This requires the name of the prototype in the comment to
    104 match a syscall number in the `zsysnum_${GOOS}_${GOARCH}.go` file. The function
    105 prototype can be exported (capitalized) or not.
    106 
    107 Adding a new syscall often just requires adding a new `//sys` function prototype
    108 with the desired arguments and a capitalized name so it is exported. However, if
    109 you want the interface to the syscall to be different, often one will make an
    110 unexported `//sys` prototype, an then write a custom wrapper in
    111 `syscall_${GOOS}.go`.
    112 
    113 ### types files
    114 
    115 For each OS, there is a hand-written Go file at `${GOOS}/types.go` (or
    116 `types_${GOOS}.go` on the old system). This file includes standard C headers and
    117 creates Go type aliases to the corresponding C types. The file is then fed
    118 through godef to get the Go compatible definitions. Finally, the generated code
    119 is fed though mkpost.go to format the code correctly and remove any hidden or
    120 private identifiers. This cleaned-up code is written to
    121 `ztypes_${GOOS}_${GOARCH}.go`.
    122 
    123 The hardest part about preparing this file is figuring out which headers to
    124 include and which symbols need to be `#define`d to get the actual data
    125 structures that pass through to the kernel system calls. Some C libraries
    126 preset alternate versions for binary compatibility and translate them on the
    127 way in and out of system calls, but there is almost always a `#define` that can
    128 get the real ones.
    129 See `types_darwin.go` and `linux/types.go` for examples.
    130 
    131 To add a new type, add in the necessary include statement at the top of the
    132 file (if it is not already there) and add in a type alias line. Note that if
    133 your type is significantly different on different architectures, you may need
    134 some `#if/#elif` macros in your include statements.
    135 
    136 ### mkerrors.sh
    137 
    138 This script is used to generate the system's various constants. This doesn't
    139 just include the error numbers and error strings, but also the signal numbers
    140 an a wide variety of miscellaneous constants. The constants come from the list
    141 of include files in the `includes_${uname}` variable. A regex then picks out
    142 the desired `#define` statements, and generates the corresponding Go constants.
    143 The error numbers and strings are generated from `#include <errno.h>`, and the
    144 signal numbers and strings are generated from `#include <signal.h>`. All of
    145 these constants are written to `zerrors_${GOOS}_${GOARCH}.go` via a C program,
    146 `_errors.c`, which prints out all the constants.
    147 
    148 To add a constant, add the header that includes it to the appropriate variable.
    149 Then, edit the regex (if necessary) to match the desired constant. Avoid making
    150 the regex too broad to avoid matching unintended constants.
    151 
    152 
    153 ## Generated files
    154 
    155 ### `zerror_${GOOS}_${GOARCH}.go`
    156 
    157 A file containing all of the system's generated error numbers, error strings,
    158 signal numbers, and constants. Generated by `mkerrors.sh` (see above).
    159 
    160 ### `zsyscall_${GOOS}_${GOARCH}.go`
    161 
    162 A file containing all the generated syscalls for a specific GOOS and GOARCH.
    163 Generated by `mksyscall.pl` (see above).
    164 
    165 ### `zsysnum_${GOOS}_${GOARCH}.go`
    166 
    167 A list of numeric constants for all the syscall number of the specific GOOS
    168 and GOARCH. Generated by mksysnum (see above).
    169 
    170 ### `ztypes_${GOOS}_${GOARCH}.go`
    171 
    172 A file containing Go types for passing into (or returning from) syscalls.
    173 Generated by godefs and the types file (see above).
    174