Deps update
This commit is contained in:
parent
dd878d4c60
commit
e8b183e576
|
@ -23,7 +23,7 @@
|
||||||
branch = "master"
|
branch = "master"
|
||||||
name = "github.com/aead/chacha20"
|
name = "github.com/aead/chacha20"
|
||||||
packages = ["chacha"]
|
packages = ["chacha"]
|
||||||
revision = "e0d4ab3067da29fbce5b60445bed6d54c41c3c62"
|
revision = "c1766ed472dff2392a1a13de7b82e8f5a64ab11d"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
branch = "master"
|
branch = "master"
|
||||||
|
@ -121,8 +121,8 @@
|
||||||
[[projects]]
|
[[projects]]
|
||||||
name = "github.com/k-sone/critbitgo"
|
name = "github.com/k-sone/critbitgo"
|
||||||
packages = ["."]
|
packages = ["."]
|
||||||
revision = "1b44ffc7fc9ad8dea28251e340eadb04093c8af3"
|
revision = "658116ef1e826b72c603cfe2091b12503f9bca43"
|
||||||
version = "v1.1.0"
|
version = "v1.2.0"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
branch = "master"
|
branch = "master"
|
||||||
|
@ -154,7 +154,7 @@
|
||||||
"poly1305",
|
"poly1305",
|
||||||
"salsa20/salsa"
|
"salsa20/salsa"
|
||||||
]
|
]
|
||||||
revision = "d6449816ce06963d9d136eee5a56fca5b0616e7e"
|
revision = "b0697eccbea9adec5b7ba8008f4c33d98d733388"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
branch = "master"
|
branch = "master"
|
||||||
|
@ -171,7 +171,7 @@
|
||||||
"ipv6",
|
"ipv6",
|
||||||
"lex/httplex"
|
"lex/httplex"
|
||||||
]
|
]
|
||||||
revision = "d41e8174641f662c5a2d1c7a5f9e828788eb8706"
|
revision = "5f9ae10d9af5b1c89ae6904293b14b064d4ada23"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
branch = "master"
|
branch = "master"
|
||||||
|
@ -183,7 +183,7 @@
|
||||||
"windows/svc/eventlog",
|
"windows/svc/eventlog",
|
||||||
"windows/svc/mgr"
|
"windows/svc/mgr"
|
||||||
]
|
]
|
||||||
revision = "b126b21c05a91c856b027c16779c12e3bf236954"
|
revision = "79b0c6888797020a994db17c8510466c72fe75d9"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
name = "golang.org/x/text"
|
name = "golang.org/x/text"
|
||||||
|
|
|
@ -1,23 +1,22 @@
|
||||||
language: go
|
language: go
|
||||||
|
|
||||||
go:
|
go:
|
||||||
- "1.8.7"
|
- "1.8.x"
|
||||||
- "1.9.4"
|
- "1.9.x"
|
||||||
- "1.10"
|
- "1.10.x"
|
||||||
|
|
||||||
env:
|
env:
|
||||||
- ARCH=x86_64
|
- ARCH=x86_64
|
||||||
- ARCH=i686
|
- ARCH=i686
|
||||||
- TRAVIS_GOARCH=amd64
|
|
||||||
- TRAVIS_GOARCH=386
|
|
||||||
|
|
||||||
before_install:
|
|
||||||
- export GOARCH=$TRAVIS_GOARCH
|
|
||||||
|
|
||||||
branches:
|
branches:
|
||||||
only:
|
only:
|
||||||
- master
|
- master
|
||||||
|
|
||||||
|
before_script:
|
||||||
|
- go get -u github.com/klauspost/asmfmt/cmd/asmfmt
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- diff -au <(gofmt -d .) <(printf "")
|
- diff -au <(gofmt -d .) <(printf "")
|
||||||
|
- diff -au <(asmfmt -d .) <(printf "")
|
||||||
- go test -v ./...
|
- go test -v ./...
|
||||||
|
|
|
@ -667,7 +667,7 @@ CHACHA_LOOP_192:
|
||||||
ADDQ $64, Src
|
ADDQ $64, Src
|
||||||
SUBQ $64, Len
|
SUBQ $64, Len
|
||||||
JZ DONE
|
JZ DONE
|
||||||
CMPQ Len, $64 // If Len <= 64 -> gen. only 64 byte keystream.
|
CMPQ Len, $64 // If Len <= 64 -> gen. only 64 byte keystream.
|
||||||
JBE GENERATE_KEYSTREAM_64
|
JBE GENERATE_KEYSTREAM_64
|
||||||
|
|
||||||
GENERATE_KEYSTREAM_128:
|
GENERATE_KEYSTREAM_128:
|
||||||
|
@ -793,13 +793,13 @@ TEXT ·xorKeyStreamAVX(SB), 4, $144-80
|
||||||
VMOVDQU ·one<>(SB), X4
|
VMOVDQU ·one<>(SB), X4
|
||||||
VMOVDQU ·rol16<>(SB), X5
|
VMOVDQU ·rol16<>(SB), X5
|
||||||
VMOVDQU ·rol8<>(SB), X6
|
VMOVDQU ·rol8<>(SB), X6
|
||||||
VMOVDQA X0, 0*16(Stack)
|
VMOVDQA X0, 0*16(Stack)
|
||||||
VMOVDQA X1, 1*16(Stack)
|
VMOVDQA X1, 1*16(Stack)
|
||||||
VMOVDQA X2, 2*16(Stack)
|
VMOVDQA X2, 2*16(Stack)
|
||||||
VMOVDQA X3, 3*16(Stack)
|
VMOVDQA X3, 3*16(Stack)
|
||||||
VMOVDQA X4, 4*16(Stack)
|
VMOVDQA X4, 4*16(Stack)
|
||||||
VMOVDQA X5, 6*16(Stack)
|
VMOVDQA X5, 6*16(Stack)
|
||||||
VMOVDQA X6, 7*16(Stack)
|
VMOVDQA X6, 7*16(Stack)
|
||||||
|
|
||||||
CMPQ Len, $64
|
CMPQ Len, $64
|
||||||
JBE GENERATE_KEYSTREAM_64
|
JBE GENERATE_KEYSTREAM_64
|
||||||
|
@ -809,22 +809,22 @@ TEXT ·xorKeyStreamAVX(SB), 4, $144-80
|
||||||
JBE GENERATE_KEYSTREAM_192
|
JBE GENERATE_KEYSTREAM_192
|
||||||
|
|
||||||
GENERATE_KEYSTREAM_256:
|
GENERATE_KEYSTREAM_256:
|
||||||
VMOVDQA X0, X12
|
VMOVDQA X0, X12
|
||||||
VMOVDQA X1, X13
|
VMOVDQA X1, X13
|
||||||
VMOVDQA X2, X14
|
VMOVDQA X2, X14
|
||||||
VMOVDQA X3, X15
|
VMOVDQA X3, X15
|
||||||
VPADDQ 4*16(Stack), X15, X15
|
VPADDQ 4*16(Stack), X15, X15
|
||||||
VMOVDQA X0, X8
|
VMOVDQA X0, X8
|
||||||
VMOVDQA X1, X9
|
VMOVDQA X1, X9
|
||||||
VMOVDQA X2, X10
|
VMOVDQA X2, X10
|
||||||
VMOVDQA X15, X11
|
VMOVDQA X15, X11
|
||||||
VPADDQ 4*16(Stack), X11, X11
|
VPADDQ 4*16(Stack), X11, X11
|
||||||
VMOVDQA X0, X4
|
VMOVDQA X0, X4
|
||||||
VMOVDQA X1, X5
|
VMOVDQA X1, X5
|
||||||
VMOVDQA X2, X6
|
VMOVDQA X2, X6
|
||||||
VMOVDQA X11, X7
|
VMOVDQA X11, X7
|
||||||
VPADDQ 4*16(Stack), X7, X7
|
VPADDQ 4*16(Stack), X7, X7
|
||||||
MOVQ Rounds, Tmp0
|
MOVQ Rounds, Tmp0
|
||||||
|
|
||||||
VMOVDQA X3, 3*16(Stack) // Save X3
|
VMOVDQA X3, 3*16(Stack) // Save X3
|
||||||
|
|
||||||
|
@ -853,22 +853,22 @@ CHACHA_LOOP_256:
|
||||||
CHACHA_SHUFFLE_AVX(X15, X14, X13)
|
CHACHA_SHUFFLE_AVX(X15, X14, X13)
|
||||||
CHACHA_SHUFFLE_AVX(X11, X10, X9)
|
CHACHA_SHUFFLE_AVX(X11, X10, X9)
|
||||||
CHACHA_SHUFFLE_AVX(X7, X6, X5)
|
CHACHA_SHUFFLE_AVX(X7, X6, X5)
|
||||||
SUBQ $2, Tmp0
|
SUBQ $2, Tmp0
|
||||||
JNZ CHACHA_LOOP_256
|
JNZ CHACHA_LOOP_256
|
||||||
|
|
||||||
VPADDD 0*16(Stack), X0, X0
|
VPADDD 0*16(Stack), X0, X0
|
||||||
VPADDD 1*16(Stack), X1, X1
|
VPADDD 1*16(Stack), X1, X1
|
||||||
VPADDD 2*16(Stack), X2, X2
|
VPADDD 2*16(Stack), X2, X2
|
||||||
VPADDD 3*16(Stack), X3, X3
|
VPADDD 3*16(Stack), X3, X3
|
||||||
VMOVDQA X4, 5*16(Stack) // Save X4
|
VMOVDQA X4, 5*16(Stack) // Save X4
|
||||||
XOR_AVX(Dst, Src, 0, X0, X1, X2, X3, X4)
|
XOR_AVX(Dst, Src, 0, X0, X1, X2, X3, X4)
|
||||||
VMOVDQA 5*16(Stack), X4 // Restore X4
|
VMOVDQA 5*16(Stack), X4 // Restore X4
|
||||||
|
|
||||||
VMOVDQA 0*16(Stack), X0
|
VMOVDQA 0*16(Stack), X0
|
||||||
VMOVDQA 1*16(Stack), X1
|
VMOVDQA 1*16(Stack), X1
|
||||||
VMOVDQA 2*16(Stack), X2
|
VMOVDQA 2*16(Stack), X2
|
||||||
VMOVDQA 3*16(Stack), X3
|
VMOVDQA 3*16(Stack), X3
|
||||||
VPADDQ 4*16(Stack), X3, X3
|
VPADDQ 4*16(Stack), X3, X3
|
||||||
|
|
||||||
VPADDD X0, X12, X12
|
VPADDD X0, X12, X12
|
||||||
VPADDD X1, X13, X13
|
VPADDD X1, X13, X13
|
||||||
|
@ -889,9 +889,9 @@ CHACHA_LOOP_256:
|
||||||
XOR_AVX(Dst, Src, 64, X12, X13, X14, X15, X0)
|
XOR_AVX(Dst, Src, 64, X12, X13, X14, X15, X0)
|
||||||
XOR_AVX(Dst, Src, 128, X8, X9, X10, X11, X0)
|
XOR_AVX(Dst, Src, 128, X8, X9, X10, X11, X0)
|
||||||
VMOVDQA 0*16(Stack), X0 // Restore X0
|
VMOVDQA 0*16(Stack), X0 // Restore X0
|
||||||
ADDQ $192, Dst
|
ADDQ $192, Dst
|
||||||
ADDQ $192, Src
|
ADDQ $192, Src
|
||||||
SUBQ $192, Len
|
SUBQ $192, Len
|
||||||
|
|
||||||
CMPQ Len, $64
|
CMPQ Len, $64
|
||||||
JB BUFFER_KEYSTREAM
|
JB BUFFER_KEYSTREAM
|
||||||
|
@ -909,21 +909,21 @@ CHACHA_LOOP_256:
|
||||||
JA GENERATE_KEYSTREAM_256
|
JA GENERATE_KEYSTREAM_256
|
||||||
|
|
||||||
GENERATE_KEYSTREAM_192:
|
GENERATE_KEYSTREAM_192:
|
||||||
VMOVDQA X0, X12
|
VMOVDQA X0, X12
|
||||||
VMOVDQA X1, X13
|
VMOVDQA X1, X13
|
||||||
VMOVDQA X2, X14
|
VMOVDQA X2, X14
|
||||||
VMOVDQA X3, X15
|
VMOVDQA X3, X15
|
||||||
VMOVDQA X0, X8
|
VMOVDQA X0, X8
|
||||||
VMOVDQA X1, X9
|
VMOVDQA X1, X9
|
||||||
VMOVDQA X2, X10
|
VMOVDQA X2, X10
|
||||||
VMOVDQA X3, X11
|
VMOVDQA X3, X11
|
||||||
VPADDQ 4*16(Stack), X11, X11
|
VPADDQ 4*16(Stack), X11, X11
|
||||||
VMOVDQA X0, X4
|
VMOVDQA X0, X4
|
||||||
VMOVDQA X1, X5
|
VMOVDQA X1, X5
|
||||||
VMOVDQA X2, X6
|
VMOVDQA X2, X6
|
||||||
VMOVDQA X11, X7
|
VMOVDQA X11, X7
|
||||||
VPADDQ 4*16(Stack), X7, X7
|
VPADDQ 4*16(Stack), X7, X7
|
||||||
MOVQ Rounds, Tmp0
|
MOVQ Rounds, Tmp0
|
||||||
|
|
||||||
VMOVDQA 6*16(Stack), X1 // Load 16 bit rotate-left constant
|
VMOVDQA 6*16(Stack), X1 // Load 16 bit rotate-left constant
|
||||||
VMOVDQA 7*16(Stack), X2 // Load 8 bit rotate-left constant
|
VMOVDQA 7*16(Stack), X2 // Load 8 bit rotate-left constant
|
||||||
|
@ -944,31 +944,31 @@ CHACHA_LOOP_192:
|
||||||
SUBQ $2, Tmp0
|
SUBQ $2, Tmp0
|
||||||
JNZ CHACHA_LOOP_192
|
JNZ CHACHA_LOOP_192
|
||||||
|
|
||||||
VMOVDQA 0*16(Stack), X0 // Restore X0
|
VMOVDQA 0*16(Stack), X0 // Restore X0
|
||||||
VMOVDQA 1*16(Stack), X1 // Restore X1
|
VMOVDQA 1*16(Stack), X1 // Restore X1
|
||||||
VMOVDQA 2*16(Stack), X2 // Restore X2
|
VMOVDQA 2*16(Stack), X2 // Restore X2
|
||||||
VPADDD X0, X12, X12
|
VPADDD X0, X12, X12
|
||||||
VPADDD X1, X13, X13
|
VPADDD X1, X13, X13
|
||||||
VPADDD X2, X14, X14
|
VPADDD X2, X14, X14
|
||||||
VPADDD X3, X15, X15
|
VPADDD X3, X15, X15
|
||||||
VPADDQ 4*16(Stack), X3, X3
|
VPADDQ 4*16(Stack), X3, X3
|
||||||
VPADDD X0, X8, X8
|
VPADDD X0, X8, X8
|
||||||
VPADDD X1, X9, X9
|
VPADDD X1, X9, X9
|
||||||
VPADDD X2, X10, X10
|
VPADDD X2, X10, X10
|
||||||
VPADDD X3, X11, X11
|
VPADDD X3, X11, X11
|
||||||
VPADDQ 4*16(Stack), X3, X3
|
VPADDQ 4*16(Stack), X3, X3
|
||||||
VPADDD X0, X4, X4
|
VPADDD X0, X4, X4
|
||||||
VPADDD X1, X5, X5
|
VPADDD X1, X5, X5
|
||||||
VPADDD X2, X6, X6
|
VPADDD X2, X6, X6
|
||||||
VPADDD X3, X7, X7
|
VPADDD X3, X7, X7
|
||||||
VPADDQ 4*16(Stack), X3, X3
|
VPADDQ 4*16(Stack), X3, X3
|
||||||
|
|
||||||
XOR_AVX(Dst, Src, 0, X12, X13, X14, X15, X0)
|
XOR_AVX(Dst, Src, 0, X12, X13, X14, X15, X0)
|
||||||
XOR_AVX(Dst, Src, 64, X8, X9, X10, X11, X0)
|
XOR_AVX(Dst, Src, 64, X8, X9, X10, X11, X0)
|
||||||
VMOVDQA 0*16(Stack), X0 // Restore X0
|
VMOVDQA 0*16(Stack), X0 // Restore X0
|
||||||
ADDQ $128, Dst
|
ADDQ $128, Dst
|
||||||
ADDQ $128, Src
|
ADDQ $128, Src
|
||||||
SUBQ $128, Len
|
SUBQ $128, Len
|
||||||
|
|
||||||
CMPQ Len, $64
|
CMPQ Len, $64
|
||||||
JB BUFFER_KEYSTREAM
|
JB BUFFER_KEYSTREAM
|
||||||
|
@ -978,20 +978,20 @@ CHACHA_LOOP_192:
|
||||||
ADDQ $64, Src
|
ADDQ $64, Src
|
||||||
SUBQ $64, Len
|
SUBQ $64, Len
|
||||||
JZ DONE
|
JZ DONE
|
||||||
CMPQ Len, $64 // If Len <= 64 -> gen. only 64 byte keystream.
|
CMPQ Len, $64 // If Len <= 64 -> gen. only 64 byte keystream.
|
||||||
JBE GENERATE_KEYSTREAM_64
|
JBE GENERATE_KEYSTREAM_64
|
||||||
|
|
||||||
GENERATE_KEYSTREAM_128:
|
GENERATE_KEYSTREAM_128:
|
||||||
VMOVDQA X0, X8
|
VMOVDQA X0, X8
|
||||||
VMOVDQA X1, X9
|
VMOVDQA X1, X9
|
||||||
VMOVDQA X2, X10
|
VMOVDQA X2, X10
|
||||||
VMOVDQA X3, X11
|
VMOVDQA X3, X11
|
||||||
VMOVDQA X0, X4
|
VMOVDQA X0, X4
|
||||||
VMOVDQA X1, X5
|
VMOVDQA X1, X5
|
||||||
VMOVDQA X2, X6
|
VMOVDQA X2, X6
|
||||||
VMOVDQA X3, X7
|
VMOVDQA X3, X7
|
||||||
VPADDQ 4*16(Stack), X7, X7
|
VPADDQ 4*16(Stack), X7, X7
|
||||||
MOVQ Rounds, Tmp0
|
MOVQ Rounds, Tmp0
|
||||||
|
|
||||||
VMOVDQA 6*16(Stack), X13 // Load 16 bit rotate-left constant
|
VMOVDQA 6*16(Stack), X13 // Load 16 bit rotate-left constant
|
||||||
VMOVDQA 7*16(Stack), X14 // Load 8 bit rotate-left constant
|
VMOVDQA 7*16(Stack), X14 // Load 8 bit rotate-left constant
|
||||||
|
@ -1038,7 +1038,7 @@ GENERATE_KEYSTREAM_64:
|
||||||
VMOVDQA X1, X5
|
VMOVDQA X1, X5
|
||||||
VMOVDQA X2, X6
|
VMOVDQA X2, X6
|
||||||
VMOVDQA X3, X7
|
VMOVDQA X3, X7
|
||||||
MOVQ Rounds, Tmp0
|
MOVQ Rounds, Tmp0
|
||||||
|
|
||||||
VMOVDQA 6*16(Stack), X9 // Load 16 bit rotate-left constant
|
VMOVDQA 6*16(Stack), X9 // Load 16 bit rotate-left constant
|
||||||
VMOVDQA 7*16(Stack), X10 // Load 8 bit rotate-left constant
|
VMOVDQA 7*16(Stack), X10 // Load 8 bit rotate-left constant
|
||||||
|
@ -1071,14 +1071,14 @@ BUFFER_KEYSTREAM:
|
||||||
VMOVDQU X5, 1*16(Buffer)
|
VMOVDQU X5, 1*16(Buffer)
|
||||||
VMOVDQU X6, 2*16(Buffer)
|
VMOVDQU X6, 2*16(Buffer)
|
||||||
VMOVDQU X7, 3*16(Buffer)
|
VMOVDQU X7, 3*16(Buffer)
|
||||||
MOVQ Len, Tmp0
|
MOVQ Len, Tmp0
|
||||||
FINALIZE(Dst, Src, Buffer, Tmp0, Tmp1, Tmp2)
|
FINALIZE(Dst, Src, Buffer, Tmp0, Tmp1, Tmp2)
|
||||||
|
|
||||||
DONE:
|
DONE:
|
||||||
MOVQ SavedSP, Stack // Restore stack pointer
|
MOVQ SavedSP, Stack // Restore stack pointer
|
||||||
VMOVDQU X3, 3*16(State)
|
VMOVDQU X3, 3*16(State)
|
||||||
VZEROUPPER
|
VZEROUPPER
|
||||||
MOVQ Len, ret+72(FP)
|
MOVQ Len, ret+72(FP)
|
||||||
RET
|
RET
|
||||||
|
|
||||||
#undef Dst
|
#undef Dst
|
||||||
|
|
|
@ -34,7 +34,7 @@ func TestHChaCha20(t *testing.T) {
|
||||||
}
|
}
|
||||||
if useAVX {
|
if useAVX {
|
||||||
t.Log("AVX version")
|
t.Log("AVX version")
|
||||||
testIncremental(t, 5, 2049)
|
testHChaCha20(t)
|
||||||
useAVX = false
|
useAVX = false
|
||||||
}
|
}
|
||||||
if useSSSE3 {
|
if useSSSE3 {
|
||||||
|
@ -63,7 +63,7 @@ func TestVectors(t *testing.T) {
|
||||||
}
|
}
|
||||||
if useAVX {
|
if useAVX {
|
||||||
t.Log("AVX version")
|
t.Log("AVX version")
|
||||||
testIncremental(t, 5, 2049)
|
testVectors(t)
|
||||||
useAVX = false
|
useAVX = false
|
||||||
}
|
}
|
||||||
if useSSSE3 {
|
if useSSSE3 {
|
||||||
|
|
|
@ -38,7 +38,7 @@ DATA ·two_AVX2<>+0x00(SB)/8, $2
|
||||||
DATA ·two_AVX2<>+0x08(SB)/8, $0
|
DATA ·two_AVX2<>+0x08(SB)/8, $0
|
||||||
DATA ·two_AVX2<>+0x10(SB)/8, $2
|
DATA ·two_AVX2<>+0x10(SB)/8, $2
|
||||||
DATA ·two_AVX2<>+0x18(SB)/8, $0
|
DATA ·two_AVX2<>+0x18(SB)/8, $0
|
||||||
GLOBL ·two_AVX2<>(SB), (NOPTR+RODATA), $32
|
GLOBL ·two_AVX2<>(SB), (NOPTR+RODATA), $32
|
||||||
|
|
||||||
DATA ·rol16_AVX2<>+0x00(SB)/8, $0x0504070601000302
|
DATA ·rol16_AVX2<>+0x00(SB)/8, $0x0504070601000302
|
||||||
DATA ·rol16_AVX2<>+0x08(SB)/8, $0x0D0C0F0E09080B0A
|
DATA ·rol16_AVX2<>+0x08(SB)/8, $0x0D0C0F0E09080B0A
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
// +build 386,!gccgo,!appengine,!nacl amd64,!gccgo,!appengine,!nacl
|
// +build 386,!gccgo,!appengine,!nacl amd64,!gccgo,!appengine,!nacl
|
||||||
|
|
||||||
// ROTL_SSE rotates all 4 32 bit values of the XMM register v
|
// ROTL_SSE rotates all 4 32 bit values of the XMM register v
|
||||||
// left by n bits using SSE2 instructions (0 <= n <= 32).
|
// left by n bits using SSE2 instructions (0 <= n <= 32).
|
||||||
// The XMM register t is used as a temp. register.
|
// The XMM register t is used as a temp. register.
|
||||||
#define ROTL_SSE(n, t, v) \
|
#define ROTL_SSE(n, t, v) \
|
||||||
MOVO v, t; \
|
MOVO v, t; \
|
||||||
|
@ -14,7 +14,7 @@
|
||||||
PXOR t, v
|
PXOR t, v
|
||||||
|
|
||||||
// ROTL_AVX rotates all 4/8 32 bit values of the AVX/AVX2 register v
|
// ROTL_AVX rotates all 4/8 32 bit values of the AVX/AVX2 register v
|
||||||
// left by n bits using AVX/AVX2 instructions (0 <= n <= 32).
|
// left by n bits using AVX/AVX2 instructions (0 <= n <= 32).
|
||||||
// The AVX/AVX2 register t is used as a temp. register.
|
// The AVX/AVX2 register t is used as a temp. register.
|
||||||
#define ROTL_AVX(n, t, v) \
|
#define ROTL_AVX(n, t, v) \
|
||||||
VPSLLD $n, v, t; \
|
VPSLLD $n, v, t; \
|
||||||
|
@ -25,41 +25,41 @@
|
||||||
// 4 XMM registers v0, v1, v2 and v3. It uses only ROTL_SSE2 for
|
// 4 XMM registers v0, v1, v2 and v3. It uses only ROTL_SSE2 for
|
||||||
// rotations. The XMM register t is used as a temp. register.
|
// rotations. The XMM register t is used as a temp. register.
|
||||||
#define CHACHA_QROUND_SSE2(v0, v1, v2, v3, t) \
|
#define CHACHA_QROUND_SSE2(v0, v1, v2, v3, t) \
|
||||||
PADDL v1, v0; \
|
PADDL v1, v0; \
|
||||||
PXOR v0, v3; \
|
PXOR v0, v3; \
|
||||||
ROTL_SSE(16, t, v3); \
|
ROTL_SSE(16, t, v3); \
|
||||||
PADDL v3, v2; \
|
PADDL v3, v2; \
|
||||||
PXOR v2, v1; \
|
PXOR v2, v1; \
|
||||||
ROTL_SSE(12, t, v1); \
|
ROTL_SSE(12, t, v1); \
|
||||||
PADDL v1, v0; \
|
PADDL v1, v0; \
|
||||||
PXOR v0, v3; \
|
PXOR v0, v3; \
|
||||||
ROTL_SSE(8, t, v3); \
|
ROTL_SSE(8, t, v3); \
|
||||||
PADDL v3, v2; \
|
PADDL v3, v2; \
|
||||||
PXOR v2, v1; \
|
PXOR v2, v1; \
|
||||||
ROTL_SSE(7, t, v1)
|
ROTL_SSE(7, t, v1)
|
||||||
|
|
||||||
// CHACHA_QROUND_SSSE3 performs a ChaCha quarter-round using the
|
// CHACHA_QROUND_SSSE3 performs a ChaCha quarter-round using the
|
||||||
// 4 XMM registers v0, v1, v2 and v3. It uses PSHUFB for 8/16 bit
|
// 4 XMM registers v0, v1, v2 and v3. It uses PSHUFB for 8/16 bit
|
||||||
// rotations. The XMM register t is used as a temp. register.
|
// rotations. The XMM register t is used as a temp. register.
|
||||||
//
|
//
|
||||||
// r16 holds the PSHUFB constant for a 16 bit left rotate.
|
// r16 holds the PSHUFB constant for a 16 bit left rotate.
|
||||||
// r8 holds the PSHUFB constant for a 8 bit left rotate.
|
// r8 holds the PSHUFB constant for a 8 bit left rotate.
|
||||||
#define CHACHA_QROUND_SSSE3(v0, v1, v2, v3, t, r16, r8) \
|
#define CHACHA_QROUND_SSSE3(v0, v1, v2, v3, t, r16, r8) \
|
||||||
PADDL v1, v0; \
|
PADDL v1, v0; \
|
||||||
PXOR v0, v3; \
|
PXOR v0, v3; \
|
||||||
PSHUFB r16, v3; \
|
PSHUFB r16, v3; \
|
||||||
PADDL v3, v2; \
|
PADDL v3, v2; \
|
||||||
PXOR v2, v1; \
|
PXOR v2, v1; \
|
||||||
ROTL_SSE(12, t, v1); \
|
ROTL_SSE(12, t, v1); \
|
||||||
PADDL v1, v0; \
|
PADDL v1, v0; \
|
||||||
PXOR v0, v3; \
|
PXOR v0, v3; \
|
||||||
PSHUFB r8, v3; \
|
PSHUFB r8, v3; \
|
||||||
PADDL v3, v2; \
|
PADDL v3, v2; \
|
||||||
PXOR v2, v1; \
|
PXOR v2, v1; \
|
||||||
ROTL_SSE(7, t, v1)
|
ROTL_SSE(7, t, v1)
|
||||||
|
|
||||||
// CHACHA_QROUND_AVX performs a ChaCha quarter-round using the
|
// CHACHA_QROUND_AVX performs a ChaCha quarter-round using the
|
||||||
// 4 AVX/AVX2 registers v0, v1, v2 and v3. It uses VPSHUFB for 8/16 bit
|
// 4 AVX/AVX2 registers v0, v1, v2 and v3. It uses VPSHUFB for 8/16 bit
|
||||||
// rotations. The AVX/AVX2 register t is used as a temp. register.
|
// rotations. The AVX/AVX2 register t is used as a temp. register.
|
||||||
//
|
//
|
||||||
// r16 holds the VPSHUFB constant for a 16 bit left rotate.
|
// r16 holds the VPSHUFB constant for a 16 bit left rotate.
|
||||||
|
@ -70,7 +70,7 @@
|
||||||
VPSHUFB r16, v3, v3; \
|
VPSHUFB r16, v3, v3; \
|
||||||
VPADDD v2, v3, v2; \
|
VPADDD v2, v3, v2; \
|
||||||
VPXOR v1, v2, v1; \
|
VPXOR v1, v2, v1; \
|
||||||
ROTL_AVX(12, t, v1); \
|
ROTL_AVX(12, t, v1); \
|
||||||
VPADDD v0, v1, v0; \
|
VPADDD v0, v1, v0; \
|
||||||
VPXOR v3, v0, v3; \
|
VPXOR v3, v0, v3; \
|
||||||
VPSHUFB r8, v3, v3; \
|
VPSHUFB r8, v3, v3; \
|
||||||
|
@ -94,8 +94,8 @@
|
||||||
VPSHUFD $0x4E, v2, v2; \
|
VPSHUFD $0x4E, v2, v2; \
|
||||||
VPSHUFD $0x93, v3, v3
|
VPSHUFD $0x93, v3, v3
|
||||||
|
|
||||||
// XOR_SSE extracts 4x16 byte vectors from src at
|
// XOR_SSE extracts 4x16 byte vectors from src at
|
||||||
// off, xors all vectors with the corresponding XMM
|
// off, xors all vectors with the corresponding XMM
|
||||||
// register (v0 - v3) and writes the result to dst
|
// register (v0 - v3) and writes the result to dst
|
||||||
// at off.
|
// at off.
|
||||||
// The XMM register t is used as a temp. register.
|
// The XMM register t is used as a temp. register.
|
||||||
|
@ -113,8 +113,8 @@
|
||||||
PXOR v3, t; \
|
PXOR v3, t; \
|
||||||
MOVOU t, 48+off(dst)
|
MOVOU t, 48+off(dst)
|
||||||
|
|
||||||
// XOR_AVX extracts 4x16 byte vectors from src at
|
// XOR_AVX extracts 4x16 byte vectors from src at
|
||||||
// off, xors all vectors with the corresponding AVX
|
// off, xors all vectors with the corresponding AVX
|
||||||
// register (v0 - v3) and writes the result to dst
|
// register (v0 - v3) and writes the result to dst
|
||||||
// at off.
|
// at off.
|
||||||
// The XMM register t is used as a temp. register.
|
// The XMM register t is used as a temp. register.
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
## 1.2.0 (2018/04/25)
|
||||||
|
|
||||||
|
- Add ContainedIP() as fast way to check an IP [#7](https://github.com/k-sone/critbitgo/pull/7)
|
||||||
|
|
||||||
## 1.1.0 (2016/12/29)
|
## 1.1.0 (2016/12/29)
|
||||||
|
|
||||||
- Add `LongestPrefix ` and `Walk` functions
|
- Add `LongestPrefix ` and `Walk` functions
|
||||||
|
|
|
@ -236,9 +236,11 @@ func (t *Trie) Allprefixed(prefix []byte, handle func(key []byte, value interfac
|
||||||
p := &t.root
|
p := &t.root
|
||||||
top := p
|
top := p
|
||||||
if len(prefix) > 0 {
|
if len(prefix) > 0 {
|
||||||
for p.internal != nil {
|
for q := p.internal; q != nil; q = p.internal {
|
||||||
top = p
|
p = &q.child[q.direction(prefix)]
|
||||||
p = &p.internal.child[p.internal.direction(prefix)]
|
if q.offset < len(prefix) {
|
||||||
|
top = p
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// check prefix
|
// check prefix
|
||||||
|
|
|
@ -137,7 +137,7 @@ func TestSize(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAllprefixed(t *testing.T) {
|
func TestAllprefixed(t *testing.T) {
|
||||||
keys := []string{"", "a", "aa", "b", "bb", "ab", "ba", "aba", "bab"}
|
keys := []string{"", "a", "aa", "b", "bb", "ab", "ba", "aba", "bab", "bc"}
|
||||||
trie := buildTrie(t, keys)
|
trie := buildTrie(t, keys)
|
||||||
|
|
||||||
elems := make([]string, 0, len(keys))
|
elems := make([]string, 0, len(keys))
|
||||||
|
@ -150,10 +150,10 @@ func TestAllprefixed(t *testing.T) {
|
||||||
if !trie.Allprefixed([]byte{}, handle) {
|
if !trie.Allprefixed([]byte{}, handle) {
|
||||||
t.Error("Allprefixed() - invalid result")
|
t.Error("Allprefixed() - invalid result")
|
||||||
}
|
}
|
||||||
if len(elems) != 9 {
|
if len(elems) != 10 {
|
||||||
t.Errorf("Allprefixed() - invalid elems length [%v]", elems)
|
t.Errorf("Allprefixed() - invalid elems length [%v]", elems)
|
||||||
}
|
}
|
||||||
for i, key := range []string{"", "a", "aa", "ab", "aba", "b", "ba", "bab", "bb"} {
|
for i, key := range []string{"", "a", "aa", "ab", "aba", "b", "ba", "bab", "bb", "bc"} {
|
||||||
if key != elems[i] {
|
if key != elems[i] {
|
||||||
t.Errorf("Allprefixed() - not found [%s]", key)
|
t.Errorf("Allprefixed() - not found [%s]", key)
|
||||||
}
|
}
|
||||||
|
@ -172,6 +172,19 @@ func TestAllprefixed(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
elems = make([]string, 0, len(keys))
|
||||||
|
if !trie.Allprefixed([]byte("bb"), handle) {
|
||||||
|
t.Error("Allprefixed() - invalid result")
|
||||||
|
}
|
||||||
|
if len(elems) != 1 {
|
||||||
|
t.Errorf("Allprefixed() - invalid elems length [%v]", elems)
|
||||||
|
}
|
||||||
|
for i, key := range []string{"bb"} {
|
||||||
|
if key != elems[i] {
|
||||||
|
t.Errorf("Allprefixed() - not found [%s]", key)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
elems = make([]string, 0, len(keys))
|
elems = make([]string, 0, len(keys))
|
||||||
handle = func(key []byte, value interface{}) bool {
|
handle = func(key []byte, value interface{}) bool {
|
||||||
if k := string(key); k == value {
|
if k := string(key); k == value {
|
||||||
|
|
|
@ -97,9 +97,25 @@ func (n *Net) MatchCIDR(s string) (route *net.IPNet, value interface{}, err erro
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return a bool indicating whether a route would be found
|
||||||
|
func (n *Net) ContainedIP(ip net.IP) (contained bool, err error) {
|
||||||
|
k, _, err := n.matchIP(ip)
|
||||||
|
contained = k != nil
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// Return a specific route by using the longest prefix matching.
|
// Return a specific route by using the longest prefix matching.
|
||||||
// If `ip` is invalid IP, or a route is not found, `route` is nil.
|
// If `ip` is invalid IP, or a route is not found, `route` is nil.
|
||||||
func (n *Net) MatchIP(ip net.IP) (route *net.IPNet, value interface{}, err error) {
|
func (n *Net) MatchIP(ip net.IP) (route *net.IPNet, value interface{}, err error) {
|
||||||
|
k, v, err := n.matchIP(ip)
|
||||||
|
if k != nil {
|
||||||
|
route = netKeyToIPNet(k)
|
||||||
|
value = v
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n *Net) matchIP(ip net.IP) (k []byte, v interface{}, err error) {
|
||||||
var isV4 bool
|
var isV4 bool
|
||||||
ip, isV4, err = netValidateIP(ip)
|
ip, isV4, err = netValidateIP(ip)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -111,10 +127,7 @@ func (n *Net) MatchIP(ip net.IP) (route *net.IPNet, value interface{}, err error
|
||||||
} else {
|
} else {
|
||||||
mask = mask128
|
mask = mask128
|
||||||
}
|
}
|
||||||
if k, v := n.match(netIPNetToKey(ip, mask)); k != nil {
|
k, v = n.match(netIPNetToKey(ip, mask))
|
||||||
route = netKeyToIPNet(k)
|
|
||||||
value = v
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,12 @@ func TestNet(t *testing.T) {
|
||||||
if r, v, err := trie.MatchIP(hostIP); r != nil || v != nil || err != nil {
|
if r, v, err := trie.MatchIP(hostIP); r != nil || v != nil || err != nil {
|
||||||
t.Errorf("MatchIP() - phantom: %v, %v, %v", r, v, err)
|
t.Errorf("MatchIP() - phantom: %v, %v, %v", r, v, err)
|
||||||
}
|
}
|
||||||
|
if _, err := trie.ContainedIP(net.IP([]byte{})); err == nil {
|
||||||
|
t.Error("ContainedIP() - not error")
|
||||||
|
}
|
||||||
|
if b, err := trie.ContainedIP(hostIP); b || err != nil {
|
||||||
|
t.Errorf("ContainedIP() - phantom: %v, %v", b, err)
|
||||||
|
}
|
||||||
if _, _, err := trie.DeleteCIDR(""); err == nil {
|
if _, _, err := trie.DeleteCIDR(""); err == nil {
|
||||||
t.Error("DeleteCIDR() - not error")
|
t.Error("DeleteCIDR() - not error")
|
||||||
}
|
}
|
||||||
|
@ -50,6 +56,9 @@ func TestNet(t *testing.T) {
|
||||||
if r, v, err := trie.MatchIP(hostIP); r == nil || r.String() != cidr || v != &cidr || err != nil {
|
if r, v, err := trie.MatchIP(hostIP); r == nil || r.String() != cidr || v != &cidr || err != nil {
|
||||||
t.Errorf("MatchIP() - failed: %v, %v, %v", r, v, err)
|
t.Errorf("MatchIP() - failed: %v, %v, %v", r, v, err)
|
||||||
}
|
}
|
||||||
|
if b, err := trie.ContainedIP(hostIP); !b || err != nil {
|
||||||
|
t.Errorf("ContainedIP() - failed: %v, %v", b, err)
|
||||||
|
}
|
||||||
if v, ok, err := trie.DeleteCIDR(cidr); v != &cidr || !ok || err != nil {
|
if v, ok, err := trie.DeleteCIDR(cidr); v != &cidr || !ok || err != nil {
|
||||||
t.Errorf("DeleteCIDR() - failed: %v, %v, %v", v, ok, err)
|
t.Errorf("DeleteCIDR() - failed: %v, %v, %v", v, ok, err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -951,6 +951,9 @@ func (cc *ClientConn) awaitOpenSlotForRequest(req *http.Request) error {
|
||||||
for {
|
for {
|
||||||
cc.lastActive = time.Now()
|
cc.lastActive = time.Now()
|
||||||
if cc.closed || !cc.canTakeNewRequestLocked() {
|
if cc.closed || !cc.canTakeNewRequestLocked() {
|
||||||
|
if waitingForConn != nil {
|
||||||
|
close(waitingForConn)
|
||||||
|
}
|
||||||
return errClientConnUnusable
|
return errClientConnUnusable
|
||||||
}
|
}
|
||||||
if int64(len(cc.streams))+1 <= int64(cc.maxConcurrentStreams) {
|
if int64(len(cc.streams))+1 <= int64(cc.maxConcurrentStreams) {
|
||||||
|
|
Loading…
Reference in New Issue