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