summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2010-06-21 19:53:08 -0700
committerRuss Cox <rsc@golang.org>2010-06-21 19:53:08 -0700
commit52c4f3e4ddeeb956b74d41ab6a0c80bc1f2b315d (patch)
treeef39af2c3ee11e81e780b37138f87e14face7fe1
parent9ea3cfaff02122d9c60e1aa2870587d0f4327feb (diff)
downloadgolang-52c4f3e4ddeeb956b74d41ab6a0c80bc1f2b315d.tar.gz
big, bytes: move assembly externs to separate file
to make it easier to build package without assembly. R=r, r2 CC=golang-dev http://codereview.appspot.com/1680045
-rw-r--r--src/pkg/big/Makefile1
-rw-r--r--src/pkg/big/arith.go11
-rw-r--r--src/pkg/big/arith_decl.go18
-rw-r--r--src/pkg/bytes/Makefile1
-rw-r--r--src/pkg/bytes/bytes.go3
-rw-r--r--src/pkg/bytes/bytes_decl.go8
6 files changed, 28 insertions, 14 deletions
diff --git a/src/pkg/big/Makefile b/src/pkg/big/Makefile
index d858e5a68..7a4311dca 100644
--- a/src/pkg/big/Makefile
+++ b/src/pkg/big/Makefile
@@ -7,6 +7,7 @@ include ../../Make.$(GOARCH)
TARG=big
GOFILES=\
arith.go\
+ arith_decl.go\
int.go\
nat.go\
rat.go\
diff --git a/src/pkg/big/arith.go b/src/pkg/big/arith.go
index a5e0dec68..29966c7bc 100644
--- a/src/pkg/big/arith.go
+++ b/src/pkg/big/arith.go
@@ -56,7 +56,6 @@ func subWW_g(x, y, c Word) (z1, z0 Word) {
// z1<<_W + z0 = x*y
-func mulWW(x, y Word) (z1, z0 Word)
func mulWW_g(x, y Word) (z1, z0 Word) {
// Split x and y into 2 halfWords each, multiply
// the halfWords separately while avoiding overflow,
@@ -243,7 +242,6 @@ func leadingZeros(x Word) uint {
// q = (x1<<_W + x0 - r)/y
-func divWW(x1, x0, y Word) (q, r Word)
func divWW_g(x1, x0, y Word) (q, r Word) {
if x1 == 0 {
q, r = x0/y, x0%y
@@ -286,7 +284,6 @@ func divWW_g(x1, x0, y Word) (q, r Word) {
}
-func addVV(z, x, y []Word) (c Word)
func addVV_g(z, x, y []Word) (c Word) {
for i := range z {
c, z[i] = addWW_g(x[i], y[i], c)
@@ -295,7 +292,6 @@ func addVV_g(z, x, y []Word) (c Word) {
}
-func subVV(z, x, y []Word) (c Word)
func subVV_g(z, x, y []Word) (c Word) {
for i := range z {
c, z[i] = subWW_g(x[i], y[i], c)
@@ -304,7 +300,6 @@ func subVV_g(z, x, y []Word) (c Word) {
}
-func addVW(z, x []Word, y Word) (c Word)
func addVW_g(z, x []Word, y Word) (c Word) {
c = y
for i := range z {
@@ -314,7 +309,6 @@ func addVW_g(z, x []Word, y Word) (c Word) {
}
-func subVW(z, x []Word, y Word) (c Word)
func subVW_g(z, x []Word, y Word) (c Word) {
c = y
for i := range z {
@@ -324,7 +318,6 @@ func subVW_g(z, x []Word, y Word) (c Word) {
}
-func shlVW(z, x []Word, s Word) (c Word)
func shlVW_g(z, x []Word, s Word) (c Word) {
if n := len(z); n > 0 {
ŝ := _W - s
@@ -341,7 +334,6 @@ func shlVW_g(z, x []Word, s Word) (c Word) {
}
-func shrVW(z, x []Word, s Word) (c Word)
func shrVW_g(z, x []Word, s Word) (c Word) {
if n := len(z); n > 0 {
ŝ := _W - s
@@ -358,7 +350,6 @@ func shrVW_g(z, x []Word, s Word) (c Word) {
}
-func mulAddVWW(z, x []Word, y, r Word) (c Word)
func mulAddVWW_g(z, x []Word, y, r Word) (c Word) {
c = r
for i := range z {
@@ -368,7 +359,6 @@ func mulAddVWW_g(z, x []Word, y, r Word) (c Word) {
}
-func addMulVVW(z, x []Word, y Word) (c Word)
func addMulVVW_g(z, x []Word, y Word) (c Word) {
for i := range z {
z1, z0 := mulAddWWW_g(x[i], y, z[i])
@@ -379,7 +369,6 @@ func addMulVVW_g(z, x []Word, y Word) (c Word) {
}
-func divWVW(z []Word, xn Word, x []Word, y Word) (r Word)
func divWVW_g(z []Word, xn Word, x []Word, y Word) (r Word) {
r = xn
for i := len(z) - 1; i >= 0; i-- {
diff --git a/src/pkg/big/arith_decl.go b/src/pkg/big/arith_decl.go
new file mode 100644
index 000000000..c456d5f67
--- /dev/null
+++ b/src/pkg/big/arith_decl.go
@@ -0,0 +1,18 @@
+// Copyright 2010 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 big
+
+// implemented in arith_$GOARCH.s
+func mulWW(x, y Word) (z1, z0 Word)
+func divWW(x1, x0, y Word) (q, r Word)
+func addVV(z, x, y []Word) (c Word)
+func subVV(z, x, y []Word) (c Word)
+func addVW(z, x []Word, y Word) (c Word)
+func subVW(z, x []Word, y Word) (c Word)
+func shlVW(z, x []Word, s Word) (c Word)
+func shrVW(z, x []Word, s Word) (c Word)
+func mulAddVWW(z, x []Word, y, r Word) (c Word)
+func addMulVVW(z, x []Word, y Word) (c Word)
+func divWVW(z []Word, xn Word, x []Word, y Word) (r Word)
diff --git a/src/pkg/bytes/Makefile b/src/pkg/bytes/Makefile
index b2076c181..d50e624d6 100644
--- a/src/pkg/bytes/Makefile
+++ b/src/pkg/bytes/Makefile
@@ -8,6 +8,7 @@ TARG=bytes
GOFILES=\
buffer.go\
bytes.go\
+ bytes_decl.go\
OFILES=\
asm_$(GOARCH).$O\
diff --git a/src/pkg/bytes/bytes.go b/src/pkg/bytes/bytes.go
index a8ecf3adf..852e0f852 100644
--- a/src/pkg/bytes/bytes.go
+++ b/src/pkg/bytes/bytes.go
@@ -103,9 +103,6 @@ func Index(s, sep []byte) int {
return -1
}
-// IndexByte returns the index of the first instance of c in s, or -1 if c is not present in s.
-func IndexByte(s []byte, c byte) int // asm_$GOARCH.s
-
func indexBytePortable(s []byte, c byte) int {
for i, b := range s {
if b == c {
diff --git a/src/pkg/bytes/bytes_decl.go b/src/pkg/bytes/bytes_decl.go
new file mode 100644
index 000000000..5d2b9e639
--- /dev/null
+++ b/src/pkg/bytes/bytes_decl.go
@@ -0,0 +1,8 @@
+// Copyright 2010 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 bytes
+
+// IndexByte returns the index of the first instance of c in s, or -1 if c is not present in s.
+func IndexByte(s []byte, c byte) int // asm_$GOARCH.s