X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/8e80bb9cec2c90dd61f810fb1525932a434288eb..085c36723242f7bd1e0fd9bf49b950da6cb96039:/libs/smux/include/stg/asn_system.h?ds=inline diff --git a/libs/smux/include/stg/asn_system.h b/libs/smux/include/stg/asn_system.h index d19837ed..fa8cf116 100644 --- a/libs/smux/include/stg/asn_system.h +++ b/libs/smux/include/stg/asn_system.h @@ -1,6 +1,5 @@ -/*- - * Copyright (c) 2003, 2004, 2007 Lev Walkin . - * All rights reserved. +/* + * Copyright (c) 2003-2017 Lev Walkin . All rights reserved. * Redistribution and modifications are permitted subject to BSD license. */ /* @@ -13,6 +12,10 @@ #include "config.h" #endif +#ifndef _DEFAULT_SOURCE +#define _DEFAULT_SOURCE 1 +#endif + #ifndef _BSD_SOURCE #define _BSD_SOURCE /* for snprintf() on some linux systems */ #endif @@ -25,10 +28,6 @@ #include /* For va_start */ #include /* for offsetof and ptrdiff_t */ -#ifdef HAVE_ALLOCA_H -#include /* For alloca(3) */ -#endif - #ifdef _WIN32 #include @@ -47,12 +46,16 @@ #endif #ifndef ASSUMESTDTYPES /* Standard types have been defined elsewhere */ #define ssize_t SSIZE_T +#if _MSC_VER < 1600 typedef char int8_t; typedef short int16_t; typedef int int32_t; typedef unsigned char uint8_t; typedef unsigned short uint16_t; typedef unsigned int uint32_t; +#else /* _MSC_VER >= 1600 */ +#include +#endif /* _MSC_VER < 1600 */ #endif /* ASSUMESTDTYPES */ #define WIN32_LEAN_AND_MEAN #include @@ -72,48 +75,21 @@ typedef unsigned int uint32_t; #else /* !defined(__vxworks) */ #include /* C99 specifies this file */ -/* - * 1. Earlier FreeBSD version didn't have , - * but was present. - * 2. Sun Solaris requires for alloca(3), - * but does not have . - */ -#if (!defined(__FreeBSD__) || !defined(_SYS_INTTYPES_H_)) -#if defined(sun) -#include /* For alloca(3) */ -#include /* for finite(3) */ -#elif defined(__hpux) -#ifdef __GNUC__ -#include /* For alloca(3) */ -#else /* !__GNUC__ */ -#define inline -#endif /* __GNUC__ */ -#else -#include /* SUSv2+ and C99 specify this file, for uintXX_t */ -#endif /* defined(sun) */ -#endif - #include /* for ntohl() */ #define sys_ntohl(foo) ntohl(foo) - #endif /* defined(__vxworks) */ #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 +#if __GNUC__ >= 3 || defined(__clang__) +#define CC_ATTRIBUTE(attr) __attribute__((attr)) #else -#ifndef GCC_PRINTFLIKE -#define GCC_PRINTFLIKE(fmt,var) /* nothing */ -#endif -#ifndef GCC_NOTUSED -#define GCC_NOTUSED +#define CC_ATTRIBUTE(attr) #endif +#define CC_PRINTFLIKE(fmt, var) CC_ATTRIBUTE(format(printf, fmt, var)) +#define CC_NOTUSED CC_ATTRIBUTE(unused) +#ifndef CC_ATTR_NO_SANITIZE +#define CC_ATTR_NO_SANITIZE(what) CC_ATTRIBUTE(no_sanitize(what)) #endif /* Figure out if thread safety is requested */ @@ -134,4 +110,41 @@ typedef unsigned int uint32_t; #endif /* __GNUC__ */ #endif /* MIN */ +#if __STDC_VERSION__ >= 199901L +#ifndef SIZE_MAX +#define SIZE_MAX ((~((size_t)0)) >> 1) +#endif + +#ifndef RSIZE_MAX /* C11, Annex K */ +#define RSIZE_MAX (SIZE_MAX >> 1) +#endif +#ifndef RSSIZE_MAX /* Halve signed size even further than unsigned */ +#define RSSIZE_MAX ((ssize_t)(RSIZE_MAX >> 1)) +#endif +#else /* Old compiler */ +#undef SIZE_MAX +#undef RSIZE_MAX +#undef RSSIZE_MAX +#define SIZE_MAX ((~((size_t)0)) >> 1) +#define RSIZE_MAX (SIZE_MAX >> 1) +#define RSSIZE_MAX ((ssize_t)(RSIZE_MAX >> 1)) +#endif + +#if __STDC_VERSION__ >= 199901L +#define ASN_PRI_SIZE "zu" +#define ASN_PRI_SSIZE "zd" +#define ASN_PRIuMAX PRIuMAX +#define ASN_PRIdMAX PRIdMAX +#else +#define ASN_PRI_SIZE "lu" +#define ASN_PRI_SSIZE "ld" +#if LLONG_MAX > LONG_MAX +#define ASN_PRIuMAX "llu" +#define ASN_PRIdMAX "lld" +#else +#define ASN_PRIuMAX "lu" +#define ASN_PRIdMAX "ld" +#endif +#endif + #endif /* ASN_SYSTEM_H */