things necessary for Sun Solaris 9 @ sparc

diff --git a/skeletons/GeneralizedTime.c b/skeletons/GeneralizedTime.c
index 631f3ed..9d5fe4a 100644
--- a/skeletons/GeneralizedTime.c
+++ b/skeletons/GeneralizedTime.c
@@ -2,6 +2,8 @@
  * Copyright (c) 2003, 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
  * Redistribution and modifications are permitted subject to BSD license.
  */
+#define	_POSIX_PTHREAD_SEMANTICS	/* for Sun */
+#define	_REENTRANT			/* for Sun */
 #include <asn_internal.h>
 #include <GeneralizedTime.h>
 #include <time.h>
@@ -34,10 +36,15 @@
 }
 
 #define	tzset()	_tzset()
+#define	putenv()	_putenv()
 #define	_EMULATE_TIMEGM
 
 #endif	/* WIN32 */
 
+#if	defined(sun)
+#define	_EMULATE_TIMEGM
+#endif
+
 /*
  * Where to look for offset from GMT, Phase I.
  * Several platforms are known.
@@ -87,7 +94,7 @@
 	char *buf;
 
 	tz = getenv("TZ");
-	_putenv("TZ=UTC");
+	putenv("TZ=UTC");
 	tzset();
 	tloc = mktime(tm);
 	if (tz) {
@@ -97,7 +104,7 @@
 	} else {
 		buf = "TZ=";
 	}
-	_putenv(buf);
+	putenv(buf);
 	tzset();
 	return tloc;
 }
diff --git a/skeletons/REAL.c b/skeletons/REAL.c
index 6d3e55e..d395c84 100644
--- a/skeletons/REAL.c
+++ b/skeletons/REAL.c
@@ -57,7 +57,7 @@
 		buf = "<NOT-A-NUMBER/>";
 		buflen = 15;
 		return (cb(buf, buflen, app_key) < 0) ? -1 : buflen;
-	} else if(isinf(d)) {
+	} else if(!finite(d)) {
 		if(copysign(1.0, d) < 0.0) {
 			buf = "<MINUS-INFINITY/>";
 			buflen = 17;
@@ -416,7 +416,7 @@
 			st->buf[0] = 0x42;	/* NaN */
 			st->buf[1] = 0;
 			st->size = 1;
-		} else if(isinf(dbl_value)) {
+		} else if(!finite(dbl_value)) {
 			if(copysign(1.0, dbl_value) < 0.0) {
 				st->buf[0] = 0x41;	/* MINUS-INFINITY */
 			} else {
diff --git a/skeletons/asn_types.h b/skeletons/asn_types.h
index 81a00c3..cf5c87e 100644
--- a/skeletons/asn_types.h
+++ b/skeletons/asn_types.h
@@ -12,7 +12,7 @@
 #include "config.h"
 #endif
 
-#include <stdio.h>	/* For fprintf() */
+#include <stdio.h>	/* For snprintf(3) */
 #include <stdlib.h>	/* For *alloc(3) */
 #include <string.h>	/* For memcpy(3) */
 #include <sys/types.h>	/* For size_t */
@@ -21,13 +21,23 @@
 
 #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.
+ * 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 */
 #endif
+#endif
 
 #ifdef	WIN32
 #define	 snprintf	_snprintf
diff --git a/skeletons/tests/check-GeneralizedTime.c b/skeletons/tests/check-GeneralizedTime.c
index 6c35a1c..0cec17d 100644
--- a/skeletons/tests/check-GeneralizedTime.c
+++ b/skeletons/tests/check-GeneralizedTime.c
@@ -14,20 +14,24 @@
 	tloc = asn_GT2time(&gt, &tm, as_gmt);
 	printf("%s: [%s] -> %ld == %ld\n",
 		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_mon + 1,
 		tm.tm_mday,
 		tm.tm_hour,
 		tm.tm_min,
 		tm.tm_sec,
-		(tm.tm_gmtoff / 3600),
-		labs(tm.tm_gmtoff % 3600)
-	);
+		(GMTOFF(tm) / 3600),
+		labs(GMTOFF(tm) % 3600)
+		);
+	}
 	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);
 }
diff --git a/skeletons/tests/check-UTCTime.c b/skeletons/tests/check-UTCTime.c
index d626359..6762865 100644
--- a/skeletons/tests/check-UTCTime.c
+++ b/skeletons/tests/check-UTCTime.c
@@ -1,7 +1,7 @@
 #define	__NO_ASN_TABLE__
-#include <UTCTime.c>
-#define	__NO_ASSERT_H__
 #include <GeneralizedTime.c>
+#define	__NO_ASN_TABLE__
+#include <UTCTime.c>
 #include <constraints.c>
 
 static void
@@ -23,11 +23,11 @@
 		tm.tm_hour,
 		tm.tm_min,
 		tm.tm_sec,
-		tm.tm_gmtoff
+		GMTOFF(tm)
 	);
 	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);
 }