diff options
author | Lev Walkin <vlm@lionet.info> | 2004-08-11 07:17:22 +0000 |
---|---|---|
committer | Lev Walkin <vlm@lionet.info> | 2004-08-11 07:17:22 +0000 |
commit | 64399727b7324e8252b902e2c0d0f18ab826f88e (patch) | |
tree | 983959c7bdffee2608e72e91fc78a89215077ff6 /skeletons | |
parent | 2c962736991d1a2759a38077335662f7936af2c2 (diff) |
Win32 portability fixes
Diffstat (limited to 'skeletons')
-rw-r--r-- | skeletons/GeneralizedTime.c | 7 | ||||
-rw-r--r-- | skeletons/OBJECT_IDENTIFIER.c | 6 | ||||
-rw-r--r-- | skeletons/asn_types.h | 23 |
3 files changed, 33 insertions, 3 deletions
diff --git a/skeletons/GeneralizedTime.c b/skeletons/GeneralizedTime.c index 5a3120d1..9e8375e5 100644 --- a/skeletons/GeneralizedTime.c +++ b/skeletons/GeneralizedTime.c @@ -9,6 +9,13 @@ #include <assert.h> #endif /* __NO_ASSERT_H__ */ +#ifdef WIN32 +#define localtime_r(tlocp, tmp) (*tmp = localtime(&tlocp)) +#warning PLEASE STOP AND READ! +#warning localtime_r is implemented via localtime(), which is not thread-safe. You must fix the code to insert appropriate locking if you want to use asn_GT2time() or asn_UT2time(). +#warning PLEASE STOP AND READ! +#endif + #ifndef __NO_ASN_TABLE__ /* diff --git a/skeletons/OBJECT_IDENTIFIER.c b/skeletons/OBJECT_IDENTIFIER.c index c910a8cc..1e4fe594 100644 --- a/skeletons/OBJECT_IDENTIFIER.c +++ b/skeletons/OBJECT_IDENTIFIER.c @@ -359,11 +359,15 @@ OBJECT_IDENTIFIER_set_single_arc(uint8_t *arcbuf, void *arcval, unsigned int arc unsigned LE = 1; unsigned isLittleEndian = *(char *)&LE; #endif - uint8_t buffer[arcval_size]; uint8_t *tp, *tend; unsigned int cache; uint8_t *bp = arcbuf; int bits; +#ifdef __GNUC__ + uint8_t buffer[arcval_size]; +#else + uint8_t *buffer = alloca(arcval_size); +#endif if(isLittleEndian && !prepared_order) { uint8_t *a = arcval + arcval_size - 1; diff --git a/skeletons/asn_types.h b/skeletons/asn_types.h index 6d426673..d2633f6f 100644 --- a/skeletons/asn_types.h +++ b/skeletons/asn_types.h @@ -13,10 +13,29 @@ #include <string.h> /* For memcpy(3) */ #include <sys/types.h> /* For size_t */ #include <stdarg.h> /* For va_start */ -#include <inttypes.h> /* C99 Standard specifies this file, for uintXX_t */ #include <stddef.h> /* for offsetof and ptrdiff_t */ +#if __STDC_VERSION__ < 199901L +#include <inttypes.h> /* C99 Standard specifies this file, for uintXX_t */ +#else +typedef unsigned char uint8_t; +typedef unsigned short int uint16_t; +typedef unsigned int uint32_t; +typedef int ssize_t; +#endif + +#ifdef WIN32 +#define snprintf(str, size, format, args...) \ + _snprintf(str, size, format, ##args) +#define vsnprintf(str, size, format, ap) \ + _vsnprintf(str, size, format, ap) +#define alloca(size) _alloca(size) +#endif + +#ifndef __GNUC__ +#define __attribute__(ignore) +#endif -#ifndef offsetof +#ifndef offsetof /* If not defined by <stddef.h> */ #define offsetof(s, m) ((ptrdiff_t)&(((s *)0)->m) - (ptrdiff_t)((s *)0)) #endif /* offsetof */ |