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
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
Sven Gestegård Robertz
LabComm
Commits
74c192aa
Commit
74c192aa
authored
Oct 26, 2014
by
Sven Gestegård Robertz
Browse files
Options
Downloads
Patches
Plain Diff
refactored c decoder towards shared registries
parent
f1cf1aa5
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/c/labcomm_decoder.c
+49
-36
49 additions, 36 deletions
lib/c/labcomm_decoder.c
with
49 additions
and
36 deletions
lib/c/labcomm_decoder.c
+
49
−
36
View file @
74c192aa
...
...
@@ -299,6 +299,54 @@ out:
return
result
;
}
static
labcomm_decoder_function
lookup_h
(
struct
labcomm_decoder
*
d
,
struct
call_handler_context
*
wrap
,
int
remote_index
,
int
**
local_index
)
{
labcomm_decoder_function
do_decode
=
NULL
;
labcomm_scheduler_data_lock
(
d
->
scheduler
);
*
local_index
=
LABCOMM_SIGNATURE_ARRAY_REF
(
d
->
memory
,
d
->
remote_to_local
,
int
,
remote_index
);
if
(
**
local_index
!=
0
)
{
struct
sample_entry
*
entry
;
entry
=
LABCOMM_SIGNATURE_ARRAY_REF
(
d
->
memory
,
d
->
local
,
struct
sample_entry
,
**
local_index
);
wrap
->
local_index
=
**
local_index
;
wrap
->
signature
=
entry
->
signature
;
wrap
->
handler
=
entry
->
handler
;
wrap
->
context
=
entry
->
context
;
do_decode
=
entry
->
decode
;
}
labcomm_scheduler_data_unlock
(
d
->
scheduler
);
return
do_decode
;
}
static
int
decode_and_handle
(
struct
labcomm_decoder
*
d
,
int
remote_index
)
{
int
result
;
int
*
local_index
;
struct
call_handler_context
wrap
=
{
.
reader
=
d
->
reader
,
.
remote_index
=
remote_index
,
.
signature
=
NULL
,
.
handler
=
NULL
,
.
context
=
NULL
,
};
labcomm_decoder_function
do_decode
=
lookup_h
(
d
,
&
wrap
,
remote_index
,
&
local_index
);
result
=
*
local_index
;
if
(
do_decode
)
{
do_decode
(
d
->
reader
,
call_handler
,
&
wrap
);
if
(
d
->
reader
->
error
<
0
)
{
result
=
d
->
reader
->
error
;
}
}
else
{
result
=
-
ENOENT
;
}
return
result
;
}
int
labcomm_decoder_decode_one
(
struct
labcomm_decoder
*
d
)
{
int
result
,
remote_index
,
length
;
...
...
@@ -328,42 +376,7 @@ int labcomm_decoder_decode_one(struct labcomm_decoder *d)
//result = remote_index;
result
=
decoder_skip
(
d
,
length
,
remote_index
);
}
else
{
int
*
local_index
;
struct
call_handler_context
wrap
=
{
.
reader
=
d
->
reader
,
.
remote_index
=
remote_index
,
.
signature
=
NULL
,
.
handler
=
NULL
,
.
context
=
NULL
,
};
labcomm_decoder_function
do_decode
=
NULL
;
labcomm_scheduler_data_lock
(
d
->
scheduler
);
local_index
=
LABCOMM_SIGNATURE_ARRAY_REF
(
d
->
memory
,
d
->
remote_to_local
,
int
,
remote_index
);
if
(
*
local_index
!=
0
)
{
struct
sample_entry
*
entry
;
entry
=
LABCOMM_SIGNATURE_ARRAY_REF
(
d
->
memory
,
d
->
local
,
struct
sample_entry
,
*
local_index
);
wrap
.
local_index
=
*
local_index
;
wrap
.
signature
=
entry
->
signature
;
wrap
.
handler
=
entry
->
handler
;
wrap
.
context
=
entry
->
context
;
do_decode
=
entry
->
decode
;
result
=
*
local_index
;
}
labcomm_scheduler_data_unlock
(
d
->
scheduler
);
if
(
do_decode
)
{
do_decode
(
d
->
reader
,
call_handler
,
&
wrap
);
if
(
d
->
reader
->
error
<
0
)
{
result
=
d
->
reader
->
error
;
}
}
else
{
result
=
-
ENOENT
;
}
result
=
decode_and_handle
(
d
,
remote_index
);
}
out:
return
result
;
...
...
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