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
eff98a50
Commit
eff98a50
authored
Sep 13, 2017
by
Lev Walkin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed under freebsd and clang
parent
dfbff614
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
70 additions
and
25 deletions
+70
-25
skeletons/NativeReal.c
skeletons/NativeReal.c
+21
-3
skeletons/REAL.c
skeletons/REAL.c
+36
-11
skeletons/constr_CHOICE_oer.c
skeletons/constr_CHOICE_oer.c
+2
-3
skeletons/constr_SEQUENCE.c
skeletons/constr_SEQUENCE.c
+3
-1
skeletons/constr_SET_OF_oer.c
skeletons/constr_SET_OF_oer.c
+7
-6
skeletons/converter-sample.c
skeletons/converter-sample.c
+1
-1
No files found.
skeletons/NativeReal.c
View file @
eff98a50
...
...
@@ -15,6 +15,24 @@
#include <OCTET_STRING.h>
#include <math.h>
#if defined(__clang__)
/*
* isnan() is defined using generic selections and won't compile in
* strict C89 mode because of too fancy system's standard library.
* However, prior to C11 the math had a perfectly working isnan()
* in the math library.
* Disable generic selection warning so we can test C89 mode with newer libc.
*/
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wc11-extensions"
static
int
asn_isnan
(
double
d
)
{
return
isnan
(
d
);
}
#pragma clang diagnostic pop
#else
#define asn_isnan(v) isnan(v)
#endif
/* generic selections */
/*
* NativeReal basic type description.
*/
...
...
@@ -359,13 +377,13 @@ NativeReal_compare(const asn_TYPE_descriptor_t *td, const void *aptr,
if
(
a
&&
b
)
{
/* NaN sorted above everything else */
if
(
isnan
(
*
a
))
{
if
(
isnan
(
*
b
))
{
if
(
asn_
isnan
(
*
a
))
{
if
(
asn_
isnan
(
*
b
))
{
return
0
;
}
else
{
return
-
1
;
}
}
else
if
(
isnan
(
*
b
))
{
}
else
if
(
asn_
isnan
(
*
b
))
{
return
1
;
}
/* Value comparison. */
...
...
skeletons/REAL.c
View file @
eff98a50
...
...
@@ -29,11 +29,36 @@ static volatile double real_zero GCC_NOTUSED = 0.0;
#define INFINITY (1.0/real_zero)
#endif
#if defined(__clang__)
/*
* isnan() is defined using generic selections and won't compile in
* strict C89 mode because of too fancy system's standard library.
* However, prior to C11 the math had a perfectly working isnan()
* in the math library.
* Disable generic selection warning so we can test C89 mode with newer libc.
*/
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wc11-extensions"
static
int
asn_isnan
(
double
d
)
{
return
isnan
(
d
);
}
static
int
asn_isfinite
(
double
d
)
{
#ifdef isfinite
return
isfinite
(
d
);
/* ISO C99 */
#else
return
finite
(
d
);
/* Deprecated on Mac OS X 10.9 */
#endif
}
#pragma clang diagnostic pop
#else
/* !clang */
#define asn_isnan(v) isnan(v)
#ifdef isfinite
#define
_
asn_isfinite(d) isfinite(d)
/* ISO C99 */
#define asn_isfinite(d) isfinite(d)
/* ISO C99 */
#else
#define
_
asn_isfinite(d) finite(d)
/* Deprecated on Mac OS X 10.9 */
#define asn_isfinite(d) finite(d)
/* Deprecated on Mac OS X 10.9 */
#endif
#endif
/* clang */
/*
* REAL basic type description.
...
...
@@ -110,11 +135,11 @@ REAL__dump(double d, int canonical, asn_app_consume_bytes_f *cb, void *app_key)
* Check whether it is a special value.
*/
/* fpclassify(3) is not portable yet */
if
(
isnan
(
d
))
{
if
(
asn_
isnan
(
d
))
{
buf
=
specialRealValue
[
SRV__NOT_A_NUMBER
].
string
;
buflen
=
specialRealValue
[
SRV__NOT_A_NUMBER
].
length
;
return
(
cb
(
buf
,
buflen
,
app_key
)
<
0
)
?
-
1
:
buflen
;
}
else
if
(
!
_
asn_isfinite
(
d
))
{
}
else
if
(
!
asn_isfinite
(
d
))
{
if
(
copysign
(
1
.
0
,
d
)
<
0
.
0
)
{
buf
=
specialRealValue
[
SRV__MINUS_INFINITY
].
string
;
buflen
=
specialRealValue
[
SRV__MINUS_INFINITY
].
length
;
...
...
@@ -311,13 +336,13 @@ REAL_compare(const asn_TYPE_descriptor_t *td, const void *aptr,
ra
=
asn_REAL2double
(
a
,
&
adbl
);
rb
=
asn_REAL2double
(
b
,
&
bdbl
);
if
(
ra
==
0
&&
rb
==
0
)
{
if
(
isnan
(
adbl
))
{
if
(
isnan
(
bdbl
))
{
if
(
asn_
isnan
(
adbl
))
{
if
(
asn_
isnan
(
bdbl
))
{
return
0
;
}
else
{
return
-
1
;
}
}
else
if
(
isnan
(
bdbl
))
{
}
else
if
(
asn_
isnan
(
bdbl
))
{
return
1
;
}
/* Value comparison. */
...
...
@@ -535,7 +560,7 @@ asn_REAL2double(const REAL_t *st, double *dbl_value) {
return
-
1
;
}
if
(
used_malloc
)
FREEMEM
(
buf
);
if
(
_
asn_isfinite
(
d
))
{
if
(
asn_isfinite
(
d
))
{
*
dbl_value
=
d
;
return
0
;
}
else
{
...
...
@@ -615,7 +640,7 @@ asn_REAL2double(const REAL_t *st, double *dbl_value) {
m = ldexp(m, scaleF) * pow(pow(2, base), expval);
*/
m
=
ldexp
(
m
,
expval
*
baseF
+
scaleF
);
if
(
_
asn_isfinite
(
m
))
{
if
(
asn_isfinite
(
m
))
{
*
dbl_value
=
sign
?
-
m
:
m
;
}
else
{
errno
=
ERANGE
;
...
...
@@ -672,11 +697,11 @@ asn_double2REAL(REAL_t *st, double dbl_value) {
st
->
buf
=
ptr
;
}
/* fpclassify(3) is not portable yet */
if
(
isnan
(
dbl_value
))
{
if
(
asn_
isnan
(
dbl_value
))
{
st
->
buf
[
0
]
=
0x42
;
/* NaN */
st
->
buf
[
1
]
=
0
;
st
->
size
=
1
;
}
else
if
(
!
_
asn_isfinite
(
dbl_value
))
{
}
else
if
(
!
asn_isfinite
(
dbl_value
))
{
if
(
copysign
(
1
.
0
,
dbl_value
)
<
0
.
0
)
{
st
->
buf
[
0
]
=
0x41
;
/* MINUS-INFINITY */
}
else
{
...
...
skeletons/constr_CHOICE_oer.c
View file @
eff98a50
...
...
@@ -134,8 +134,6 @@ CHOICE_decode_oer(const asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *t
asn_CHOICE_specifics_t
*
specs
=
(
asn_CHOICE_specifics_t
*
)
td
->
specifics
;
asn_TYPE_member_t
*
elements
=
td
->
elements
;
(
void
)
specs
;
/*
* Parts of the structure being constructed.
*/
...
...
@@ -180,7 +178,8 @@ CHOICE_decode_oer(const asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *t
do
{
const
asn_TYPE_tag2member_t
*
t2m
;
asn_TYPE_tag2member_t
key
=
{
tlv_tag
,
0
,
0
,
0
};
asn_TYPE_tag2member_t
key
=
{
0
,
0
,
0
,
0
};
key
.
el_tag
=
tlv_tag
;
t2m
=
(
const
asn_TYPE_tag2member_t
*
)
bsearch
(
&
key
,
specs
->
tag2el
,
specs
->
tag2el_count
,
...
...
skeletons/constr_SEQUENCE.c
View file @
eff98a50
...
...
@@ -312,7 +312,9 @@ SEQUENCE_decode_ber(const asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t
* sorted array of tags.
*/
const
asn_TYPE_tag2member_t
*
t2m
;
asn_TYPE_tag2member_t
key
=
{
tlv_tag
,
edx
,
0
,
0
};
asn_TYPE_tag2member_t
key
=
{
0
,
0
,
0
,
0
};
key
.
el_tag
=
tlv_tag
;
key
.
el_no
=
edx
;
t2m
=
(
const
asn_TYPE_tag2member_t
*
)
bsearch
(
&
key
,
specs
->
tag2el
,
specs
->
tag2el_count
,
sizeof
(
specs
->
tag2el
[
0
]),
_t2e_cmp
);
...
...
skeletons/constr_SET_OF_oer.c
View file @
eff98a50
...
...
@@ -63,6 +63,8 @@
*/
static
ssize_t
oer_fetch_quantity
(
const
void
*
ptr
,
size_t
size
,
size_t
*
qty_r
)
{
const
uint8_t
*
b
;
const
uint8_t
*
bend
;
size_t
len
=
0
;
size_t
qty
;
...
...
@@ -77,15 +79,13 @@ oer_fetch_quantity(const void *ptr, size_t size, size_t *qty_r) {
return
0
;
}
const
uint8_t
*
b
=
(
const
uint8_t
*
)
ptr
+
len_len
;
const
uint8_t
*
bend
=
b
+
len
;
b
=
(
const
uint8_t
*
)
ptr
+
len_len
;
bend
=
b
+
len
;
/* Skip the leading 0-bytes */
for
(;
b
<
bend
&&
*
b
==
0
;
b
++
)
{
}
if
((
bend
-
b
)
>
(
ssize_t
)
sizeof
(
size_t
))
{
/* Length is not representable by the native size_t type */
*
qty_r
=
0
;
...
...
@@ -261,8 +261,9 @@ SET_OF_encode_oer(asn_TYPE_descriptor_t *td,
}
{
asn_enc_rval_t
erval
=
{
computed_size
,
0
,
0
};
return
erval
;
asn_enc_rval_t
erval
;
erval
.
encoded
=
computed_size
;
ASN__ENCODED_OK
(
erval
);
}
}
...
...
skeletons/converter-sample.c
View file @
eff98a50
...
...
@@ -67,7 +67,7 @@ static void junk_bytes_with_probability(uint8_t *, size_t, double prob);
#endif
/* Debug output function */
static
inline
void
static
void
DEBUG
(
const
char
*
fmt
,
...)
{
va_list
ap
;
if
(
!
opt_debug
)
return
;
...
...
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