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
d1c5d264
Commit
d1c5d264
authored
12 years ago
by
Dmitry Simonenko
Browse files
Options
Downloads
Patches
Plain Diff
connector-c-lite: added tp_req and tp_reqbuf functions.
parent
b5e73e3f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
connector/c/include/tp.h
+17
-4
17 additions, 4 deletions
connector/c/include/tp.h
test/connector_c/tp.c
+2
-3
2 additions, 3 deletions
test/connector_c/tp.c
with
19 additions
and
7 deletions
connector/c/include/tp.h
+
17
−
4
View file @
d1c5d264
...
...
@@ -481,8 +481,20 @@ tp_sz(struct tp *p, char *sz) {
return
tp_field
(
p
,
sz
,
strlen
(
sz
));
}
static
ssize_t
tp_required
(
struct
tp
*
p
)
{
static
inline
ssize_t
tp_reqbuf
(
char
*
buf
,
size_t
size
)
{
if
(
tp_unlikely
(
size
<
sizeof
(
struct
tp_h
)))
return
sizeof
(
struct
tp_h
)
-
size
;
register
int
sz
=
((
struct
tp_h
*
)
buf
)
->
len
+
sizeof
(
struct
tp_h
);
return
(
tp_likely
(
size
<
sz
))
?
sz
-
size
:
size
-
sz
;
}
static
inline
ssize_t
tp_req
(
struct
tp
*
p
)
{
return
tp_reqbuf
(
p
->
s
,
tp_used
(
p
));
/*
register size_t used = tp_used(p);
if (tp_unlikely(used < sizeof(struct tp_h)))
return sizeof(struct tp_h) - used;
...
...
@@ -490,6 +502,7 @@ tp_required(struct tp *p) {
register struct tp_h *h = (struct tp_h*)p->s;
return (tp_likely(used < h->len)) ?
h->len - used : used - h->len;
*/
}
static
inline
size_t
...
...
@@ -512,7 +525,7 @@ tp_replyerror(struct tp *p) {
static
inline
int
tp_replyerrorlen
(
struct
tp
*
p
)
{
return
tp_unfetched
(
p
)
+
tp_req
uired
(
p
);
return
tp_unfetched
(
p
)
+
tp_req
(
p
);
}
static
inline
uint32_t
...
...
@@ -532,7 +545,7 @@ tp_replyop(struct tp *p) {
tp_function_unused
static
ssize_t
tp_reply
(
struct
tp
*
p
)
{
if
(
tp_unlikely
(
tp_req
uired
(
p
)
>
0
))
if
(
tp_unlikely
(
tp_req
(
p
)
>
0
))
return
-
1
;
p
->
c
=
p
->
s
;
p
->
h
=
tp_fetch
(
p
,
sizeof
(
struct
tp_h
));
...
...
This diff is collapsed.
Click to expand it.
test/connector_c/tp.c
+
2
−
3
View file @
d1c5d264
...
...
@@ -3,8 +3,7 @@
#include
<tp.h>
static
void
reply_print
(
struct
tp
*
rep
)
{
char
*
tu
;
while
((
tu
=
tp_next
(
rep
)))
{
while
(
tp_next
(
rep
))
{
printf
(
"tuple fields: %d
\n
"
,
tp_tuplecount
(
rep
));
printf
(
"tuple size: %d
\n
"
,
tp_tuplesize
(
rep
));
printf
(
"["
);
...
...
@@ -24,7 +23,7 @@ static int reply(void) {
tp_init
(
&
rep
,
NULL
,
0
,
tp_reallocator_noloss
,
NULL
);
while
(
1
)
{
ssize_t
to_read
=
tp_req
uired
(
&
rep
);
ssize_t
to_read
=
tp_req
(
&
rep
);
printf
(
"to_read: %zu
\n
"
,
to_read
);
if
(
to_read
<=
0
)
break
;
...
...
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