aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvlm <vlm@59561ff5-6e30-0410-9f3c-9617f08c8826>2007-06-29 11:38:57 +0000
committervlm <vlm@59561ff5-6e30-0410-9f3c-9617f08c8826>2007-06-29 11:38:57 +0000
commitd97308e7befc01baefd9aa98e929551ae080539d (patch)
tree495f71f503d9eeef00355ba9eea2dc77dfa7e796
parent36fc702cec3477fb71d4b27a417290a14b8cd86b (diff)
thread safety to the masses
git-svn-id: https://asn1c.svn.sourceforge.net/svnroot/asn1c/trunk@1360 59561ff5-6e30-0410-9f3c-9617f08c8826
-rw-r--r--skeletons/asn_internal.h17
-rw-r--r--skeletons/asn_system.h8
2 files changed, 19 insertions, 6 deletions
diff --git a/skeletons/asn_internal.h b/skeletons/asn_internal.h
index 3f99452f..674ed511 100644
--- a/skeletons/asn_internal.h
+++ b/skeletons/asn_internal.h
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 2003, 2004, 2005 Lev Walkin <vlm@lionet.info>.
+ * Copyright (c) 2003, 2004, 2005, 2007 Lev Walkin <vlm@lionet.info>.
* All rights reserved.
* Redistribution and modifications are permitted subject to BSD license.
*/
@@ -35,10 +35,17 @@ int get_asn1c_environment_version(void); /* Run-time version */
#ifndef ASN_DEBUG /* If debugging code is not defined elsewhere... */
#if EMIT_ASN_DEBUG == 1 /* And it was asked to emit this code... */
#ifdef __GNUC__
-#define ASN_DEBUG(fmt, args...) do { \
- fprintf(stderr, fmt, ##args); \
- fprintf(stderr, " (%s:%d)\n", \
- __FILE__, __LINE__); \
+#ifdef ASN_THREAD_SAFE
+#define asn_debug_indent 0
+#endif
+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)
#else /* !__GNUC__ */
void ASN_DEBUG_f(const char *fmt, ...);
diff --git a/skeletons/asn_system.h b/skeletons/asn_system.h
index b1e0212e..51af1dfb 100644
--- a/skeletons/asn_system.h
+++ b/skeletons/asn_system.h
@@ -1,5 +1,6 @@
/*-
- * 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.
*/
/*
@@ -103,6 +104,11 @@ typedef unsigned int uint32_t;
#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> */
#define offsetof(s, m) ((ptrdiff_t)&(((s *)0)->m) - (ptrdiff_t)((s *)0))
#endif /* offsetof */