for OER use IEEE754 binary32 and binary64 format over the wire
diff --git a/libasn1compiler/asn1c_C.c b/libasn1compiler/asn1c_C.c
index d26b77d..009f91c 100644
--- a/libasn1compiler/asn1c_C.c
+++ b/libasn1compiler/asn1c_C.c
@@ -122,21 +122,6 @@
return 1;
}
-static int
-REAL_fits_float32(arg_t *arg, asn1p_expr_t *expr) {
- asn1p_expr_type_e etype = expr_get_type(arg, arg->expr);
- if(etype == ASN_BASIC_REAL) {
- asn1cnst_range_t *range = asn1constraint_compute_OER_range(
- expr->Identifier, etype, expr->combined_constraints, ACT_EL_RANGE,
- 0, 0, 0);
- int fits = range->narrowing == NARROW_FLOAT32;
- asn1constraint_range_free(range);
- return fits;
- } else {
- return 0;
- }
-}
-
int
asn1c_lang_C_type_common_INTEGER(arg_t *arg) {
asn1p_expr_t *expr = arg->expr;
@@ -1313,7 +1298,7 @@
&& expr_elements_count(arg, expr))
|| (expr->expr_type == ASN_BASIC_INTEGER
&& asn1c_type_fits_long(arg, expr) == FL_FITS_UNSIGN)
- || REAL_fits_float32(arg, expr)
+ || asn1c_REAL_fits(arg, expr) == RL_FITS_FLOAT32
)
etd_spec = ETD_HAS_SPECIFICS;
else
@@ -1355,7 +1340,11 @@
REDIR(OT_STAT_DEFS);
- if(REAL_fits_float32(arg, expr)) {
+ /*
+ * By default, NativeReal is double. We only override this if
+ * (OER) constraints suggested that we may use float.
+ */
+ if(asn1c_REAL_fits(arg, expr) == RL_FITS_FLOAT32) {
if(!(expr->_type_referenced)) OUT("static ");
OUT("const asn_NativeReal_specifics_t asn_SPC_%s_specs_%d = {\n",
MKID(expr), expr->_type_unique_index);
@@ -1875,7 +1864,7 @@
} else if(expr_get_type(arg, arg->expr) == ASN_BASIC_REAL) {
if(range->narrowing == NARROW_FLOAT32) {
OUT("{ sizeof(float), 0 }");
- } else if(range->narrowing == NARROW_FLOAT64) {
+ } else if(range->narrowing == NARROW_DOUBLE64) {
OUT("{ sizeof(double), 0 }");
} else {
OUT("{ 0, 0 }");
diff --git a/libasn1compiler/asn1c_constraint.c b/libasn1compiler/asn1c_constraint.c
index bd025d5..6b23d5c 100644
--- a/libasn1compiler/asn1c_constraint.c
+++ b/libasn1compiler/asn1c_constraint.c
@@ -80,8 +80,9 @@
produce_st = 1;
break;
case ASN_BASIC_REAL:
- if((arg->flags & A1C_USE_WIDE_TYPES))
- produce_st = 1;
+ if((arg->flags & A1C_USE_WIDE_TYPES)
+ && asn1c_REAL_fits(arg, arg->expr) == RL_NOTFIT)
+ produce_st = 1;
break;
case ASN_BASIC_BIT_STRING:
case ASN_BASIC_OCTET_STRING:
diff --git a/libasn1compiler/asn1c_misc.c b/libasn1compiler/asn1c_misc.c
index 086a8fa..f026eea 100644
--- a/libasn1compiler/asn1c_misc.c
+++ b/libasn1compiler/asn1c_misc.c
@@ -235,10 +235,11 @@
case ASN_BASIC_INTEGER:
case ASN_BASIC_ENUMERATED:
case ASN_BASIC_REAL:
- if((expr->expr_type == ASN_BASIC_REAL
- && (_format == TNF_CONSTYPE || !(arg->flags & A1C_USE_WIDE_TYPES)))
- || asn1c_type_fits_long(arg, expr)) {
- switch(_format) {
+ if((expr->expr_type == ASN_BASIC_REAL
+ && (_format == TNF_CONSTYPE || !(arg->flags & A1C_USE_WIDE_TYPES)
+ || asn1c_REAL_fits(arg, expr) != RL_NOTFIT))
+ || asn1c_type_fits_long(arg, expr)) {
+ switch(_format) {
case TNF_CONSTYPE:
if(expr->expr_type == ASN_BASIC_REAL) {
return "double";
@@ -328,6 +329,40 @@
return typename;
}
+static asn1p_expr_type_e
+expr_get_type(arg_t *arg, asn1p_expr_t *expr) {
+ asn1p_expr_t *terminal;
+ terminal = asn1f_find_terminal_type_ex(arg->asn, arg->ns, expr);
+ if(terminal) return terminal->expr_type;
+ return A1TC_INVALID;
+}
+
+enum asn1c_fitsfloat_e
+asn1c_REAL_fits(arg_t *arg, asn1p_expr_t *expr) {
+ asn1p_expr_type_e etype = expr_get_type(arg, arg->expr);
+ if(etype == ASN_BASIC_REAL) {
+ asn1cnst_range_t *range = asn1constraint_compute_OER_range(
+ expr->Identifier, etype, expr->combined_constraints, ACT_EL_RANGE,
+ 0, 0, 0);
+ enum asn1c_fitsfloat_e fits;
+ switch(range->narrowing) {
+ case NARROW_FLOAT32:
+ fits = RL_FITS_FLOAT32;
+ break;
+ case NARROW_DOUBLE64:
+ fits = RL_FITS_DOUBLE64;
+ break;
+ default:
+ fits = RL_NOTFIT;
+ break;
+ }
+ asn1constraint_range_free(range);
+ return fits;
+ } else {
+ return 0;
+ }
+}
+
/*
* Check whether the specified INTEGER or ENUMERATED type can be represented
* using the generic 'long' or 'unsigned long' type.
diff --git a/libasn1compiler/asn1c_misc.h b/libasn1compiler/asn1c_misc.h
index 77e3827..439a2d0 100644
--- a/libasn1compiler/asn1c_misc.h
+++ b/libasn1compiler/asn1c_misc.h
@@ -46,4 +46,11 @@
};
enum asn1c_fitslong_e asn1c_type_fits_long(arg_t *arg, asn1p_expr_t *expr);
+enum asn1c_fitsfloat_e {
+ RL_NOTFIT,
+ RL_FITS_FLOAT32,
+ RL_FITS_DOUBLE64
+};
+enum asn1c_fitsfloat_e asn1c_REAL_fits(arg_t *arg, asn1p_expr_t *expr);
+
#endif /* ASN1_COMPILER_MISC_H */
diff --git a/libasn1fix/asn1fix_crange.c b/libasn1fix/asn1fix_crange.c
index c05a775..9761dca 100644
--- a/libasn1fix/asn1fix_crange.c
+++ b/libasn1fix/asn1fix_crange.c
@@ -943,7 +943,7 @@
&& base->left.value == 2 && base->right.value == 2
&& exponent->left.type == ARE_VALUE && exponent->right.type == ARE_VALUE
&& exponent->left.value >= -1074 && exponent->right.value <= 971) {
- range->narrowing = NARROW_FLOAT64;
+ range->narrowing = NARROW_DOUBLE64;
}
FREE_MEB();
diff --git a/libasn1fix/asn1fix_crange.h b/libasn1fix/asn1fix_crange.h
index df1bfaa..1896392 100644
--- a/libasn1fix/asn1fix_crange.h
+++ b/libasn1fix/asn1fix_crange.h
@@ -16,9 +16,9 @@
asn1cnst_edge_t right; /* 10 from (MIN..10) */
enum asn1cnst_range_narrowing {
- /* Sorted from softest to hardest narrowing */
+ /* Sorted from softest to strictest narrowing */
NOT_NARROW,
- NARROW_FLOAT64,
+ NARROW_DOUBLE64,
NARROW_FLOAT32,
} narrowing; /* Constrained to a known narrow type */
diff --git a/skeletons/NativeReal.c b/skeletons/NativeReal.c
index da3d328..7a0d82a 100644
--- a/skeletons/NativeReal.c
+++ b/skeletons/NativeReal.c
@@ -558,6 +558,7 @@
-1267650600228229401496703205376.0, 1267650600228229401496703205376.0,
#if __STDC_VERSION__ >= 199901L
-FLT_MAX, FLT_MAX,
+ -DBL_TRUE_MIN, DBL_TRUE_MIN,
#endif
INFINITY, -INFINITY, NAN};
ssize_t float_set_size;
diff --git a/skeletons/REAL.c b/skeletons/REAL.c
index 72f07b6..77e0063 100644
--- a/skeletons/REAL.c
+++ b/skeletons/REAL.c
@@ -79,8 +79,8 @@
0,
0,
#else
- 0,
- 0,
+ REAL_decode_oer,
+ REAL_encode_oer,
#endif /* ASN_DISABLE_OER_SUPPORT */
#ifdef ASN_DISABLE_PER_SUPPORT
0,
@@ -832,6 +832,90 @@
return 0;
}
+#ifndef ASN_DISABLE_OER_SUPPORT
+
+/*
+ * Encode as Canonical OER
+ */
+asn_enc_rval_t
+REAL_encode_oer(asn_TYPE_descriptor_t *td,
+ const asn_oer_constraints_t *constraints, void *sptr,
+ asn_app_consume_bytes_f *cb, void *app_key) {
+ const REAL_t *st = sptr;
+ asn_enc_rval_t er;
+ ssize_t len_len;
+
+ if(!st || !st->buf || !td)
+ ASN__ENCODE_FAILED;
+
+ if(!constraints) constraints = td->encoding_constraints.oer_constraints;
+ if(constraints && constraints->value.width != 0) {
+ /* If we're constrained to a narrow float/double representation, we
+ * shouldn't have ended up using REAL. Expecting NativeReal. */
+ ASN__ENCODE_FAILED;
+ }
+
+ /* Encode a fake REAL */
+ len_len = oer_serialize_length(st->size, cb, app_key);
+ if(len_len < 0 || cb(st->buf, st->size, app_key) < 0) {
+ ASN__ENCODE_FAILED;
+ } else {
+ er.encoded = len_len + st->size;
+ ASN__ENCODED_OK(er);
+ }
+}
+
+asn_dec_rval_t
+REAL_decode_oer(const asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
+ const asn_oer_constraints_t *constraints, void **sptr,
+ const void *ptr, size_t size) {
+ asn_dec_rval_t ok = {RC_OK, 0};
+ REAL_t *st;
+ uint8_t *buf;
+ ssize_t len_len;
+ size_t real_body_len;
+
+ if(!constraints) constraints = td->encoding_constraints.oer_constraints;
+ if(constraints && constraints->value.width != 0) {
+ /* If we're constrained to a narrow float/double representation, we
+ * shouldn't have ended up using REAL. Expecting NativeReal. */
+ ASN__DECODE_FAILED;
+ }
+
+ len_len = oer_fetch_length(ptr, size, &real_body_len);
+ if(len_len < 0) ASN__DECODE_FAILED;
+ if(len_len == 0) ASN__DECODE_STARVED;
+
+ ptr = (const char *)ptr + len_len;
+ size -= len_len;
+
+ if(real_body_len > size) ASN__DECODE_STARVED;
+
+ buf = CALLOC(1, real_body_len + 1);
+ if(!buf) ASN__DECODE_FAILED;
+
+ if(!(st = *sptr)) {
+ st = (*sptr = CALLOC(1, sizeof(REAL_t)));
+ if(!st) {
+ FREEMEM(buf);
+ ASN__DECODE_FAILED;
+ }
+ } else {
+ FREEMEM(st->buf);
+ }
+
+ memcpy(buf, ptr, real_body_len);
+ buf[real_body_len] = '\0';
+
+ st->buf = buf;
+ st->size = real_body_len;
+
+ ok.consumed = len_len + real_body_len;
+ return ok;
+}
+
+#endif /* ASN_DISABLE_OER_SUPPORT */
+
#ifndef ASN_DISABLE_PER_SUPPORT
asn_dec_rval_t
@@ -870,6 +954,7 @@
-1267650600228229401496703205376.0, 1267650600228229401496703205376.0,
#if __STDC_VERSION__ >= 199901L
-FLT_MAX, FLT_MAX,
+ -DBL_TRUE_MIN, DBL_TRUE_MIN,
#endif
INFINITY, -INFINITY, NAN};
REAL_t *st;
diff --git a/skeletons/REAL.h b/skeletons/REAL.h
index 6c26ef1..a003816 100644
--- a/skeletons/REAL.h
+++ b/skeletons/REAL.h
@@ -19,10 +19,12 @@
asn_struct_print_f REAL_print;
asn_struct_compare_f REAL_compare;
-xer_type_decoder_f REAL_decode_xer;
-xer_type_encoder_f REAL_encode_xer;
+oer_type_decoder_f REAL_decode_oer;
+oer_type_encoder_f REAL_encode_oer;
per_type_decoder_f REAL_decode_uper;
per_type_encoder_f REAL_encode_uper;
+xer_type_decoder_f REAL_decode_xer;
+xer_type_encoder_f REAL_encode_xer;
asn_random_fill_f REAL_random_fill;
#define REAL_free ASN__PRIMITIVE_TYPE_free,
diff --git a/tests/tests-asn1c-compiler/154-with-REAL-components-OK.asn1.-Pfwide-types b/tests/tests-asn1c-compiler/154-with-REAL-components-OK.asn1.-Pfwide-types
index 8304905..529f5c8 100644
--- a/tests/tests-asn1c-compiler/154-with-REAL-components-OK.asn1.-Pfwide-types
+++ b/tests/tests-asn1c-compiler/154-with-REAL-components-OK.asn1.-Pfwide-types
@@ -149,7 +149,6 @@
int
Indirect_IEEE_binary32_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
asn_app_constraint_failed_f *ctfailcb, void *app_key) {
- const UnconstrainedREAL_t *st = (const UnconstrainedREAL_t *)sptr;
if(!sptr) {
ASN__CTFAIL(app_key, td, sptr,
@@ -160,7 +159,6 @@
if(1 /* No applicable constraints whatsoever */) {
- (void)st; /* Unused variable */
/* Nothing is here. See below */
}
@@ -198,16 +196,16 @@
/*** <<< INCLUDES [IEEE-binary32-w] >>> ***/
-#include <REAL.h>
+#include <NativeReal.h>
/*** <<< TYPE-DECLS [IEEE-binary32-w] >>> ***/
-typedef REAL_t IEEE_binary32_w_t;
+typedef float IEEE_binary32_w_t;
/*** <<< FUNC-DECLS [IEEE-binary32-w] >>> ***/
extern asn_TYPE_descriptor_t asn_DEF_IEEE_binary32_w;
-extern const asn_REAL_specifics_t asn_SPC_IEEE_binary32_w_specs_1;
+extern const asn_NativeReal_specifics_t asn_SPC_IEEE_binary32_w_specs_1;
asn_struct_free_f IEEE_binary32_w_free;
asn_struct_print_f IEEE_binary32_w_print;
asn_constr_check_f IEEE_binary32_w_constraint;
@@ -221,7 +219,6 @@
int
IEEE_binary32_w_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
asn_app_constraint_failed_f *ctfailcb, void *app_key) {
- const REAL_t *st = (const REAL_t *)sptr;
if(!sptr) {
ASN__CTFAIL(app_key, td, sptr,
@@ -232,7 +229,6 @@
if(1 /* No applicable constraints whatsoever */) {
- (void)st; /* Unused variable */
/* Nothing is here. See below */
}
@@ -240,7 +236,7 @@
}
/*
- * This type is implemented using REAL,
+ * This type is implemented using NativeReal,
* so here we adjust the DEF accordingly.
*/
@@ -255,7 +251,7 @@
asn_TYPE_descriptor_t asn_DEF_IEEE_binary32_w = {
"IEEE-binary32-w",
"IEEE-binary32-w",
- &asn_OP_REAL,
+ &asn_OP_NativeReal,
asn_DEF_IEEE_binary32_w_tags_1,
sizeof(asn_DEF_IEEE_binary32_w_tags_1)
/sizeof(asn_DEF_IEEE_binary32_w_tags_1[0]), /* 1 */
@@ -270,16 +266,16 @@
/*** <<< INCLUDES [IEEE-binary32-0w] >>> ***/
-#include <REAL.h>
+#include <NativeReal.h>
/*** <<< TYPE-DECLS [IEEE-binary32-0w] >>> ***/
-typedef REAL_t IEEE_binary32_0w_t;
+typedef float IEEE_binary32_0w_t;
/*** <<< FUNC-DECLS [IEEE-binary32-0w] >>> ***/
extern asn_TYPE_descriptor_t asn_DEF_IEEE_binary32_0w;
-extern const asn_REAL_specifics_t asn_SPC_IEEE_binary32_0w_specs_1;
+extern const asn_NativeReal_specifics_t asn_SPC_IEEE_binary32_0w_specs_1;
asn_struct_free_f IEEE_binary32_0w_free;
asn_struct_print_f IEEE_binary32_0w_print;
asn_constr_check_f IEEE_binary32_0w_constraint;
@@ -293,7 +289,6 @@
int
IEEE_binary32_0w_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
asn_app_constraint_failed_f *ctfailcb, void *app_key) {
- const REAL_t *st = (const REAL_t *)sptr;
if(!sptr) {
ASN__CTFAIL(app_key, td, sptr,
@@ -304,7 +299,6 @@
if(1 /* No applicable constraints whatsoever */) {
- (void)st; /* Unused variable */
/* Nothing is here. See below */
}
@@ -312,7 +306,7 @@
}
/*
- * This type is implemented using REAL,
+ * This type is implemented using NativeReal,
* so here we adjust the DEF accordingly.
*/
@@ -327,7 +321,7 @@
asn_TYPE_descriptor_t asn_DEF_IEEE_binary32_0w = {
"IEEE-binary32-0w",
"IEEE-binary32-0w",
- &asn_OP_REAL,
+ &asn_OP_NativeReal,
asn_DEF_IEEE_binary32_0w_tags_1,
sizeof(asn_DEF_IEEE_binary32_0w_tags_1)
/sizeof(asn_DEF_IEEE_binary32_0w_tags_1[0]), /* 1 */
@@ -342,16 +336,16 @@
/*** <<< INCLUDES [IEEE-binary32-w0] >>> ***/
-#include <REAL.h>
+#include <NativeReal.h>
/*** <<< TYPE-DECLS [IEEE-binary32-w0] >>> ***/
-typedef REAL_t IEEE_binary32_w0_t;
+typedef float IEEE_binary32_w0_t;
/*** <<< FUNC-DECLS [IEEE-binary32-w0] >>> ***/
extern asn_TYPE_descriptor_t asn_DEF_IEEE_binary32_w0;
-extern const asn_REAL_specifics_t asn_SPC_IEEE_binary32_w0_specs_1;
+extern const asn_NativeReal_specifics_t asn_SPC_IEEE_binary32_w0_specs_1;
asn_struct_free_f IEEE_binary32_w0_free;
asn_struct_print_f IEEE_binary32_w0_print;
asn_constr_check_f IEEE_binary32_w0_constraint;
@@ -365,7 +359,6 @@
int
IEEE_binary32_w0_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
asn_app_constraint_failed_f *ctfailcb, void *app_key) {
- const REAL_t *st = (const REAL_t *)sptr;
if(!sptr) {
ASN__CTFAIL(app_key, td, sptr,
@@ -376,7 +369,6 @@
if(1 /* No applicable constraints whatsoever */) {
- (void)st; /* Unused variable */
/* Nothing is here. See below */
}
@@ -384,7 +376,7 @@
}
/*
- * This type is implemented using REAL,
+ * This type is implemented using NativeReal,
* so here we adjust the DEF accordingly.
*/
@@ -399,7 +391,7 @@
asn_TYPE_descriptor_t asn_DEF_IEEE_binary32_w0 = {
"IEEE-binary32-w0",
"IEEE-binary32-w0",
- &asn_OP_REAL,
+ &asn_OP_NativeReal,
asn_DEF_IEEE_binary32_w0_tags_1,
sizeof(asn_DEF_IEEE_binary32_w0_tags_1)
/sizeof(asn_DEF_IEEE_binary32_w0_tags_1[0]), /* 1 */
@@ -414,11 +406,11 @@
/*** <<< INCLUDES [IEEE-binary64-w] >>> ***/
-#include <REAL.h>
+#include <NativeReal.h>
/*** <<< TYPE-DECLS [IEEE-binary64-w] >>> ***/
-typedef REAL_t IEEE_binary64_w_t;
+typedef double IEEE_binary64_w_t;
/*** <<< FUNC-DECLS [IEEE-binary64-w] >>> ***/
@@ -436,7 +428,6 @@
int
IEEE_binary64_w_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
asn_app_constraint_failed_f *ctfailcb, void *app_key) {
- const REAL_t *st = (const REAL_t *)sptr;
if(!sptr) {
ASN__CTFAIL(app_key, td, sptr,
@@ -447,7 +438,6 @@
if(1 /* No applicable constraints whatsoever */) {
- (void)st; /* Unused variable */
/* Nothing is here. See below */
}
@@ -455,7 +445,7 @@
}
/*
- * This type is implemented using REAL,
+ * This type is implemented using NativeReal,
* so here we adjust the DEF accordingly.
*/
@@ -467,7 +457,7 @@
asn_TYPE_descriptor_t asn_DEF_IEEE_binary64_w = {
"IEEE-binary64-w",
"IEEE-binary64-w",
- &asn_OP_REAL,
+ &asn_OP_NativeReal,
asn_DEF_IEEE_binary64_w_tags_1,
sizeof(asn_DEF_IEEE_binary64_w_tags_1)
/sizeof(asn_DEF_IEEE_binary64_w_tags_1[0]), /* 1 */
@@ -482,11 +472,11 @@
/*** <<< INCLUDES [IEEE-binary64-0w] >>> ***/
-#include <REAL.h>
+#include <NativeReal.h>
/*** <<< TYPE-DECLS [IEEE-binary64-0w] >>> ***/
-typedef REAL_t IEEE_binary64_0w_t;
+typedef double IEEE_binary64_0w_t;
/*** <<< FUNC-DECLS [IEEE-binary64-0w] >>> ***/
@@ -504,7 +494,6 @@
int
IEEE_binary64_0w_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
asn_app_constraint_failed_f *ctfailcb, void *app_key) {
- const REAL_t *st = (const REAL_t *)sptr;
if(!sptr) {
ASN__CTFAIL(app_key, td, sptr,
@@ -515,7 +504,6 @@
if(1 /* No applicable constraints whatsoever */) {
- (void)st; /* Unused variable */
/* Nothing is here. See below */
}
@@ -523,7 +511,7 @@
}
/*
- * This type is implemented using REAL,
+ * This type is implemented using NativeReal,
* so here we adjust the DEF accordingly.
*/
@@ -535,7 +523,7 @@
asn_TYPE_descriptor_t asn_DEF_IEEE_binary64_0w = {
"IEEE-binary64-0w",
"IEEE-binary64-0w",
- &asn_OP_REAL,
+ &asn_OP_NativeReal,
asn_DEF_IEEE_binary64_0w_tags_1,
sizeof(asn_DEF_IEEE_binary64_0w_tags_1)
/sizeof(asn_DEF_IEEE_binary64_0w_tags_1[0]), /* 1 */
@@ -550,11 +538,11 @@
/*** <<< INCLUDES [IEEE-binary64-w0] >>> ***/
-#include <REAL.h>
+#include <NativeReal.h>
/*** <<< TYPE-DECLS [IEEE-binary64-w0] >>> ***/
-typedef REAL_t IEEE_binary64_w0_t;
+typedef double IEEE_binary64_w0_t;
/*** <<< FUNC-DECLS [IEEE-binary64-w0] >>> ***/
@@ -572,7 +560,6 @@
int
IEEE_binary64_w0_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
asn_app_constraint_failed_f *ctfailcb, void *app_key) {
- const REAL_t *st = (const REAL_t *)sptr;
if(!sptr) {
ASN__CTFAIL(app_key, td, sptr,
@@ -583,7 +570,6 @@
if(1 /* No applicable constraints whatsoever */) {
- (void)st; /* Unused variable */
/* Nothing is here. See below */
}
@@ -591,7 +577,7 @@
}
/*
- * This type is implemented using REAL,
+ * This type is implemented using NativeReal,
* so here we adjust the DEF accordingly.
*/
@@ -603,7 +589,7 @@
asn_TYPE_descriptor_t asn_DEF_IEEE_binary64_w0 = {
"IEEE-binary64-w0",
"IEEE-binary64-w0",
- &asn_OP_REAL,
+ &asn_OP_NativeReal,
asn_DEF_IEEE_binary64_w0_tags_1,
sizeof(asn_DEF_IEEE_binary64_w0_tags_1)
/sizeof(asn_DEF_IEEE_binary64_w0_tags_1[0]), /* 1 */
@@ -655,7 +641,6 @@
static int
indirect_ieee_binary32_2_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
asn_app_constraint_failed_f *ctfailcb, void *app_key) {
- const Indirect_IEEE_binary32_t *st = (const Indirect_IEEE_binary32_t *)sptr;
if(!sptr) {
ASN__CTFAIL(app_key, td, sptr,
@@ -666,7 +651,6 @@
if(1 /* No applicable constraints whatsoever */) {
- (void)st; /* Unused variable */
/* Nothing is here. See below */
}
@@ -680,7 +664,6 @@
static int
ieee_binary32_w_3_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
asn_app_constraint_failed_f *ctfailcb, void *app_key) {
- const IEEE_binary32_w_t *st = (const IEEE_binary32_w_t *)sptr;
if(!sptr) {
ASN__CTFAIL(app_key, td, sptr,
@@ -691,7 +674,6 @@
if(1 /* No applicable constraints whatsoever */) {
- (void)st; /* Unused variable */
/* Nothing is here. See below */
}
@@ -705,7 +687,6 @@
static int
ieee_binary32_0w_4_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
asn_app_constraint_failed_f *ctfailcb, void *app_key) {
- const IEEE_binary32_0w_t *st = (const IEEE_binary32_0w_t *)sptr;
if(!sptr) {
ASN__CTFAIL(app_key, td, sptr,
@@ -716,7 +697,6 @@
if(1 /* No applicable constraints whatsoever */) {
- (void)st; /* Unused variable */
/* Nothing is here. See below */
}
@@ -730,7 +710,6 @@
static int
ieee_binary32_w0_5_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
asn_app_constraint_failed_f *ctfailcb, void *app_key) {
- const IEEE_binary32_w0_t *st = (const IEEE_binary32_w0_t *)sptr;
if(!sptr) {
ASN__CTFAIL(app_key, td, sptr,
@@ -741,7 +720,6 @@
if(1 /* No applicable constraints whatsoever */) {
- (void)st; /* Unused variable */
/* Nothing is here. See below */
}
@@ -787,7 +765,7 @@
asn_TYPE_descriptor_t asn_DEF_ieee_binary32_w_3 = {
"ieee-binary32-w",
"ieee-binary32-w",
- &asn_OP_REAL,
+ &asn_OP_NativeReal,
asn_DEF_ieee_binary32_w_tags_3,
sizeof(asn_DEF_ieee_binary32_w_tags_3)
/sizeof(asn_DEF_ieee_binary32_w_tags_3[0]), /* 1 */
@@ -809,7 +787,7 @@
asn_TYPE_descriptor_t asn_DEF_ieee_binary32_0w_4 = {
"ieee-binary32-0w",
"ieee-binary32-0w",
- &asn_OP_REAL,
+ &asn_OP_NativeReal,
asn_DEF_ieee_binary32_0w_tags_4,
sizeof(asn_DEF_ieee_binary32_0w_tags_4)
/sizeof(asn_DEF_ieee_binary32_0w_tags_4[0]), /* 1 */
@@ -831,7 +809,7 @@
asn_TYPE_descriptor_t asn_DEF_ieee_binary32_w0_5 = {
"ieee-binary32-w0",
"ieee-binary32-w0",
- &asn_OP_REAL,
+ &asn_OP_NativeReal,
asn_DEF_ieee_binary32_w0_tags_5,
sizeof(asn_DEF_ieee_binary32_w0_tags_5)
/sizeof(asn_DEF_ieee_binary32_w0_tags_5[0]), /* 1 */
diff --git a/tests/tests-randomized/check-bundles.sh b/tests/tests-randomized/check-bundles.sh
index db1321b..a80c747 100755
--- a/tests/tests-randomized/check-bundles.sh
+++ b/tests/tests-randomized/check-bundles.sh
@@ -14,10 +14,11 @@
echo " $0 [--dirty] -t \"<ASN.1 text defining type T, in string form>\""
echo " $0 [--dirty] bundles/<bundle-name.txt> [<line>]"
echo "Where options are:"
- echo " -h Show this help screen"
- echo " -e <syntax> Verify a given encoding explicitly (default is ALL)"
- echo " --dirty Reuse compile results from the previous run(s)"
- echo " -t <ASN.1> Run this particular typel"
+ echo " -h Show this help screen"
+ echo " -e <syntax> Verify a given encoding explicitly (default is ALL)"
+ echo " --asn1c <flag> Add this flag to asn1c"
+ echo " --dirty Reuse compile results from the previous run(s)"
+ echo " -t <ASN.1> Run this particular typel"
echo "Examples:"
echo " $0 -t UTF8String"
echo " $0 -t \"T ::= INTEGER (0..1)\""
@@ -38,6 +39,7 @@
need_clean_before_test=1 # Before each line in a bundle file
encodings="" # Default is to verify all supported ASN.1 transfer syntaxes
parallelism=4
+asn1c_flags=""
make_clean_before_bundle() {
test "${need_clean_before_bundle}" = "1" && make clean
@@ -81,8 +83,6 @@
local where="$*"
test "x$asn" != "x" || usage
- make_clean_before_test
-
if echo "$asn" | grep -qv "::="; then
asn="T ::= $asn"
fi
@@ -98,11 +98,35 @@
fi
}
+# compile_and_test "<text>" "<where found>" [<asn.1 flags>]
compile_and_test() {
- local asn="$1"
- shift
+ if [ "x${asn1c_flags}" != "x" ]; then
+ if ! compile_and_test_with "$@" ${asn1c_flags} ; then
+ return 1
+ fi
+ else
+ if ! compile_and_test_with "$@" ; then
+ echo "Can't compile and test narrow"
+ return 1
+ fi
- if ! asn_compile "$asn" "$*"; then
+ if ! compile_and_test_with "$@" "-fwide-types"; then
+ echo "Can't compile and test wide"
+ return 2
+ fi
+ fi
+
+ return 0
+}
+
+compile_and_test_with() {
+ local asn="$1"
+ local where="$2"
+ shift 2
+
+ make_clean_before_test
+
+ if ! asn_compile "$asn" "$where" "$@"; then
echo "Cannot compile ASN.1 $asn"
return 1
fi
@@ -170,7 +194,8 @@
asn_compile() {
local asn="$1"
- shift
+ local where="$2"
+ shift 2
# Create "INTEGER (1..2)" from "T ::= INTEGER (1..2) -- RMAX=5"
local short_asn=$(echo "$asn" | sed -e 's/ *--.*//;s/RMAX=[^ ]* //;')
@@ -180,10 +205,10 @@
test ! -f Makefile.am # Protection from accidental clobbering
echo "Test DEFINITIONS ::= BEGIN $asn" > test.asn1
- echo "-- $*" >> test.asn1
+ echo "-- ${where}" >> test.asn1
echo "END" >> test.asn1
if ! ${abs_top_builddir}/asn1c/asn1c -S ${abs_top_srcdir}/skeletons \
- -gen-OER -gen-PER test.asn1
+ -gen-OER -gen-PER "$@" test.asn1
then
return 1
fi
@@ -199,6 +224,7 @@
while :; do
case "$1" in
-h) usage ;;
+ --asn1c) asn1c_flags+="$2"; shift 2; continue ;;
--dirty)
need_clean_before_bundle=0
need_clean_before_test=0