Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
asn1c
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
Libraries
asn1c
Commits
c4c6196c
Commit
c4c6196c
authored
Jun 14, 2004
by
Lev Walkin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
faster path for common size
parent
46bf935e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
7 deletions
+28
-7
skeletons/OBJECT_IDENTIFIER.c
skeletons/OBJECT_IDENTIFIER.c
+24
-6
skeletons/tests/check-OIDs.c
skeletons/tests/check-OIDs.c
+4
-1
No files found.
skeletons/OBJECT_IDENTIFIER.c
View file @
c4c6196c
...
...
@@ -91,6 +91,7 @@ OBJECT_IDENTIFIER_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
return
0
;
}
int
OBJECT_IDENTIFIER_get_single_arc
(
uint8_t
*
arcbuf
,
unsigned
int
arclen
,
signed
int
add
,
void
*
rvbuf
,
unsigned
int
rvsize
)
{
unsigned
LE
=
1
;
/* Little endian (x86) */
...
...
@@ -130,23 +131,39 @@ OBJECT_IDENTIFIER_get_single_arc(uint8_t *arcbuf, unsigned int arclen, signed in
}
}
/* Faster path for common size */
if
(
rvsize
==
(
CHAR_BIT
*
sizeof
(
unsigned
long
)))
{
unsigned
long
accum
;
/* Gather all bits into the accumulator */
for
(
accum
=
cache
;
arcbuf
<
arcend
;
arcbuf
++
)
accum
=
(
accum
<<
7
)
|
(
*
arcbuf
&
~
0x80
);
if
(
accum
<
(
unsigned
)
-
add
)
{
errno
=
ERANGE
;
/* Overflow */
return
-
1
;
}
*
(
unsigned
long
*
)
rvbuf
=
accum
+
add
;
return
0
;
}
#ifndef WORDS_BIGENDIAN
if
(
*
(
unsigned
char
*
)
&
LE
)
{
/* Little endian (x86) */
/* "Convert" to big endian */
rvbuf
+=
rvsize
/
CHAR_BIT
;
rvbuf
+=
rvsize
/
CHAR_BIT
-
1
;
((
unsigned
char
*
)
rvstart
)
--
;
inc
=
-
1
;
/* Descending */
}
else
{
inc
=
+
1
;
/* Ascending */
}
}
else
#endif
/* !WORDS_BIGENDIAN */
inc
=
+
1
;
/* Big endian is known [at compile time] */
{
/* Native big endian (Sparc, PPC) */
{
unsigned
int
bits
;
/* typically no more than 3-4 bits */
/* Clear the high unused bits */
for
(
bits
=
rvsize
-
arclen
;
bits
>
CHAR_BIT
;
rvbuf
+=
inc
,
bits
-=
CHAR_BIT
)
*
(
unsigned
char
*
)
rvbuf
=
0
;
/* Fill the body of a value */
for
(;
arcbuf
<
arcend
;
arcbuf
++
)
{
cache
=
(
cache
<<
7
)
|
(
*
arcbuf
&
0x7f
);
...
...
@@ -323,8 +340,8 @@ OBJECT_IDENTIFIER_set_arcs_l(OBJECT_IDENTIFIER_t *oid, unsigned long *arcs, unsi
uint8_t
*
buf
;
uint8_t
*
bp
;
unsigned
long
long
first_value
;
unsigned
i
;
int
size
;
int
i
;
if
(
oid
==
NULL
||
arcs
==
NULL
||
arc_slots
<
2
)
{
errno
=
EINVAL
;
...
...
@@ -423,3 +440,4 @@ OBJECT_IDENTIFIER_set_arcs_l(OBJECT_IDENTIFIER_t *oid, unsigned long *arcs, unsi
return
0
;
}
skeletons/tests/check-OIDs.c
View file @
c4c6196c
...
...
@@ -269,7 +269,10 @@ main() {
CHECK_REGEN_OID
(
12
);
CHECK_REGEN_OID
(
13
);
if
(
getenv
(
"CHECK_SPEED"
))
{
/* Useful for developers only */
check_speed
();
}
return
0
;
}
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