LEFT | RIGHT |
1 // Copyright 2012 The Go Authors. All rights reserved. | 1 // Copyright 2012 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 // +build ignore | 5 // +build ignore |
6 | 6 |
7 // This program generates md5block.go | 7 // This program generates md5block.go |
8 // Invoke as | 8 // Invoke as |
9 // | 9 // |
10 // go run gen.go [-full] |gofmt >md5block.go | 10 // go run gen.go [-full] |gofmt >md5block.go |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 for len(p) >= chunk { | 196 for len(p) >= chunk { |
197 aa, bb, cc, dd := a, b, c, d | 197 aa, bb, cc, dd := a, b, c, d |
198 | 198 |
199 // This is a constant condition - it is not evaluated on each it
eration. | 199 // This is a constant condition - it is not evaluated on each it
eration. |
200 if runtime.GOARCH == "amd64" || runtime.GOARCH == "386" { | 200 if runtime.GOARCH == "amd64" || runtime.GOARCH == "386" { |
201 // MD5 was designed so that x86 processors can just iter
ate | 201 // MD5 was designed so that x86 processors can just iter
ate |
202 // over the block data directly as uint32s, and we gener
ate | 202 // over the block data directly as uint32s, and we gener
ate |
203 // less code and run 1.3x faster if we take advantage of
that. | 203 // less code and run 1.3x faster if we take advantage of
that. |
204 // My apologies. | 204 // My apologies. |
205 X = (*[16]uint32)(unsafe.Pointer(&p[0])) | 205 X = (*[16]uint32)(unsafe.Pointer(&p[0])) |
206 » » } else if uintptr(unsafe.Pointer(&p[0])) & 3 == 0 { | 206 » » } else if uintptr(unsafe.Pointer(&p[0]))&(unsafe.Alignof(uint32(
0))-1) == 0 { |
207 X = (*[16]uint32)(unsafe.Pointer(&p[0])) | 207 X = (*[16]uint32)(unsafe.Pointer(&p[0])) |
208 } else { | 208 } else { |
209 X = &xbuf | 209 X = &xbuf |
210 j := 0 | 210 j := 0 |
211 for i := 0; i < 16; i++ { | 211 for i := 0; i < 16; i++ { |
212 X[i&15] = uint32(p[j]) | uint32(p[j+1])<<8 | uin
t32(p[j+2])<<16 | uint32(p[j+3])<<24 | 212 X[i&15] = uint32(p[j]) | uint32(p[j+1])<<8 | uin
t32(p[j+2])<<16 | uint32(p[j+3])<<24 |
213 j += 4 | 213 j += 4 |
214 } | 214 } |
215 } | 215 } |
216 | 216 |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 | 291 |
292 p = p[chunk:] | 292 p = p[chunk:] |
293 } | 293 } |
294 | 294 |
295 dig.s[0] = a | 295 dig.s[0] = a |
296 dig.s[1] = b | 296 dig.s[1] = b |
297 dig.s[2] = c | 297 dig.s[2] = c |
298 dig.s[3] = d | 298 dig.s[3] = d |
299 } | 299 } |
300 ` | 300 ` |
LEFT | RIGHT |