fixed under freebsd and clang
diff --git a/skeletons/NativeReal.c b/skeletons/NativeReal.c
index 89cd005..1983a3b 100644
--- a/skeletons/NativeReal.c
+++ b/skeletons/NativeReal.c
@@ -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 @@
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. */
diff --git a/skeletons/REAL.c b/skeletons/REAL.c
index 0bdeb82..5910ee5 100644
--- a/skeletons/REAL.c
+++ b/skeletons/REAL.c
@@ -29,11 +29,36 @@
#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
-#define _asn_isfinite(d) isfinite(d) /* ISO C99 */
+ return isfinite(d); /* ISO C99 */
#else
-#define _asn_isfinite(d) finite(d) /* Deprecated on Mac OS X 10.9 */
+ 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 */
+#else
+#define asn_isfinite(d) finite(d) /* Deprecated on Mac OS X 10.9 */
+#endif
+#endif /* clang */
+
/*
* REAL basic type description.
@@ -110,11 +135,11 @@
* 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 @@
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 @@
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 @@
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 @@
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 {
diff --git a/skeletons/constr_CHOICE_oer.c b/skeletons/constr_CHOICE_oer.c
index 4319fde..b975fd1 100644
--- a/skeletons/constr_CHOICE_oer.c
+++ b/skeletons/constr_CHOICE_oer.c
@@ -134,8 +134,6 @@
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 @@
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,
diff --git a/skeletons/constr_SEQUENCE.c b/skeletons/constr_SEQUENCE.c
index 9fe88f7..3caf5d2 100644
--- a/skeletons/constr_SEQUENCE.c
+++ b/skeletons/constr_SEQUENCE.c
@@ -312,7 +312,9 @@
* 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);
diff --git a/skeletons/constr_SET_OF_oer.c b/skeletons/constr_SET_OF_oer.c
index 8cbf81f..49f56c5 100644
--- a/skeletons/constr_SET_OF_oer.c
+++ b/skeletons/constr_SET_OF_oer.c
@@ -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 @@
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 @@
}
{
- asn_enc_rval_t erval = {computed_size, 0, 0};
- return erval;
+ asn_enc_rval_t erval;
+ erval.encoded = computed_size;
+ ASN__ENCODED_OK(erval);
}
}
diff --git a/skeletons/converter-sample.c b/skeletons/converter-sample.c
index 178264e..a8fe1b4 100644
--- a/skeletons/converter-sample.c
+++ b/skeletons/converter-sample.c
@@ -67,7 +67,7 @@
#endif
/* Debug output function */
-static inline void
+static void
DEBUG(const char *fmt, ...) {
va_list ap;
if(!opt_debug) return;