Commit 3e86a4ea authored by Lev Walkin's avatar Lev Walkin
Browse files

thread safety to the masses

parent 7c97b88e
/*- /*-
* Copyright (c) 2003, 2004, 2005 Lev Walkin <vlm@lionet.info>. * Copyright (c) 2003, 2004, 2005, 2007 Lev Walkin <vlm@lionet.info>.
* All rights reserved. * All rights reserved.
* Redistribution and modifications are permitted subject to BSD license. * Redistribution and modifications are permitted subject to BSD license.
*/ */
...@@ -35,10 +35,17 @@ int get_asn1c_environment_version(void); /* Run-time version */ ...@@ -35,10 +35,17 @@ int get_asn1c_environment_version(void); /* Run-time version */
#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__ #ifdef __GNUC__
#define ASN_DEBUG(fmt, args...) do { \ #ifdef ASN_THREAD_SAFE
fprintf(stderr, fmt, ##args); \ #define asn_debug_indent 0
fprintf(stderr, " (%s:%d)\n", \ #endif
__FILE__, __LINE__); \ int asn_debug_indent;
#endif
#define ASN_DEBUG(fmt, args...) do { \
int adi = asn_debug_indent; \
while(adi--) fprintf(stderr, " "); \
fprintf(stderr, fmt, ##args); \
fprintf(stderr, " (%s:%d)\n", \
__FILE__, __LINE__); \
} while(0) } while(0)
#else /* !__GNUC__ */ #else /* !__GNUC__ */
void ASN_DEBUG_f(const char *fmt, ...); void ASN_DEBUG_f(const char *fmt, ...);
......
/*- /*-
* Copyright (c) 2003, 2004 Lev Walkin <vlm@lionet.info>. All rights reserved. * Copyright (c) 2003, 2004, 2007 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.
*/ */
/* /*
...@@ -103,6 +104,11 @@ typedef unsigned int uint32_t; ...@@ -103,6 +104,11 @@ typedef unsigned int uint32_t;
#endif #endif
#endif #endif
/* Figure out if thread safety is requested */
#if !defined(ASN_THREAD_SAFE) && (defined(THREAD_SAFE) || define(_REENTRANT))
#define ASN_THREAD_SAFE
#endif /* Thread safety */
#ifndef offsetof /* If not defined by <stddef.h> */ #ifndef offsetof /* If not defined by <stddef.h> */
#define offsetof(s, m) ((ptrdiff_t)&(((s *)0)->m) - (ptrdiff_t)((s *)0)) #define offsetof(s, m) ((ptrdiff_t)&(((s *)0)->m) - (ptrdiff_t)((s *)0))
#endif /* offsetof */ #endif /* offsetof */
......
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