2009-11-14 16:29:09 -07:00
|
|
|
#!/usr/bin/env bash
|
2009-06-01 23:14:57 -06:00
|
|
|
# Copyright 2009 The Go Authors. All rights reserved.
|
|
|
|
# Use of this source code is governed by a BSD-style
|
|
|
|
# license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
# The syscall package provides access to the raw system call
|
|
|
|
# interface of the underlying operating system. Porting Go to
|
|
|
|
# a new architecture/operating system combination requires
|
|
|
|
# some manual effort, though there are tools that automate
|
|
|
|
# much of the process. The auto-generated files have names
|
|
|
|
# beginning with z.
|
|
|
|
#
|
2009-11-01 12:13:27 -07:00
|
|
|
# This script runs or (given -n) prints suggested commands to generate z files
|
2009-06-01 23:14:57 -06:00
|
|
|
# for the current system. Running those commands is not automatic.
|
|
|
|
# This script is documentation more than anything else.
|
|
|
|
#
|
|
|
|
# * asm_${GOOS}_${GOARCH}.s
|
|
|
|
#
|
|
|
|
# This hand-written assembly file implements system call dispatch.
|
|
|
|
# There are three entry points:
|
|
|
|
#
|
|
|
|
# func Syscall(trap, a1, a2, a3 uintptr) (r1, r2, err uintptr);
|
|
|
|
# func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr);
|
|
|
|
# func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2, err uintptr);
|
|
|
|
#
|
|
|
|
# The first and second are the standard ones; they differ only in
|
|
|
|
# how many arguments can be passed to the kernel.
|
|
|
|
# The third is for low-level use by the ForkExec wrapper;
|
|
|
|
# unlike the first two, it does not call into the scheduler to
|
|
|
|
# let it know that a system call is running.
|
|
|
|
#
|
|
|
|
# * syscall_${GOOS}.go
|
|
|
|
#
|
|
|
|
# This hand-written Go file implements system calls that need
|
|
|
|
# special handling and lists "//sys" comments giving prototypes
|
|
|
|
# for ones that can be auto-generated. Mksyscall reads those
|
|
|
|
# comments to generate the stubs.
|
|
|
|
#
|
|
|
|
# * syscall_${GOOS}_${GOARCH}.go
|
|
|
|
#
|
|
|
|
# Same as syscall_${GOOS}.go except that it contains code specific
|
|
|
|
# to ${GOOS} on one particular architecture.
|
|
|
|
#
|
|
|
|
# * types_${GOOS}.c
|
|
|
|
#
|
|
|
|
# This hand-written C file includes standard C headers and then
|
|
|
|
# creates typedef or enum names beginning with a dollar sign
|
|
|
|
# (use of $ in variable names is a gcc extension). The hardest
|
|
|
|
# part about preparing this file is figuring out which headers to
|
|
|
|
# include and which symbols need to be #defined to get the
|
|
|
|
# actual data structures that pass through to the kernel system calls.
|
|
|
|
# Some C libraries present alternate versions for binary compatibility
|
|
|
|
# and translate them on the way in and out of system calls, but
|
|
|
|
# there is almost always a #define that can get the real ones.
|
|
|
|
# See types_darwin.c and types_linux.c for examples.
|
|
|
|
#
|
|
|
|
# * zerror_${GOOS}_${GOARCH}.go
|
|
|
|
#
|
|
|
|
# This machine-generated file defines the system's error numbers,
|
2009-08-13 14:22:37 -06:00
|
|
|
# error strings, and signal numbers. The generator is "mkerrors.sh".
|
|
|
|
# Usually no arguments are needed, but mkerrors.sh will pass its
|
2009-06-01 23:14:57 -06:00
|
|
|
# arguments on to godefs.
|
|
|
|
#
|
|
|
|
# * zsyscall_${GOOS}_${GOARCH}.go
|
|
|
|
#
|
2009-08-13 14:22:37 -06:00
|
|
|
# Generated by mksyscall.sh; see syscall_${GOOS}.go above.
|
2009-06-01 23:14:57 -06:00
|
|
|
#
|
|
|
|
# * zsysnum_${GOOS}_${GOARCH}.go
|
|
|
|
#
|
|
|
|
# Generated by mksysnum_${GOOS}.
|
|
|
|
#
|
|
|
|
# * ztypes_${GOOS}_${GOARCH}.go
|
|
|
|
#
|
|
|
|
# Generated by godefs; see types_${GOOS}.c above.
|
|
|
|
|
|
|
|
GOOSARCH="${GOOS}_${GOARCH}"
|
|
|
|
|
|
|
|
# defaults
|
2010-03-17 21:07:14 -06:00
|
|
|
mksyscall="./mksyscall.sh"
|
|
|
|
mkerrors="./mkerrors.sh"
|
2009-11-01 12:13:27 -07:00
|
|
|
run="sh"
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
-n)
|
|
|
|
run="cat"
|
|
|
|
shift
|
|
|
|
esac
|
|
|
|
|
|
|
|
case "$#" in
|
|
|
|
0)
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo 'usage: mkall.sh [-n]' 1>&2
|
|
|
|
exit 2
|
|
|
|
esac
|
2009-06-01 23:14:57 -06:00
|
|
|
|
|
|
|
case "$GOOSARCH" in
|
|
|
|
_* | *_ | _)
|
|
|
|
echo 'undefined $GOOS_$GOARCH:' "$GOOSARCH" 1>&2
|
|
|
|
exit 1
|
|
|
|
;;
|
2009-11-18 00:58:51 -07:00
|
|
|
freebsd_386)
|
2010-04-30 00:34:06 -06:00
|
|
|
mkerrors="$mkerrors -f -m32"
|
2010-03-17 21:07:14 -06:00
|
|
|
mksyscall="./mksyscall.sh -l32"
|
|
|
|
mksysnum="./mksysnum_freebsd.sh /usr/src/sys/kern/syscalls.master"
|
2009-11-18 00:58:51 -07:00
|
|
|
mktypes="godefs -gsyscall -f-m32"
|
|
|
|
;;
|
2009-11-14 16:29:09 -07:00
|
|
|
freebsd_amd64)
|
2010-04-30 00:34:06 -06:00
|
|
|
mkerrors="$mkerrors -f -m64"
|
2010-03-17 21:07:14 -06:00
|
|
|
mksysnum="./mksysnum_freebsd.sh /usr/src/sys/kern/syscalls.master"
|
2009-11-14 16:29:09 -07:00
|
|
|
mktypes="godefs -gsyscall -f-m64"
|
|
|
|
;;
|
2009-06-01 23:14:57 -06:00
|
|
|
darwin_386)
|
2010-04-30 00:34:06 -06:00
|
|
|
mkerrors="$mkerrors -f -m32"
|
2010-03-17 21:07:14 -06:00
|
|
|
mksyscall="./mksyscall.sh -l32"
|
|
|
|
mksysnum="./mksysnum_darwin.sh /home/rsc/pub/xnu-1228/bsd/kern/syscalls.master"
|
2009-06-01 23:14:57 -06:00
|
|
|
mktypes="godefs -gsyscall -f-m32"
|
|
|
|
;;
|
|
|
|
darwin_amd64)
|
2010-04-30 00:34:06 -06:00
|
|
|
mkerrors="$mkerrors -f -m64"
|
2010-03-17 21:07:14 -06:00
|
|
|
mksysnum="./mksysnum_darwin.sh /home/rsc/pub/xnu-1228/bsd/kern/syscalls.master"
|
2009-06-01 23:14:57 -06:00
|
|
|
mktypes="godefs -gsyscall -f-m64"
|
2010-03-17 21:07:14 -06:00
|
|
|
mkerrors="./mkerrors.sh"
|
2009-06-01 23:14:57 -06:00
|
|
|
;;
|
2009-06-04 14:33:40 -06:00
|
|
|
linux_386)
|
2010-04-30 00:34:06 -06:00
|
|
|
mkerrors="$mkerrors -f -m32"
|
2010-03-17 21:07:14 -06:00
|
|
|
mksyscall="./mksyscall.sh -l32"
|
|
|
|
mksysnum="./mksysnum_linux.sh /usr/include/asm/unistd_32.h"
|
2009-06-04 14:33:40 -06:00
|
|
|
mktypes="godefs -gsyscall -f-m32"
|
|
|
|
;;
|
2009-06-01 23:14:57 -06:00
|
|
|
linux_amd64)
|
2010-04-30 00:34:06 -06:00
|
|
|
mkerrors="$mkerrors -f -m64"
|
2010-03-17 21:07:14 -06:00
|
|
|
mksysnum="./mksysnum_linux.sh /usr/include/asm/unistd_64.h"
|
2009-06-01 23:14:57 -06:00
|
|
|
mktypes="godefs -gsyscall -f-m64"
|
|
|
|
;;
|
2009-09-22 08:49:31 -06:00
|
|
|
nacl_386)
|
|
|
|
NACL="/home/rsc/pub/nacl/native_client"
|
|
|
|
NACLRUN="$NACL/src/trusted/service_runtime"
|
|
|
|
NACLSDK="$NACL/src/third_party/nacl_sdk/linux/sdk/nacl-sdk/nacl"
|
2010-03-17 21:07:14 -06:00
|
|
|
mksyscall="./mksyscall.sh -l32"
|
|
|
|
mksysnum="./mksysnum_nacl.sh $NACLRUN/include/bits/nacl_syscalls.h"
|
2009-09-22 08:49:31 -06:00
|
|
|
mktypes="godefs -gsyscall -f-m32 -f-I$NACLSDK/include -f-I$NACL"
|
2010-03-17 21:07:14 -06:00
|
|
|
mkerrors="./mkerrors_nacl.sh $NACLRUN/include/sys/errno.h"
|
2009-09-22 08:49:31 -06:00
|
|
|
;;
|
2009-10-01 07:55:01 -06:00
|
|
|
linux_arm)
|
|
|
|
ARM="/home/kaib/public/linux-2.6.28"
|
2010-03-17 21:07:14 -06:00
|
|
|
mksyscall="./mksyscall.sh -l32"
|
|
|
|
mksysnum="./mksysnum_linux.sh $ARM/arch/arm/include/asm/unistd.h"
|
2009-10-01 07:55:01 -06:00
|
|
|
// mktypes="godefs -gsyscall -carm-gcc -f-I$ARM/arch/arm/include -f-I$ARM/include -f-D__deprecated='' -f-I$ARM/arch/arm/mach-at91/include -f-DCONFIG_ARCH_AT91SAM9260 "
|
|
|
|
mktypes="godefs -gsyscall -carm-gcc"
|
2010-03-17 21:07:14 -06:00
|
|
|
mkerrors="./mkerrors.sh"
|
2009-10-01 07:55:01 -06:00
|
|
|
;;
|
2010-04-30 00:45:14 -06:00
|
|
|
windows_386)
|
|
|
|
mksyscall="./mksyscall_windows.sh -l32"
|
2010-03-17 00:10:07 -06:00
|
|
|
mksysnum=
|
|
|
|
mktypes=
|
|
|
|
mkerrors=
|
2010-03-09 16:09:09 -07:00
|
|
|
;;
|
2009-06-01 23:14:57 -06:00
|
|
|
*)
|
|
|
|
echo 'unrecognized $GOOS_$GOARCH: ' "$GOOSARCH" 1>&2
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2009-11-01 12:13:27 -07:00
|
|
|
(
|
2010-03-17 00:10:07 -06:00
|
|
|
if [ -n "$mkerrors" ]; then echo "$mkerrors |gofmt >zerrors_$GOOSARCH.go"; fi
|
|
|
|
if [ -n "$mksyscall" ]; then echo "$mksyscall syscall_$GOOS.go syscall_$GOOSARCH.go |gofmt >zsyscall_$GOOSARCH.go"; fi
|
|
|
|
if [ -n "$mksysnum" ]; then echo "$mksysnum |gofmt >zsysnum_$GOOSARCH.go"; fi
|
|
|
|
if [ -n "$mktypes" ]; then echo "$mktypes types_$GOOS.c |gofmt >ztypes_$GOOSARCH.go"; fi
|
2009-11-01 12:13:27 -07:00
|
|
|
) | $run
|