summaryrefslogtreecommitdiffstats
path: root/include/asn1c/asn_system.h
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2010-07-20 00:03:44 +0200
committerHarald Welte <laforge@gnumonks.org>2010-07-20 00:03:44 +0200
commitec0e217b0647eb798576a7d3366b39c159c00624 (patch)
tree88404309798e2fac2844b4e76224b6ad1d7c5375 /include/asn1c/asn_system.h
parentb1e3ee75318536dac0a91817c5e4d35d61893ba6 (diff)
Update to asn1c official repository svn trunk r1409
Diffstat (limited to 'include/asn1c/asn_system.h')
-rw-r--r--include/asn1c/asn_system.h29
1 files changed, 27 insertions, 2 deletions
diff --git a/include/asn1c/asn_system.h b/include/asn1c/asn_system.h
index d7ebdaa..0a9b092 100644
--- a/include/asn1c/asn_system.h
+++ b/include/asn1c/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.
*/
/*
@@ -16,20 +17,27 @@
#include <stdlib.h> /* For *alloc(3) */
#include <string.h> /* For memcpy(3) */
#include <sys/types.h> /* For size_t */
+#include <limits.h> /* For LONG_MAX */
#include <stdarg.h> /* For va_start */
#include <stddef.h> /* for offsetof and ptrdiff_t */
#ifdef WIN32
#include <malloc.h>
-#include <stdint.h>
#define snprintf _snprintf
#define vsnprintf _vsnprintf
+/* To avoid linking with ws2_32.lib, here's the definition of ntohl() */
+#define sys_ntohl(l) ((((l) << 24) & 0xff000000) \
+ | (((l) << 16) & 0xff0000) \
+ | (((l) << 8) & 0xff00) \
+ | ((l) & 0xff))
+
#ifdef _MSC_VER /* MSVS.Net */
#ifndef __cplusplus
#define inline __inline
#endif
+#ifndef ASSUMESTDTYPES /* Standard types have been defined elsewhere */
#define ssize_t SSIZE_T
typedef char int8_t;
typedef short int16_t;
@@ -37,6 +45,7 @@ typedef int int32_t;
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned int uint32_t;
+#endif /* ASSUMESTDTYPES */
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <float.h>
@@ -44,6 +53,8 @@ typedef unsigned int uint32_t;
#define finite _finite
#define copysign _copysign
#define ilogb _logb
+#else /* !_MSC_VER */
+#include <stdint.h>
#endif /* _MSC_VER */
#else /* !WIN32 */
@@ -74,6 +85,9 @@ typedef unsigned int uint32_t;
#endif /* defined(sun) */
#endif
+#include <netinet/in.h> /* for ntohl() */
+#define sys_ntohl(foo) ntohl(foo)
+
#endif /* defined(__vxworks) */
#endif /* WIN32 */
@@ -82,12 +96,23 @@ typedef unsigned int uint32_t;
#ifndef GCC_PRINTFLIKE
#define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
#endif
+#ifndef GCC_NOTUSED
+#define GCC_NOTUSED __attribute__((unused))
+#endif
#else
#ifndef GCC_PRINTFLIKE
#define GCC_PRINTFLIKE(fmt,var) /* nothing */
#endif
+#ifndef GCC_NOTUSED
+#define GCC_NOTUSED
+#endif
#endif
+/* Figure out if thread safety is requested */
+#if !defined(ASN_THREAD_SAFE) && (defined(THREAD_SAFE) || defined(_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 */