Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
tarantool
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
core
tarantool
Commits
2f3fedc4
Commit
2f3fedc4
authored
11 years ago
by
Dmitry Simonenko
Browse files
Options
Downloads
Patches
Plain Diff
tp.h: rename leb128 to ber128
parent
ba124bdd
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
connector/c/include/tp.h
+21
-21
21 additions, 21 deletions
connector/c/include/tp.h
with
21 additions
and
21 deletions
connector/c/include/tp.h
+
21
−
21
View file @
2f3fedc4
...
...
@@ -479,9 +479,9 @@ tp_tuple(struct tp *p) {
return
tp_used
(
p
);
}
/*
Leb
128 calculation functions, internally used by the library */
/*
Ber
128 calculation functions, internally used by the library */
static
inline
size_t
tp_
leb
128sizeof
(
uint32_t
value
)
{
tp_
ber
128sizeof
(
uint32_t
value
)
{
return
(
tp_likely
(
value
<
(
1
<<
7
)))
?
1
:
(
tp_likely
(
value
<
(
1
<<
14
)))
?
2
:
(
tp_unlikely
(
value
<
(
1
<<
21
)))
?
3
:
...
...
@@ -489,7 +489,7 @@ tp_leb128sizeof(uint32_t value) {
}
static
tp_noinline
void
tp_hot
tp_
leb
128save_slowpath
(
struct
tp
*
p
,
uint32_t
value
)
{
tp_
ber
128save_slowpath
(
struct
tp
*
p
,
uint32_t
value
)
{
if
(
tp_unlikely
(
value
>=
(
1
<<
21
)))
{
if
(
tp_unlikely
(
value
>=
(
1
<<
28
)))
*
(
p
->
p
++
)
=
(
value
>>
28
)
|
0x80
;
...
...
@@ -502,9 +502,9 @@ tp_leb128save_slowpath(struct tp *p, uint32_t value) {
}
static
inline
void
tp_hot
tp_
leb
128save
(
struct
tp
*
p
,
uint32_t
value
)
{
tp_
ber
128save
(
struct
tp
*
p
,
uint32_t
value
)
{
if
(
tp_unlikely
(
value
>=
(
1
<<
14
)))
{
tp_
leb
128save_slowpath
(
p
,
value
);
tp_
ber
128save_slowpath
(
p
,
value
);
return
;
}
if
(
tp_likely
(
value
>=
(
1
<<
7
)))
...
...
@@ -513,7 +513,7 @@ tp_leb128save(struct tp *p, uint32_t value) {
}
static
tp_noinline
int
tp_hot
tp_
leb
128load_slowpath
(
struct
tp
*
p
,
uint32_t
*
value
)
{
tp_
ber
128load_slowpath
(
struct
tp
*
p
,
uint32_t
*
value
)
{
if
(
tp_likely
(
!
(
p
->
f
[
2
]
&
0x80
)))
{
*
value
=
(
p
->
f
[
0
]
&
0x7f
)
<<
14
|
(
p
->
f
[
1
]
&
0x7f
)
<<
7
|
...
...
@@ -540,7 +540,7 @@ tp_leb128load_slowpath(struct tp *p, uint32_t *value) {
}
static
inline
int
tp_hot
tp_
leb
128load
(
struct
tp
*
p
,
uint32_t
*
value
)
{
tp_
ber
128load
(
struct
tp
*
p
,
uint32_t
*
value
)
{
if
(
tp_likely
(
!
(
p
->
f
[
0
]
&
0x80
)))
{
*
value
=
*
(
p
->
f
++
)
&
0x7f
;
}
else
...
...
@@ -548,7 +548,7 @@ tp_leb128load(struct tp *p, uint32_t *value) {
*
value
=
(
p
->
f
[
0
]
&
0x7f
)
<<
7
|
(
p
->
f
[
1
]
&
0x7f
);
p
->
f
+=
2
;
}
else
return
tp_
leb
128load_slowpath
(
p
,
value
);
return
tp_
ber
128load_slowpath
(
p
,
value
);
return
0
;
}
...
...
@@ -560,10 +560,10 @@ static inline ssize_t
tp_field
(
struct
tp
*
p
,
const
char
*
data
,
size_t
size
)
{
assert
(
p
->
h
!=
NULL
);
assert
(
p
->
t
!=
NULL
);
register
int
esz
=
tp_
leb
128sizeof
(
size
);
register
int
esz
=
tp_
ber
128sizeof
(
size
);
if
(
tp_unlikely
(
tp_ensure
(
p
,
esz
+
size
)
==
-
1
))
return
-
1
;
tp_
leb
128save
(
p
,
size
);
tp_
ber
128save
(
p
,
size
);
memcpy
(
p
->
p
,
data
,
size
);
p
->
p
+=
size
;
(
*
(
uint32_t
*
)
p
->
t
)
++
;
...
...
@@ -678,7 +678,7 @@ tp_call(struct tp *p, uint32_t flags, const char *name, size_t name_len) {
struct
tp_h
h
;
struct
tp_hcall
c
;
}
h
;
size_t
sz
=
tp_
leb
128sizeof
(
name_len
);
size_t
sz
=
tp_
ber
128sizeof
(
name_len
);
h
.
h
.
type
=
TP_CALL
;
h
.
h
.
len
=
sizeof
(
struct
tp_hcall
)
+
sz
+
name_len
;
h
.
h
.
reqid
=
0
;
...
...
@@ -688,7 +688,7 @@ tp_call(struct tp *p, uint32_t flags, const char *name, size_t name_len) {
tp_setreq
(
p
);
memcpy
(
p
->
p
,
&
h
,
sizeof
(
h
));
p
->
p
+=
sizeof
(
h
);
tp_
leb
128save
(
p
,
name_len
);
tp_
ber
128save
(
p
,
name_len
);
memcpy
(
p
->
p
,
name
,
name_len
);
p
->
p
+=
name_len
;
return
tp_used
(
p
);
...
...
@@ -788,7 +788,7 @@ tp_op(struct tp *p, uint32_t field, uint8_t op, const char *data,
assert
(
p
->
h
!=
NULL
);
assert
(
p
->
u
!=
NULL
);
assert
(
p
->
h
->
type
==
TP_UPDATE
);
size_t
sz
=
4
+
1
+
tp_
leb
128sizeof
(
size
)
+
size
;
size_t
sz
=
4
+
1
+
tp_
ber
128sizeof
(
size
)
+
size
;
if
(
tp_unlikely
(
tp_ensure
(
p
,
sz
))
==
-
1
)
return
-
1
;
/* field */
...
...
@@ -798,7 +798,7 @@ tp_op(struct tp *p, uint32_t field, uint8_t op, const char *data,
*
(
uint8_t
*
)(
p
->
p
)
=
op
;
p
->
p
+=
sizeof
(
uint8_t
);
/* data */
tp_
leb
128save
(
p
,
size
);
tp_
ber
128save
(
p
,
size
);
if
(
tp_likely
(
data
))
memcpy
(
p
->
p
,
data
,
size
);
p
->
p
+=
size
;
...
...
@@ -814,22 +814,22 @@ tp_op(struct tp *p, uint32_t field, uint8_t op, const char *data,
static
inline
ssize_t
tp_opsplice
(
struct
tp
*
p
,
uint32_t
field
,
uint32_t
offset
,
uint32_t
cut
,
const
char
*
paste
,
size_t
paste_len
)
{
uint32_t
olen
=
tp_
leb
128sizeof
(
sizeof
(
offset
)),
clen
=
tp_
leb
128sizeof
(
sizeof
(
cut
)),
plen
=
tp_
leb
128sizeof
(
paste_len
);
uint32_t
olen
=
tp_
ber
128sizeof
(
sizeof
(
offset
)),
clen
=
tp_
ber
128sizeof
(
sizeof
(
cut
)),
plen
=
tp_
ber
128sizeof
(
paste_len
);
uint32_t
sz
=
olen
+
sizeof
(
offset
)
+
clen
+
sizeof
(
cut
)
+
plen
+
paste_len
;
ssize_t
rc
=
tp_op
(
p
,
field
,
TP_OPSPLICE
,
NULL
,
sz
);
if
(
tp_unlikely
(
rc
==
-
1
))
return
-
1
;
p
->
p
-=
sz
;
tp_
leb
128save
(
p
,
sizeof
(
offset
));
tp_
ber
128save
(
p
,
sizeof
(
offset
));
memcpy
(
p
->
p
,
&
offset
,
sizeof
(
offset
));
p
->
p
+=
sizeof
(
offset
);
tp_
leb
128save
(
p
,
sizeof
(
cut
));
tp_
ber
128save
(
p
,
sizeof
(
cut
));
memcpy
(
p
->
p
,
&
cut
,
sizeof
(
cut
));
p
->
p
+=
sizeof
(
cut
);
tp_
leb
128save
(
p
,
paste_len
);
tp_
ber
128save
(
p
,
paste_len
);
memcpy
(
p
->
p
,
paste
,
paste_len
);
p
->
p
+=
paste_len
;
return
rc
;
...
...
@@ -1092,7 +1092,7 @@ tp_nextfield(struct tp *p) {
return
0
;
p
->
f
+=
p
->
fsz
;
fetch:
;
register
int
rc
=
tp_
leb
128load
(
p
,
&
p
->
fsz
);
register
int
rc
=
tp_
ber
128load
(
p
,
&
p
->
fsz
);
if
(
tp_unlikely
(
rc
==
-
1
))
return
-
1
;
if
(
tp_unlikely
((
p
->
f
+
p
->
fsz
)
>
p
->
e
))
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment