Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
varnish-cache
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
varnishcache
varnish-cache
Commits
38994b55
Commit
38994b55
authored
Aug 05, 2018
by
Guillaume Quintard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[varnishtest] generate the decoding tables
parent
02b73e11
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
362 additions
and
1060 deletions
+362
-1060
Makefile.am
bin/varnishtest/Makefile.am
+6
-1
huffman_gen.py
bin/varnishtest/huffman_gen.py
+96
-0
huffman_input
bin/varnishtest/huffman_input
+257
-0
vtc_h2_dectbl.h
bin/varnishtest/vtc_h2_dectbl.h
+0
-1056
vtc_h2_hpack.c
bin/varnishtest/vtc_h2_hpack.c
+3
-3
No files found.
bin/varnishtest/Makefile.am
View file @
38994b55
...
...
@@ -76,7 +76,8 @@ EXTRA_DIST = $(top_srcdir)/bin/varnishtest/tests/*.vtc \
$(top_srcdir)
/bin/varnishtest/tests/README
\
$(top_srcdir)
/bin/varnishtest/gensequences
\
$(top_srcdir)
/bin/varnishtest/sequences
\
$(top_srcdir)
/bin/varnishtest/teken.3
$(top_srcdir)
/bin/varnishtest/teken.3
\
huffman_gen.py
teken.c
:
teken_state.h
...
...
@@ -84,4 +85,8 @@ teken_state.h: $(srcdir)/sequences $(srcdir)/gensequences
awk
-f
$(srcdir)
/gensequences
$(srcdir)
/sequences
\
>
$(builddir)
/teken_state.h
vtc_h2_dectbl.h
:
huffman_gen.py $(top_srcdir)/include/tbl/vhp_huffman.h
$(srcdir)
/huffman_gen.py
$(top_srcdir)
/include/tbl/vhp_huffman.h
>
$@
_
mv
$@
_
$@
CLEANFILES
=
$(builddir)
/teken_state.h
bin/varnishtest/huffman_gen.py
0 → 100755
View file @
38994b55
#!/usr/bin/env python
import
re
import
sys
#HPH(0x30, 0x00000000, 5)
regex
=
re
.
compile
(
"^HPH
\
((.{4}), (.{10}), +(.{1,3})
\
)"
)
if
len
(
sys
.
argv
)
!=
2
:
print
(
"{} takes one and only one argument"
.
format
(
sys
.
argv
[
0
]))
sys
.
exit
(
2
)
class
sym
:
def
__init__
(
self
,
bigval
,
bigvall
,
chr
=
0
,
esc
=
None
):
self
.
vall
=
bigvall
%
8
if
bigvall
%
8
else
8
self
.
val
=
bigval
&
((
1
<<
self
.
vall
)
-
1
)
self
.
pfx
=
(
bigval
>>
self
.
vall
)
# & 0xff
self
.
chr
=
chr
self
.
esc
=
esc
tbls
=
{}
msl
=
{}
# max sym length
f
=
open
(
sys
.
argv
[
1
])
for
l
in
f
:
grp
=
1
match
=
regex
.
match
(
l
)
if
not
match
:
continue
chr
=
int
(
match
.
group
(
grp
),
16
)
grp
+=
1
val
=
int
(
match
.
group
(
grp
),
16
)
grp
+=
1
vall
=
int
(
match
.
group
(
grp
))
s
=
sym
(
val
,
vall
,
chr
)
if
s
.
pfx
not
in
tbls
:
tbls
[
s
.
pfx
]
=
{}
if
(
s
.
val
in
tbls
[
s
.
pfx
]):
assert
(
tbls
[
s
.
pfx
][
s
.
val
]
.
e
)
tbls
[
s
.
pfx
][
s
.
val
]
=
s
# add the escape entry in the "previous" table
if
s
.
pfx
:
pp
=
s
.
pfx
>>
8
pv
=
s
.
pfx
&
0xff
if
pp
not
in
tbls
:
tbls
[
pp
]
=
{}
tbls
[
pp
][
pv
]
=
sym
(
pv
,
8
,
0
,
"&tbl_{:x}"
.
format
(
s
.
pfx
))
f
.
close
()
# add the EOS case
s
=
sym
(
63
,
6
,
0
)
tbls
[
0xffffff
][
63
]
=
s
print
(
'''/* NB: This file is machine generated, DO NOT EDIT!
* edit bin/varnishtest/huffman_input instead
*/
struct stbl;
struct ssym {
uint8_t csm; /* bits consumed */
uint8_t chr; /* character */
struct stbl *nxt; /* next table */
};
struct stbl {
int msk;
struct ssym *syms;
};
'''
)
for
pfx
in
sorted
(
tbls
.
keys
(),
reverse
=
True
):
msl
=
max
([
x
.
vall
for
x
in
tbls
[
pfx
]
.
values
()
])
for
s
in
tbls
[
pfx
]
.
values
():
s
.
val
=
s
.
val
<<
(
msl
-
s
.
vall
)
tbl
=
sorted
(
tbls
[
pfx
]
.
values
(),
key
=
lambda
x
:
x
.
val
)
print
(
"
\n
static struct ssym sym_{:x}_array[] = {{"
.
format
(
pfx
))
for
s
in
tbl
:
for
j
in
range
(
2
**
(
msl
-
s
.
vall
)):
print
(
" {} {{{}, {:3d}, {}}},"
.
format
(
" "
*
13
if
j
else
"/* idx {:3d} */"
.
format
(
s
.
val
+
j
),
s
.
vall
,
s
.
chr
%
256
,
s
.
esc
if
s
.
esc
else
"NULL"
))
print
(
'''}};
static struct stbl tbl_{:x} = {{
{},
sym_{:x}_array
}};'''
.
format
(
pfx
,
msl
,
pfx
))
bin/varnishtest/huffman_input
0 → 100644
View file @
38994b55
This diff is collapsed.
Click to expand it.
bin/varnishtest/vtc_h2_dectbl.h
deleted
100644 → 0
View file @
02b73e11
This diff is collapsed.
Click to expand it.
bin/varnishtest/vtc_h2_hpack.c
View file @
38994b55
...
...
@@ -61,7 +61,7 @@ huff_decode(char *str, int nm, struct hpk_iter *iter, int ilen)
int
l
=
0
;
uint64_t
pack
=
0
;
unsigned
pl
=
0
;
/* pack length*/
struct
stbl
*
tbl
=
&
byte
0
;
struct
stbl
*
tbl
=
&
tbl_
0
;
struct
ssym
*
sym
;
(
void
)
nm
;
...
...
@@ -71,7 +71,7 @@ huff_decode(char *str, int nm, struct hpk_iter *iter, int ilen)
if
(
ilen
==
0
)
{
if
(
pl
==
0
||
(
MASK
(
pack
,
pl
)
==
(
unsigned
)((
1U
<<
pl
)
-
1U
)))
{
assert
(
tbl
==
&
byte
0
);
assert
(
tbl
==
&
tbl_
0
);
return
(
l
);
}
}
...
...
@@ -102,7 +102,7 @@ huff_decode(char *str, int nm, struct hpk_iter *iter, int ilen)
continue
;
}
str
[
l
++
]
=
sym
->
chr
;
tbl
=
&
byte
0
;
tbl
=
&
tbl_
0
;
}
return
(
l
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment