Commit a460ba3f authored by Lev Walkin's avatar Lev Walkin

things necessary for Sun Solaris 9 @ sparc

parent cc11653d
0.9.8: 2004-Oct-13 0.9.8: 2004-Oct-20
* -X command line option added to asn1c to generate XML DTD. * -X command line option added to asn1c to generate XML DTD.
* Empty SEQUENCE and SET clauses are now allowed. * Empty SEQUENCE and SET clauses are now allowed.
* Code compiled and tested on Sun Solaris 9 @ sparc.
Improved includes/defines of/for system headers.
0.9.7.1: 2004-Oct-12 0.9.7.1: 2004-Oct-12
...@@ -200,7 +202,7 @@ ...@@ -200,7 +202,7 @@
* Compiler: fixed recursive ASN.1 types inclusion (Severity: low, * Compiler: fixed recursive ASN.1 types inclusion (Severity: low,
Security impact: none). Security impact: none).
* Parser: IMPORTS/FROM fixes, now allowing multiple sections. * Parser: IMPORTS/FROM fixes, now allowing multiple sections.
* Code compiled and checked on PowerPC (@MacOS X). No major portability * Code compiled and tested on MacOS X (@ PowerPC). No major portability
issues experienced. issues experienced.
0.8.7: 2004-Apr-11 T-version-0-8-7 0.8.7: 2004-Apr-11 T-version-0-8-7
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
tmpfile=".check-parsing.$$.tmp" tmpfile=".check-parsing.$$.tmp"
diff -a . . 2>/dev/null && diffArgs="-a"
ec=0 ec=0
for ref in ../tests/*.asn1.-*; do for ref in ../tests/*.asn1.-*; do
...@@ -10,7 +12,7 @@ for ref in ../tests/*.asn1.-*; do ...@@ -10,7 +12,7 @@ for ref in ../tests/*.asn1.-*; do
echo "Checking $src against $ref" echo "Checking $src against $ref"
./asn1c "-$flags" "$src" > "$tmpfile" || ec=$? ./asn1c "-$flags" "$src" > "$tmpfile" || ec=$?
if [ $? = 0 ]; then if [ $? = 0 ]; then
diff -a -u "$ref" "$tmpfile" || ec=$? diff $diffArgs -u "$ref" "$tmpfile" || ec=$?
fi fi
if [ "$1" != "regenerate" ]; then if [ "$1" != "regenerate" ]; then
rm -f "$tmpfile" rm -f "$tmpfile"
......
...@@ -3,7 +3,7 @@ AM_CFLAGS = @ADD_CFLAGS@ ...@@ -3,7 +3,7 @@ AM_CFLAGS = @ADD_CFLAGS@
check_SCRIPTS = check-assembly.sh check_SCRIPTS = check-assembly.sh
TESTS_ENVIRONMENT= CFLAGS="${CFLAGS}" CXXFLAGS="${CXXFLAGS}" ./check-assembly.sh TESTS_ENVIRONMENT= CC="${CC}" CFLAGS="${CFLAGS}" CXXFLAGS="${CXXFLAGS}" ./check-assembly.sh
if CPLUSPLUS_FOUND if CPLUSPLUS_FOUND
TESTS = check-*.c check-*.cc ## Include C++ test filed (.cc) TESTS = check-*.c check-*.cc ## Include C++ test filed (.cc)
......
...@@ -157,7 +157,7 @@ target_os = @target_os@ ...@@ -157,7 +157,7 @@ target_os = @target_os@
target_vendor = @target_vendor@ target_vendor = @target_vendor@
AM_CFLAGS = @ADD_CFLAGS@ AM_CFLAGS = @ADD_CFLAGS@
check_SCRIPTS = check-assembly.sh check_SCRIPTS = check-assembly.sh
TESTS_ENVIRONMENT = CFLAGS="${CFLAGS}" CXXFLAGS="${CXXFLAGS}" ./check-assembly.sh TESTS_ENVIRONMENT = CC="${CC}" CFLAGS="${CFLAGS}" CXXFLAGS="${CXXFLAGS}" ./check-assembly.sh
@CPLUSPLUS_FOUND_FALSE@TESTS = check-*.c @CPLUSPLUS_FOUND_FALSE@TESTS = check-*.c
@CPLUSPLUS_FOUND_TRUE@TESTS = check-*.c check-*.cc ## Include C++ test filed (.cc) @CPLUSPLUS_FOUND_TRUE@TESTS = check-*.c check-*.cc ## Include C++ test filed (.cc)
EXTRA_DIST = \ EXTRA_DIST = \
......
...@@ -11,10 +11,10 @@ if [ "x$1" = "x" ]; then ...@@ -11,10 +11,10 @@ if [ "x$1" = "x" ]; then
fi fi
# Compute the .asn1 spec name by the given file name. # Compute the .asn1 spec name by the given file name.
source=$(echo "$1" | sed -e 's/.*\///') source=`echo "$1" | sed -e 's/.*\///'`
testno=`echo "$source" | cut -f2 -d'-' | cut -f1 -d'.'` testno=`echo "$source" | cut -f2 -d'-' | cut -f1 -d'.'`
args=$(echo "$source" | sed -e 's/\.c[c]*$//') args=`echo "$source" | sed -e 's/\.c[c]*$//'`
testdir=test-${args} testdir=test-${args}
OFS=$IFS OFS=$IFS
...@@ -30,9 +30,10 @@ if [ ! -d $testdir ]; then ...@@ -30,9 +30,10 @@ if [ ! -d $testdir ]; then
mkdir $testdir || exit $? mkdir $testdir || exit $?
fi fi
cd $testdir || exit $? cd $testdir || exit $?
ln -fs ../$source || exit $? rm -f ./$source 2>/dev/null
ln -fns ../$source || exit $?
asn_module=$(echo ../../../tests/${testno}-*.asn1) asn_module=`echo ../../../tests/${testno}-*.asn1`
# Create a Makefile for the project. # Create a Makefile for the project.
cat > Makefile <<EOM cat > Makefile <<EOM
...@@ -42,6 +43,8 @@ COMMON_FLAGS= -I. -DEMIT_ASN_DEBUG ...@@ -42,6 +43,8 @@ COMMON_FLAGS= -I. -DEMIT_ASN_DEBUG
CFLAGS=\${COMMON_FLAGS} ${CFLAGS} CFLAGS=\${COMMON_FLAGS} ${CFLAGS}
CXXFLAGS=\${COMMON_FLAGS} ${CXXFLAGS} CXXFLAGS=\${COMMON_FLAGS} ${CXXFLAGS}
CC=${CC}
all: check-executable all: check-executable
check-executable: compiled-module *.c* check-executable: compiled-module *.c*
@rm -f *.core @rm -f *.core
......
...@@ -12,7 +12,6 @@ asn1c_compiled_output(arg_t *arg, const char *fmt, ...) { ...@@ -12,7 +12,6 @@ asn1c_compiled_output(arg_t *arg, const char *fmt, ...) {
int lf_found; int lf_found;
va_list ap; va_list ap;
out_chunk_t *m; out_chunk_t *m;
char *buf;
int ret; int ret;
switch(arg->target->target) { switch(arg->target->target) {
...@@ -48,35 +47,30 @@ asn1c_compiled_output(arg_t *arg, const char *fmt, ...) { ...@@ -48,35 +47,30 @@ asn1c_compiled_output(arg_t *arg, const char *fmt, ...) {
if(lf_found) if(lf_found)
dst->indented = 0; dst->indented = 0;
/*
* Estimate necessary size.
*/
buf = "";
va_start(ap, fmt);
ret = vsnprintf(buf, 0, fmt, ap);
va_end(ap);
assert(ret >= 0);
/* /*
* Allocate buffer. * Allocate buffer.
*/ */
m = calloc(1, sizeof(out_chunk_t)); m = calloc(1, sizeof(out_chunk_t));
if(m == NULL) return -1; if(m == NULL) return -1;
m->len = ret + 1;
m->buf = malloc(ret + 1);
if(m->buf == NULL) {
free(m);
return -1;
}
/* m->len = 16;
* Fill the buffer. do {
*/ void *tmp;
va_start(ap, fmt); m->len <<= 2;
ret = vsnprintf(m->buf, m->len, fmt, ap); tmp = realloc(m->buf, m->len);
assert(ret < m->len); if(tmp) {
m->buf = (char *)tmp;
} else {
free(m->buf);
free(m);
return -1;
}
va_start(ap, fmt);
ret = vsnprintf(m->buf, m->len, fmt, ap);
va_end(ap);
} while(ret >= (m->len - 1) || ret < 0);
m->len = ret; m->len = ret;
va_end(ap);
if(arg->target->target == OT_INCLUDES) { if(arg->target->target == OT_INCLUDES) {
out_chunk_t *v; out_chunk_t *v;
......
...@@ -345,9 +345,11 @@ asn1f_make_known_external_type(const char *type_name) { ...@@ -345,9 +345,11 @@ asn1f_make_known_external_type(const char *type_name) {
int int
asn1f_check_known_external_type(const char *type_name) { asn1f_check_known_external_type(const char *type_name) {
void *p = bsearch(&type_name, known_types, known_types_count, if(known_types_count) {
sizeof(known_types[0]), _known_types_cmp); void *p = bsearch(&type_name, known_types, known_types_count,
if(p) return 0; sizeof(known_types[0]), _known_types_cmp);
if(p) return 0;
}
errno = ESRCH; errno = ESRCH;
return -1; return -1;
} }
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
* Copyright (c) 2003, 2004 Lev Walkin <vlm@lionet.info>. All rights reserved. * Copyright (c) 2003, 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
* Redistribution and modifications are permitted subject to BSD license. * Redistribution and modifications are permitted subject to BSD license.
*/ */
#define _POSIX_PTHREAD_SEMANTICS /* for Sun */
#define _REENTRANT /* for Sun */
#include <asn_internal.h> #include <asn_internal.h>
#include <GeneralizedTime.h> #include <GeneralizedTime.h>
#include <time.h> #include <time.h>
...@@ -34,10 +36,15 @@ static struct tm *gmtime_r(const time_t *tloc, struct tm *result) { ...@@ -34,10 +36,15 @@ static struct tm *gmtime_r(const time_t *tloc, struct tm *result) {
} }
#define tzset() _tzset() #define tzset() _tzset()
#define putenv() _putenv()
#define _EMULATE_TIMEGM #define _EMULATE_TIMEGM
#endif /* WIN32 */ #endif /* WIN32 */
#if defined(sun)
#define _EMULATE_TIMEGM
#endif
/* /*
* Where to look for offset from GMT, Phase I. * Where to look for offset from GMT, Phase I.
* Several platforms are known. * Several platforms are known.
...@@ -87,7 +94,7 @@ static time_t timegm(struct tm *tm) { ...@@ -87,7 +94,7 @@ static time_t timegm(struct tm *tm) {
char *buf; char *buf;
tz = getenv("TZ"); tz = getenv("TZ");
_putenv("TZ=UTC"); putenv("TZ=UTC");
tzset(); tzset();
tloc = mktime(tm); tloc = mktime(tm);
if (tz) { if (tz) {
...@@ -97,7 +104,7 @@ static time_t timegm(struct tm *tm) { ...@@ -97,7 +104,7 @@ static time_t timegm(struct tm *tm) {
} else { } else {
buf = "TZ="; buf = "TZ=";
} }
_putenv(buf); putenv(buf);
tzset(); tzset();
return tloc; return tloc;
} }
......
...@@ -57,7 +57,7 @@ REAL__dump(double d, int canonical, asn_app_consume_bytes_f *cb, void *app_key) ...@@ -57,7 +57,7 @@ REAL__dump(double d, int canonical, asn_app_consume_bytes_f *cb, void *app_key)
buf = "<NOT-A-NUMBER/>"; buf = "<NOT-A-NUMBER/>";
buflen = 15; buflen = 15;
return (cb(buf, buflen, app_key) < 0) ? -1 : buflen; return (cb(buf, buflen, app_key) < 0) ? -1 : buflen;
} else if(isinf(d)) { } else if(!finite(d)) {
if(copysign(1.0, d) < 0.0) { if(copysign(1.0, d) < 0.0) {
buf = "<MINUS-INFINITY/>"; buf = "<MINUS-INFINITY/>";
buflen = 17; buflen = 17;
...@@ -416,7 +416,7 @@ asn_double2REAL(REAL_t *st, double dbl_value) { ...@@ -416,7 +416,7 @@ asn_double2REAL(REAL_t *st, double dbl_value) {
st->buf[0] = 0x42; /* NaN */ st->buf[0] = 0x42; /* NaN */
st->buf[1] = 0; st->buf[1] = 0;
st->size = 1; st->size = 1;
} else if(isinf(dbl_value)) { } else if(!finite(dbl_value)) {
if(copysign(1.0, dbl_value) < 0.0) { if(copysign(1.0, dbl_value) < 0.0) {
st->buf[0] = 0x41; /* MINUS-INFINITY */ st->buf[0] = 0x41; /* MINUS-INFINITY */
} else { } else {
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
#include "config.h" #include "config.h"
#endif #endif
#include <stdio.h> /* For fprintf() */ #include <stdio.h> /* For snprintf(3) */
#include <stdlib.h> /* For *alloc(3) */ #include <stdlib.h> /* For *alloc(3) */
#include <string.h> /* For memcpy(3) */ #include <string.h> /* For memcpy(3) */
#include <sys/types.h> /* For size_t */ #include <sys/types.h> /* For size_t */
...@@ -21,13 +21,23 @@ ...@@ -21,13 +21,23 @@
#include <inttypes.h> /* C99 specifies this file */ #include <inttypes.h> /* C99 specifies this file */
#if defined(sun)
#include <ieeefp.h> /* for finite(3) */
#endif
/* /*
* Earlier FreeBSD version didn't have <stdint.h>, * 1. Earlier FreeBSD version didn't have <stdint.h>,
* but <inttypes.h> was present. * but <inttypes.h> was present.
* 2. Sun Solaris requires <alloca.h> for alloca(3),
* but does not have <stdint.h>.
*/ */
#if !defined(__FreeBSD__) || !defined(_SYS_INTTYPES_H_) /* Workaround */ #if (!defined(__FreeBSD__) || !defined(_SYS_INTTYPES_H_))
#if defined(sun)
#include <alloca.h> /* For alloca(3) */
#else
#include <stdint.h> /* SUSv2+ and C99 specify this file, for uintXX_t */ #include <stdint.h> /* SUSv2+ and C99 specify this file, for uintXX_t */
#endif #endif
#endif
#ifdef WIN32 #ifdef WIN32
#define snprintf _snprintf #define snprintf _snprintf
......
...@@ -14,20 +14,24 @@ check(char *time_str, time_t expect, int as_gmt) { ...@@ -14,20 +14,24 @@ check(char *time_str, time_t expect, int as_gmt) {
tloc = asn_GT2time(&gt, &tm, as_gmt); tloc = asn_GT2time(&gt, &tm, as_gmt);
printf("%s: [%s] -> %ld == %ld\n", printf("%s: [%s] -> %ld == %ld\n",
as_gmt?"GMT":"ofs", time_str, (long)tloc, (long)expect); as_gmt?"GMT":"ofs", time_str, (long)tloc, (long)expect);
if(tloc != -1)
printf("\t%04d-%02d-%02dT%02d:%02d:%02d%+03ld%02ld\n", if(tloc != -1) {
printf("\t%04d-%02d-%02dT%02d:%02d:%02d%+03ld%02ld\n",
tm.tm_year + 1900, tm.tm_year + 1900,
tm.tm_mon + 1, tm.tm_mon + 1,
tm.tm_mday, tm.tm_mday,
tm.tm_hour, tm.tm_hour,
tm.tm_min, tm.tm_min,
tm.tm_sec, tm.tm_sec,
(tm.tm_gmtoff / 3600), (GMTOFF(tm) / 3600),
labs(tm.tm_gmtoff % 3600) labs(GMTOFF(tm) % 3600)
); );
}
assert(tloc == expect); assert(tloc == expect);
assert(tloc == -1 || as_gmt == 0 || tm.tm_gmtoff == 0); #ifdef HAVE_TM_GMTOFF
assert(tloc == -1 || as_gmt == 0 || GMTOFF(tm) == 0);
#endif
if(!as_gmt) check(time_str, expect, 1); if(!as_gmt) check(time_str, expect, 1);
} }
......
#define __NO_ASN_TABLE__ #define __NO_ASN_TABLE__
#include <UTCTime.c>
#define __NO_ASSERT_H__
#include <GeneralizedTime.c> #include <GeneralizedTime.c>
#define __NO_ASN_TABLE__
#include <UTCTime.c>
#include <constraints.c> #include <constraints.c>
static void static void
...@@ -23,11 +23,11 @@ check(char *time_str, time_t sample, int as_gmt) { ...@@ -23,11 +23,11 @@ check(char *time_str, time_t sample, int as_gmt) {
tm.tm_hour, tm.tm_hour,
tm.tm_min, tm.tm_min,
tm.tm_sec, tm.tm_sec,
tm.tm_gmtoff GMTOFF(tm)
); );
assert(tloc == sample); assert(tloc == sample);
assert(tloc == -1 || as_gmt == 0 || tm.tm_gmtoff == 0); assert(tloc == -1 || as_gmt == 0 || GMTOFF(tm) == 0);
if(as_gmt) check(time_str, sample, as_gmt); if(as_gmt) check(time_str, sample, as_gmt);
} }
......
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