summaryrefslogtreecommitdiff
path: root/src/pkg/math
diff options
context:
space:
mode:
Diffstat (limited to 'src/pkg/math')
-rw-r--r--src/pkg/math/abs_386.s4
-rw-r--r--src/pkg/math/abs_amd64.s4
-rw-r--r--src/pkg/math/abs_arm.s4
-rw-r--r--src/pkg/math/asin.go4
-rw-r--r--src/pkg/math/asin_386.s6
-rw-r--r--src/pkg/math/asin_amd64.s6
-rw-r--r--src/pkg/math/asin_arm.s6
-rw-r--r--src/pkg/math/atan.go2
-rw-r--r--src/pkg/math/atan2_386.s4
-rw-r--r--src/pkg/math/atan2_amd64.s4
-rw-r--r--src/pkg/math/atan2_arm.s4
-rw-r--r--src/pkg/math/atan_386.s4
-rw-r--r--src/pkg/math/atan_amd64.s4
-rw-r--r--src/pkg/math/atan_arm.s4
-rw-r--r--src/pkg/math/big/arith_386.s26
-rw-r--r--src/pkg/math/big/arith_amd64.s26
-rw-r--r--src/pkg/math/big/arith_arm.s26
-rw-r--r--src/pkg/math/big/int.go18
-rw-r--r--src/pkg/math/big/int_test.go28
-rw-r--r--src/pkg/math/big/nat_test.go2
-rw-r--r--src/pkg/math/big/rat.go12
-rw-r--r--src/pkg/math/big/rat_test.go26
-rw-r--r--src/pkg/math/bits.go10
-rw-r--r--src/pkg/math/dim_386.s8
-rw-r--r--src/pkg/math/dim_amd64.s8
-rw-r--r--src/pkg/math/dim_arm.s8
-rw-r--r--src/pkg/math/exp2_386.s4
-rw-r--r--src/pkg/math/exp2_amd64.s4
-rw-r--r--src/pkg/math/exp2_arm.s4
-rw-r--r--src/pkg/math/exp_386.s4
-rw-r--r--src/pkg/math/exp_amd64.s4
-rw-r--r--src/pkg/math/exp_arm.s4
-rw-r--r--src/pkg/math/expm1_386.s4
-rw-r--r--src/pkg/math/expm1_amd64.s4
-rw-r--r--src/pkg/math/expm1_arm.s4
-rw-r--r--src/pkg/math/floor_386.s8
-rw-r--r--src/pkg/math/floor_amd64.s8
-rw-r--r--src/pkg/math/floor_arm.s8
-rw-r--r--src/pkg/math/fltasm_amd64.s67
-rw-r--r--src/pkg/math/frexp_386.s4
-rw-r--r--src/pkg/math/frexp_amd64.s4
-rw-r--r--src/pkg/math/frexp_arm.s4
-rw-r--r--src/pkg/math/hypot_386.s4
-rw-r--r--src/pkg/math/hypot_amd64.s4
-rw-r--r--src/pkg/math/hypot_arm.s4
-rw-r--r--src/pkg/math/ldexp_386.s4
-rw-r--r--src/pkg/math/ldexp_amd64.s4
-rw-r--r--src/pkg/math/ldexp_arm.s4
-rw-r--r--src/pkg/math/log10_386.s6
-rw-r--r--src/pkg/math/log10_amd64.s6
-rw-r--r--src/pkg/math/log10_arm.s6
-rw-r--r--src/pkg/math/log1p_386.s4
-rw-r--r--src/pkg/math/log1p_amd64.s4
-rw-r--r--src/pkg/math/log1p_arm.s4
-rw-r--r--src/pkg/math/log_386.s4
-rw-r--r--src/pkg/math/log_amd64.s4
-rw-r--r--src/pkg/math/log_arm.s4
-rw-r--r--src/pkg/math/mod_386.s4
-rw-r--r--src/pkg/math/mod_amd64.s4
-rw-r--r--src/pkg/math/mod_arm.s4
-rw-r--r--src/pkg/math/modf_386.s4
-rw-r--r--src/pkg/math/modf_amd64.s4
-rw-r--r--src/pkg/math/modf_arm.s4
-rw-r--r--src/pkg/math/rand/example_test.go32
-rw-r--r--src/pkg/math/rand/rand.go42
-rw-r--r--src/pkg/math/remainder_386.s4
-rw-r--r--src/pkg/math/remainder_amd64.s4
-rw-r--r--src/pkg/math/remainder_arm.s4
-rw-r--r--src/pkg/math/sin.go4
-rw-r--r--src/pkg/math/sin_386.s6
-rw-r--r--src/pkg/math/sin_amd64.s6
-rw-r--r--src/pkg/math/sin_arm.s6
-rw-r--r--src/pkg/math/sincos_386.s4
-rw-r--r--src/pkg/math/sincos_amd64.s4
-rw-r--r--src/pkg/math/sincos_arm.s4
-rw-r--r--src/pkg/math/sqrt_386.s4
-rw-r--r--src/pkg/math/sqrt_amd64.s4
-rw-r--r--src/pkg/math/sqrt_arm.s4
-rw-r--r--src/pkg/math/tan.go2
-rw-r--r--src/pkg/math/tan_386.s4
-rw-r--r--src/pkg/math/tan_amd64.s4
-rw-r--r--src/pkg/math/tan_arm.s4
82 files changed, 406 insertions, 227 deletions
diff --git a/src/pkg/math/abs_386.s b/src/pkg/math/abs_386.s
index 574676475..3490cf66c 100644
--- a/src/pkg/math/abs_386.s
+++ b/src/pkg/math/abs_386.s
@@ -2,8 +2,10 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+#include "../../cmd/ld/textflag.h"
+
// func Abs(x float64) float64
-TEXT ·Abs(SB),7,$0
+TEXT ·Abs(SB),NOSPLIT,$0
FMOVD x+0(FP), F0 // F0=x
FABS // F0=|x|
FMOVDP F0, ret+8(FP)
diff --git a/src/pkg/math/abs_amd64.s b/src/pkg/math/abs_amd64.s
index 119346045..779c8f548 100644
--- a/src/pkg/math/abs_amd64.s
+++ b/src/pkg/math/abs_amd64.s
@@ -2,8 +2,10 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+#include "../../cmd/ld/textflag.h"
+
// func Abs(x float64) float64
-TEXT ·Abs(SB),7,$0
+TEXT ·Abs(SB),NOSPLIT,$0
MOVQ $(1<<63), BX
MOVQ BX, X0 // movsd $(-0.0), x0
MOVSD x+0(FP), X1
diff --git a/src/pkg/math/abs_arm.s b/src/pkg/math/abs_arm.s
index 929e1ce67..b5117ab39 100644
--- a/src/pkg/math/abs_arm.s
+++ b/src/pkg/math/abs_arm.s
@@ -2,7 +2,9 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-TEXT ·Abs(SB),7,$0
+#include "../../cmd/ld/textflag.h"
+
+TEXT ·Abs(SB),NOSPLIT,$0
MOVW x_lo+0(FP), R0
MOVW x_hi+4(FP), R1
AND $((1<<31)-1), R1
diff --git a/src/pkg/math/asin.go b/src/pkg/math/asin.go
index 00bf61ee4..88b851e55 100644
--- a/src/pkg/math/asin.go
+++ b/src/pkg/math/asin.go
@@ -11,7 +11,7 @@ package math
after appropriate range reduction.
*/
-// Asin returns the arcsine of x.
+// Asin returns the arcsine, in radians, of x.
//
// Special cases are:
// Asin(±0) = ±0
@@ -44,7 +44,7 @@ func asin(x float64) float64 {
return temp
}
-// Acos returns the arccosine of x.
+// Acos returns the arccosine, in radians, of x.
//
// Special case is:
// Acos(x) = NaN if x < -1 or x > 1
diff --git a/src/pkg/math/asin_386.s b/src/pkg/math/asin_386.s
index cd3f9cd9b..2c1d27094 100644
--- a/src/pkg/math/asin_386.s
+++ b/src/pkg/math/asin_386.s
@@ -2,8 +2,10 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+#include "../../cmd/ld/textflag.h"
+
// func Asin(x float64) float64
-TEXT ·Asin(SB),7,$0
+TEXT ·Asin(SB),NOSPLIT,$0
FMOVD x+0(FP), F0 // F0=sin(x)
FMOVD F0, F1 // F0=sin(x), F1=sin(x)
FMULD F0, F0 // F0=sin(x)*sin(x), F1=sin(x)
@@ -15,7 +17,7 @@ TEXT ·Asin(SB),7,$0
RET
// func Acos(x float64) float64
-TEXT ·Acos(SB),7,$0
+TEXT ·Acos(SB),NOSPLIT,$0
FMOVD x+0(FP), F0 // F0=cos(x)
FMOVD F0, F1 // F0=cos(x), F1=cos(x)
FMULD F0, F0 // F0=cos(x)*cos(x), F1=cos(x)
diff --git a/src/pkg/math/asin_amd64.s b/src/pkg/math/asin_amd64.s
index 42151f1e9..ea48104ac 100644
--- a/src/pkg/math/asin_amd64.s
+++ b/src/pkg/math/asin_amd64.s
@@ -2,8 +2,10 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-TEXT ·Asin(SB),7,$0
+#include "../../cmd/ld/textflag.h"
+
+TEXT ·Asin(SB),NOSPLIT,$0
JMP ·asin(SB)
-TEXT ·Acos(SB),7,$0
+TEXT ·Acos(SB),NOSPLIT,$0
JMP ·acos(SB)
diff --git a/src/pkg/math/asin_arm.s b/src/pkg/math/asin_arm.s
index d27213fad..b90526003 100644
--- a/src/pkg/math/asin_arm.s
+++ b/src/pkg/math/asin_arm.s
@@ -2,8 +2,10 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-TEXT ·Asin(SB),7,$0
+#include "../../cmd/ld/textflag.h"
+
+TEXT ·Asin(SB),NOSPLIT,$0
B ·asin(SB)
-TEXT ·Acos(SB),7,$0
+TEXT ·Acos(SB),NOSPLIT,$0
B ·acos(SB)
diff --git a/src/pkg/math/atan.go b/src/pkg/math/atan.go
index c107d388d..7fcc90b8b 100644
--- a/src/pkg/math/atan.go
+++ b/src/pkg/math/atan.go
@@ -87,7 +87,7 @@ func satan(x float64) float64 {
return Pi/4 + xatan((x-1)/(x+1)) + 0.5*Morebits
}
-// Atan returns the arctangent of x.
+// Atan returns the arctangent, in radians, of x.
//
// Special cases are:
// Atan(±0) = ±0
diff --git a/src/pkg/math/atan2_386.s b/src/pkg/math/atan2_386.s
index 1bf301c4c..fb649316a 100644
--- a/src/pkg/math/atan2_386.s
+++ b/src/pkg/math/atan2_386.s
@@ -2,8 +2,10 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+#include "../../cmd/ld/textflag.h"
+
// func Atan2(y, x float64) float64 // =atan(y/x)
-TEXT ·Atan2(SB),7,$0
+TEXT ·Atan2(SB),NOSPLIT,$0
FMOVD y+0(FP), F0 // F0=y
FMOVD x+8(FP), F0 // F0=x, F1=y
FPATAN // F0=atan(F1/F0)
diff --git a/src/pkg/math/atan2_amd64.s b/src/pkg/math/atan2_amd64.s
index 1c5b038c2..f7a5a11d4 100644
--- a/src/pkg/math/atan2_amd64.s
+++ b/src/pkg/math/atan2_amd64.s
@@ -2,5 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-TEXT ·Atan2(SB),7,$0
+#include "../../cmd/ld/textflag.h"
+
+TEXT ·Atan2(SB),NOSPLIT,$0
JMP ·atan2(SB)
diff --git a/src/pkg/math/atan2_arm.s b/src/pkg/math/atan2_arm.s
index c2edafae1..24bff2c03 100644
--- a/src/pkg/math/atan2_arm.s
+++ b/src/pkg/math/atan2_arm.s
@@ -2,5 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-TEXT ·Atan2(SB),7,$0
+#include "../../cmd/ld/textflag.h"
+
+TEXT ·Atan2(SB),NOSPLIT,$0
B ·atan2(SB)
diff --git a/src/pkg/math/atan_386.s b/src/pkg/math/atan_386.s
index c988705be..aad8ffcec 100644
--- a/src/pkg/math/atan_386.s
+++ b/src/pkg/math/atan_386.s
@@ -2,8 +2,10 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+#include "../../cmd/ld/textflag.h"
+
// func Atan(x float64) float64
-TEXT ·Atan(SB),7,$0
+TEXT ·Atan(SB),NOSPLIT,$0
FMOVD x+0(FP), F0 // F0=x
FLD1 // F0=1, F1=x
FPATAN // F0=atan(F1/F0)
diff --git a/src/pkg/math/atan_amd64.s b/src/pkg/math/atan_amd64.s
index 206072b93..fc4a91b0d 100644
--- a/src/pkg/math/atan_amd64.s
+++ b/src/pkg/math/atan_amd64.s
@@ -2,5 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-TEXT ·Atan(SB),7,$0
+#include "../../cmd/ld/textflag.h"
+
+TEXT ·Atan(SB),NOSPLIT,$0
JMP ·atan(SB)
diff --git a/src/pkg/math/atan_arm.s b/src/pkg/math/atan_arm.s
index ed492ab46..defa93a1e 100644
--- a/src/pkg/math/atan_arm.s
+++ b/src/pkg/math/atan_arm.s
@@ -2,5 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-TEXT ·Atan(SB),7,$0
+#include "../../cmd/ld/textflag.h"
+
+TEXT ·Atan(SB),NOSPLIT,$0
B ·atan(SB)
diff --git a/src/pkg/math/big/arith_386.s b/src/pkg/math/big/arith_386.s
index f0118ec0d..15b036c65 100644
--- a/src/pkg/math/big/arith_386.s
+++ b/src/pkg/math/big/arith_386.s
@@ -2,11 +2,13 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+#include "../../../cmd/ld/textflag.h"
+
// This file provides fast assembly versions for the elementary
// arithmetic operations on vectors implemented in arith.go.
// func mulWW(x, y Word) (z1, z0 Word)
-TEXT ·mulWW(SB),7,$0
+TEXT ·mulWW(SB),NOSPLIT,$0
MOVL x+0(FP), AX
MULL y+4(FP)
MOVL DX, z1+8(FP)
@@ -15,7 +17,7 @@ TEXT ·mulWW(SB),7,$0
// func divWW(x1, x0, y Word) (q, r Word)
-TEXT ·divWW(SB),7,$0
+TEXT ·divWW(SB),NOSPLIT,$0
MOVL x1+0(FP), DX
MOVL x0+4(FP), AX
DIVL y+8(FP)
@@ -25,7 +27,7 @@ TEXT ·divWW(SB),7,$0
// func addVV(z, x, y []Word) (c Word)
-TEXT ·addVV(SB),7,$0
+TEXT ·addVV(SB),NOSPLIT,$0
MOVL z+0(FP), DI
MOVL x+12(FP), SI
MOVL y+24(FP), CX
@@ -50,7 +52,7 @@ E1: CMPL BX, BP // i < n
// func subVV(z, x, y []Word) (c Word)
// (same as addVV except for SBBL instead of ADCL and label names)
-TEXT ·subVV(SB),7,$0
+TEXT ·subVV(SB),NOSPLIT,$0
MOVL z+0(FP), DI
MOVL x+12(FP), SI
MOVL y+24(FP), CX
@@ -74,7 +76,7 @@ E2: CMPL BX, BP // i < n
// func addVW(z, x []Word, y Word) (c Word)
-TEXT ·addVW(SB),7,$0
+TEXT ·addVW(SB),NOSPLIT,$0
MOVL z+0(FP), DI
MOVL x+12(FP), SI
MOVL y+24(FP), AX // c = y
@@ -96,7 +98,7 @@ E3: CMPL BX, BP // i < n
// func subVW(z, x []Word, y Word) (c Word)
-TEXT ·subVW(SB),7,$0
+TEXT ·subVW(SB),NOSPLIT,$0
MOVL z+0(FP), DI
MOVL x+12(FP), SI
MOVL y+24(FP), AX // c = y
@@ -119,7 +121,7 @@ E4: CMPL BX, BP // i < n
// func shlVU(z, x []Word, s uint) (c Word)
-TEXT ·shlVU(SB),7,$0
+TEXT ·shlVU(SB),NOSPLIT,$0
MOVL z_len+4(FP), BX // i = z
SUBL $1, BX // i--
JL X8b // i < 0 (n <= 0)
@@ -154,7 +156,7 @@ X8b: MOVL $0, c+28(FP)
// func shrVU(z, x []Word, s uint) (c Word)
-TEXT ·shrVU(SB),7,$0
+TEXT ·shrVU(SB),NOSPLIT,$0
MOVL z_len+4(FP), BP
SUBL $1, BP // n--
JL X9b // n < 0 (n <= 0)
@@ -191,7 +193,7 @@ X9b: MOVL $0, c+28(FP)
// func mulAddVWW(z, x []Word, y, r Word) (c Word)
-TEXT ·mulAddVWW(SB),7,$0
+TEXT ·mulAddVWW(SB),NOSPLIT,$0
MOVL z+0(FP), DI
MOVL x+12(FP), SI
MOVL y+24(FP), BP
@@ -218,7 +220,7 @@ E5: CMPL BX, $0 // i < 0
// func addMulVVW(z, x []Word, y Word) (c Word)
-TEXT ·addMulVVW(SB),7,$0
+TEXT ·addMulVVW(SB),NOSPLIT,$0
MOVL z+0(FP), DI
MOVL x+12(FP), SI
MOVL y+24(FP), BP
@@ -246,7 +248,7 @@ E6: CMPL BX, $0 // i < 0
// func divWVW(z* Word, xn Word, x []Word, y Word) (r Word)
-TEXT ·divWVW(SB),7,$0
+TEXT ·divWVW(SB),NOSPLIT,$0
MOVL z+0(FP), DI
MOVL xn+12(FP), DX // r = xn
MOVL x+16(FP), SI
@@ -265,7 +267,7 @@ E7: SUBL $1, BX // i--
RET
// func bitLen(x Word) (n int)
-TEXT ·bitLen(SB),7,$0
+TEXT ·bitLen(SB),NOSPLIT,$0
BSRL x+0(FP), AX
JZ Z1
INCL AX
diff --git a/src/pkg/math/big/arith_amd64.s b/src/pkg/math/big/arith_amd64.s
index 62da65030..e2113a7e3 100644
--- a/src/pkg/math/big/arith_amd64.s
+++ b/src/pkg/math/big/arith_amd64.s
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+#include "../../../cmd/ld/textflag.h"
+
// This file provides fast assembly versions for the elementary
// arithmetic operations on vectors implemented in arith.go.
@@ -16,7 +18,7 @@
BYTE $0x00
// func mulWW(x, y Word) (z1, z0 Word)
-TEXT ·mulWW(SB),7,$0
+TEXT ·mulWW(SB),NOSPLIT,$0
MOVQ x+0(FP), AX
MULQ y+8(FP)
MOVQ DX, z1+16(FP)
@@ -25,7 +27,7 @@ TEXT ·mulWW(SB),7,$0
// func divWW(x1, x0, y Word) (q, r Word)
-TEXT ·divWW(SB),7,$0
+TEXT ·divWW(SB),NOSPLIT,$0
MOVQ x1+0(FP), DX
MOVQ x0+8(FP), AX
DIVQ y+16(FP)
@@ -35,7 +37,7 @@ TEXT ·divWW(SB),7,$0
// func addVV(z, x, y []Word) (c Word)
-TEXT ·addVV(SB),7,$0
+TEXT ·addVV(SB),NOSPLIT,$0
MOVQ z_len+8(FP), DI
MOVQ x+24(FP), R8
MOVQ y+48(FP), R9
@@ -89,7 +91,7 @@ E1: MOVQ CX, c+72(FP) // return c
// func subVV(z, x, y []Word) (c Word)
// (same as addVV except for SBBQ instead of ADCQ and label names)
-TEXT ·subVV(SB),7,$0
+TEXT ·subVV(SB),NOSPLIT,$0
MOVQ z_len+8(FP), DI
MOVQ x+24(FP), R8
MOVQ y+48(FP), R9
@@ -142,7 +144,7 @@ E2: MOVQ CX, c+72(FP) // return c
// func addVW(z, x []Word, y Word) (c Word)
-TEXT ·addVW(SB),7,$0
+TEXT ·addVW(SB),NOSPLIT,$0
MOVQ z_len+8(FP), DI
MOVQ x+24(FP), R8
MOVQ y+48(FP), CX // c = y
@@ -194,7 +196,7 @@ E3: MOVQ CX, c+56(FP) // return c
// func subVW(z, x []Word, y Word) (c Word)
// (same as addVW except for SUBQ/SBBQ instead of ADDQ/ADCQ and label names)
-TEXT ·subVW(SB),7,$0
+TEXT ·subVW(SB),NOSPLIT,$0
MOVQ z_len+8(FP), DI
MOVQ x+24(FP), R8
MOVQ y+48(FP), CX // c = y
@@ -246,7 +248,7 @@ E4: MOVQ CX, c+56(FP) // return c
// func shlVU(z, x []Word, s uint) (c Word)
-TEXT ·shlVU(SB),7,$0
+TEXT ·shlVU(SB),NOSPLIT,$0
MOVQ z_len+8(FP), BX // i = z
SUBQ $1, BX // i--
JL X8b // i < 0 (n <= 0)
@@ -281,7 +283,7 @@ X8b: MOVQ $0, c+56(FP)
// func shrVU(z, x []Word, s uint) (c Word)
-TEXT ·shrVU(SB),7,$0
+TEXT ·shrVU(SB),NOSPLIT,$0
MOVQ z_len+8(FP), R11
SUBQ $1, R11 // n--
JL X9b // n < 0 (n <= 0)
@@ -318,7 +320,7 @@ X9b: MOVQ $0, c+56(FP)
// func mulAddVWW(z, x []Word, y, r Word) (c Word)
-TEXT ·mulAddVWW(SB),7,$0
+TEXT ·mulAddVWW(SB),NOSPLIT,$0
MOVQ z+0(FP), R10
MOVQ x+24(FP), R8
MOVQ y+48(FP), R9
@@ -343,7 +345,7 @@ E5: CMPQ BX, R11 // i < n
// func addMulVVW(z, x []Word, y Word) (c Word)
-TEXT ·addMulVVW(SB),7,$0
+TEXT ·addMulVVW(SB),NOSPLIT,$0
MOVQ z+0(FP), R10
MOVQ x+24(FP), R8
MOVQ y+48(FP), R9
@@ -369,7 +371,7 @@ E6: CMPQ BX, R11 // i < n
// func divWVW(z []Word, xn Word, x []Word, y Word) (r Word)
-TEXT ·divWVW(SB),7,$0
+TEXT ·divWVW(SB),NOSPLIT,$0
MOVQ z+0(FP), R10
MOVQ xn+24(FP), DX // r = xn
MOVQ x+32(FP), R8
@@ -388,7 +390,7 @@ E7: SUBQ $1, BX // i--
RET
// func bitLen(x Word) (n int)
-TEXT ·bitLen(SB),7,$0
+TEXT ·bitLen(SB),NOSPLIT,$0
BSRQ x+0(FP), AX
JZ Z1
ADDQ $1, AX
diff --git a/src/pkg/math/big/arith_arm.s b/src/pkg/math/big/arith_arm.s
index 6e2d23d33..ecf55b344 100644
--- a/src/pkg/math/big/arith_arm.s
+++ b/src/pkg/math/big/arith_arm.s
@@ -2,13 +2,15 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+#include "../../../cmd/ld/textflag.h"
+
// This file provides fast assembly versions for the elementary
// arithmetic operations on vectors implemented in arith.go.
#define CFLAG 29 // bit position of carry flag
// func addVV(z, x, y []Word) (c Word)
-TEXT ·addVV(SB),7,$0
+TEXT ·addVV(SB),NOSPLIT,$0
MOVW $0, R0
MOVW z+0(FP), R1
MOVW x+12(FP), R2
@@ -36,7 +38,7 @@ E1:
// func subVV(z, x, y []Word) (c Word)
// (same as addVV except for SBC instead of ADC and label names)
-TEXT ·subVV(SB),7,$0
+TEXT ·subVV(SB),NOSPLIT,$0
MOVW $(1<<CFLAG), R0
MOVW z+0(FP), R1
MOVW x+12(FP), R2
@@ -64,7 +66,7 @@ E2:
// func addVW(z, x []Word, y Word) (c Word)
-TEXT ·addVW(SB),7,$0
+TEXT ·addVW(SB),NOSPLIT,$0
MOVW z+0(FP), R1
MOVW x+12(FP), R2
MOVW y+24(FP), R3
@@ -98,7 +100,7 @@ E3:
// func subVW(z, x []Word, y Word) (c Word)
-TEXT ·subVW(SB),7,$0
+TEXT ·subVW(SB),NOSPLIT,$0
MOVW z+0(FP), R1
MOVW x+12(FP), R2
MOVW y+24(FP), R3
@@ -133,7 +135,7 @@ E4:
// func shlVU(z, x []Word, s uint) (c Word)
-TEXT ·shlVU(SB),7,$0
+TEXT ·shlVU(SB),NOSPLIT,$0
MOVW z_len+4(FP), R5
CMP $0, R5
BEQ X7
@@ -182,7 +184,7 @@ X7:
// func shrVU(z, x []Word, s uint) (c Word)
-TEXT ·shrVU(SB),7,$0
+TEXT ·shrVU(SB),NOSPLIT,$0
MOVW z_len+4(FP), R5
CMP $0, R5
BEQ X6
@@ -232,7 +234,7 @@ X6:
// func mulAddVWW(z, x []Word, y, r Word) (c Word)
-TEXT ·mulAddVWW(SB),7,$0
+TEXT ·mulAddVWW(SB),NOSPLIT,$0
MOVW $0, R0
MOVW z+0(FP), R1
MOVW x+12(FP), R2
@@ -260,7 +262,7 @@ E8:
// func addMulVVW(z, x []Word, y Word) (c Word)
-TEXT ·addMulVVW(SB),7,$0
+TEXT ·addMulVVW(SB),NOSPLIT,$0
MOVW $0, R0
MOVW z+0(FP), R1
MOVW x+12(FP), R2
@@ -291,19 +293,19 @@ E9:
// func divWVW(z* Word, xn Word, x []Word, y Word) (r Word)
-TEXT ·divWVW(SB),7,$0
+TEXT ·divWVW(SB),NOSPLIT,$0
// ARM has no multiword division, so use portable code.
B ·divWVW_g(SB)
// func divWW(x1, x0, y Word) (q, r Word)
-TEXT ·divWW(SB),7,$0
+TEXT ·divWW(SB),NOSPLIT,$0
// ARM has no multiword division, so use portable code.
B ·divWW_g(SB)
// func mulWW(x, y Word) (z1, z0 Word)
-TEXT ·mulWW(SB),7,$0
+TEXT ·mulWW(SB),NOSPLIT,$0
MOVW x+0(FP), R1
MOVW y+4(FP), R2
MULLU R1, R2, (R4, R3)
@@ -312,7 +314,7 @@ TEXT ·mulWW(SB),7,$0
RET
// func bitLen(x Word) (n int)
-TEXT ·bitLen(SB),7,$0
+TEXT ·bitLen(SB),NOSPLIT,$0
MOVW x+0(FP), R0
CLZ R0, R0
MOVW $32, R1
diff --git a/src/pkg/math/big/int.go b/src/pkg/math/big/int.go
index d1b5602d6..7bbb152d7 100644
--- a/src/pkg/math/big/int.go
+++ b/src/pkg/math/big/int.go
@@ -563,13 +563,13 @@ func (z *Int) SetBytes(buf []byte) *Int {
return z
}
-// Bytes returns the absolute value of z as a big-endian byte slice.
+// Bytes returns the absolute value of x as a big-endian byte slice.
func (x *Int) Bytes() []byte {
buf := make([]byte, len(x.abs)*_S)
return buf[x.abs.bytes(buf):]
}
-// BitLen returns the length of the absolute value of z in bits.
+// BitLen returns the length of the absolute value of x in bits.
// The bit length of 0 is 0.
func (x *Int) BitLen() int {
return x.abs.bitLen()
@@ -703,14 +703,15 @@ func (z *Int) binaryGCD(a, b *Int) *Int {
// reduce t
t.Rsh(t, t.abs.trailingZeroBits())
if t.neg {
- v.Neg(t)
+ v, t = t, v
+ v.neg = len(v.abs) > 0 && !v.neg // 0 has no sign
} else {
- u.Set(t)
+ u, t = t, u
}
t.Sub(u, v)
}
- return u.Lsh(u, k)
+ return z.Lsh(u, k)
}
// ProbablyPrime performs n Miller-Rabin tests to check whether x is prime.
@@ -951,6 +952,9 @@ const intGobVersion byte = 1
// GobEncode implements the gob.GobEncoder interface.
func (x *Int) GobEncode() ([]byte, error) {
+ if x == nil {
+ return nil, nil
+ }
buf := make([]byte, 1+len(x.abs)*_S) // extra byte for version and sign bit
i := x.abs.bytes(buf) - 1 // i >= 0
b := intGobVersion << 1 // make space for sign bit
@@ -964,7 +968,9 @@ func (x *Int) GobEncode() ([]byte, error) {
// GobDecode implements the gob.GobDecoder interface.
func (z *Int) GobDecode(buf []byte) error {
if len(buf) == 0 {
- return errors.New("Int.GobDecode: no data")
+ // Other side sent a nil or default value.
+ *z = Int{}
+ return nil
}
b := buf[0]
if b>>1 != intGobVersion {
diff --git a/src/pkg/math/big/int_test.go b/src/pkg/math/big/int_test.go
index 6c981e775..87b975d5c 100644
--- a/src/pkg/math/big/int_test.go
+++ b/src/pkg/math/big/int_test.go
@@ -89,7 +89,7 @@ func testFunZZ(t *testing.T, msg string, f funZZ, a argZZ) {
var z Int
f(&z, a.x, a.y)
if !isNormalized(&z) {
- t.Errorf("%s%v is not normalized", z, msg)
+ t.Errorf("%s%v is not normalized", msg, z)
}
if (&z).Cmp(a.z) != 0 {
t.Errorf("%s%+v\n\tgot z = %v; want %v", msg, a, &z, a.z)
@@ -1484,6 +1484,32 @@ func TestIntGobEncoding(t *testing.T) {
}
}
+// Sending a nil Int pointer (inside a slice) on a round trip through gob should yield a zero.
+// TODO: top-level nils.
+func TestGobEncodingNilIntInSlice(t *testing.T) {
+ buf := new(bytes.Buffer)
+ enc := gob.NewEncoder(buf)
+ dec := gob.NewDecoder(buf)
+
+ var in = make([]*Int, 1)
+ err := enc.Encode(&in)
+ if err != nil {
+ t.Errorf("gob encode failed: %q", err)
+ }
+ var out []*Int
+ err = dec.Decode(&out)
+ if err != nil {
+ t.Fatalf("gob decode failed: %q", err)
+ }
+ if len(out) != 1 {
+ t.Fatalf("wrong len; want 1 got %d", len(out))
+ }
+ var zero Int
+ if out[0].Cmp(&zero) != 0 {
+ t.Errorf("transmission of (*Int)(nill) failed: got %s want 0", out)
+ }
+}
+
func TestIntJSONEncoding(t *testing.T) {
for _, test := range encodingTests {
var tx Int
diff --git a/src/pkg/math/big/nat_test.go b/src/pkg/math/big/nat_test.go
index 2dd7bf639..1d4dfe80d 100644
--- a/src/pkg/math/big/nat_test.go
+++ b/src/pkg/math/big/nat_test.go
@@ -685,7 +685,7 @@ func runModWTests(t *testing.T, tests []modWTest) {
r := in.abs.modW(d.abs[0])
if r != out.abs[0] {
- t.Errorf("#%d failed: got %s want %s", i, r, out)
+ t.Errorf("#%d failed: got %d want %s", i, r, out)
}
}
}
diff --git a/src/pkg/math/big/rat.go b/src/pkg/math/big/rat.go
index 75d044fe2..7faee61a4 100644
--- a/src/pkg/math/big/rat.go
+++ b/src/pkg/math/big/rat.go
@@ -164,8 +164,9 @@ func quotToFloat(a, b nat) (f float64, exact bool) {
}
// Float64 returns the nearest float64 value for x and a bool indicating
-// whether f represents x exactly. The sign of f always matches the sign
-// of x, even if f == 0.
+// whether f represents x exactly. If the magnitude of x is too large to
+// be represented by a float64, f is an infinity and exact is false.
+// The sign of f always matches the sign of x, even if f == 0.
func (x *Rat) Float64() (f float64, exact bool) {
b := x.b.abs
if len(b) == 0 {
@@ -545,6 +546,9 @@ const ratGobVersion byte = 1
// GobEncode implements the gob.GobEncoder interface.
func (x *Rat) GobEncode() ([]byte, error) {
+ if x == nil {
+ return nil, nil
+ }
buf := make([]byte, 1+4+(len(x.a.abs)+len(x.b.abs))*_S) // extra bytes for version and sign bit (1), and numerator length (4)
i := x.b.abs.bytes(buf)
j := x.a.abs.bytes(buf[0:i])
@@ -566,7 +570,9 @@ func (x *Rat) GobEncode() ([]byte, error) {
// GobDecode implements the gob.GobDecoder interface.
func (z *Rat) GobDecode(buf []byte) error {
if len(buf) == 0 {
- return errors.New("Rat.GobDecode: no data")
+ // Other side sent a nil or default value.
+ *z = Rat{}
+ return nil
}
b := buf[0]
if b>>1 != ratGobVersion {
diff --git a/src/pkg/math/big/rat_test.go b/src/pkg/math/big/rat_test.go
index 1c2c64237..0d432637b 100644
--- a/src/pkg/math/big/rat_test.go
+++ b/src/pkg/math/big/rat_test.go
@@ -407,6 +407,32 @@ func TestRatGobEncoding(t *testing.T) {
}
}
+// Sending a nil Rat pointer (inside a slice) on a round trip through gob should yield a zero.
+// TODO: top-level nils.
+func TestGobEncodingNilRatInSlice(t *testing.T) {
+ buf := new(bytes.Buffer)
+ enc := gob.NewEncoder(buf)
+ dec := gob.NewDecoder(buf)
+
+ var in = make([]*Rat, 1)
+ err := enc.Encode(&in)
+ if err != nil {
+ t.Errorf("gob encode failed: %q", err)
+ }
+ var out []*Rat
+ err = dec.Decode(&out)
+ if err != nil {
+ t.Fatalf("gob decode failed: %q", err)
+ }
+ if len(out) != 1 {
+ t.Fatalf("wrong len; want 1 got %d", len(out))
+ }
+ var zero Rat
+ if out[0].Cmp(&zero) != 0 {
+ t.Errorf("transmission of (*Int)(nill) failed: got %s want 0", out)
+ }
+}
+
func TestIssue2379(t *testing.T) {
// 1) no aliasing
q := NewRat(3, 2)
diff --git a/src/pkg/math/bits.go b/src/pkg/math/bits.go
index 0df0b1cc9..d85ee9cb1 100644
--- a/src/pkg/math/bits.go
+++ b/src/pkg/math/bits.go
@@ -27,7 +27,7 @@ func Inf(sign int) float64 {
// NaN returns an IEEE 754 ``not-a-number'' value.
func NaN() float64 { return Float64frombits(uvnan) }
-// IsNaN returns whether f is an IEEE 754 ``not-a-number'' value.
+// IsNaN reports whether f is an IEEE 754 ``not-a-number'' value.
func IsNaN(f float64) (is bool) {
// IEEE 754 says that only NaNs satisfy f != f.
// To avoid the floating-point hardware, could use:
@@ -36,10 +36,10 @@ func IsNaN(f float64) (is bool) {
return f != f
}
-// IsInf returns whether f is an infinity, according to sign.
-// If sign > 0, IsInf returns whether f is positive infinity.
-// If sign < 0, IsInf returns whether f is negative infinity.
-// If sign == 0, IsInf returns whether f is either infinity.
+// IsInf reports whether f is an infinity, according to sign.
+// If sign > 0, IsInf reports whether f is positive infinity.
+// If sign < 0, IsInf reports whether f is negative infinity.
+// If sign == 0, IsInf reports whether f is either infinity.
func IsInf(f float64, sign int) bool {
// Test for infinity by comparing against maximum float.
// To avoid the floating-point hardware, could use:
diff --git a/src/pkg/math/dim_386.s b/src/pkg/math/dim_386.s
index 6a31c7540..f715114c4 100644
--- a/src/pkg/math/dim_386.s
+++ b/src/pkg/math/dim_386.s
@@ -2,11 +2,13 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-TEXT ·Dim(SB),7,$0
+#include "../../cmd/ld/textflag.h"
+
+TEXT ·Dim(SB),NOSPLIT,$0
JMP ·dim(SB)
-TEXT ·Max(SB),7,$0
+TEXT ·Max(SB),NOSPLIT,$0
JMP ·max(SB)
-TEXT ·Min(SB),7,$0
+TEXT ·Min(SB),NOSPLIT,$0
JMP ·min(SB)
diff --git a/src/pkg/math/dim_amd64.s b/src/pkg/math/dim_amd64.s
index 0ae8ad196..38423ef02 100644
--- a/src/pkg/math/dim_amd64.s
+++ b/src/pkg/math/dim_amd64.s
@@ -2,12 +2,14 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+#include "../../cmd/ld/textflag.h"
+
#define PosInf 0x7FF0000000000000
#define NaN 0x7FF8000000000001
#define NegInf 0xFFF0000000000000
// func Dim(x, y float64) float64
-TEXT ·Dim(SB),7,$0
+TEXT ·Dim(SB),NOSPLIT,$0
// (+Inf, +Inf) special case
MOVQ x+0(FP), BX
MOVQ y+8(FP), CX
@@ -45,7 +47,7 @@ isDimNaN:
RET
// func ·Max(x, y float64) float64
-TEXT ·Max(SB),7,$0
+TEXT ·Max(SB),NOSPLIT,$0
// +Inf special cases
MOVQ $PosInf, AX
MOVQ x+0(FP), R8
@@ -98,7 +100,7 @@ isMaxZero:
*/
// func Min(x, y float64) float64
-TEXT ·Min(SB),7,$0
+TEXT ·Min(SB),NOSPLIT,$0
// -Inf special cases
MOVQ $NegInf, AX
MOVQ x+0(FP), R8
diff --git a/src/pkg/math/dim_arm.s b/src/pkg/math/dim_arm.s
index 304fa78cd..162f08cda 100644
--- a/src/pkg/math/dim_arm.s
+++ b/src/pkg/math/dim_arm.s
@@ -2,11 +2,13 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-TEXT ·Dim(SB),7,$0
+#include "../../cmd/ld/textflag.h"
+
+TEXT ·Dim(SB),NOSPLIT,$0
B ·dim(SB)
-TEXT ·Min(SB),7,$0
+TEXT ·Min(SB),NOSPLIT,$0
B ·min(SB)
-TEXT ·Max(SB),7,$0
+TEXT ·Max(SB),NOSPLIT,$0
B ·max(SB)
diff --git a/src/pkg/math/exp2_386.s b/src/pkg/math/exp2_386.s
index 153762631..71959d94d 100644
--- a/src/pkg/math/exp2_386.s
+++ b/src/pkg/math/exp2_386.s
@@ -2,8 +2,10 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+#include "../../cmd/ld/textflag.h"
+
// func Exp2(x float64) float64
-TEXT ·Exp2(SB),7,$0
+TEXT ·Exp2(SB),NOSPLIT,$0
// test bits for not-finite
MOVL x_hi+4(FP), AX
ANDL $0x7ff00000, AX
diff --git a/src/pkg/math/exp2_amd64.s b/src/pkg/math/exp2_amd64.s
index 7bb44f78a..77a53dad4 100644
--- a/src/pkg/math/exp2_amd64.s
+++ b/src/pkg/math/exp2_amd64.s
@@ -2,5 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-TEXT ·Exp2(SB),7,$0
+#include "../../cmd/ld/textflag.h"
+
+TEXT ·Exp2(SB),NOSPLIT,$0
JMP ·exp2(SB)
diff --git a/src/pkg/math/exp2_arm.s b/src/pkg/math/exp2_arm.s
index 41b63bfaf..fe51f2522 100644
--- a/src/pkg/math/exp2_arm.s
+++ b/src/pkg/math/exp2_arm.s
@@ -2,5 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-TEXT ·Exp2(SB),7,$0
+#include "../../cmd/ld/textflag.h"
+
+TEXT ·Exp2(SB),NOSPLIT,$0
B ·exp2(SB)
diff --git a/src/pkg/math/exp_386.s b/src/pkg/math/exp_386.s
index aeceb3cad..af2d680d5 100644
--- a/src/pkg/math/exp_386.s
+++ b/src/pkg/math/exp_386.s
@@ -2,8 +2,10 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+#include "../../cmd/ld/textflag.h"
+
// func Exp(x float64) float64
-TEXT ·Exp(SB),7,$0
+TEXT ·Exp(SB),NOSPLIT,$0
// test bits for not-finite
MOVL x_hi+4(FP), AX
ANDL $0x7ff00000, AX
diff --git a/src/pkg/math/exp_amd64.s b/src/pkg/math/exp_amd64.s
index eb6fb0432..070b45264 100644
--- a/src/pkg/math/exp_amd64.s
+++ b/src/pkg/math/exp_amd64.s
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+#include "../../cmd/ld/textflag.h"
+
// The method is based on a paper by Naoki Shibata: "Efficient evaluation
// methods of elementary functions suitable for SIMD computation", Proc.
// of International Supercomputing Conference 2010 (ISC'10), pp. 25 -- 32
@@ -31,7 +33,7 @@
#define NegInf 0xFFF0000000000000
// func Exp(x float64) float64
-TEXT ·Exp(SB),7,$0
+TEXT ·Exp(SB),NOSPLIT,$0
// test bits for not-finite
MOVQ x+0(FP), BX
MOVQ $~(1<<63), AX // sign bit mask
diff --git a/src/pkg/math/exp_arm.s b/src/pkg/math/exp_arm.s
index a95fa9342..130b502ac 100644
--- a/src/pkg/math/exp_arm.s
+++ b/src/pkg/math/exp_arm.s
@@ -2,5 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-TEXT ·Exp(SB),7,$0
+#include "../../cmd/ld/textflag.h"
+
+TEXT ·Exp(SB),NOSPLIT,$0
B ·exp(SB)
diff --git a/src/pkg/math/expm1_386.s b/src/pkg/math/expm1_386.s
index 0ff9c4ab0..b268c58c6 100644
--- a/src/pkg/math/expm1_386.s
+++ b/src/pkg/math/expm1_386.s
@@ -2,8 +2,10 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+#include "../../cmd/ld/textflag.h"
+
// func Expm1(x float64) float64
-TEXT ·Expm1(SB),7,$0
+TEXT ·Expm1(SB),NOSPLIT,$0
FLDLN2 // F0=log(2) = 1/log2(e) ~ 0.693147
FMOVD x+0(FP), F0 // F0=x, F1=1/log2(e)
FABS // F0=|x|, F1=1/log2(e)
diff --git a/src/pkg/math/expm1_amd64.s b/src/pkg/math/expm1_amd64.s
index a3b09e2f6..66a75b3d5 100644
--- a/src/pkg/math/expm1_amd64.s
+++ b/src/pkg/math/expm1_amd64.s
@@ -2,5 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-TEXT ·Expm1(SB),7,$0
+#include "../../cmd/ld/textflag.h"
+
+TEXT ·Expm1(SB),NOSPLIT,$0
JMP ·expm1(SB)
diff --git a/src/pkg/math/expm1_arm.s b/src/pkg/math/expm1_arm.s
index e4e40441b..838744447 100644
--- a/src/pkg/math/expm1_arm.s
+++ b/src/pkg/math/expm1_arm.s
@@ -2,5 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-TEXT ·Expm1(SB),7,$0
+#include "../../cmd/ld/textflag.h"
+
+TEXT ·Expm1(SB),NOSPLIT,$0
B ·expm1(SB)
diff --git a/src/pkg/math/floor_386.s b/src/pkg/math/floor_386.s
index 9aa71c043..37d5a4559 100644
--- a/src/pkg/math/floor_386.s
+++ b/src/pkg/math/floor_386.s
@@ -2,8 +2,10 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+#include "../../cmd/ld/textflag.h"
+
// func Ceil(x float64) float64
-TEXT ·Ceil(SB),7,$0
+TEXT ·Ceil(SB),NOSPLIT,$0
FMOVD x+0(FP), F0 // F0=x
FSTCW -2(SP) // save old Control Word
MOVW -2(SP), AX
@@ -17,7 +19,7 @@ TEXT ·Ceil(SB),7,$0
RET
// func Floor(x float64) float64
-TEXT ·Floor(SB),7,$0
+TEXT ·Floor(SB),NOSPLIT,$0
FMOVD x+0(FP), F0 // F0=x
FSTCW -2(SP) // save old Control Word
MOVW -2(SP), AX
@@ -31,7 +33,7 @@ TEXT ·Floor(SB),7,$0
RET
// func Trunc(x float64) float64
-TEXT ·Trunc(SB),7,$0
+TEXT ·Trunc(SB),NOSPLIT,$0
FMOVD x+0(FP), F0 // F0=x
FSTCW -2(SP) // save old Control Word
MOVW -2(SP), AX
diff --git a/src/pkg/math/floor_amd64.s b/src/pkg/math/floor_amd64.s
index bb1a2fd22..2fd31c4fa 100644
--- a/src/pkg/math/floor_amd64.s
+++ b/src/pkg/math/floor_amd64.s
@@ -2,10 +2,12 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+#include "../../cmd/ld/textflag.h"
+
#define Big 0x4330000000000000 // 2**52
// func Floor(x float64) float64
-TEXT ·Floor(SB),7,$0
+TEXT ·Floor(SB),NOSPLIT,$0
MOVQ x+0(FP), AX
MOVQ $~(1<<63), DX // sign bit mask
ANDQ AX,DX // DX = |x|
@@ -27,7 +29,7 @@ isBig_floor:
RET
// func Ceil(x float64) float64
-TEXT ·Ceil(SB),7,$0
+TEXT ·Ceil(SB),NOSPLIT,$0
MOVQ x+0(FP), AX
MOVQ $~(1<<63), DX // sign bit mask
MOVQ AX, BX // BX = copy of x
@@ -53,7 +55,7 @@ isBig_ceil:
RET
// func Trunc(x float64) float64
-TEXT ·Trunc(SB),7,$0
+TEXT ·Trunc(SB),NOSPLIT,$0
MOVQ x+0(FP), AX
MOVQ $~(1<<63), DX // sign bit mask
MOVQ AX, BX // BX = copy of x
diff --git a/src/pkg/math/floor_arm.s b/src/pkg/math/floor_arm.s
index e3ae53f52..cb3b98e95 100644
--- a/src/pkg/math/floor_arm.s
+++ b/src/pkg/math/floor_arm.s
@@ -2,11 +2,13 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-TEXT ·Floor(SB),7,$0
+#include "../../cmd/ld/textflag.h"
+
+TEXT ·Floor(SB),NOSPLIT,$0
B ·floor(SB)
-TEXT ·Ceil(SB),7,$0
+TEXT ·Ceil(SB),NOSPLIT,$0
B ·ceil(SB)
-TEXT ·Trunc(SB),7,$0
+TEXT ·Trunc(SB),NOSPLIT,$0
B ·trunc(SB)
diff --git a/src/pkg/math/fltasm_amd64.s b/src/pkg/math/fltasm_amd64.s
deleted file mode 100644
index 66442cd30..000000000
--- a/src/pkg/math/fltasm_amd64.s
+++ /dev/null
@@ -1,67 +0,0 @@
-// Derived from Inferno's libkern/getfcr-amd64.s
-// http://code.google.com/p/inferno-os/source/browse/libkern/getfcr-amd64.s
-//
-// Copyright © 1994-1999 Lucent Technologies Inc. All rights reserved.
-// Revisions Copyright © 2000-2007 Vita Nuova Holdings Limited (www.vitanuova.com). All rights reserved.
-// Portions Copyright 2009 The Go Authors. All rights reserved.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
-
-TEXT ·SetFPControl(SB), 7, $8
- // Set new
- MOVL p+0(FP), DI
- XORL $(0x3F<<7), DI
- ANDL $0xFFC0, DI
- WAIT
- STMXCSR 0(SP)
- MOVL 0(SP), AX
- ANDL $~0x3F, AX
- ORL DI, AX
- MOVL AX, 0(SP)
- LDMXCSR 0(SP)
- RET
-
-TEXT ·GetFPControl(SB), 7, $0
- WAIT
- STMXCSR 0(SP)
- MOVWLZX 0(SP), AX
- ANDL $0xFFC0, AX
- XORL $(0x3F<<7), AX
- MOVL AX, ret+0(FP)
- RET
-
-TEXT ·SetFPStatus(SB), $0
- MOVL p+0(FP), DI
- ANDL $0x3F, DI
- WAIT
- STMXCSR 0(SP)
- MOVL 0(SP), AX
- ANDL $~0x3F, AX
- ORL DI, AX
- MOVL AX, 0(SP)
- LDMXCSR 0(SP)
- RET
-
-TEXT ·GetFPStatus(SB), $0
- WAIT
- STMXCSR 0(SP)
- MOVL 0(SP), AX
- ANDL $0x3F, AX
- MOVL AX, ret+0(FP)
- RET
diff --git a/src/pkg/math/frexp_386.s b/src/pkg/math/frexp_386.s
index 95e50de02..c6d0a80ed 100644
--- a/src/pkg/math/frexp_386.s
+++ b/src/pkg/math/frexp_386.s
@@ -2,8 +2,10 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+#include "../../cmd/ld/textflag.h"
+
// func Frexp(f float64) (frac float64, exp int)
-TEXT ·Frexp(SB),7,$0
+TEXT ·Frexp(SB),NOSPLIT,$0
FMOVD f+0(FP), F0 // F0=f
FXAM
FSTSW AX
diff --git a/src/pkg/math/frexp_amd64.s b/src/pkg/math/frexp_amd64.s
index bc52b79ab..03d101243 100644
--- a/src/pkg/math/frexp_amd64.s
+++ b/src/pkg/math/frexp_amd64.s
@@ -2,5 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-TEXT ·Frexp(SB),7,$0
+#include "../../cmd/ld/textflag.h"
+
+TEXT ·Frexp(SB),NOSPLIT,$0
JMP ·frexp(SB)
diff --git a/src/pkg/math/frexp_arm.s b/src/pkg/math/frexp_arm.s
index cfd5d0b52..9d40ae46a 100644
--- a/src/pkg/math/frexp_arm.s
+++ b/src/pkg/math/frexp_arm.s
@@ -2,5 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-TEXT ·Frexp(SB),7,$0
+#include "../../cmd/ld/textflag.h"
+
+TEXT ·Frexp(SB),NOSPLIT,$0
B ·frexp(SB)
diff --git a/src/pkg/math/hypot_386.s b/src/pkg/math/hypot_386.s
index 8edfe064f..eec1bf554 100644
--- a/src/pkg/math/hypot_386.s
+++ b/src/pkg/math/hypot_386.s
@@ -2,8 +2,10 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+#include "../../cmd/ld/textflag.h"
+
// func Hypot(p, q float64) float64
-TEXT ·Hypot(SB),7,$0
+TEXT ·Hypot(SB),NOSPLIT,$0
// test bits for not-finite
MOVL p_hi+4(FP), AX // high word p
ANDL $0x7ff00000, AX
diff --git a/src/pkg/math/hypot_amd64.s b/src/pkg/math/hypot_amd64.s
index 40ba6f41d..5c0ff4dd8 100644
--- a/src/pkg/math/hypot_amd64.s
+++ b/src/pkg/math/hypot_amd64.s
@@ -2,11 +2,13 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+#include "../../cmd/ld/textflag.h"
+
#define PosInf 0x7FF0000000000000
#define NaN 0x7FF8000000000001
// func Hypot(p, q float64) float64
-TEXT ·Hypot(SB),7,$0
+TEXT ·Hypot(SB),NOSPLIT,$0
// test bits for special cases
MOVQ p+0(FP), BX
MOVQ $~(1<<63), AX
diff --git a/src/pkg/math/hypot_arm.s b/src/pkg/math/hypot_arm.s
index 2c599fd55..2562aa830 100644
--- a/src/pkg/math/hypot_arm.s
+++ b/src/pkg/math/hypot_arm.s
@@ -2,5 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-TEXT ·Hypot(SB),7,$0
+#include "../../cmd/ld/textflag.h"
+
+TEXT ·Hypot(SB),NOSPLIT,$0
B ·hypot(SB)
diff --git a/src/pkg/math/ldexp_386.s b/src/pkg/math/ldexp_386.s
index 566245dc2..baf377ead 100644
--- a/src/pkg/math/ldexp_386.s
+++ b/src/pkg/math/ldexp_386.s
@@ -2,8 +2,10 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+#include "../../cmd/ld/textflag.h"
+
// func Ldexp(frac float64, exp int) float64
-TEXT ·Ldexp(SB),7,$0
+TEXT ·Ldexp(SB),NOSPLIT,$0
FMOVL exp+8(FP), F0 // F0=exp
FMOVD frac+0(FP), F0 // F0=frac, F1=e
FSCALE // F0=x*2**e, F1=e
diff --git a/src/pkg/math/ldexp_amd64.s b/src/pkg/math/ldexp_amd64.s
index a8d458322..c7fc226ef 100644
--- a/src/pkg/math/ldexp_amd64.s
+++ b/src/pkg/math/ldexp_amd64.s
@@ -2,5 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-TEXT ·Ldexp(SB),7,$0
+#include "../../cmd/ld/textflag.h"
+
+TEXT ·Ldexp(SB),NOSPLIT,$0
JMP ·ldexp(SB)
diff --git a/src/pkg/math/ldexp_arm.s b/src/pkg/math/ldexp_arm.s
index 3c42f515e..16744ea57 100644
--- a/src/pkg/math/ldexp_arm.s
+++ b/src/pkg/math/ldexp_arm.s
@@ -2,5 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-TEXT ·Ldexp(SB),7,$0
+#include "../../cmd/ld/textflag.h"
+
+TEXT ·Ldexp(SB),NOSPLIT,$0
B ·ldexp(SB)
diff --git a/src/pkg/math/log10_386.s b/src/pkg/math/log10_386.s
index d4f94235e..4ae069da6 100644
--- a/src/pkg/math/log10_386.s
+++ b/src/pkg/math/log10_386.s
@@ -2,8 +2,10 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+#include "../../cmd/ld/textflag.h"
+
// func Log10(x float64) float64
-TEXT ·Log10(SB),7,$0
+TEXT ·Log10(SB),NOSPLIT,$0
FLDLG2 // F0=log10(2)
FMOVD x+0(FP), F0 // F0=x, F1=log10(2)
FYL2X // F0=log10(x)=log2(x)*log10(2)
@@ -11,7 +13,7 @@ TEXT ·Log10(SB),7,$0
RET
// func Log2(x float64) float64
-TEXT ·Log2(SB),7,$0
+TEXT ·Log2(SB),NOSPLIT,$0
FLD1 // F0=1
FMOVD x+0(FP), F0 // F0=x, F1=1
FYL2X // F0=log2(x)
diff --git a/src/pkg/math/log10_amd64.s b/src/pkg/math/log10_amd64.s
index 86a3b0577..b9ae83268 100644
--- a/src/pkg/math/log10_amd64.s
+++ b/src/pkg/math/log10_amd64.s
@@ -2,8 +2,10 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-TEXT ·Log10(SB),7,$0
+#include "../../cmd/ld/textflag.h"
+
+TEXT ·Log10(SB),NOSPLIT,$0
JMP ·log10(SB)
-TEXT ·Log2(SB),7,$0
+TEXT ·Log2(SB),NOSPLIT,$0
JMP ·log2(SB)
diff --git a/src/pkg/math/log10_arm.s b/src/pkg/math/log10_arm.s
index 619b0fe1e..fa7580f6f 100644
--- a/src/pkg/math/log10_arm.s
+++ b/src/pkg/math/log10_arm.s
@@ -2,8 +2,10 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-TEXT ·Log10(SB),7,$0
+#include "../../cmd/ld/textflag.h"
+
+TEXT ·Log10(SB),NOSPLIT,$0
B ·log10(SB)
-TEXT ·Log2(SB),7,$0
+TEXT ·Log2(SB),NOSPLIT,$0
B ·log2(SB)
diff --git a/src/pkg/math/log1p_386.s b/src/pkg/math/log1p_386.s
index 30dc8033d..3b30fd5b7 100644
--- a/src/pkg/math/log1p_386.s
+++ b/src/pkg/math/log1p_386.s
@@ -2,8 +2,10 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+#include "../../cmd/ld/textflag.h"
+
// func Log1p(x float64) float64
-TEXT ·Log1p(SB),7,$0
+TEXT ·Log1p(SB),NOSPLIT,$0
FMOVD $(2.928932188134524e-01), F0
FMOVD x+0(FP), F0 // F0=x, F1=1-sqrt(2)/2 = 0.29289321881345247559915564
FABS // F0=|x|, F1=1-sqrt(2)/2
diff --git a/src/pkg/math/log1p_amd64.s b/src/pkg/math/log1p_amd64.s
index 65c93adad..48c24f41f 100644
--- a/src/pkg/math/log1p_amd64.s
+++ b/src/pkg/math/log1p_amd64.s
@@ -2,5 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-TEXT ·Log1p(SB),7,$0
+#include "../../cmd/ld/textflag.h"
+
+TEXT ·Log1p(SB),NOSPLIT,$0
JMP ·log1p(SB)
diff --git a/src/pkg/math/log1p_arm.s b/src/pkg/math/log1p_arm.s
index 0e599aaff..fd2740d0d 100644
--- a/src/pkg/math/log1p_arm.s
+++ b/src/pkg/math/log1p_arm.s
@@ -2,5 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-TEXT ·Log1p(SB),7,$0
+#include "../../cmd/ld/textflag.h"
+
+TEXT ·Log1p(SB),NOSPLIT,$0
B ·log1p(SB)
diff --git a/src/pkg/math/log_386.s b/src/pkg/math/log_386.s
index 7a6f2c052..21a0633b1 100644
--- a/src/pkg/math/log_386.s
+++ b/src/pkg/math/log_386.s
@@ -2,8 +2,10 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+#include "../../cmd/ld/textflag.h"
+
// func Log(x float64) float64
-TEXT ·Log(SB),7,$0
+TEXT ·Log(SB),NOSPLIT,$0
FLDLN2 // F0=log(2)
FMOVD x+0(FP), F0 // F0=x, F1=log(2)
FYL2X // F0=log(x)=log2(x)*log(2)
diff --git a/src/pkg/math/log_amd64.s b/src/pkg/math/log_amd64.s
index 6ae5fbc95..dffc5aec8 100644
--- a/src/pkg/math/log_amd64.s
+++ b/src/pkg/math/log_amd64.s
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+#include "../../cmd/ld/textflag.h"
+
#define HSqrt2 7.07106781186547524401e-01 // sqrt(2)/2
#define Ln2Hi 6.93147180369123816490e-01 // 0x3fe62e42fee00000
#define Ln2Lo 1.90821492927058770002e-10 // 0x3dea39ef35793c76
@@ -17,7 +19,7 @@
#define PosInf 0x7FF0000000000000
// func Log(x float64) float64
-TEXT ·Log(SB),7,$0
+TEXT ·Log(SB),NOSPLIT,$0
// test bits for special cases
MOVQ x+0(FP), BX
MOVQ $~(1<<63), AX // sign bit mask
diff --git a/src/pkg/math/log_arm.s b/src/pkg/math/log_arm.s
index 3dce1e9d4..28448aeef 100644
--- a/src/pkg/math/log_arm.s
+++ b/src/pkg/math/log_arm.s
@@ -2,5 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-TEXT ·Log(SB),7,$0
+#include "../../cmd/ld/textflag.h"
+
+TEXT ·Log(SB),NOSPLIT,$0
B ·log(SB)
diff --git a/src/pkg/math/mod_386.s b/src/pkg/math/mod_386.s
index bcb451b5d..9b3b6bd06 100644
--- a/src/pkg/math/mod_386.s
+++ b/src/pkg/math/mod_386.s
@@ -2,8 +2,10 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+#include "../../cmd/ld/textflag.h"
+
// func Mod(x, y float64) float64
-TEXT ·Mod(SB),7,$0
+TEXT ·Mod(SB),NOSPLIT,$0
FMOVD y+8(FP), F0 // F0=y
FMOVD x+0(FP), F0 // F0=x, F1=y
FPREM // F0=reduced_x, F1=y
diff --git a/src/pkg/math/mod_amd64.s b/src/pkg/math/mod_amd64.s
index 33b86be40..bef83fcf7 100644
--- a/src/pkg/math/mod_amd64.s
+++ b/src/pkg/math/mod_amd64.s
@@ -2,5 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-TEXT ·Mod(SB),7,$0
+#include "../../cmd/ld/textflag.h"
+
+TEXT ·Mod(SB),NOSPLIT,$0
JMP ·mod(SB)
diff --git a/src/pkg/math/mod_arm.s b/src/pkg/math/mod_arm.s
index 47c564bf1..1f51588f8 100644
--- a/src/pkg/math/mod_arm.s
+++ b/src/pkg/math/mod_arm.s
@@ -2,5 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-TEXT ·Mod(SB),7,$0
+#include "../../cmd/ld/textflag.h"
+
+TEXT ·Mod(SB),NOSPLIT,$0
B ·mod(SB)
diff --git a/src/pkg/math/modf_386.s b/src/pkg/math/modf_386.s
index f5dc415c3..07a0dc5cf 100644
--- a/src/pkg/math/modf_386.s
+++ b/src/pkg/math/modf_386.s
@@ -2,8 +2,10 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+#include "../../cmd/ld/textflag.h"
+
// func Modf(f float64) (int float64, frac float64)
-TEXT ·Modf(SB),7,$0
+TEXT ·Modf(SB),NOSPLIT,$0
FMOVD f+0(FP), F0 // F0=f
FMOVD F0, F1 // F0=f, F1=f
FSTCW -2(SP) // save old Control Word
diff --git a/src/pkg/math/modf_amd64.s b/src/pkg/math/modf_amd64.s
index 2a6d7ea04..05feb4bf9 100644
--- a/src/pkg/math/modf_amd64.s
+++ b/src/pkg/math/modf_amd64.s
@@ -2,5 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-TEXT ·Modf(SB),7,$0
+#include "../../cmd/ld/textflag.h"
+
+TEXT ·Modf(SB),NOSPLIT,$0
JMP ·modf(SB)
diff --git a/src/pkg/math/modf_arm.s b/src/pkg/math/modf_arm.s
index 6cef18734..e6bd26d53 100644
--- a/src/pkg/math/modf_arm.s
+++ b/src/pkg/math/modf_arm.s
@@ -2,5 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-TEXT ·Modf(SB),7,$0
+#include "../../cmd/ld/textflag.h"
+
+TEXT ·Modf(SB),NOSPLIT,$0
B ·modf(SB)
diff --git a/src/pkg/math/rand/example_test.go b/src/pkg/math/rand/example_test.go
index 4fe207d85..f42991453 100644
--- a/src/pkg/math/rand/example_test.go
+++ b/src/pkg/math/rand/example_test.go
@@ -11,12 +11,40 @@ import (
"text/tabwriter"
)
-// This test serves as an example but also makes sure we don't change
+// These tests serve as an example but also make sure we don't change
// the output of the random number generator when given a fixed seed.
+func Example() {
+ rand.Seed(42) // Try changing this number!
+ answers := []string{
+ "It is certain",
+ "It is decidedly so",
+ "Without a doubt",
+ "Yes definitely",
+ "You may rely on it",
+ "As I see it yes",
+ "Most likely",
+ "Outlook good",
+ "Yes",
+ "Signs point to yes",
+ "Reply hazy try again",
+ "Ask again later",
+ "Better not tell you now",
+ "Cannot predict now",
+ "Concentrate and ask again",
+ "Don't count on it",
+ "My reply is no",
+ "My sources say no",
+ "Outlook not so good",
+ "Very doubtful",
+ }
+ fmt.Println("Magic 8-Ball says:", answers[rand.Intn(len(answers))])
+ // Output: Magic 8-Ball says: As I see it yes
+}
+
// This example shows the use of each of the methods on a *Rand.
// The use of the global functions is the same, without the receiver.
-func Example() {
+func Example_rand() {
// Create and seed the generator.
// Typically a non-fixed seed should be used, such as time.Now().UnixNano().
// Using a fixed seed will produce the same output on every run.
diff --git a/src/pkg/math/rand/rand.go b/src/pkg/math/rand/rand.go
index 94f84a85f..2157cdb46 100644
--- a/src/pkg/math/rand/rand.go
+++ b/src/pkg/math/rand/rand.go
@@ -3,6 +3,12 @@
// license that can be found in the LICENSE file.
// Package rand implements pseudo-random number generators.
+//
+// Random numbers are generated by a Source. Top-level functions, such as
+// Float64 and Int, use a default shared Source that produces a deterministic
+// sequence of values each time a program is run. Use the Seed function to
+// initialize the default Source if different behavior is required for each run.
+// The default Source is safe for concurrent use by multiple goroutines.
package rand
import "sync"
@@ -113,47 +119,57 @@ func (r *Rand) Perm(n int) []int {
var globalRand = New(&lockedSource{src: NewSource(1)})
-// Seed uses the provided seed value to initialize the generator to a
+// Seed uses the provided seed value to initialize the default Source to a
// deterministic state. If Seed is not called, the generator behaves as
// if seeded by Seed(1).
func Seed(seed int64) { globalRand.Seed(seed) }
-// Int63 returns a non-negative pseudo-random 63-bit integer as an int64.
+// Int63 returns a non-negative pseudo-random 63-bit integer as an int64
+// from the default Source.
func Int63() int64 { return globalRand.Int63() }
-// Uint32 returns a pseudo-random 32-bit value as a uint32.
+// Uint32 returns a pseudo-random 32-bit value as a uint32
+// from the default Source.
func Uint32() uint32 { return globalRand.Uint32() }
-// Int31 returns a non-negative pseudo-random 31-bit integer as an int32.
+// Int31 returns a non-negative pseudo-random 31-bit integer as an int32
+// from the default Source.
func Int31() int32 { return globalRand.Int31() }
-// Int returns a non-negative pseudo-random int.
+// Int returns a non-negative pseudo-random int from the default Source.
func Int() int { return globalRand.Int() }
-// Int63n returns, as an int64, a non-negative pseudo-random number in [0,n).
+// Int63n returns, as an int64, a non-negative pseudo-random number in [0,n)
+// from the default Source.
// It panics if n <= 0.
func Int63n(n int64) int64 { return globalRand.Int63n(n) }
-// Int31n returns, as an int32, a non-negative pseudo-random number in [0,n).
+// Int31n returns, as an int32, a non-negative pseudo-random number in [0,n)
+// from the default Source.
// It panics if n <= 0.
func Int31n(n int32) int32 { return globalRand.Int31n(n) }
-// Intn returns, as an int, a non-negative pseudo-random number in [0,n).
+// Intn returns, as an int, a non-negative pseudo-random number in [0,n)
+// from the default Source.
// It panics if n <= 0.
func Intn(n int) int { return globalRand.Intn(n) }
-// Float64 returns, as a float64, a pseudo-random number in [0.0,1.0).
+// Float64 returns, as a float64, a pseudo-random number in [0.0,1.0)
+// from the default Source.
func Float64() float64 { return globalRand.Float64() }
-// Float32 returns, as a float32, a pseudo-random number in [0.0,1.0).
+// Float32 returns, as a float32, a pseudo-random number in [0.0,1.0)
+// from the default Source.
func Float32() float32 { return globalRand.Float32() }
-// Perm returns, as a slice of n ints, a pseudo-random permutation of the integers [0,n).
+// Perm returns, as a slice of n ints, a pseudo-random permutation of the integers [0,n)
+// from the default Source.
func Perm(n int) []int { return globalRand.Perm(n) }
// NormFloat64 returns a normally distributed float64 in the range
// [-math.MaxFloat64, +math.MaxFloat64] with
-// standard normal distribution (mean = 0, stddev = 1).
+// standard normal distribution (mean = 0, stddev = 1)
+// from the default Source.
// To produce a different normal distribution, callers can
// adjust the output using:
//
@@ -163,7 +179,7 @@ func NormFloat64() float64 { return globalRand.NormFloat64() }
// ExpFloat64 returns an exponentially distributed float64 in the range
// (0, +math.MaxFloat64] with an exponential distribution whose rate parameter
-// (lambda) is 1 and whose mean is 1/lambda (1).
+// (lambda) is 1 and whose mean is 1/lambda (1) from the default Source.
// To produce a distribution with a different rate parameter,
// callers can adjust the output using:
//
diff --git a/src/pkg/math/remainder_386.s b/src/pkg/math/remainder_386.s
index 2238aba49..bbe13a0d9 100644
--- a/src/pkg/math/remainder_386.s
+++ b/src/pkg/math/remainder_386.s
@@ -2,8 +2,10 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+#include "../../cmd/ld/textflag.h"
+
// func Remainder(x, y float64) float64
-TEXT ·Remainder(SB),7,$0
+TEXT ·Remainder(SB),NOSPLIT,$0
FMOVD y+8(FP), F0 // F0=y
FMOVD x+0(FP), F0 // F0=x, F1=y
FPREM1 // F0=reduced_x, F1=y
diff --git a/src/pkg/math/remainder_amd64.s b/src/pkg/math/remainder_amd64.s
index f04bd3de7..e5e23c7ce 100644
--- a/src/pkg/math/remainder_amd64.s
+++ b/src/pkg/math/remainder_amd64.s
@@ -2,5 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-TEXT ·Remainder(SB),7,$0
+#include "../../cmd/ld/textflag.h"
+
+TEXT ·Remainder(SB),NOSPLIT,$0
JMP ·remainder(SB)
diff --git a/src/pkg/math/remainder_arm.s b/src/pkg/math/remainder_arm.s
index 642af6a85..8728afe93 100644
--- a/src/pkg/math/remainder_arm.s
+++ b/src/pkg/math/remainder_arm.s
@@ -2,5 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-TEXT ·Remainder(SB),7,$0
+#include "../../cmd/ld/textflag.h"
+
+TEXT ·Remainder(SB),NOSPLIT,$0
B ·remainder(SB)
diff --git a/src/pkg/math/sin.go b/src/pkg/math/sin.go
index 8beb8bbe3..ed85f21be 100644
--- a/src/pkg/math/sin.go
+++ b/src/pkg/math/sin.go
@@ -109,7 +109,7 @@ var _cos = [...]float64{
4.16666666666665929218E-2, // 0x3fa555555555554b
}
-// Cos returns the cosine of x.
+// Cos returns the cosine of the radian argument x.
//
// Special cases are:
// Cos(±Inf) = NaN
@@ -165,7 +165,7 @@ func cos(x float64) float64 {
return y
}
-// Sin returns the sine of x.
+// Sin returns the sine of the radian argument x.
//
// Special cases are:
// Sin(±0) = ±0
diff --git a/src/pkg/math/sin_386.s b/src/pkg/math/sin_386.s
index b2a836eb1..09271c035 100644
--- a/src/pkg/math/sin_386.s
+++ b/src/pkg/math/sin_386.s
@@ -2,8 +2,10 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+#include "../../cmd/ld/textflag.h"
+
// func Cos(x float64) float64
-TEXT ·Cos(SB),7,$0
+TEXT ·Cos(SB),NOSPLIT,$0
FMOVD x+0(FP), F0 // F0=x
FCOS // F0=cos(x) if -2**63 < x < 2**63
FSTSW AX // AX=status word
@@ -24,7 +26,7 @@ TEXT ·Cos(SB),7,$0
RET
// func Sin(x float64) float64
-TEXT ·Sin(SB),7,$0
+TEXT ·Sin(SB),NOSPLIT,$0
FMOVD x+0(FP), F0 // F0=x
FSIN // F0=sin(x) if -2**63 < x < 2**63
FSTSW AX // AX=status word
diff --git a/src/pkg/math/sin_amd64.s b/src/pkg/math/sin_amd64.s
index c9c99e5b3..008bf4be5 100644
--- a/src/pkg/math/sin_amd64.s
+++ b/src/pkg/math/sin_amd64.s
@@ -2,8 +2,10 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-TEXT ·Sin(SB),7,$0
+#include "../../cmd/ld/textflag.h"
+
+TEXT ·Sin(SB),NOSPLIT,$0
JMP ·sin(SB)
-TEXT ·Cos(SB),7,$0
+TEXT ·Cos(SB),NOSPLIT,$0
JMP ·cos(SB)
diff --git a/src/pkg/math/sin_arm.s b/src/pkg/math/sin_arm.s
index 9447ca2eb..a057b4fc9 100644
--- a/src/pkg/math/sin_arm.s
+++ b/src/pkg/math/sin_arm.s
@@ -2,8 +2,10 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-TEXT ·Sin(SB),7,$0
+#include "../../cmd/ld/textflag.h"
+
+TEXT ·Sin(SB),NOSPLIT,$0
B ·sin(SB)
-TEXT ·Cos(SB),7,$0
+TEXT ·Cos(SB),NOSPLIT,$0
B ·cos(SB)
diff --git a/src/pkg/math/sincos_386.s b/src/pkg/math/sincos_386.s
index 8f5e0f8d1..bf964b168 100644
--- a/src/pkg/math/sincos_386.s
+++ b/src/pkg/math/sincos_386.s
@@ -2,8 +2,10 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+#include "../../cmd/ld/textflag.h"
+
// func Sincos(x float64) (sin, cos float64)
-TEXT ·Sincos(SB),7,$0
+TEXT ·Sincos(SB),NOSPLIT,$0
FMOVD x+0(FP), F0 // F0=x
FSINCOS // F0=cos(x), F1=sin(x) if -2**63 < x < 2**63
FSTSW AX // AX=status word
diff --git a/src/pkg/math/sincos_amd64.s b/src/pkg/math/sincos_amd64.s
index c9dea0916..bccc1ade1 100644
--- a/src/pkg/math/sincos_amd64.s
+++ b/src/pkg/math/sincos_amd64.s
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+#include "../../cmd/ld/textflag.h"
+
// The method is based on a paper by Naoki Shibata: "Efficient evaluation
// methods of elementary functions suitable for SIMD computation", Proc.
// of International Supercomputing Conference 2010 (ISC'10), pp. 25 -- 32
@@ -31,7 +33,7 @@
#define T4 5.51146384479717813051146e-07 // (+1.0/1814400)
// func Sincos(d float64) (sin, cos float64)
-TEXT ·Sincos(SB),7,$0
+TEXT ·Sincos(SB),NOSPLIT,$0
// test for special cases
MOVQ $~(1<<63), DX // sign bit mask
MOVQ x+0(FP), BX
diff --git a/src/pkg/math/sincos_arm.s b/src/pkg/math/sincos_arm.s
index 3e2b0e4e0..b6866af54 100644
--- a/src/pkg/math/sincos_arm.s
+++ b/src/pkg/math/sincos_arm.s
@@ -2,5 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-TEXT ·Sincos(SB),7,$0
+#include "../../cmd/ld/textflag.h"
+
+TEXT ·Sincos(SB),NOSPLIT,$0
B ·sincos(SB)
diff --git a/src/pkg/math/sqrt_386.s b/src/pkg/math/sqrt_386.s
index 824fa634c..2d0c786d0 100644
--- a/src/pkg/math/sqrt_386.s
+++ b/src/pkg/math/sqrt_386.s
@@ -2,8 +2,10 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+#include "../../cmd/ld/textflag.h"
+
// func Sqrt(x float64) float64
-TEXT ·Sqrt(SB),7,$0
+TEXT ·Sqrt(SB),NOSPLIT,$0
FMOVD x+0(FP),F0
FSQRT
FMOVDP F0,ret+8(FP)
diff --git a/src/pkg/math/sqrt_amd64.s b/src/pkg/math/sqrt_amd64.s
index 553c4e01b..1508944c9 100644
--- a/src/pkg/math/sqrt_amd64.s
+++ b/src/pkg/math/sqrt_amd64.s
@@ -2,8 +2,10 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+#include "../../cmd/ld/textflag.h"
+
// func Sqrt(x float64) float64
-TEXT ·Sqrt(SB),7,$0
+TEXT ·Sqrt(SB),NOSPLIT,$0
SQRTSD x+0(FP), X0
MOVSD X0, ret+8(FP)
RET
diff --git a/src/pkg/math/sqrt_arm.s b/src/pkg/math/sqrt_arm.s
index b965b4845..f731ee976 100644
--- a/src/pkg/math/sqrt_arm.s
+++ b/src/pkg/math/sqrt_arm.s
@@ -2,8 +2,10 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+#include "../../cmd/ld/textflag.h"
+
// func Sqrt(x float64) float64
-TEXT ·Sqrt(SB),7,$0
+TEXT ·Sqrt(SB),NOSPLIT,$0
MOVD x+0(FP),F0
SQRTD F0,F0
MOVD F0,ret+8(FP)
diff --git a/src/pkg/math/tan.go b/src/pkg/math/tan.go
index b2f29cc3b..285eff1ab 100644
--- a/src/pkg/math/tan.go
+++ b/src/pkg/math/tan.go
@@ -73,7 +73,7 @@ var _tanQ = [...]float64{
-5.38695755929454629881E7, //0xc189afe03cbe5a31
}
-// Tan returns the tangent of x.
+// Tan returns the tangent of the radian argument x.
//
// Special cases are:
// Tan(±0) = ±0
diff --git a/src/pkg/math/tan_386.s b/src/pkg/math/tan_386.s
index f3ad33907..2320326e3 100644
--- a/src/pkg/math/tan_386.s
+++ b/src/pkg/math/tan_386.s
@@ -2,8 +2,10 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+#include "../../cmd/ld/textflag.h"
+
// func Tan(x float64) float64
-TEXT ·Tan(SB),7,$0
+TEXT ·Tan(SB),NOSPLIT,$0
FMOVD x+0(FP), F0 // F0=x
FPTAN // F0=1, F1=tan(x) if -2**63 < x < 2**63
FSTSW AX // AX=status word
diff --git a/src/pkg/math/tan_amd64.s b/src/pkg/math/tan_amd64.s
index 823ceb254..9fa5f148e 100644
--- a/src/pkg/math/tan_amd64.s
+++ b/src/pkg/math/tan_amd64.s
@@ -2,5 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-TEXT ·Tan(SB),7,$0
+#include "../../cmd/ld/textflag.h"
+
+TEXT ·Tan(SB),NOSPLIT,$0
JMP ·tan(SB)
diff --git a/src/pkg/math/tan_arm.s b/src/pkg/math/tan_arm.s
index 4be35c38b..68fea318d 100644
--- a/src/pkg/math/tan_arm.s
+++ b/src/pkg/math/tan_arm.s
@@ -2,5 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-TEXT ·Tan(SB),7,$0
+#include "../../cmd/ld/textflag.h"
+
+TEXT ·Tan(SB),NOSPLIT,$0
B ·tan(SB)