Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
L
LabComm
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Anders Blomdell
LabComm
Commits
9b875283
Commit
9b875283
authored
10 years ago
by
Sven Gestegård Robertz
Browse files
Options
Downloads
Patches
Plain Diff
handling for type_bindings in C
parent
17d3b32c
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
examples/user_types/example_decoder.c
+6
-1
6 additions, 1 deletion
examples/user_types/example_decoder.c
lib/c/2014/labcomm_decoder.c
+70
-16
70 additions, 16 deletions
lib/c/2014/labcomm_decoder.c
lib/c/2014/labcomm_type_signature.h
+19
-1
19 additions, 1 deletion
lib/c/2014/labcomm_type_signature.h
with
95 additions
and
18 deletions
examples/user_types/example_decoder.c
+
6
−
1
View file @
9b875283
...
@@ -21,7 +21,11 @@ static void handle_test_theSecondInt(int *v,void *context) {
...
@@ -21,7 +21,11 @@ static void handle_test_theSecondInt(int *v,void *context) {
}
}
static
void
handle_typedef
(
struct
labcomm_raw_typedef
*
v
,
void
*
context
)
{
static
void
handle_typedef
(
struct
labcomm_raw_typedef
*
v
,
void
*
context
)
{
printf
(
"Got typedef. (%d) %s
\n
"
,
v
->
index
,
v
->
name
);
printf
(
"Got typedef. (0x%x) %s
\n
"
,
v
->
index
,
v
->
name
);
}
static
void
handle_type_binding
(
struct
labcomm_type_binding
*
v
,
void
*
context
)
{
printf
(
"Got type binding. 0x%x --> 0x%x
\n
"
,
v
->
sample_index
,
v
->
type_index
);
}
}
static
void
handle_test_twoLines
(
test_twoLines
*
v
,
void
*
context
)
{
static
void
handle_test_twoLines
(
test_twoLines
*
v
,
void
*
context
)
{
...
@@ -54,6 +58,7 @@ int main(int argc, char *argv[]) {
...
@@ -54,6 +58,7 @@ int main(int argc, char *argv[]) {
labcomm_decoder_register_test_theSecondInt
(
decoder
,
handle_test_theSecondInt
,
context
);
labcomm_decoder_register_test_theSecondInt
(
decoder
,
handle_test_theSecondInt
,
context
);
labcomm_decoder_register_test_twoLines
(
decoder
,
handle_test_twoLines
,
context
);
labcomm_decoder_register_test_twoLines
(
decoder
,
handle_test_twoLines
,
context
);
labcomm_decoder_register_labcomm_typedef
(
decoder
,
handle_typedef
,
context
);
labcomm_decoder_register_labcomm_typedef
(
decoder
,
handle_typedef
,
context
);
labcomm_decoder_register_labcomm_type_binding
(
decoder
,
handle_type_binding
,
context
);
printf
(
"Decoding:
\n
"
);
printf
(
"Decoding:
\n
"
);
labcomm_decoder_run
(
decoder
);
labcomm_decoder_run
(
decoder
);
...
...
This diff is collapsed.
Click to expand it.
lib/c/2014/labcomm_decoder.c
+
70
−
16
View file @
9b875283
...
@@ -182,6 +182,7 @@ static int decoder_skip(struct labcomm_decoder *d, int len, int tag)
...
@@ -182,6 +182,7 @@ static int decoder_skip(struct labcomm_decoder *d, int len, int tag)
return
tag
;
return
tag
;
}
}
#ifdef OLD_TYPEDEF_DECODING_TEST_CODE
static
int
decode_type_binding
(
struct
labcomm_decoder
*
d
,
int
kind
)
static
int
decode_type_binding
(
struct
labcomm_decoder
*
d
,
int
kind
)
{
{
int
result
;
int
result
;
...
@@ -199,7 +200,7 @@ static int decode_type_binding(struct labcomm_decoder *d, int kind)
...
@@ -199,7 +200,7 @@ static int decode_type_binding(struct labcomm_decoder *d, int kind)
out:
out:
return
result
;
return
result
;
}
}
#ifdef OLD_TYPEDEF_DECODING_TEST_CODE
static
int
decode_type_def
(
struct
labcomm_decoder
*
d
,
int
kind
){
static
int
decode_type_def
(
struct
labcomm_decoder
*
d
,
int
kind
){
int
i
,
remote_index
,
result
;
int
i
,
remote_index
,
result
;
char
*
name
;
char
*
name
;
...
@@ -455,7 +456,15 @@ int labcomm_decoder_decode_one(struct labcomm_decoder *d)
...
@@ -455,7 +456,15 @@ int labcomm_decoder_decode_one(struct labcomm_decoder *d)
#endif
#endif
}
}
}
else
if
(
remote_index
==
LABCOMM_TYPE_BINDING
)
{
}
else
if
(
remote_index
==
LABCOMM_TYPE_BINDING
)
{
result
=
decode_and_handle
(
d
,
d
,
remote_index
);
if
(
result
==
-
ENOENT
)
{
//No handler for type_bindings, skip
#ifdef OLD_TYPEDEF_DECODING_TEST_CODE
result
=
decode_type_binding
(
d
,
LABCOMM_TYPE_BINDING
);
result
=
decode_type_binding
(
d
,
LABCOMM_TYPE_BINDING
);
#else
result
=
decoder_skip
(
d
,
length
,
remote_index
);
#endif
}
}
else
if
(
remote_index
==
LABCOMM_PRAGMA
)
{
}
else
if
(
remote_index
==
LABCOMM_PRAGMA
)
{
result
=
decode_pragma
(
d
,
d
,
length
);
result
=
decode_pragma
(
d
,
d
,
length
);
}
else
if
(
remote_index
<
LABCOMM_USER
)
{
}
else
if
(
remote_index
<
LABCOMM_USER
)
{
...
@@ -550,25 +559,17 @@ static void decode_raw_typedef(
...
@@ -550,25 +559,17 @@ static void decode_raw_typedef(
{
{
struct
labcomm_raw_typedef
v
;
struct
labcomm_raw_typedef
v
;
v
.
index
=
labcomm_read_packed32
(
r
);
v
.
index
=
labcomm_read_packed32
(
r
);
if
(
r
->
error
<
0
)
{
if
(
r
->
error
<
0
)
{
goto
out
;
}
goto
out
;
}
v
.
name
=
labcomm_read_string
(
r
);
v
.
name
=
labcomm_read_string
(
r
);
if
(
r
->
error
<
0
)
{
if
(
r
->
error
<
0
)
{
goto
free_name
;
}
goto
free_name
;
}
v
.
length
=
labcomm_read_packed32
(
r
);
v
.
length
=
labcomm_read_packed32
(
r
);
if
(
r
->
error
<
0
)
{
if
(
r
->
error
<
0
)
{
goto
free_name
;
}
goto
free_name
;
}
int
i
;
int
i
;
v
.
signature_data
=
labcomm_memory_alloc
(
r
->
memory
,
1
,
v
.
length
);
v
.
signature_data
=
labcomm_memory_alloc
(
r
->
memory
,
1
,
v
.
length
);
if
(
v
.
signature_data
)
{
if
(
v
.
signature_data
)
{
for
(
i
=
0
;
i
<
v
.
length
;
i
++
)
{
for
(
i
=
0
;
i
<
v
.
length
;
i
++
)
{
v
.
signature_data
[
i
]
=
labcomm_read_byte
(
r
);
v
.
signature_data
[
i
]
=
labcomm_read_byte
(
r
);
if
(
r
->
error
<
0
)
{
if
(
r
->
error
<
0
)
{
goto
free_sig
;
}
goto
free_sig
;
}
}
}
handle
(
&
v
,
context
);
handle
(
&
v
,
context
);
}
}
...
@@ -579,7 +580,6 @@ free_name:
...
@@ -579,7 +580,6 @@ free_name:
out:
out:
return
;
return
;
}
}
int
labcomm_decoder_register_labcomm_typedef
(
int
labcomm_decoder_register_labcomm_typedef
(
struct
labcomm_decoder
*
d
,
struct
labcomm_decoder
*
d
,
void
(
*
handler
)(
void
(
*
handler
)(
...
@@ -598,7 +598,7 @@ int labcomm_decoder_register_labcomm_typedef(
...
@@ -598,7 +598,7 @@ int labcomm_decoder_register_labcomm_typedef(
d
->
local
,
struct
sample_entry
,
d
->
local
,
struct
sample_entry
,
tag
);
tag
);
if
(
entry
==
NULL
)
{
tag
=
-
ENOMEM
;
goto
unlock
;
}
if
(
entry
==
NULL
)
{
tag
=
-
ENOMEM
;
goto
unlock
;
}
entry
->
remote_index
=
LABCOMM_TYPE_DEF
;
entry
->
remote_index
=
tag
;
entry
->
signature
=
NULL
;
entry
->
signature
=
NULL
;
entry
->
decode
=
(
labcomm_decoder_function
)
decode_raw_typedef
;
entry
->
decode
=
(
labcomm_decoder_function
)
decode_raw_typedef
;
entry
->
handler
=
(
labcomm_handler_function
)
handler
;
entry
->
handler
=
(
labcomm_handler_function
)
handler
;
...
@@ -614,6 +614,60 @@ unlock:
...
@@ -614,6 +614,60 @@ unlock:
return
tag
;
return
tag
;
}
}
static
void
decode_type_binding
(
struct
labcomm_reader
*
r
,
void
(
*
handle
)(
struct
labcomm_type_binding
*
v
,
void
*
context
),
void
*
context
)
{
struct
labcomm_type_binding
v
;
v
.
sample_index
=
labcomm_read_packed32
(
r
);
if
(
r
->
error
<
0
)
{
goto
out
;
}
v
.
type_index
=
labcomm_read_packed32
(
r
);
if
(
r
->
error
<
0
)
{
goto
out
;
}
handle
(
&
v
,
context
);
out:
return
;
}
int
labcomm_decoder_register_labcomm_type_binding
(
struct
labcomm_decoder
*
d
,
void
(
*
handler
)(
struct
labcomm_type_binding
*
v
,
void
*
context
),
void
*
context
)
{
int
tag
=
LABCOMM_TYPE_BINDING
;
struct
sample_entry
*
entry
;
int
*
remote_to_local
;
labcomm_scheduler_data_lock
(
d
->
scheduler
);
entry
=
LABCOMM_SIGNATURE_ARRAY_REF
(
d
->
memory
,
d
->
local
,
struct
sample_entry
,
tag
);
if
(
entry
==
NULL
)
{
tag
=
-
ENOMEM
;
goto
unlock
;
}
entry
->
remote_index
=
tag
;
entry
->
signature
=
NULL
;
entry
->
decode
=
(
labcomm_decoder_function
)
decode_type_binding
;
entry
->
handler
=
(
labcomm_handler_function
)
handler
;
entry
->
context
=
context
;
remote_to_local
=
LABCOMM_SIGNATURE_ARRAY_REF
(
d
->
memory
,
d
->
remote_to_local
,
int
,
tag
);
*
remote_to_local
=
tag
;
unlock:
labcomm_scheduler_data_unlock
(
d
->
scheduler
);
return
tag
;
}
//// End typedef handling
//// End typedef handling
#endif
#endif
...
...
This diff is collapsed.
Click to expand it.
lib/c/2014/labcomm_type_signature.h
+
19
−
1
View file @
9b875283
...
@@ -72,12 +72,20 @@ struct labcomm_raw_typedef {
...
@@ -72,12 +72,20 @@ struct labcomm_raw_typedef {
char
*
signature_data
;
char
*
signature_data
;
};
};
/* a struct for type bindings
*/
struct
labcomm_type_binding
{
int
sample_index
;
int
type_index
;
};
/*
/*
* functions
* functions
*/
*/
/* register a handler for typedefs
/* register a handler for typedefs
and type bindings
*/
*/
int
labcomm_decoder_register_labcomm_typedef
(
int
labcomm_decoder_register_labcomm_typedef
(
...
@@ -88,6 +96,16 @@ int labcomm_decoder_register_labcomm_typedef(
...
@@ -88,6 +96,16 @@ int labcomm_decoder_register_labcomm_typedef(
),
),
void
*
context
void
*
context
);
);
int
labcomm_decoder_register_labcomm_type_binding
(
struct
labcomm_decoder
*
d
,
void
(
*
handler
)(
struct
labcomm_type_binding
*
v
,
void
*
context
),
void
*
context
);
/* Dump signature bytes on stdout
/* Dump signature bytes on stdout
*/
*/
...
...
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