X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/46b0747592074017ff0ea4b33d4a7194235886e5..38f134e6a96c08fdd7d4ed07ca3550e8434d56e9:/libs/smux/include/stg/asn_system.h?ds=sidebyside diff --git a/libs/smux/include/stg/asn_system.h b/libs/smux/include/stg/asn_system.h index d7ebdaa4..d19837ed 100644 --- a/libs/smux/include/stg/asn_system.h +++ b/libs/smux/include/stg/asn_system.h @@ -1,35 +1,51 @@ /*- - * Copyright (c) 2003, 2004 Lev Walkin . All rights reserved. + * Copyright (c) 2003, 2004, 2007 Lev Walkin . + * All rights reserved. * Redistribution and modifications are permitted subject to BSD license. */ /* * Miscellaneous system-dependent types. */ -#ifndef _ASN_SYSTEM_H_ -#define _ASN_SYSTEM_H_ +#ifndef ASN_SYSTEM_H +#define ASN_SYSTEM_H #ifdef HAVE_CONFIG_H #include "config.h" #endif +#ifndef _BSD_SOURCE +#define _BSD_SOURCE /* for snprintf() on some linux systems */ +#endif + #include /* For snprintf(3) */ #include /* For *alloc(3) */ #include /* For memcpy(3) */ #include /* For size_t */ +#include /* For LONG_MAX */ #include /* For va_start */ #include /* for offsetof and ptrdiff_t */ -#ifdef WIN32 +#ifdef HAVE_ALLOCA_H +#include /* For alloca(3) */ +#endif + +#ifdef _WIN32 #include -#include #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) << 8) & 0xff0000) \ + | (((l) >> 8) & 0xff00) \ + | ((l >> 24) & 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 +53,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 #include @@ -44,9 +61,11 @@ typedef unsigned int uint32_t; #define finite _finite #define copysign _copysign #define ilogb _logb +#else /* !_MSC_VER */ +#include #endif /* _MSC_VER */ -#else /* !WIN32 */ +#else /* !_WIN32 */ #if defined(__vxworks) #include @@ -74,20 +93,34 @@ typedef unsigned int uint32_t; #endif /* defined(sun) */ #endif +#include /* for ntohl() */ +#define sys_ntohl(foo) ntohl(foo) + #endif /* defined(__vxworks) */ -#endif /* WIN32 */ +#endif /* _WIN32 */ #if __GNUC__ >= 3 #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 */ #define offsetof(s, m) ((ptrdiff_t)&(((s *)0)->m) - (ptrdiff_t)((s *)0)) #endif /* offsetof */ @@ -101,4 +134,4 @@ typedef unsigned int uint32_t; #endif /* __GNUC__ */ #endif /* MIN */ -#endif /* _ASN_SYSTEM_H_ */ +#endif /* ASN_SYSTEM_H */