• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

.gitignoreH A D01-Dec-202116 32

README.mdH A D01-Dec-20218.5 KiB185138

affinity_linux.goH A D01-Dec-20211.9 KiB8757

aliases.goH A D01-Dec-2021484 165

asm_aix_ppc64.sH A D01-Dec-2021420 195

asm_bsd_386.sH A D01-Dec-2021742 3011

asm_bsd_amd64.sH A D01-Dec-2021785 3011

asm_bsd_arm.sH A D01-Dec-2021732 3011

asm_bsd_arm64.sH A D01-Dec-2021762 3011

asm_linux_386.sH A D01-Dec-20211.4 KiB6740

asm_linux_amd64.sH A D01-Dec-20211.2 KiB5937

asm_linux_arm.sH A D01-Dec-20211.1 KiB5836

asm_linux_arm64.sH A D01-Dec-20211.1 KiB5435

asm_linux_mips64x.sH A D01-Dec-20211.2 KiB5835

asm_linux_mipsx.sH A D01-Dec-20211.2 KiB5632

asm_linux_ppc64x.sH A D01-Dec-2021962 4627

asm_linux_riscv64.sH A D01-Dec-20211 KiB5029

asm_linux_s390x.sH A D01-Dec-20211.2 KiB5835

asm_openbsd_mips64.sH A D01-Dec-2021690 3111

asm_solaris_amd64.sH A D01-Dec-2021436 195

asm_zos_s390x.sH A D01-Dec-20218.4 KiB427314

bluetooth_linux.goH A D01-Dec-2021680 3725

cap_freebsd.goH A D01-Dec-20215 KiB197148

constants.goH A D01-Dec-2021390 156

dev_aix_ppc.goH A D01-Dec-2021757 2810

dev_aix_ppc64.goH A D01-Dec-2021878 3012

dev_darwin.goH A D01-Dec-2021747 2510

dev_dragonfly.goH A D01-Dec-20211 KiB3110

dev_freebsd.goH A D01-Dec-20211,013 3110

dev_linux.goH A D01-Dec-20211.5 KiB4318

dev_netbsd.goH A D01-Dec-2021913 3015

dev_openbsd.goH A D01-Dec-2021918 3015

dev_zos.goH A D01-Dec-2021850 3010

dirent.goH A D01-Dec-20213.1 KiB10485

endian_big.goH A D01-Dec-2021421 112

endian_little.goH A D01-Dec-2021451 112

env_unix.goH A D01-Dec-2021717 3317

epoll_zos.goH A D01-Dec-20215 KiB222155

errors_freebsd_386.goH A D01-Dec-20219.4 KiB234225

errors_freebsd_amd64.goH A D01-Dec-20219.4 KiB234225

errors_freebsd_arm.goH A D01-Dec-20218.8 KiB227219

errors_freebsd_arm64.goH A D01-Dec-2021481 189

fcntl.goH A D01-Dec-20211.1 KiB3821

fcntl_darwin.goH A D01-Dec-2021806 2513

fcntl_linux_32bit.goH A D01-Dec-2021500 154

fdset.goH A D01-Dec-2021853 3115

fstatfs_zos.goH A D01-Dec-20214.1 KiB165146

gccgo.goH A D01-Dec-20211.9 KiB6140

gccgo_c.cH A D01-Dec-20211.5 KiB4628

gccgo_linux_amd64.goH A D01-Dec-2021464 2210

ifreq_linux.goH A D01-Dec-20214.5 KiB15072

ioctl.goH A D01-Dec-20212.5 KiB7637

ioctl_linux.goH A D01-Dec-20216.5 KiB197131

ioctl_zos.goH A D01-Dec-20212.1 KiB7539

mkall.shH A D01-Dec-20218 KiB232196

mkerrors.shH A D01-Dec-202119 KiB764680

pagesize_unix.goH A D01-Dec-2021457 175

pledge_openbsd.goH A D01-Dec-20213.7 KiB164102

ptrace_darwin.goH A D01-Dec-2021337 134

ptrace_ios.goH A D01-Dec-2021298 134

race.goH A D01-Dec-2021675 3218

race0.goH A D01-Dec-2021643 2713

readdirent_getdents.goH A D01-Dec-2021454 144

readdirent_getdirentries.goH A D01-Dec-2021715 216

sockcmsg_dragonfly.goH A D01-Dec-2021544 178

sockcmsg_linux.goH A D01-Dec-20212.6 KiB8660

sockcmsg_unix.goH A D01-Dec-20212.7 KiB9464

sockcmsg_unix_other.goH A D01-Dec-20211.3 KiB4825

str.goH A D01-Dec-2021705 2818

syscall.goH A D01-Dec-20213 KiB9647

syscall_aix.goH A D01-Dec-202115.5 KiB550310

syscall_aix_ppc.goH A D01-Dec-20211.4 KiB5531

syscall_aix_ppc64.goH A D01-Dec-20212 KiB8656

syscall_bsd.goH A D01-Dec-202115.9 KiB653492

syscall_darwin.1_12.goH A D01-Dec-2021885 3319

syscall_darwin.1_13.goH A D01-Dec-20212.7 KiB10965

syscall_darwin.goH A D01-Dec-202121.7 KiB771304

syscall_darwin_amd64.goH A D01-Dec-20211.5 KiB5226

syscall_darwin_arm64.goH A D01-Dec-20211.4 KiB5226

syscall_darwin_libSystem.goH A D01-Dec-20211.2 KiB289

syscall_dragonfly.goH A D01-Dec-202114.3 KiB542168

syscall_dragonfly_amd64.goH A D01-Dec-20211.3 KiB5838

syscall_freebsd.goH A D01-Dec-202124.4 KiB873423

syscall_freebsd_386.goH A D01-Dec-20211.8 KiB6846

syscall_freebsd_amd64.goH A D01-Dec-20211.7 KiB6846

syscall_freebsd_arm.goH A D01-Dec-20211.6 KiB6443

syscall_freebsd_arm64.goH A D01-Dec-20211.6 KiB6443

syscall_illumos.goH A D01-Dec-20214.2 KiB187137

syscall_linux.goH A D01-Dec-202169.4 KiB2,4151,516

syscall_linux_386.goH A D01-Dec-202110 KiB355251

syscall_linux_amd64.goH A D01-Dec-20215.6 KiB15262

syscall_linux_amd64_gc.goH A D01-Dec-2021315 143

syscall_linux_arm.goH A D01-Dec-20217.9 KiB250144

syscall_linux_arm64.goH A D01-Dec-20216.5 KiB200107

syscall_linux_gc.goH A D01-Dec-2021514 163

syscall_linux_gc_386.goH A D01-Dec-2021608 185

syscall_linux_gc_arm.goH A D01-Dec-2021434 153

syscall_linux_gccgo_386.goH A D01-Dec-20211,012 3220

syscall_linux_gccgo_arm.goH A D01-Dec-2021622 2212

syscall_linux_mips64x.goH A D01-Dec-20216.2 KiB197108

syscall_linux_mipsx.goH A D01-Dec-20216.7 KiB209111

syscall_linux_ppc.goH A D01-Dec-20217.7 KiB238134

syscall_linux_ppc64x.goH A D01-Dec-20215.4 KiB12434

syscall_linux_riscv64.goH A D01-Dec-20216.1 KiB18596

syscall_linux_s390x.goH A D01-Dec-20219.9 KiB312218

syscall_linux_sparc64.goH A D01-Dec-20214.7 KiB12041

syscall_netbsd.goH A D01-Dec-202116.2 KiB619177

syscall_netbsd_386.goH A D01-Dec-2021840 3924

syscall_netbsd_amd64.goH A D01-Dec-2021837 3924

syscall_netbsd_arm.goH A D01-Dec-2021840 3924

syscall_netbsd_arm64.goH A D01-Dec-2021837 3924

syscall_openbsd.goH A D01-Dec-202111.1 KiB391156

syscall_openbsd_386.goH A D01-Dec-20211,022 4325

syscall_openbsd_amd64.goH A D01-Dec-20211,014 4325

syscall_openbsd_arm.goH A D01-Dec-20211,022 4325

syscall_openbsd_arm64.goH A D01-Dec-20211,014 4325

syscall_openbsd_mips64.goH A D01-Dec-2021874 3622

syscall_solaris.goH A D01-Dec-202127.5 KiB979662

syscall_solaris_amd64.goH A D01-Dec-2021617 2916

syscall_unix.goH A D01-Dec-202111 KiB436337

syscall_unix_gc.goH A D01-Dec-2021751 196

syscall_unix_gc_ppc64x.goH A D01-Dec-2021839 2614

syscall_zos_s390x.goH A D01-Dec-202149 KiB1,8221,410

sysvshm_linux.goH A D01-Dec-2021537 229

sysvshm_unix.goH A D01-Dec-20211.6 KiB6232

sysvshm_unix_other.goH A D01-Dec-2021420 154

timestruct.goH A D01-Dec-20212.3 KiB7844

unveil_openbsd.goH A D01-Dec-20211 KiB4328

xattr_bsd.goH A D01-Dec-20215 KiB242178

zerrors_aix_ppc.goH A D01-Dec-202152.4 KiB1,3861,366

zerrors_aix_ppc64.goH A D01-Dec-202152.7 KiB1,3871,367

zerrors_darwin_amd64.goH A D01-Dec-202186.5 KiB1,8931,873

zerrors_darwin_arm64.goH A D01-Dec-202186.5 KiB1,8931,873

zerrors_dragonfly_amd64.goH A D01-Dec-202170.7 KiB1,7391,719

zerrors_freebsd_386.goH A D01-Dec-202175.9 KiB1,9491,929

zerrors_freebsd_amd64.goH A D01-Dec-202175.9 KiB1,9481,928

zerrors_freebsd_arm.goH A D01-Dec-202171.9 KiB1,8471,827

zerrors_freebsd_arm64.goH A D01-Dec-202175.9 KiB1,9491,929

zerrors_linux.goH A D01-Dec-2021152.2 KiB3,0082,996

zerrors_linux_386.goH A D01-Dec-202133.3 KiB824804

zerrors_linux_amd64.goH A D01-Dec-202133.3 KiB824804

zerrors_linux_arm.goH A D01-Dec-202133.5 KiB830810

zerrors_linux_arm64.goH A D01-Dec-202133.2 KiB821801

zerrors_linux_mips.goH A D01-Dec-202133.8 KiB831811

zerrors_linux_mips64.goH A D01-Dec-202133.8 KiB831811

zerrors_linux_mips64le.goH A D01-Dec-202133.8 KiB831811

zerrors_linux_mipsle.goH A D01-Dec-202133.8 KiB831811

zerrors_linux_ppc.goH A D01-Dec-202135.9 KiB883863

zerrors_linux_ppc64.goH A D01-Dec-202136.1 KiB887867

zerrors_linux_ppc64le.goH A D01-Dec-202136.1 KiB887867

zerrors_linux_riscv64.goH A D01-Dec-202132.8 KiB811791

zerrors_linux_s390x.goH A D01-Dec-202135.8 KiB886866

zerrors_linux_sparc64.goH A D01-Dec-202136 KiB881861

zerrors_netbsd_386.goH A D01-Dec-202172.8 KiB1,7811,761

zerrors_netbsd_amd64.goH A D01-Dec-202172.4 KiB1,7711,751

zerrors_netbsd_arm.goH A D01-Dec-202171.9 KiB1,7601,740

zerrors_netbsd_arm64.goH A D01-Dec-202172.4 KiB1,7711,751

zerrors_openbsd_386.goH A D01-Dec-202168.3 KiB1,6691,649

zerrors_openbsd_amd64.goH A D01-Dec-202172.7 KiB1,7761,756

zerrors_openbsd_arm.goH A D01-Dec-202168.4 KiB1,6711,651

zerrors_openbsd_arm64.goH A D01-Dec-202173.8 KiB1,7991,779

zerrors_openbsd_mips64.goH A D01-Dec-202176.8 KiB1,8641,844

zerrors_solaris_amd64.goH A D01-Dec-202159 KiB1,5581,538

zerrors_zos_s390x.goH A D01-Dec-202134.5 KiB861842

zptrace_armnn_linux.goH A D01-Dec-20211.2 KiB4323

zptrace_linux_arm64.goH A D01-Dec-2021733 1810

zptrace_mipsnn_linux.goH A D01-Dec-20211.4 KiB5232

zptrace_mipsnnle_linux.goH A D01-Dec-20211.5 KiB5232

zptrace_x86_linux.goH A D01-Dec-20211.9 KiB8262

zsyscall_aix_ppc.goH A D01-Dec-202136.3 KiB1,486992

zsyscall_aix_ppc64.goH A D01-Dec-202130.6 KiB1,4441,073

zsyscall_aix_ppc64_gc.goH A D01-Dec-202142.6 KiB1,193594

zsyscall_aix_ppc64_gccgo.goH A D01-Dec-202130.9 KiB1,071590

zsyscall_darwin_amd64.1_13.goH A D01-Dec-20211 KiB4120

zsyscall_darwin_amd64.1_13.sH A D01-Dec-2021766 2613

zsyscall_darwin_amd64.goH A D01-Dec-202165.4 KiB2,4911,600

zsyscall_darwin_amd64.sH A D01-Dec-202128.7 KiB884585

zsyscall_darwin_arm64.1_13.goH A D01-Dec-20211 KiB4120

zsyscall_darwin_arm64.1_13.sH A D01-Dec-2021766 2613

zsyscall_darwin_arm64.goH A D01-Dec-202165.3 KiB2,4911,600

zsyscall_darwin_arm64.sH A D01-Dec-202128.6 KiB884585

zsyscall_dragonfly_amd64.goH A D01-Dec-202139.1 KiB1,6801,272

zsyscall_freebsd_386.goH A D01-Dec-202148.3 KiB2,0171,543

zsyscall_freebsd_amd64.goH A D01-Dec-202148.1 KiB2,0171,543

zsyscall_freebsd_arm.goH A D01-Dec-202148.3 KiB2,0171,543

zsyscall_freebsd_arm64.goH A D01-Dec-202148.1 KiB2,0171,543

zsyscall_illumos_amd64.goH A D01-Dec-20213.5 KiB12983

zsyscall_linux.goH A D01-Dec-202148.9 KiB2,0351,596

zsyscall_linux_386.goH A D01-Dec-202113.1 KiB527386

zsyscall_linux_amd64.goH A D01-Dec-202117.6 KiB694508

zsyscall_linux_arm.goH A D01-Dec-202117.2 KiB664487

zsyscall_linux_arm64.goH A D01-Dec-202115.5 KiB604439

zsyscall_linux_mips.goH A D01-Dec-202118 KiB705516

zsyscall_linux_mips64.goH A D01-Dec-202117.6 KiB699513

zsyscall_linux_mips64le.goH A D01-Dec-202117.6 KiB699513

zsyscall_linux_mipsle.goH A D01-Dec-202118.1 KiB705516

zsyscall_linux_ppc.goH A D01-Dec-202118.1 KiB710521

zsyscall_linux_ppc64.goH A D01-Dec-202119.1 KiB756555

zsyscall_linux_ppc64le.goH A D01-Dec-202119.1 KiB756555

zsyscall_linux_riscv64.goH A D01-Dec-202115 KiB584422

zsyscall_linux_s390x.goH A D01-Dec-202113.1 KiB536395

zsyscall_linux_sparc64.goH A D01-Dec-202117.7 KiB700514

zsyscall_netbsd_386.goH A D01-Dec-202144.3 KiB1,8631,428

zsyscall_netbsd_amd64.goH A D01-Dec-202144.1 KiB1,8631,428

zsyscall_netbsd_arm.goH A D01-Dec-202144.3 KiB1,8631,428

zsyscall_netbsd_arm64.goH A D01-Dec-202144.1 KiB1,8631,428

zsyscall_openbsd_386.goH A D01-Dec-202139.6 KiB1,6941,283

zsyscall_openbsd_amd64.goH A D01-Dec-202139.4 KiB1,6941,283

zsyscall_openbsd_arm.goH A D01-Dec-202139.6 KiB1,6941,283

zsyscall_openbsd_arm64.goH A D01-Dec-202139.4 KiB1,6941,283

zsyscall_openbsd_mips64.goH A D01-Dec-202139.4 KiB1,6941,283

zsyscall_solaris_amd64.goH A D01-Dec-202156.9 KiB2,0541,368

zsyscall_zos_s390x.goH A D01-Dec-202129.9 KiB1,256942

zsysctl_openbsd_386.goH A D01-Dec-202111.8 KiB275266

zsysctl_openbsd_amd64.goH A D01-Dec-202111.7 KiB273264

zsysctl_openbsd_arm.goH A D01-Dec-202111.8 KiB275266

zsysctl_openbsd_arm64.goH A D01-Dec-202111.8 KiB277268

zsysctl_openbsd_mips64.goH A D01-Dec-202111.9 KiB281272

zsysnum_darwin_amd64.goH A D01-Dec-202117.9 KiB441432

zsysnum_darwin_arm64.goH A D01-Dec-202117.8 KiB439430

zsysnum_dragonfly_amd64.goH A D01-Dec-202127.6 KiB318309

zsysnum_freebsd_386.goH A D01-Dec-202136.2 KiB398389

zsysnum_freebsd_amd64.goH A D01-Dec-202136.2 KiB398389

zsysnum_freebsd_arm.goH A D01-Dec-202136.2 KiB398389

zsysnum_freebsd_arm64.goH A D01-Dec-202136.2 KiB398389

zsysnum_linux_386.goH A D01-Dec-202117.2 KiB449441

zsysnum_linux_amd64.goH A D01-Dec-202112.4 KiB371363

zsysnum_linux_arm.goH A D01-Dec-202115.8 KiB413405

zsysnum_linux_arm64.goH A D01-Dec-202110.6 KiB316308

zsysnum_linux_mips.goH A D01-Dec-202117.1 KiB433425

zsysnum_linux_mips64.goH A D01-Dec-202112.6 KiB363355

zsysnum_linux_mips64le.goH A D01-Dec-202112.6 KiB363355

zsysnum_linux_mipsle.goH A D01-Dec-202117.1 KiB433425

zsysnum_linux_ppc.goH A D01-Dec-202116.9 KiB440432

zsysnum_linux_ppc64.goH A D01-Dec-202113.8 KiB412404

zsysnum_linux_ppc64le.goH A D01-Dec-202113.8 KiB412404

zsysnum_linux_riscv64.goH A D01-Dec-202110.5 KiB314306

zsysnum_linux_s390x.goH A D01-Dec-202112.7 KiB377369

zsysnum_linux_sparc64.goH A D01-Dec-202113.1 KiB391383

zsysnum_netbsd_386.goH A D01-Dec-202125.7 KiB276268

zsysnum_netbsd_amd64.goH A D01-Dec-202125.7 KiB276268

zsysnum_netbsd_arm.goH A D01-Dec-202125.7 KiB276268

zsysnum_netbsd_arm64.goH A D01-Dec-202125.7 KiB276268

zsysnum_openbsd_386.goH A D01-Dec-202117.9 KiB220212

zsysnum_openbsd_amd64.goH A D01-Dec-202117.9 KiB220212

zsysnum_openbsd_arm.goH A D01-Dec-202117.9 KiB220212

zsysnum_openbsd_arm64.goH A D01-Dec-202117.8 KiB219211

zsysnum_openbsd_mips64.goH A D01-Dec-202118 KiB222214

zsysnum_zos_s390x.goH A D01-Dec-2021117 KiB2,6712,660

ztypes_aix_ppc.goH A D01-Dec-20214.9 KiB355296

ztypes_aix_ppc64.goH A D01-Dec-20215 KiB359300

ztypes_darwin_amd64.goH A D01-Dec-202111.5 KiB769679

ztypes_darwin_arm64.goH A D01-Dec-202111.5 KiB769679

ztypes_dragonfly_amd64.goH A D01-Dec-20216.9 KiB475413

ztypes_freebsd_386.goH A D01-Dec-202110.9 KiB724640

ztypes_freebsd_amd64.goH A D01-Dec-202110.9 KiB727643

ztypes_freebsd_arm.goH A D01-Dec-202110.7 KiB708624

ztypes_freebsd_arm64.goH A D01-Dec-202110.6 KiB705621

ztypes_illumos_amd64.goH A D01-Dec-2021647 4330

ztypes_linux.goH A D01-Dec-2021140.6 KiB3,9713,765

ztypes_linux_386.goH A D01-Dec-202111.8 KiB671592

ztypes_linux_amd64.goH A D01-Dec-202112 KiB686607

ztypes_linux_arm.goH A D01-Dec-202111.8 KiB666587

ztypes_linux_arm64.goH A D01-Dec-202111.7 KiB665586

ztypes_linux_mips.goH A D01-Dec-202111.8 KiB671592

ztypes_linux_mips64.goH A D01-Dec-202111.7 KiB668589

ztypes_linux_mips64le.goH A D01-Dec-202111.7 KiB668589

ztypes_linux_mipsle.goH A D01-Dec-202111.9 KiB671592

ztypes_linux_ppc.goH A D01-Dec-202112 KiB679600

ztypes_linux_ppc64.goH A D01-Dec-202111.9 KiB674595

ztypes_linux_ppc64le.goH A D01-Dec-202111.9 KiB674595

ztypes_linux_riscv64.goH A D01-Dec-202112 KiB693614

ztypes_linux_s390x.goH A D01-Dec-202112.2 KiB688606

ztypes_linux_sparc64.goH A D01-Dec-202111.7 KiB669590

ztypes_netbsd_386.goH A D01-Dec-20217.4 KiB503435

ztypes_netbsd_amd64.goH A D01-Dec-20217.6 KiB511443

ztypes_netbsd_arm.goH A D01-Dec-20217.6 KiB508440

ztypes_netbsd_arm64.goH A D01-Dec-20217.6 KiB511443

ztypes_openbsd_386.goH A D01-Dec-20219.5 KiB575509

ztypes_openbsd_amd64.goH A D01-Dec-20219.4 KiB575509

ztypes_openbsd_arm.goH A D01-Dec-20219.4 KiB576510

ztypes_openbsd_arm64.goH A D01-Dec-20219.3 KiB569503

ztypes_openbsd_mips64.goH A D01-Dec-20219.3 KiB569503

ztypes_solaris_amd64.goH A D01-Dec-20217.1 KiB483418

ztypes_zos_s390x.goH A D01-Dec-20216.6 KiB407351

README.md

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