Commit a8464243 by Ian Lance Taylor Committed by Ian Lance Taylor

runtime/internal/sys: new package, API copied from Go 1.7

    
    Copy over the Go 1.7 runtime/internal/sys package, but instead of having
    separate files for each GOARCH and GOOS value, set the values in
    configure.ac and write them out in Makefile.am.  Setting the values in
    configure.ac should make it easier to add new processors.
    
    Remove the automake GOARCH conditionals, which are no longer used.
    Leave the GOOS conditionals for now, as they are used for the C runtime
    package.
    
    Reviewed-on: https://go-review.googlesource.com/29018

From-SVN: r240083
parent a1cd04ac
2016-09-11 Ian Lance Taylor <iant@golang.org>
* go-gcc.cc (Gcc_backend::Gcc_backend): Add builtin versions of
ctz, ctzll, bswap32, bswap64.
2016-09-10 Ian Lance Taylor <iant@golang.org> 2016-09-10 Ian Lance Taylor <iant@golang.org>
* go-backend.c (go_trampoline_info): Remove. * go-backend.c (go_trampoline_info): Remove.
......
...@@ -692,6 +692,28 @@ Gcc_backend::Gcc_backend() ...@@ -692,6 +692,28 @@ Gcc_backend::Gcc_backend()
NULL_TREE), NULL_TREE),
false, false); false, false);
// Used by runtime/internal/sys.
this->define_builtin(BUILT_IN_CTZ, "__builtin_ctz", "ctz",
build_function_type_list(integer_type_node,
unsigned_type_node,
NULL_TREE),
true, false);
this->define_builtin(BUILT_IN_CTZLL, "__builtin_ctzll", "ctzll",
build_function_type_list(integer_type_node,
long_long_unsigned_type_node,
NULL_TREE),
true, false);
this->define_builtin(BUILT_IN_BSWAP32, "__builtin_bswap32", "bswap32",
build_function_type_list(uint32_type_node,
uint32_type_node,
NULL_TREE),
true, false);
this->define_builtin(BUILT_IN_BSWAP64, "__builtin_bswap64", "bswap64",
build_function_type_list(uint64_type_node,
uint64_type_node,
NULL_TREE),
true, false);
// We provide some functions for the math library. // We provide some functions for the math library.
tree math_function_type = build_function_type_list(double_type_node, tree math_function_type = build_function_type_list(double_type_node,
double_type_node, double_type_node,
......
d3a145b111a4f4ea772b812c6a0b3a853c207819 841bea960b1f097e2cff5ad2618800296dcd4ec2
The first line of this file holds the git revision number of the last The first line of this file holds the git revision number of the last
merge done from the gofrontend repository. merge done from the gofrontend repository.
...@@ -586,12 +586,54 @@ time.c: $(srcdir)/runtime/time.goc goc2c ...@@ -586,12 +586,54 @@ time.c: $(srcdir)/runtime/time.goc goc2c
version.go: s-version; @true version.go: s-version; @true
s-version: Makefile s-version: Makefile
rm -f version.go.tmp rm -f version.go.tmp
echo "package runtime" > version.go.tmp echo "package sys" > version.go.tmp
echo 'const defaultGoroot = "$(prefix)"' >> version.go.tmp echo 'const DefaultGoroot = "$(prefix)"' >> version.go.tmp
echo 'const theVersion = "'`cat $(srcdir)/VERSION | sed 1q`' '`$(GOC) --version | sed 1q`'"' >> version.go.tmp echo 'const TheVersion = "'`cat $(srcdir)/VERSION | sed 1q`' '`$(GOC) --version | sed 1q`'"' >> version.go.tmp
echo 'const theGoarch = "'$(GOARCH)'"' >> version.go.tmp echo 'const GOARCH = "'$(GOARCH)'"' >> version.go.tmp
echo 'const theGoos = "'$(GOOS)'"' >> version.go.tmp echo 'const GOOS = "'$(GOOS)'"' >> version.go.tmp
echo 'const theGccgoToolDir = "$(libexecsubdir)"' >> version.go.tmp echo 'const GccgoToolDir = "$(libexecsubdir)"' >> version.go.tmp
echo >> version.go.tmp
echo "type ArchFamilyType int" >> version.go.tmp
echo >> version.go.tmp
echo "const (" >> version.go.tmp
echo " UNKNOWN ArchFamilyType = iota" >> version.go.tmp
for a in $(ALLGOARCHFAMILY); do \
echo " $${a}" >> version.go.tmp; \
done
echo ")" >> version.go.tmp
echo >> version.go.tmp
for a in $(ALLGOARCH); do \
f=`echo $${a} | sed -e 's/\(.\).*/\1/' -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`; \
n="$${f}`echo $${a} | sed -e 's/.//'`"; \
if test "$${a}" = "$(GOARCH)"; then \
echo "const Goarch$${n} = 1" >> version.go.tmp; \
else \
echo "const Goarch$${n} = 0" >> version.go.tmp; \
fi; \
done
echo >> version.go.tmp
echo "const (" >> version.go.tmp
echo " ArchFamily = $(GOARCH_FAMILY)" >> version.go.tmp
echo " BigEndian = $(GOARCH_BIGENDIAN)" >> version.go.tmp
echo " CacheLineSize = $(GOARCH_CACHELINESIZE)" >> version.go.tmp
echo " PhysPageSize = $(GOARCH_PHYSPAGESIZE)" >> version.go.tmp
echo " PCQuantum = $(GOARCH_PCQUANTUM)" >> version.go.tmp
echo " Int64Align = $(GOARCH_INT64ALIGN)" >> version.go.tmp
echo " HugePageSize = $(GOARCH_HUGEPAGESIZE)" >> version.go.tmp
echo " MinFrameSize = $(GOARCH_MINFRAMESIZE)" >> version.go.tmp
echo ")" >> version.go.tmp
echo >> version.go.tmp
for a in $(ALLGOOS); do \
f=`echo $${a} | sed -e 's/\(.\).*/\1/' -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`; \
n="$${f}`echo $${a} | sed -e 's/.//'`"; \
if test "$${a}" = "$(GOOS)"; then \
echo "const Goos$${n} = 1" >> version.go.tmp; \
else \
echo "const Goos$${n} = 0" >> version.go.tmp; \
fi; \
done
echo >> version.go.tmp
echo "type Uintreg uintptr" >> version.go.tmp
$(SHELL) $(srcdir)/mvifdiff.sh version.go.tmp version.go $(SHELL) $(srcdir)/mvifdiff.sh version.go.tmp version.go
$(STAMP) $@ $(STAMP) $@
...@@ -845,6 +887,7 @@ libgo_go_objs = \ ...@@ -845,6 +887,7 @@ libgo_go_objs = \
runtime/pprof.lo \ runtime/pprof.lo \
runtime/internal/atomic.lo \ runtime/internal/atomic.lo \
runtime/internal/atomic_c.lo \ runtime/internal/atomic_c.lo \
runtime/internal/sys.lo \
sync/atomic.lo \ sync/atomic.lo \
sync/atomic_c.lo \ sync/atomic_c.lo \
text/scanner.lo \ text/scanner.lo \
...@@ -1224,7 +1267,7 @@ regexp/check: $(CHECK_DEPS) ...@@ -1224,7 +1267,7 @@ regexp/check: $(CHECK_DEPS)
@$(CHECK) @$(CHECK)
.PHONY: regexp/check .PHONY: regexp/check
extra_go_files_runtime = runtime_sysinfo.go version.go extra_go_files_runtime = runtime_sysinfo.go
@go_include@ runtime-go.lo.dep @go_include@ runtime-go.lo.dep
runtime-go.lo.dep: $(srcdir)/go/runtime/*.go $(extra_go_files_runtime) runtime-go.lo.dep: $(srcdir)/go/runtime/*.go $(extra_go_files_runtime)
...@@ -2379,6 +2422,18 @@ runtime/internal/atomic/check: $(CHECK_DEPS) ...@@ -2379,6 +2422,18 @@ runtime/internal/atomic/check: $(CHECK_DEPS)
@$(CHECK) @$(CHECK)
.PHONY: runtime/internal/atomic/check .PHONY: runtime/internal/atomic/check
extra_go_files_runtime_internal_sys = version.go
@go_include@ runtime/internal/sys.lo.dep
runtime/internal/sys.lo.dep: $(srcdir)/go/runtime/internal/sys/*.go
$(BUILDDEPS)
runtime_internal_sys_lo_GOCFLAGS = -fgo-compiling-runtime
runtime/internal/sys.lo:
$(BUILDPACKAGE)
runtime/internal/sys/check: $(CHECK_DEPS)
@$(CHECK)
.PHONY: runtime/internal/sys/check
@go_include@ sync/atomic.lo.dep @go_include@ sync/atomic.lo.dep
sync/atomic.lo.dep: $(srcdir)/go/sync/atomic/*.go sync/atomic.lo.dep: $(srcdir)/go/sync/atomic/*.go
$(BUILDDEPS) $(BUILDDEPS)
...@@ -2816,6 +2871,8 @@ runtime/pprof.gox: runtime/pprof.lo ...@@ -2816,6 +2871,8 @@ runtime/pprof.gox: runtime/pprof.lo
$(BUILDGOX) $(BUILDGOX)
runtime/internal/atomic.gox: runtime/internal/atomic.lo runtime/internal/atomic.gox: runtime/internal/atomic.lo
$(BUILDGOX) $(BUILDGOX)
runtime/internal/sys.gox: runtime/internal/sys.lo
$(BUILDGOX)
sync/atomic.gox: sync/atomic.lo sync/atomic.gox: sync/atomic.lo
$(BUILDGOX) $(BUILDGOX)
...@@ -2971,6 +3028,7 @@ TEST_PACKAGES = \ ...@@ -2971,6 +3028,7 @@ TEST_PACKAGES = \
regexp/syntax/check \ regexp/syntax/check \
runtime/pprof/check \ runtime/pprof/check \
runtime/internal/atomic/check \ runtime/internal/atomic/check \
runtime/internal/sys/check \
sync/atomic/check \ sync/atomic/check \
text/scanner/check \ text/scanner/check \
text/tabwriter/check \ text/tabwriter/check \
......
...@@ -213,10 +213,10 @@ am__DEPENDENCIES_1 = bufio.lo bytes.lo bytes/index.lo context.lo \ ...@@ -213,10 +213,10 @@ am__DEPENDENCIES_1 = bufio.lo bytes.lo bytes/index.lo context.lo \
os/user.lo path/filepath.lo regexp/syntax.lo \ os/user.lo path/filepath.lo regexp/syntax.lo \
net/rpc/jsonrpc.lo runtime/debug.lo runtime/pprof.lo \ net/rpc/jsonrpc.lo runtime/debug.lo runtime/pprof.lo \
runtime/internal/atomic.lo runtime/internal/atomic_c.lo \ runtime/internal/atomic.lo runtime/internal/atomic_c.lo \
sync/atomic.lo sync/atomic_c.lo text/scanner.lo \ runtime/internal/sys.lo sync/atomic.lo sync/atomic_c.lo \
text/tabwriter.lo text/template.lo text/template/parse.lo \ text/scanner.lo text/tabwriter.lo text/template.lo \
testing/iotest.lo testing/quick.lo unicode/utf16.lo \ text/template/parse.lo testing/iotest.lo testing/quick.lo \
unicode/utf8.lo unicode/utf16.lo unicode/utf8.lo
am__DEPENDENCIES_2 = am__DEPENDENCIES_2 =
am__DEPENDENCIES_3 = $(am__DEPENDENCIES_1) \ am__DEPENDENCIES_3 = $(am__DEPENDENCIES_1) \
../libbacktrace/libbacktrace.la $(am__DEPENDENCIES_2) \ ../libbacktrace/libbacktrace.la $(am__DEPENDENCIES_2) \
...@@ -341,6 +341,9 @@ ETAGS = etags ...@@ -341,6 +341,9 @@ ETAGS = etags
CTAGS = ctags CTAGS = ctags
DIST_SUBDIRS = testsuite DIST_SUBDIRS = testsuite
ACLOCAL = @ACLOCAL@ ACLOCAL = @ACLOCAL@
ALLGOARCH = @ALLGOARCH@
ALLGOARCHFAMILY = @ALLGOARCHFAMILY@
ALLGOOS = @ALLGOOS@
AMTAR = @AMTAR@ AMTAR = @AMTAR@
AR = @AR@ AR = @AR@
AUTOCONF = @AUTOCONF@ AUTOCONF = @AUTOCONF@
...@@ -365,6 +368,14 @@ EGREP = @EGREP@ ...@@ -365,6 +368,14 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@ EXEEXT = @EXEEXT@
FGREP = @FGREP@ FGREP = @FGREP@
GOARCH = @GOARCH@ GOARCH = @GOARCH@
GOARCH_BIGENDIAN = @GOARCH_BIGENDIAN@
GOARCH_CACHELINESIZE = @GOARCH_CACHELINESIZE@
GOARCH_FAMILY = @GOARCH_FAMILY@
GOARCH_HUGEPAGESIZE = @GOARCH_HUGEPAGESIZE@
GOARCH_INT64ALIGN = @GOARCH_INT64ALIGN@
GOARCH_MINFRAMESIZE = @GOARCH_MINFRAMESIZE@
GOARCH_PCQUANTUM = @GOARCH_PCQUANTUM@
GOARCH_PHYSPAGESIZE = @GOARCH_PHYSPAGESIZE@
GOC = @GOC@ GOC = @GOC@
GOCFLAGS = $(CFLAGS) GOCFLAGS = $(CFLAGS)
GOOS = @GOOS@ GOOS = @GOOS@
...@@ -1099,6 +1110,7 @@ libgo_go_objs = \ ...@@ -1099,6 +1110,7 @@ libgo_go_objs = \
runtime/pprof.lo \ runtime/pprof.lo \
runtime/internal/atomic.lo \ runtime/internal/atomic.lo \
runtime/internal/atomic_c.lo \ runtime/internal/atomic_c.lo \
runtime/internal/sys.lo \
sync/atomic.lo \ sync/atomic.lo \
sync/atomic_c.lo \ sync/atomic_c.lo \
text/scanner.lo \ text/scanner.lo \
...@@ -1238,7 +1250,7 @@ CHECK_DEPS = $(toolexeclibgo_DATA) $(toolexeclibgoarchive_DATA) \ ...@@ -1238,7 +1250,7 @@ CHECK_DEPS = $(toolexeclibgo_DATA) $(toolexeclibgoarchive_DATA) \
@HAVE_STAT_TIMESPEC_FALSE@@LIBGO_IS_SOLARIS_TRUE@matchargs_os = @HAVE_STAT_TIMESPEC_FALSE@@LIBGO_IS_SOLARIS_TRUE@matchargs_os =
@HAVE_STAT_TIMESPEC_TRUE@@LIBGO_IS_SOLARIS_TRUE@matchargs_os = --tag=solaristag @HAVE_STAT_TIMESPEC_TRUE@@LIBGO_IS_SOLARIS_TRUE@matchargs_os = --tag=solaristag
@LIBGO_IS_SOLARIS_FALSE@matchargs_os = @LIBGO_IS_SOLARIS_FALSE@matchargs_os =
extra_go_files_runtime = runtime_sysinfo.go version.go extra_go_files_runtime = runtime_sysinfo.go
runtime_go_lo_GOCFLAGS = -fgo-c-header=runtime.inc.tmp -fgo-compiling-runtime runtime_go_lo_GOCFLAGS = -fgo-c-header=runtime.inc.tmp -fgo-compiling-runtime
@LIBGO_IS_BSD_TRUE@golang_org_x_net_route_lo = \ @LIBGO_IS_BSD_TRUE@golang_org_x_net_route_lo = \
@LIBGO_IS_BSD_TRUE@ golang_org/x/net/route/route.lo @LIBGO_IS_BSD_TRUE@ golang_org/x/net/route/route.lo
...@@ -1251,6 +1263,8 @@ runtime_go_lo_GOCFLAGS = -fgo-c-header=runtime.inc.tmp -fgo-compiling-runtime ...@@ -1251,6 +1263,8 @@ runtime_go_lo_GOCFLAGS = -fgo-c-header=runtime.inc.tmp -fgo-compiling-runtime
# Also use -fno-inline to get better results from the memory profiler. # Also use -fno-inline to get better results from the memory profiler.
runtime_pprof_check_GOCFLAGS = -static-libgo -fno-inline runtime_pprof_check_GOCFLAGS = -static-libgo -fno-inline
runtime_internal_atomic_lo_GOCFLAGS = -fgo-compiling-runtime runtime_internal_atomic_lo_GOCFLAGS = -fgo-compiling-runtime
extra_go_files_runtime_internal_sys = version.go
runtime_internal_sys_lo_GOCFLAGS = -fgo-compiling-runtime
# How to build a .gox file from a .lo file. # How to build a .gox file from a .lo file.
BUILDGOX = \ BUILDGOX = \
...@@ -1389,6 +1403,7 @@ TEST_PACKAGES = \ ...@@ -1389,6 +1403,7 @@ TEST_PACKAGES = \
regexp/syntax/check \ regexp/syntax/check \
runtime/pprof/check \ runtime/pprof/check \
runtime/internal/atomic/check \ runtime/internal/atomic/check \
runtime/internal/sys/check \
sync/atomic/check \ sync/atomic/check \
text/scanner/check \ text/scanner/check \
text/tabwriter/check \ text/tabwriter/check \
...@@ -3567,12 +3582,54 @@ time.c: $(srcdir)/runtime/time.goc goc2c ...@@ -3567,12 +3582,54 @@ time.c: $(srcdir)/runtime/time.goc goc2c
version.go: s-version; @true version.go: s-version; @true
s-version: Makefile s-version: Makefile
rm -f version.go.tmp rm -f version.go.tmp
echo "package runtime" > version.go.tmp echo "package sys" > version.go.tmp
echo 'const defaultGoroot = "$(prefix)"' >> version.go.tmp echo 'const DefaultGoroot = "$(prefix)"' >> version.go.tmp
echo 'const theVersion = "'`cat $(srcdir)/VERSION | sed 1q`' '`$(GOC) --version | sed 1q`'"' >> version.go.tmp echo 'const TheVersion = "'`cat $(srcdir)/VERSION | sed 1q`' '`$(GOC) --version | sed 1q`'"' >> version.go.tmp
echo 'const theGoarch = "'$(GOARCH)'"' >> version.go.tmp echo 'const GOARCH = "'$(GOARCH)'"' >> version.go.tmp
echo 'const theGoos = "'$(GOOS)'"' >> version.go.tmp echo 'const GOOS = "'$(GOOS)'"' >> version.go.tmp
echo 'const theGccgoToolDir = "$(libexecsubdir)"' >> version.go.tmp echo 'const GccgoToolDir = "$(libexecsubdir)"' >> version.go.tmp
echo >> version.go.tmp
echo "type ArchFamilyType int" >> version.go.tmp
echo >> version.go.tmp
echo "const (" >> version.go.tmp
echo " UNKNOWN ArchFamilyType = iota" >> version.go.tmp
for a in $(ALLGOARCHFAMILY); do \
echo " $${a}" >> version.go.tmp; \
done
echo ")" >> version.go.tmp
echo >> version.go.tmp
for a in $(ALLGOARCH); do \
f=`echo $${a} | sed -e 's/\(.\).*/\1/' -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`; \
n="$${f}`echo $${a} | sed -e 's/.//'`"; \
if test "$${a}" = "$(GOARCH)"; then \
echo "const Goarch$${n} = 1" >> version.go.tmp; \
else \
echo "const Goarch$${n} = 0" >> version.go.tmp; \
fi; \
done
echo >> version.go.tmp
echo "const (" >> version.go.tmp
echo " ArchFamily = $(GOARCH_FAMILY)" >> version.go.tmp
echo " BigEndian = $(GOARCH_BIGENDIAN)" >> version.go.tmp
echo " CacheLineSize = $(GOARCH_CACHELINESIZE)" >> version.go.tmp
echo " PhysPageSize = $(GOARCH_PHYSPAGESIZE)" >> version.go.tmp
echo " PCQuantum = $(GOARCH_PCQUANTUM)" >> version.go.tmp
echo " Int64Align = $(GOARCH_INT64ALIGN)" >> version.go.tmp
echo " HugePageSize = $(GOARCH_HUGEPAGESIZE)" >> version.go.tmp
echo " MinFrameSize = $(GOARCH_MINFRAMESIZE)" >> version.go.tmp
echo ")" >> version.go.tmp
echo >> version.go.tmp
for a in $(ALLGOOS); do \
f=`echo $${a} | sed -e 's/\(.\).*/\1/' -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`; \
n="$${f}`echo $${a} | sed -e 's/.//'`"; \
if test "$${a}" = "$(GOOS)"; then \
echo "const Goos$${n} = 1" >> version.go.tmp; \
else \
echo "const Goos$${n} = 0" >> version.go.tmp; \
fi; \
done
echo >> version.go.tmp
echo "type Uintreg uintptr" >> version.go.tmp
$(SHELL) $(srcdir)/mvifdiff.sh version.go.tmp version.go $(SHELL) $(srcdir)/mvifdiff.sh version.go.tmp version.go
$(STAMP) $@ $(STAMP) $@
...@@ -5003,6 +5060,15 @@ runtime/internal/atomic/check: $(CHECK_DEPS) ...@@ -5003,6 +5060,15 @@ runtime/internal/atomic/check: $(CHECK_DEPS)
@$(CHECK) @$(CHECK)
.PHONY: runtime/internal/atomic/check .PHONY: runtime/internal/atomic/check
@go_include@ runtime/internal/sys.lo.dep
runtime/internal/sys.lo.dep: $(srcdir)/go/runtime/internal/sys/*.go
$(BUILDDEPS)
runtime/internal/sys.lo:
$(BUILDPACKAGE)
runtime/internal/sys/check: $(CHECK_DEPS)
@$(CHECK)
.PHONY: runtime/internal/sys/check
@go_include@ sync/atomic.lo.dep @go_include@ sync/atomic.lo.dep
sync/atomic.lo.dep: $(srcdir)/go/sync/atomic/*.go sync/atomic.lo.dep: $(srcdir)/go/sync/atomic/*.go
$(BUILDDEPS) $(BUILDDEPS)
...@@ -5433,6 +5499,8 @@ runtime/pprof.gox: runtime/pprof.lo ...@@ -5433,6 +5499,8 @@ runtime/pprof.gox: runtime/pprof.lo
$(BUILDGOX) $(BUILDGOX)
runtime/internal/atomic.gox: runtime/internal/atomic.lo runtime/internal/atomic.gox: runtime/internal/atomic.lo
$(BUILDGOX) $(BUILDGOX)
runtime/internal/sys.gox: runtime/internal/sys.lo
$(BUILDGOX)
sync/atomic.gox: sync/atomic.lo sync/atomic.gox: sync/atomic.lo
$(BUILDGOX) $(BUILDGOX)
......
...@@ -142,6 +142,11 @@ AC_SUBST(LIBATOMIC) ...@@ -142,6 +142,11 @@ AC_SUBST(LIBATOMIC)
go_include="-include" go_include="-include"
AC_SUBST(go_include) AC_SUBST(go_include)
# All known GOOS values. This is the union of all operating systems
# supported by the gofrontend and all operating systems supported by
# the gc toolchain.
ALLGOOS="android darwin dragonfly freebsd irix linux netbsd openbsd plan9 rtems solaris windows"
is_darwin=no is_darwin=no
is_freebsd=no is_freebsd=no
is_irix=no is_irix=no
...@@ -174,6 +179,7 @@ AM_CONDITIONAL(LIBGO_IS_RTEMS, test $is_rtems = yes) ...@@ -174,6 +179,7 @@ AM_CONDITIONAL(LIBGO_IS_RTEMS, test $is_rtems = yes)
AM_CONDITIONAL(LIBGO_IS_SOLARIS, test $is_solaris = yes) AM_CONDITIONAL(LIBGO_IS_SOLARIS, test $is_solaris = yes)
AM_CONDITIONAL(LIBGO_IS_BSD, test $is_darwin = yes -o $is_dragonfly = yes -o $is_freebsd = yes -o $is_netbsd = yes -o $is_openbsd = yes) AM_CONDITIONAL(LIBGO_IS_BSD, test $is_darwin = yes -o $is_dragonfly = yes -o $is_freebsd = yes -o $is_netbsd = yes -o $is_openbsd = yes)
AC_SUBST(GOOS) AC_SUBST(GOOS)
AC_SUBST(ALLGOOS)
dnl Test whether we need to use DejaGNU or whether we can use the dnl Test whether we need to use DejaGNU or whether we can use the
dnl simpler gotest approach. We can only use gotest for a native dnl simpler gotest approach. We can only use gotest for a native
...@@ -186,35 +192,46 @@ case ${host} in ...@@ -186,35 +192,46 @@ case ${host} in
esac esac
AC_SUBST(USE_DEJAGNU) AC_SUBST(USE_DEJAGNU)
dnl N.B. Keep in sync with gcc/testsuite/go.test/go-test.exp (go-set-goarch). # All known GOARCH values. This is the union of all architectures
is_386=no # supported by the gofrontend and all architectures supported by the
is_alpha=no # gc toolchain.
is_arm=no # N.B. Keep in sync with gcc/testsuite/go.test/go-test.exp (go-set-goarch).
is_arm64=no ALLGOARCH="386 alpha amd64 amd64p32 arm armbe arm64 arm64be ia64 m68k mipso32 mipsn32 mipso64 mipsn64 mips mipsle mips64 mips64le mips64p32 mips64pe32le ppc ppc64 ppc64le s390 s390x sparc sparc64"
is_ia64=no
is_m68k=no # All known GOARCH_FAMILY values.
mips_abi=unknown ALLGOARCHFAMILY="I386 ALPHA AMD64 ARM ARM64 IA64 M68K MIPS MIPS64 PPC PPC64 S390 S390X SPARC SPARC64"
is_ppc=no
is_ppc64=no
is_ppc64le=no
is_s390=no
is_s390x=no
is_sparc=no
is_sparc64=no
is_x86_64=no
GOARCH=unknown GOARCH=unknown
GOARCH_FAMILY=unknown
GOARCH_BIGENDIAN=0
GOARCH_CACHELINESIZE=64
GOARCH_PHYSPAGESIZE=4096
GOARCH_PCQUANTUM=1
GOARCH_INT64ALIGN=8
GOARCH_HUGEPAGESIZE=0
GOARCH_MINFRAMESIZE=0
case ${host} in case ${host} in
alpha*-*-*) alpha*-*-*)
is_alpha=yes
GOARCH=alpha GOARCH=alpha
GOARCH_FAMILY=ALPHA
GOARCH_PHYSPAGESIZE=8192
GOARCH_PCQUANTUM=4
;; ;;
aarch64-*-*) aarch64-*-*)
is_arm64=yes
GOARCH=arm64 GOARCH=arm64
GOARCH_FAMILY=ARM64
GOARCH_CACHELINESIZE=32
GOARCH_PHYSPAGESIZE=65536
GOARCH_PCQUANTUm=4
GOARCH_MINFRAMESIZE=8
;; ;;
arm*-*-* | strongarm*-*-* | ep9312*-*-* | xscale-*-*) arm*-*-* | strongarm*-*-* | ep9312*-*-* | xscale-*-*)
is_arm=yes
GOARCH=arm GOARCH=arm
GOARCH_FAMILY=ARM
GOARCH_CACHELINESIZE=32
GOARCH_PCQUANTUM=4
GOARCH_INT64ALIGN=4
GOARCH_MINFRAMESIZE=4
;; ;;
changequote(,)dnl changequote(,)dnl
i[34567]86-*-* | x86_64-*-*) i[34567]86-*-* | x86_64-*-*)
...@@ -223,20 +240,29 @@ changequote([,])dnl ...@@ -223,20 +240,29 @@ changequote([,])dnl
#ifdef __x86_64__ #ifdef __x86_64__
#error 64-bit #error 64-bit
#endif], #endif],
[is_386=yes], [is_x86_64=yes]) [GOARCH=386
if test "$is_386" = "yes"; then GOARCH_FAMILY=I386
GOARCH=386 GOARCH_INT64ALIGN=4
else GOARCH_HUGEPAGESIZE="1 << 21"
GOARCH=amd64 ],
fi [GOARCH=amd64
GOARCH_FAMILY=AMD64
GOARCH_HUGEPAGESIZE="1 << 21"
])
;; ;;
ia64-*-*) ia64-*-*)
is_ia64=yes
GOARCH=ia64 GOARCH=ia64
GOARCH_FAMILY=IA64
GOARCH_CACHELINESIZE=16384
GOARCH_PHYSPAGESIZE=8192
;; ;;
m68k*-*-*) m68k*-*-*)
is_m68k=yes
GOARCH=m68k GOARCH=m68k
GOARCH_FAMILY=M68K
GOARCH_BIGENDIAN=1
GOARCH_CACHELINESIZE=16
GOARCH_PCQUANTUM=4
GOARCH_INT64ALIGN=4
;; ;;
mips*-*-*) mips*-*-*)
AC_COMPILE_IFELSE([ AC_COMPILE_IFELSE([
...@@ -267,72 +293,98 @@ changequote([,])dnl ...@@ -267,72 +293,98 @@ changequote([,])dnl
"n64") GOARCH=mipsn64 ;; "n64") GOARCH=mipsn64 ;;
"o64") GOARCH=mipso64 ;; "o64") GOARCH=mipso64 ;;
esac esac
case "$mips_abi" in
"o32" | "n32")
GOARCH_FAMILY=MIPS
GOARCH_INT64ALIGN=4
GOARCH_MINFRAMESIZE=4
;;
"n64" | "o64")
GOARCH_FAMILY=MIPS64
GOARCH_MINFRAMESIZE=8
;;
esac
case "${host}" in
mips*el)
;;
*)
GOARCH_BIGENDIAN=1
;;
esac
GOARCH_CACHELINESIZE=32
GOARCH_PHYSPAGESIZE=16384
GOARCH_PCQUANTUM=4
;; ;;
rs6000*-*-* | powerpc*-*-*) rs6000*-*-* | powerpc*-*-*)
AC_COMPILE_IFELSE([ AC_COMPILE_IFELSE([
#ifdef _ARCH_PPC64 #ifdef _ARCH_PPC64
#error 64-bit #error 64-bit
#endif], #endif],
[is_ppc=yes], [GOARCH=ppc
[AC_COMPILE_IFELSE([ GOARCH_FAMILY=PPC
GOARCH_BIGENDIAN=1
GOARCH_INT64ALIGN=4
],
[
GOARCH_FAMILY=PPC64
AC_COMPILE_IFELSE([
#if defined(_BIG_ENDIAN) || defined(__BIG_ENDIAN__) #if defined(_BIG_ENDIAN) || defined(__BIG_ENDIAN__)
#error 64be #error 64be
#endif], #endif],
[is_ppc64le=yes],[is_ppc64=yes])]) [GOARCH=ppc64le
if test "$is_ppc" = "yes"; then ],
GOARCH=ppc [GOARCH=ppc64
elif test "$is_ppc64" = "yes"; then GOARCH_BIGENDIAN=1
GOARCH=ppc64 ])])
else GOARCH_PHYSPAGESIZE=65536
GOARCH=ppc64le GOARCH_PCQUANTUM=4
fi GOARCH_MINFRAMESIZE=32
;; ;;
s390*-*-*) s390*-*-*)
AC_COMPILE_IFELSE([ AC_COMPILE_IFELSE([
#if defined(__s390x__) #if defined(__s390x__)
#error 64-bit #error 64-bit
#endif], #endif],
[is_s390=yes], [is_s390x=yes]) [GOARCH=s390
if test "$is_s390" = "yes"; then GOARCH_FAMILY=S390
GOARCH=s390 GOARCH_INT64ALIGN=4
else GOARCH_MINFRAMESIZE=4
GOARCH=s390x ], [GOARCH=s390x
fi GOARCH_FAMILY=S390X
GOARCH_MINFRAMESIZE=8
])
GOARCH_BIGENDIAN=1
GOARCH_CACHELINESIZE=256
GOARCH_PCQUANTUM=2
;; ;;
sparc*-*-*) sparc*-*-*)
AC_COMPILE_IFELSE([ AC_COMPILE_IFELSE([
#if defined(__sparcv9) || defined(__arch64__) #if defined(__sparcv9) || defined(__arch64__)
#error 64-bit #error 64-bit
#endif], #endif],
[is_sparc=yes], [is_sparc64=yes]) [GOARCH=sparc
if test "$is_sparc" = "yes"; then GOARCH_FAMILY=SPARC
GOARCH=sparc GOARCH_INT64ALIGN=4
else ],
GOARCH=sparc64 [GOARCH=sparc64
fi GOARCH_FAMILY=SPARC64
])
GOARCH_BIGENDIAN=1
GOARCH_PHYSPAGESIZE=8192
GOARCH_PCQUANTUM=4
;; ;;
esac esac
AM_CONDITIONAL(LIBGO_IS_386, test $is_386 = yes)
AM_CONDITIONAL(LIBGO_IS_ALPHA, test $is_alpha = yes)
AM_CONDITIONAL(LIBGO_IS_ARM, test $is_arm = yes)
AM_CONDITIONAL(LIBGO_IS_ARM64, test $is_arm64 = yes)
AM_CONDITIONAL(LIBGO_IS_IA64, test $is_ia64 = yes)
AM_CONDITIONAL(LIBGO_IS_M68K, test $is_m68k = yes)
AM_CONDITIONAL(LIBGO_IS_MIPS, test $mips_abi != unknown)
AM_CONDITIONAL(LIBGO_IS_MIPSO32, test $mips_abi = o32)
AM_CONDITIONAL(LIBGO_IS_MIPSN32, test $mips_abi = n32)
AM_CONDITIONAL(LIBGO_IS_MIPSN64, test $mips_abi = n64)
AM_CONDITIONAL(LIBGO_IS_MIPSO64, test $mips_abi = o64)
AM_CONDITIONAL(LIBGO_IS_MIPS64, test $mips_abi = n64 -o $mips_abi = o64)
AM_CONDITIONAL(LIBGO_IS_PPC, test $is_ppc = yes)
AM_CONDITIONAL(LIBGO_IS_PPC64, test $is_ppc64 = yes)
AM_CONDITIONAL(LIBGO_IS_PPC64LE, test $is_ppc64le = yes)
AM_CONDITIONAL(LIBGO_IS_S390, test $is_s390 = yes)
AM_CONDITIONAL(LIBGO_IS_S390X, test $is_s390x = yes)
AM_CONDITIONAL(LIBGO_IS_SPARC, test $is_sparc = yes)
AM_CONDITIONAL(LIBGO_IS_SPARC64, test $is_sparc64 = yes)
AM_CONDITIONAL(LIBGO_IS_X86_64, test $is_x86_64 = yes)
AC_SUBST(GOARCH) AC_SUBST(GOARCH)
AC_SUBST(GOARCH_FAMILY)
AC_SUBST(GOARCH_BIGENDIAN)
AC_SUBST(GOARCH_CACHELINESIZE)
AC_SUBST(GOARCH_PHYSPAGESIZE)
AC_SUBST(GOARCH_PCQUANTUM)
AC_SUBST(GOARCH_INT64ALIGN)
AC_SUBST(GOARCH_HUGEPAGESIZE)
AC_SUBST(GOARCH_MINFRAMESIZE)
AC_SUBST(ALLGOARCH)
AC_SUBST(ALLGOARCHFAMILY)
dnl Some files are only present when needed for specific architectures. dnl Some files are only present when needed for specific architectures.
GO_LIBCALL_OS_FILE= GO_LIBCALL_OS_FILE=
......
...@@ -157,6 +157,8 @@ of the run-time system. ...@@ -157,6 +157,8 @@ of the run-time system.
*/ */
package runtime package runtime
import "runtime/internal/sys"
// Gosched yields the processor, allowing other goroutines to run. It does not // Gosched yields the processor, allowing other goroutines to run. It does not
// suspend the current goroutine, so execution resumes automatically. // suspend the current goroutine, so execution resumes automatically.
func Gosched() func Gosched()
...@@ -282,23 +284,23 @@ func GOROOT() string { ...@@ -282,23 +284,23 @@ func GOROOT() string {
if s != "" { if s != "" {
return s return s
} }
return defaultGoroot return sys.DefaultGoroot
} }
// Version returns the Go tree's version string. // Version returns the Go tree's version string.
// It is either the commit hash and date at the time of the build or, // It is either the commit hash and date at the time of the build or,
// when possible, a release tag like "go1.3". // when possible, a release tag like "go1.3".
func Version() string { func Version() string {
return theVersion return sys.TheVersion
} }
// GOOS is the running program's operating system target: // GOOS is the running program's operating system target:
// one of darwin, freebsd, linux, and so on. // one of darwin, freebsd, linux, and so on.
const GOOS string = theGoos const GOOS string = sys.GOOS
// GOARCH is the running program's architecture target: // GOARCH is the running program's architecture target:
// 386, amd64, arm, or s390x. // 386, amd64, arm, or s390x.
const GOARCH string = theGoarch const GOARCH string = sys.GOARCH
// GCCGOTOOLDIR is the Tool Dir for the gccgo build // GCCGOTOOLDIR is the Tool Dir for the gccgo build
const GCCGOTOOLDIR string = theGccgoToolDir const GCCGOTOOLDIR string = sys.GccgoToolDir
// Copyright 2016 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.
package sys
//extern __builtin_ctz
func builtinCtz32(uint32) int32
//extern __builtin_ctzll
func builtinCtz64(uint64) int32
//go:nosplit
// Ctz64 counts trailing (low-order) zeroes,
// and if all are zero, then 64.
func Ctz64(x uint64) uint64 {
if x == 0 {
return 64
}
return uint64(builtinCtz64(x))
}
//go:nosplit
// Ctz32 counts trailing (low-order) zeroes,
// and if all are zero, then 32.
func Ctz32(x uint32) uint32 {
if x == 0 {
return 32
}
return uint32(builtinCtz32(x))
}
//go:nosplit
// Ctz16 counts trailing (low-order) zeroes,
// and if all are zero, then 16.
func Ctz16(x uint16) uint16 {
if x == 0 {
return 16
}
return uint16(builtinCtz32(uint32(x)))
}
//go:nosplit
// Ctz8 counts trailing (low-order) zeroes,
// and if all are zero, then 8.
func Ctz8(x uint8) uint8 {
if x == 0 {
return 8
}
return uint8(builtinCtz32(uint32(x)))
}
//extern __builtin_bswap64
func bswap64(uint64) uint64
//go:nosplit
// Bswap64 returns its input with byte order reversed
// 0x0102030405060708 -> 0x0807060504030201
func Bswap64(x uint64) uint64 {
return bswap64(x)
}
//extern __builtin_bswap32
func bswap32(uint32) uint32
//go:nosplit
// Bswap32 returns its input with byte order reversed
// 0x01020304 -> 0x04030201
func Bswap32(x uint32) uint32 {
return bswap32(x)
}
package sys_test
import (
"runtime/internal/sys"
"testing"
)
func TestCtz64(t *testing.T) {
for i := uint(0); i <= 64; i++ {
x := uint64(5) << i
if got := sys.Ctz64(x); got != uint64(i) {
t.Errorf("Ctz64(%d)=%d, want %d", x, got, i)
}
}
}
func TestCtz32(t *testing.T) {
for i := uint(0); i <= 32; i++ {
x := uint32(5) << i
if got := sys.Ctz32(x); got != uint32(i) {
t.Errorf("Ctz32(%d)=%d, want %d", x, got, i)
}
}
}
func TestCtz16(t *testing.T) {
for i := uint(0); i <= 16; i++ {
x := uint16(5) << i
if got := sys.Ctz16(x); got != uint16(i) {
t.Errorf("Ctz16(%d)=%d, want %d", x, got, i)
}
}
}
func TestCtz8(t *testing.T) {
for i := uint(0); i <= 8; i++ {
x := uint8(5) << i
if got := sys.Ctz8(x); got != uint8(i) {
t.Errorf("Ctz8(%d)=%d, want %d", x, got, i)
}
}
}
func TestBswap64(t *testing.T) {
x := uint64(0x1122334455667788)
y := sys.Bswap64(x)
if y != 0x8877665544332211 {
t.Errorf("Bswap(%x)=%x, want 0x8877665544332211", x, y)
}
}
func TestBswap32(t *testing.T) {
x := uint32(0x11223344)
y := sys.Bswap32(x)
if y != 0x44332211 {
t.Errorf("Bswap(%x)=%x, want 0x44332211", x, y)
}
}
// Copyright 2014 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.
package sys
// Declarations for runtime services implemented in C or assembly.
const PtrSize = 4 << (^uintptr(0) >> 63) // unsafe.Sizeof(uintptr(0)) but an ideal const
const RegSize = 4 << (^Uintreg(0) >> 63) // unsafe.Sizeof(uintreg(0)) but an ideal const
const SpAlign = 1*(1-GoarchArm64) + 16*GoarchArm64 // SP alignment: 1 normally, 16 for ARM64
// Copyright 2015 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.
// package sys contains system- and configuration- and architecture-specific
// constants used by the runtime.
package sys
// The next line makes 'go generate' write the zgen_*.go files with
// per-OS and per-arch information, including constants
// named goos_$GOOS and goarch_$GOARCH for every
// known GOOS and GOARCH. The constant is 1 on the
// current system, 0 otherwise; multiplying by them is
// useful for defining GOOS- or GOARCH-specific constants.
//go:generate go run gengoos.go
...@@ -79,6 +79,9 @@ am__can_run_installinfo = \ ...@@ -79,6 +79,9 @@ am__can_run_installinfo = \
DEJATOOL = $(PACKAGE) DEJATOOL = $(PACKAGE)
RUNTESTDEFAULTFLAGS = --tool $$tool --srcdir $$srcdir RUNTESTDEFAULTFLAGS = --tool $$tool --srcdir $$srcdir
ACLOCAL = @ACLOCAL@ ACLOCAL = @ACLOCAL@
ALLGOARCH = @ALLGOARCH@
ALLGOARCHFAMILY = @ALLGOARCHFAMILY@
ALLGOOS = @ALLGOOS@
AMTAR = @AMTAR@ AMTAR = @AMTAR@
AR = @AR@ AR = @AR@
AUTOCONF = @AUTOCONF@ AUTOCONF = @AUTOCONF@
...@@ -103,6 +106,14 @@ EGREP = @EGREP@ ...@@ -103,6 +106,14 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@ EXEEXT = @EXEEXT@
FGREP = @FGREP@ FGREP = @FGREP@
GOARCH = @GOARCH@ GOARCH = @GOARCH@
GOARCH_BIGENDIAN = @GOARCH_BIGENDIAN@
GOARCH_CACHELINESIZE = @GOARCH_CACHELINESIZE@
GOARCH_FAMILY = @GOARCH_FAMILY@
GOARCH_HUGEPAGESIZE = @GOARCH_HUGEPAGESIZE@
GOARCH_INT64ALIGN = @GOARCH_INT64ALIGN@
GOARCH_MINFRAMESIZE = @GOARCH_MINFRAMESIZE@
GOARCH_PCQUANTUM = @GOARCH_PCQUANTUM@
GOARCH_PHYSPAGESIZE = @GOARCH_PHYSPAGESIZE@
GOC = @GOC@ GOC = @GOC@
GOCFLAGS = @GOCFLAGS@ GOCFLAGS = @GOCFLAGS@
GOOS = @GOOS@ GOOS = @GOOS@
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment