Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
codes
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
38
Issues
38
List
Boards
Labels
Milestones
Merge Requests
8
Merge Requests
8
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
codes
codes
Commits
1de8c287
Commit
1de8c287
authored
Aug 26, 2015
by
Jonathan Jenkins
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add a simpler version of codes_mapping_get_lp_info
parent
48d60634
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
70 additions
and
0 deletions
+70
-0
codes/codes_mapping.h
codes/codes_mapping.h
+18
-0
src/util/codes_mapping.c
src/util/codes_mapping.c
+52
-0
No files found.
codes/codes_mapping.h
View file @
1de8c287
...
...
@@ -142,6 +142,24 @@ void codes_mapping_get_lp_info(
int
*
rep_id
,
int
*
offset
);
/* same end result as codes_mapping_get_lp_info, except:
* - uses pointer-to-const instead of copying to output parameters.
* much less copying
* - gets rid of arguments that are largely intended for internal usage
* - disambiguates annotation representation - empty string no longer copied
* into annotation argument to indicate no annotation - instead, annotation
* is set to NULL
*
* This function is preferred for performance and simplicity reasons
*/
void
codes_mapping_get_lp_info2
(
tw_lpid
gid
,
char
const
*
*
group_name
,
char
const
*
*
lp_type_name
,
char
const
*
*
annotation
,
int
*
rep_id
,
int
*
offset
);
//void codes_mapping_get_lp_info(tw_lpid gid, char* group_name, int* grp_id, int* lp_type_id, char* lp_type_name, int* grp_rep_id, int* offset);
/* Returns the annotation for the given LP.
...
...
src/util/codes_mapping.c
View file @
1de8c287
...
...
@@ -394,6 +394,58 @@ void codes_mapping_get_lp_info(
tw_error
(
TW_LOC
,
"Unable to find LP info given gid %lu"
,
gid
);
}
void
codes_mapping_get_lp_info2
(
tw_lpid
gid
,
char
const
*
*
group_name
,
char
const
*
*
lp_type_name
,
char
const
*
*
annotation
,
int
*
rep_id
,
int
*
offset
)
{
// running total of lp's we've seen so far
tw_lpid
id_total
=
0
;
// for each group
for
(
int
g
=
0
;
g
<
lpconf
.
lpgroups_count
;
g
++
){
const
config_lpgroup_t
*
lpg
=
&
lpconf
.
lpgroups
[
g
];
tw_lpid
num_id_group
,
num_id_per_rep
=
0
;
// count up the number of ids in this group
for
(
int
l
=
0
;
l
<
lpg
->
lptypes_count
;
l
++
){
num_id_per_rep
+=
lpg
->
lptypes
[
l
].
count
;
}
num_id_group
=
num_id_per_rep
*
lpg
->
repetitions
;
if
(
num_id_group
+
id_total
>
gid
){
// we've found the group
tw_lpid
rem
=
gid
-
id_total
;
if
(
group_name
!=
NULL
)
*
group_name
=
lpg
->
name
.
ptr
;
// find repetition within group
*
rep_id
=
(
int
)
(
rem
/
num_id_per_rep
);
rem
-=
num_id_per_rep
*
(
tw_lpid
)
*
rep_id
;
num_id_per_rep
=
0
;
for
(
int
l
=
0
;
l
<
lpg
->
lptypes_count
;
l
++
){
const
config_lptype_t
*
lpt
=
&
lpg
->
lptypes
[
l
];
if
(
rem
<
num_id_per_rep
+
lpt
->
count
){
// found the specific LP
if
(
lp_type_name
!=
NULL
)
*
lp_type_name
=
lpt
->
name
.
ptr
;
if
(
annotation
!=
NULL
)
*
annotation
=
lpt
->
anno
.
ptr
;
*
offset
=
(
int
)
(
rem
-
num_id_per_rep
);
return
;
// done
}
else
{
num_id_per_rep
+=
lpg
->
lptypes
[
l
].
count
;
}
}
}
else
{
id_total
+=
num_id_group
;
}
}
// LP not found
tw_error
(
TW_LOC
,
"Unable to find LP info given gid %lu"
,
gid
);
}
/* This function assigns local and global LP Ids to LPs */
static
void
codes_mapping_init
(
void
)
{
...
...
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