Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OpenXG-RAN
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
promise
OpenXG-RAN
Commits
4b68033b
Commit
4b68033b
authored
Mar 15, 2016
by
Cedric Roux
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
some work for buffer handling
parent
1e20abdd
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
9 deletions
+23
-9
T.h
T.h
+7
-5
T_messages.txt
T_messages.txt
+1
-0
main.c
main.c
+4
-2
tracer/main.c
tracer/main.c
+11
-2
No files found.
T.h
View file @
4b68033b
...
@@ -36,10 +36,12 @@
...
@@ -36,10 +36,12 @@
#define T_PUT_buffer(argnum, val) \
#define T_PUT_buffer(argnum, val) \
do { \
do { \
T_buffer T_PUT_var = (val); \
T_buffer T_PUT_buffer_var = (val); \
T_CHECK_SIZE(T_PUT_var.length, argnum); \
T_PUT_int(argnum, T_PUT_buffer_var.length); \
memcpy(T_LOCAL_buf + T_LOCAL_size, T_PUT_var.addr, T_PUT_var.length); \
T_CHECK_SIZE(T_PUT_buffer_var.length, argnum); \
T_LOCAL_size += T_PUT_var.length; \
memcpy(T_LOCAL_buf + T_LOCAL_size, T_PUT_buffer_var.addr, \
T_PUT_buffer_var.length); \
T_LOCAL_size += T_PUT_buffer_var.length; \
} while (0)
} while (0)
#define T_PUT_string(argnum, val) \
#define T_PUT_string(argnum, val) \
...
@@ -117,7 +119,7 @@ extern T_cache_t *T_cache;
...
@@ -117,7 +119,7 @@ extern T_cache_t *T_cache;
T_send(T_LOCAL_buf, T_LOCAL_size)
T_send(T_LOCAL_buf, T_LOCAL_size)
#define T_CHECK_SIZE(len, argnum) \
#define T_CHECK_SIZE(len, argnum) \
if (T_LOCAL_size +
len
> T_BUFFER_MAX) { \
if (T_LOCAL_size +
(len)
> T_BUFFER_MAX) { \
printf("%s:%d:%s: cannot put argument %d in T macro, not enough space" \
printf("%s:%d:%s: cannot put argument %d in T macro, not enough space" \
", consider increasing T_BUFFER_MAX (%d)\n", \
", consider increasing T_BUFFER_MAX (%d)\n", \
__FILE__, __LINE__, __FUNCTION__, argnum, T_BUFFER_MAX); \
__FILE__, __LINE__, __FUNCTION__, argnum, T_BUFFER_MAX); \
...
...
T_messages.txt
View file @
4b68033b
...
@@ -138,3 +138,4 @@ ID = LEGACY_CLI_DEBUG
...
@@ -138,3 +138,4 @@ ID = LEGACY_CLI_DEBUG
ID = LEGACY_CLI_TRACE
ID = LEGACY_CLI_TRACE
ID = first
ID = first
ID = buf_test
main.c
View file @
4b68033b
...
@@ -10,8 +10,10 @@ int main(void)
...
@@ -10,8 +10,10 @@ int main(void)
T_connect_to_tracer
(
"127.0.0.1"
,
2020
);
T_connect_to_tracer
(
"127.0.0.1"
,
2020
);
printf
(
"after connect
\n
"
);
printf
(
"after connect
\n
"
);
while
(
1
)
{
while
(
1
)
{
T
(
T_first
,
T_PRINTF
(
"hello world %s!
\n
"
,
"yo"
));
char
*
buf
=
"hello world %s!
\n
"
;
//usleep(1);
//T(T_first, T_PRINTF("hello world %s!\n", "yo"));
T
(
T_buf_test
,
T_BUFFER
(
"hello world %s!
\n
"
,
strlen
(
buf
)
+
1
));
usleep
(
1
);
}
}
while
(
1
)
pause
();
while
(
1
)
pause
();
...
...
tracer/main.c
View file @
4b68033b
...
@@ -73,7 +73,7 @@ void get_string(int s, char *out)
...
@@ -73,7 +73,7 @@ void get_string(int s, char *out)
void
get_message
(
int
s
)
void
get_message
(
int
s
)
{
{
#define S(x, y) do { \
#define S(x, y) do { \
char str[
1024
]; \
char str[
T_BUFFER_MAX
]; \
get_string(s, str); \
get_string(s, str); \
printf("["x"]["y"] %s", str); \
printf("["x"]["y"] %s", str); \
} while (0)
} while (0)
...
@@ -85,7 +85,7 @@ void get_message(int s)
...
@@ -85,7 +85,7 @@ void get_message(int s)
if
(
GET
(
s
,
&
m
,
sizeof
(
int
))
!=
sizeof
(
int
))
abort
();
if
(
GET
(
s
,
&
m
,
sizeof
(
int
))
!=
sizeof
(
int
))
abort
();
switch
(
m
)
{
switch
(
m
)
{
case
T_first
:
{
case
T_first
:
{
char
str
[
1024
];
char
str
[
T_BUFFER_MAX
];
get_string
(
s
,
str
);
get_string
(
s
,
str
);
printf
(
"%s"
,
str
);
printf
(
"%s"
,
str
);
break
;
break
;
...
@@ -195,6 +195,15 @@ void get_message(int s)
...
@@ -195,6 +195,15 @@ void get_message(int s)
case
T_LEGACY_CLI_WARNING
:
S
(
"CLI"
,
"WARNING"
);
break
;
case
T_LEGACY_CLI_WARNING
:
S
(
"CLI"
,
"WARNING"
);
break
;
case
T_LEGACY_CLI_DEBUG
:
S
(
"CLI"
,
"DEBUG"
);
break
;
case
T_LEGACY_CLI_DEBUG
:
S
(
"CLI"
,
"DEBUG"
);
break
;
case
T_LEGACY_CLI_TRACE
:
S
(
"CLI"
,
"TRACE"
);
break
;
case
T_LEGACY_CLI_TRACE
:
S
(
"CLI"
,
"TRACE"
);
break
;
case
T_buf_test
:
{
unsigned
char
buf
[
T_BUFFER_MAX
];
int
size
;
GET
(
s
,
&
size
,
sizeof
(
int
));
GET
(
s
,
buf
,
size
);
printf
(
"got buffer size %d %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x %2.2x
\n
"
,
size
,
buf
[
0
],
buf
[
1
],
buf
[
2
],
buf
[
3
],
buf
[
4
],
buf
[
5
],
buf
[
6
],
buf
[
7
],
buf
[
8
],
buf
[
9
],
buf
[
10
],
buf
[
11
],
buf
[
12
],
buf
[
13
],
buf
[
14
],
buf
[
15
]);
break
;
}
default:
printf
(
"unkown message type %d
\n
"
,
m
);
abort
();
default:
printf
(
"unkown message type %d
\n
"
,
m
);
abort
();
}
}
...
...
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