Add 64-bit integer support to ASN.1 compiler
ASN.1 INTEGERs will now compile to C int64_t or uint64_t, depending on whether the constraint ranges include numbers that cannot be represented in 32-bit ints and whether they include negative numbers. Template backend support included. check-template is now built with --template, so we know we're testing it. Tests included.
This commit is contained in:

committed by
Nicolas Williams

parent
0e7437ba2e
commit
19d378f44d
@@ -189,19 +189,19 @@ range_check(const char *name,
|
||||
{
|
||||
if (r->min == r->max + 2 || r->min < r->max)
|
||||
fprintf (codefile,
|
||||
"if ((%s)->%s > %d) {\n"
|
||||
"if ((%s)->%s > %lld) {\n"
|
||||
"e = ASN1_MAX_CONSTRAINT; %s;\n"
|
||||
"}\n",
|
||||
name, length, r->max, forwstr);
|
||||
if (r->min - 1 == r->max || r->min < r->max)
|
||||
fprintf (codefile,
|
||||
"if ((%s)->%s < %d) {\n"
|
||||
"if ((%s)->%s < %lld) {\n"
|
||||
"e = ASN1_MIN_CONSTRAINT; %s;\n"
|
||||
"}\n",
|
||||
name, length, r->min, forwstr);
|
||||
if (r->max == r->min)
|
||||
fprintf (codefile,
|
||||
"if ((%s)->%s != %d) {\n"
|
||||
"if ((%s)->%s != %lld) {\n"
|
||||
"e = ASN1_EXACT_CONSTRAINT; %s;\n"
|
||||
"}\n",
|
||||
name, length, r->min, forwstr);
|
||||
@@ -252,14 +252,16 @@ decode_type (const char *name, const Type *t, int optional,
|
||||
name);
|
||||
} else if (t->range == NULL) {
|
||||
decode_primitive ("heim_integer", name, forwstr);
|
||||
} else if (t->range->min == INT_MIN && t->range->max == INT_MAX) {
|
||||
} else if (t->range->min < INT_MIN && t->range->max <= INT64_MAX) {
|
||||
decode_primitive ("integer64", name, forwstr);
|
||||
} else if (t->range->min >= 0 && t->range->max > UINT_MAX) {
|
||||
decode_primitive ("unsigned64", name, forwstr);
|
||||
} else if (t->range->min >= INT_MIN && t->range->max <= INT_MAX) {
|
||||
decode_primitive ("integer", name, forwstr);
|
||||
} else if (t->range->min == 0 && t->range->max == UINT_MAX) {
|
||||
decode_primitive ("unsigned", name, forwstr);
|
||||
} else if (t->range->min == 0 && t->range->max == INT_MAX) {
|
||||
} else if (t->range->min >= 0 && t->range->max <= UINT_MAX) {
|
||||
decode_primitive ("unsigned", name, forwstr);
|
||||
} else
|
||||
errx(1, "%s: unsupported range %d -> %d",
|
||||
errx(1, "%s: unsupported range %lld -> %lld",
|
||||
name, t->range->min, t->range->max);
|
||||
break;
|
||||
case TBoolean:
|
||||
|
Reference in New Issue
Block a user