]> Cypherpunks repositories - gostls13.git/commitdiff
big, bytes: move assembly externs to separate file
authorRuss Cox <rsc@golang.org>
Tue, 22 Jun 2010 02:53:08 +0000 (19:53 -0700)
committerRuss Cox <rsc@golang.org>
Tue, 22 Jun 2010 02:53:08 +0000 (19:53 -0700)
to make it easier to build package without assembly.

R=r, r2
CC=golang-dev
https://golang.org/cl/1680045

src/pkg/big/Makefile
src/pkg/big/arith.go
src/pkg/big/arith_decl.go [new file with mode: 0644]
src/pkg/bytes/Makefile
src/pkg/bytes/bytes.go
src/pkg/bytes/bytes_decl.go [new file with mode: 0644]

index d858e5a687bf7cdc1808ae36b2d8917ae5af6dfc..7a4311dca49202edf90036a63b1b76149f85cd9d 100644 (file)
@@ -7,6 +7,7 @@ include ../../Make.$(GOARCH)
 TARG=big
 GOFILES=\
        arith.go\
+       arith_decl.go\
        int.go\
        nat.go\
        rat.go\
index a5e0dec68ecc559689dee3d37cbc5d810b2de438..29966c7bc57ebf0e0ef67737dbd8791923f1d036 100644 (file)
@@ -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 (file)
index 0000000..c456d5f
--- /dev/null
@@ -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)
index b2076c181ccdafd67acebf400f9d57d3427bb4c7..d50e624d6eb971c9c3d8146301fff6ba0980703a 100644 (file)
@@ -8,6 +8,7 @@ TARG=bytes
 GOFILES=\
        buffer.go\
        bytes.go\
+       bytes_decl.go\
 
 OFILES=\
        asm_$(GOARCH).$O\
index a8ecf3adf9a9695785884eaf616b85b30e39952b..852e0f8529d919dfd4f4ef76b241cd58551c32b8 100644 (file)
@@ -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 (file)
index 0000000..5d2b9e6
--- /dev/null
@@ -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