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

portability

parent 3af51b46
...@@ -24,10 +24,8 @@ typedef int ssize_t; ...@@ -24,10 +24,8 @@ typedef int ssize_t;
#endif #endif
#ifdef WIN32 #ifdef WIN32
#define snprintf(str, size, format, args...) \ #define snprintf _snprintf
_snprintf(str, size, format, ##args) #define vsnprintf _vsnprintf
#define vsnprintf(str, size, format, ap) \
_vsnprintf(str, size, format, ap)
#define alloca(size) _alloca(size) #define alloca(size) _alloca(size)
#endif #endif
...@@ -59,10 +57,15 @@ typedef int ssize_t; ...@@ -59,10 +57,15 @@ typedef int ssize_t;
*/ */
#ifndef ASN_DEBUG /* If debugging code is not defined elsewhere... */ #ifndef ASN_DEBUG /* If debugging code is not defined elsewhere... */
#if EMIT_ASN_DEBUG == 1 /* And it was asked to emit this code... */ #if EMIT_ASN_DEBUG == 1 /* And it was asked to emit this code... */
#ifdef __GNUC__
#define ASN_DEBUG(fmt, args...) do { \ #define ASN_DEBUG(fmt, args...) do { \
fprintf(stderr, fmt, ##args); \ fprintf(stderr, fmt, ##args); \
fprintf(stderr, "\n"); \ fprintf(stderr, "\n"); \
} while(0) } while(0)
#else /* !__GNUC__ */
extern void ASN_DEBUG_f(const char *fmt, ...);
#define ASN_DEBUG ASN_DEBUG_f
#endif /* __GNUC__ */
#else /* EMIT_ASN_DEBUG */ #else /* EMIT_ASN_DEBUG */
#define ASN_DEBUG(fmt, args...) ((void)0) /* Emit a no-op operator */ #define ASN_DEBUG(fmt, args...) ((void)0) /* Emit a no-op operator */
#endif /* EMIT_ASN_DEBUG */ #endif /* EMIT_ASN_DEBUG */
......
...@@ -56,3 +56,15 @@ _print2fp(const void *buffer, size_t size, void *app_key) { ...@@ -56,3 +56,15 @@ _print2fp(const void *buffer, size_t size, void *app_key) {
return 0; return 0;
} }
/*
* Some compilers do not support variable args macros.
* This function is a replacement of ASN_DEBUG() macro.
*/
void ASN_DEBUG_f(const char *fmt, ...) {
va_list ap;
va_start(ap, fmt);
vfprintf(stderr, fmt, ap);
fprintf(stderr, "\n");
va_end(ap);
}
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