aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.8/libgo/go/crypto/md5
diff options
context:
space:
mode:
Diffstat (limited to 'gcc-4.8/libgo/go/crypto/md5')
-rw-r--r--gcc-4.8/libgo/go/crypto/md5/gen.go19
-rw-r--r--gcc-4.8/libgo/go/crypto/md5/md5_test.go9
-rw-r--r--gcc-4.8/libgo/go/crypto/md5/md5block.go5
-rw-r--r--gcc-4.8/libgo/go/crypto/md5/md5block_decl.go9
4 files changed, 35 insertions, 7 deletions
diff --git a/gcc-4.8/libgo/go/crypto/md5/gen.go b/gcc-4.8/libgo/go/crypto/md5/gen.go
index 966bdae26..275b4aeea 100644
--- a/gcc-4.8/libgo/go/crypto/md5/gen.go
+++ b/gcc-4.8/libgo/go/crypto/md5/gen.go
@@ -161,6 +161,11 @@ var data = Data{
}
var program = `
+// DO NOT EDIT.
+// Generate with: go run gen.go{{if .Full}} -full{{end}} | gofmt >md5block.go
+
+// +build !amd64
+
package md5
import (
@@ -186,6 +191,16 @@ import (
}
{{end}}
+const x86 = runtime.GOARCH == "amd64" || runtime.GOARCH == "386"
+
+var littleEndian bool
+
+func init() {
+ x := uint32(0x04030201)
+ y := [4]byte{0x1, 0x2, 0x3, 0x4}
+ littleEndian = *(*[4]byte)(unsafe.Pointer(&x)) == y
+}
+
func block(dig *digest, p []byte) {
a := dig.s[0]
b := dig.s[1]
@@ -197,13 +212,13 @@ func block(dig *digest, p []byte) {
aa, bb, cc, dd := a, b, c, d
// This is a constant condition - it is not evaluated on each iteration.
- if runtime.GOARCH == "amd64" || runtime.GOARCH == "386" {
+ if x86 {
// MD5 was designed so that x86 processors can just iterate
// over the block data directly as uint32s, and we generate
// less code and run 1.3x faster if we take advantage of that.
// My apologies.
X = (*[16]uint32)(unsafe.Pointer(&p[0]))
- } else if uintptr(unsafe.Pointer(&p[0]))&(unsafe.Alignof(uint32(0))-1) == 0 {
+ } else if littleEndian && uintptr(unsafe.Pointer(&p[0]))&(unsafe.Alignof(uint32(0))-1) == 0 {
X = (*[16]uint32)(unsafe.Pointer(&p[0]))
} else {
X = &xbuf
diff --git a/gcc-4.8/libgo/go/crypto/md5/md5_test.go b/gcc-4.8/libgo/go/crypto/md5/md5_test.go
index cac39ad05..3ef4519b9 100644
--- a/gcc-4.8/libgo/go/crypto/md5/md5_test.go
+++ b/gcc-4.8/libgo/go/crypto/md5/md5_test.go
@@ -2,10 +2,9 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-package md5_test
+package md5
import (
- "crypto/md5"
"fmt"
"io"
"testing"
@@ -54,7 +53,7 @@ var golden = []md5Test{
func TestGolden(t *testing.T) {
for i := 0; i < len(golden); i++ {
g := golden[i]
- c := md5.New()
+ c := New()
buf := make([]byte, len(g.in)+4)
for j := 0; j < 3+4; j++ {
if j < 2 {
@@ -79,14 +78,14 @@ func TestGolden(t *testing.T) {
}
func ExampleNew() {
- h := md5.New()
+ h := New()
io.WriteString(h, "The fog is getting thicker!")
io.WriteString(h, "And Leon's getting laaarger!")
fmt.Printf("%x", h.Sum(nil))
// Output: e2c569be17396eca2a2e3c11578123ed
}
-var bench = md5.New()
+var bench = New()
var buf = make([]byte, 8192+1)
var sum = make([]byte, bench.Size())
diff --git a/gcc-4.8/libgo/go/crypto/md5/md5block.go b/gcc-4.8/libgo/go/crypto/md5/md5block.go
index 0ca421774..a376fbee9 100644
--- a/gcc-4.8/libgo/go/crypto/md5/md5block.go
+++ b/gcc-4.8/libgo/go/crypto/md5/md5block.go
@@ -1,3 +1,8 @@
+// DO NOT EDIT.
+// Generate with: go run gen.go -full | gofmt >md5block.go
+
+// +build !amd64,!386
+
package md5
import (
diff --git a/gcc-4.8/libgo/go/crypto/md5/md5block_decl.go b/gcc-4.8/libgo/go/crypto/md5/md5block_decl.go
new file mode 100644
index 000000000..14190c6ff
--- /dev/null
+++ b/gcc-4.8/libgo/go/crypto/md5/md5block_decl.go
@@ -0,0 +1,9 @@
+// Copyright 2013 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.
+
+// +build amd64 386
+
+package md5
+
+func block(dig *digest, p []byte)