Commit 7e033b54 authored by Lev Walkin's avatar Lev Walkin
Browse files

adjusted definitions to include gcc 4.x into the supported compilers list

parent 2f505029
......@@ -91,8 +91,14 @@ NativeInteger_decode_ber(asn_codec_ctx_t *opt_codec_ctx,
*/
{
INTEGER_t tmp;
union {
const void *constbuf;
void *nonconstbuf;
} unconst_buf;
long l;
(const uint8_t *)tmp.buf = (const uint8_t *)buf_ptr;
unconst_buf.constbuf = buf_ptr;
tmp.buf = (uint8_t *)unconst_buf.nonconstbuf;
tmp.size = length;
if(asn_INTEGER2long(&tmp, &l)) {
......
......@@ -93,8 +93,14 @@ NativeReal_decode_ber(asn_codec_ctx_t *opt_codec_ctx,
*/
{
REAL_t tmp;
union {
const void *constbuf;
void *nonconstbuf;
} unconst_buf;
double d;
(const uint8_t *)tmp.buf = (const uint8_t *)buf_ptr;
unconst_buf.constbuf = buf_ptr;
tmp.buf = (uint8_t *)unconst_buf.nonconstbuf;
tmp.size = length;
if(asn_REAL2double(&tmp, &d)) {
......
......@@ -28,7 +28,6 @@ static void *data_decode_from_file(asn_TYPE_descriptor_t *asnTypeOfPDU,
int opt_debug; /* -d */
static int opt_check; /* -c */
static int opt_print; /* -p */
static int opt_stack; /* -s */
static enum output_method {
OUT_NONE, /* No pretty-printing */
......
......@@ -6,14 +6,12 @@
#include <asn_SET_OF.h>
#include <errno.h>
typedef A_SET_OF(void) asn_set;
/*
* Add another element into the set.
*/
int
asn_set_add(void *asn_set_of_x, void *ptr) {
asn_set *as = (asn_set *)asn_set_of_x;
asn_anonymous_set_ *as = _A_SET_FROM_VOID(asn_set_of_x);
if(as == 0 || ptr == 0) {
errno = EINVAL; /* Invalid arguments */
......@@ -43,7 +41,7 @@ asn_set_add(void *asn_set_of_x, void *ptr) {
void
asn_set_del(void *asn_set_of_x, int number, int _do_free) {
asn_set *as = (asn_set *)asn_set_of_x;
asn_anonymous_set_ *as = _A_SET_FROM_VOID(asn_set_of_x);
if(as) {
void *ptr;
......@@ -71,7 +69,7 @@ asn_set_del(void *asn_set_of_x, int number, int _do_free) {
*/
void
asn_set_empty(void *asn_set_of_x) {
asn_set *as = (asn_set *)asn_set_of_x;
asn_anonymous_set_ *as = _A_SET_FROM_VOID(asn_set_of_x);
if(as) {
if(as->array) {
......
......@@ -80,4 +80,16 @@ static void ASN_DEBUG(const char *fmt, ...) { (void)fmt; };
if(cb(" ", 4, app_key) < 0) return -1; \
} while(0)
/*
* Cope with implicit conversions to/from void.
*/
#include <asn_SET_OF.h>
#include <asn_SEQUENCE_OF.h>
typedef A_SEQUENCE_OF(void) asn_anonymous_sequence_;
typedef A_SET_OF(void) asn_anonymous_set_;
#define _A_SET_FROM_VOID(ptr) ((asn_anonymous_set_ *)(ptr))
#define _A_CSET_FROM_VOID(ptr) ((const asn_anonymous_set_ *)(ptr))
#define _A_SEQUENCE_FROM_VOID(ptr) ((asn_anonymous_sequence_ *)(ptr))
#define _A_CSEQUENCE_FROM_VOID(ptr) ((const asn_anonymous_sequence_ *)(ptr))
#endif /* _ASN_INTERNAL_H_ */
......@@ -14,7 +14,7 @@ SEQUENCE_OF_encode_der(asn_TYPE_descriptor_t *td, void *ptr,
int tag_mode, ber_tlv_tag_t tag,
asn_app_consume_bytes_f *cb, void *app_key) {
asn_TYPE_member_t *elm = td->elements;
A_SEQUENCE_OF(void) *list;
asn_anonymous_sequence_ *list = _A_SEQUENCE_FROM_VOID(ptr);
size_t computed_size = 0;
ssize_t encoding_size = 0;
asn_enc_rval_t erval;
......@@ -25,7 +25,6 @@ SEQUENCE_OF_encode_der(asn_TYPE_descriptor_t *td, void *ptr,
/*
* Gather the length of the underlying members sequence.
*/
(void *)list = ptr;
for(edx = 0; edx < list->count; edx++) {
void *memb_ptr = list->array[edx];
erval = elm->type->der_encoder(elm->type, memb_ptr,
......@@ -90,7 +89,7 @@ SEQUENCE_OF_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
asn_enc_rval_t er;
asn_SET_OF_specifics_t *specs = (asn_SET_OF_specifics_t *)td->specifics;
asn_TYPE_member_t *element = td->elements;
A_SEQUENCE_OF(void) *list;
asn_anonymous_sequence_ *list = _A_SEQUENCE_FROM_VOID(sptr);
const char *mname = specs->as_XMLValueList
? 0 : ((*element->name)
? element->name : element->type->xml_tag);
......@@ -102,7 +101,6 @@ SEQUENCE_OF_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
er.encoded = 0;
(void *)list = sptr;
for(i = 0; i < list->count; i++) {
asn_enc_rval_t tmper;
......
......@@ -212,8 +212,7 @@ SET_OF_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
switch(rval.code) {
case RC_OK:
{
A_SET_OF(void) *list;
(void *)list = (void *)st;
asn_anonymous_set_ *list = _A_SET_FROM_VOID(st);
if(ASN_SET_ADD(list, ctx->ptr) != 0)
RETURN(RC_FAIL);
else
......@@ -314,7 +313,7 @@ SET_OF_encode_der(asn_TYPE_descriptor_t *td, void *ptr,
asn_TYPE_member_t *elm = td->elements;
asn_TYPE_descriptor_t *elm_type = elm->type;
der_type_encoder_f *der_encoder = elm_type->der_encoder;
A_SET_OF(void) *list;
asn_anonymous_set_ *list = _A_SET_FROM_VOID(ptr);
size_t computed_size = 0;
ssize_t encoding_size = 0;
struct _el_buffer *encoded_els;
......@@ -328,7 +327,6 @@ SET_OF_encode_der(asn_TYPE_descriptor_t *td, void *ptr,
/*
* Gather the length of the underlying members sequence.
*/
(void *)list = ptr;
for(edx = 0; edx < list->count; edx++) {
void *memb_ptr = list->array[edx];
erval = der_encoder(elm_type, memb_ptr, 0, elm->tag, 0, 0);
......@@ -516,8 +514,7 @@ SET_OF_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
element->type, &ctx->ptr, elm_tag,
buf_ptr, size);
if(tmprval.code == RC_OK) {
A_SET_OF(void) *list;
(void *)list = (void *)st;
asn_anonymous_set_ *list = _A_SET_FROM_VOID(st);
if(ASN_SET_ADD(list, ctx->ptr) != 0)
RETURN(RC_FAIL);
ctx->ptr = 0;
......@@ -642,7 +639,7 @@ SET_OF_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
asn_enc_rval_t er;
asn_SET_OF_specifics_t *specs = (asn_SET_OF_specifics_t *)td->specifics;
asn_TYPE_member_t *element = td->elements;
A_SET_OF(void) *list;
asn_anonymous_set_ *list = _A_SET_FROM_VOID(sptr);
const char *mname = specs->as_XMLValueList
? 0 : ((*element->name)
? element->name : element->type->xml_tag);
......@@ -656,8 +653,6 @@ SET_OF_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
if(!sptr) _ASN_ENCODE_FAILED;
(void *)list = sptr;
if(xcan) {
encs = (xer_tmp_enc_t *)MALLOC(list->count * sizeof(encs[0]));
if(!encs) _ASN_ENCODE_FAILED;
......@@ -747,7 +742,7 @@ int
SET_OF_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
asn_app_consume_bytes_f *cb, void *app_key) {
asn_TYPE_member_t *element = td->elements;
const A_SET_OF(void) *list;
const asn_anonymous_set_ *list = _A_CSET_FROM_VOID(sptr);
int ret;
int i;
......@@ -758,7 +753,6 @@ SET_OF_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|| cb(" ::= {", 6, app_key) < 0)
return -1;
(const void *)list = sptr;
for(i = 0; i < list->count; i++) {
const void *memb_ptr = list->array[i];
if(!memb_ptr) continue;
......@@ -780,14 +774,13 @@ void
SET_OF_free(asn_TYPE_descriptor_t *td, void *ptr, int contents_only) {
if(td && ptr) {
asn_TYPE_member_t *element = td->elements;
A_SET_OF(void) *list;
asn_anonymous_set_ *list = _A_SET_FROM_VOID(ptr);
int i;
/*
* Could not use set_of_empty() because of (*free)
* incompatibility.
*/
(void *)list = ptr;
for(i = 0; i < list->count; i++) {
void *memb_ptr = list->array[i];
if(memb_ptr)
......@@ -808,7 +801,7 @@ SET_OF_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
asn_app_consume_bytes_f *app_errlog, void *app_key) {
asn_TYPE_member_t *element = td->elements;
asn_constr_check_f *constr;
const A_SET_OF(void) *list;
const asn_anonymous_set_ *list = _A_CSET_FROM_VOID(sptr);
int i;
if(!sptr) {
......@@ -818,8 +811,6 @@ SET_OF_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
return -1;
}
(const void *)list = sptr;
constr = element->memb_constraints;
if(!constr) constr = element->type->check_constraints;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment