blob: d7ebdaa4e16a2636184db6ba4fe34fda5860a6bc [file] [log] [blame]
vlmfa67ddc2004-06-03 03:38:44 +00001/*-
2 * Copyright (c) 2003, 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
3 * Redistribution and modifications are permitted subject to BSD license.
4 */
5/*
6 * Miscellaneous system-dependent types.
7 */
vlm9de248e2004-10-20 15:50:55 +00008#ifndef _ASN_SYSTEM_H_
9#define _ASN_SYSTEM_H_
vlmfa67ddc2004-06-03 03:38:44 +000010
vlm75021432004-09-07 10:47:39 +000011#ifdef HAVE_CONFIG_H
12#include "config.h"
13#endif
14
vlm6534a8d2004-10-20 15:40:04 +000015#include <stdio.h> /* For snprintf(3) */
vlmfa67ddc2004-06-03 03:38:44 +000016#include <stdlib.h> /* For *alloc(3) */
17#include <string.h> /* For memcpy(3) */
18#include <sys/types.h> /* For size_t */
19#include <stdarg.h> /* For va_start */
vlmfa67ddc2004-06-03 03:38:44 +000020#include <stddef.h> /* for offsetof and ptrdiff_t */
vlm75021432004-09-07 10:47:39 +000021
vlm8a09e0f2005-02-25 14:20:30 +000022#ifdef WIN32
23
vlmb5a69432006-05-02 18:55:41 +000024#include <malloc.h>
25#include <stdint.h>
vlm8a09e0f2005-02-25 14:20:30 +000026#define snprintf _snprintf
27#define vsnprintf _vsnprintf
vlm8a09e0f2005-02-25 14:20:30 +000028
vlm0b569402005-05-27 20:56:08 +000029#ifdef _MSC_VER /* MSVS.Net */
vlm7c05fdf2005-08-17 18:39:36 +000030#ifndef __cplusplus
31#define inline __inline
32#endif
vlm0b569402005-05-27 20:56:08 +000033#define ssize_t SSIZE_T
34typedef char int8_t;
35typedef short int16_t;
36typedef int int32_t;
37typedef unsigned char uint8_t;
38typedef unsigned short uint16_t;
39typedef unsigned int uint32_t;
40#define WIN32_LEAN_AND_MEAN
41#include <windows.h>
vlmcb4aaa72005-07-01 08:28:18 +000042#include <float.h>
43#define isnan _isnan
44#define finite _finite
45#define copysign _copysign
46#define ilogb _logb
vlm0b569402005-05-27 20:56:08 +000047#endif /* _MSC_VER */
48
vlm8a09e0f2005-02-25 14:20:30 +000049#else /* !WIN32 */
50
vlmb5a69432006-05-02 18:55:41 +000051#if defined(__vxworks)
52#include <types/vxTypes.h>
53#else /* !defined(__vxworks) */
54
vlm75021432004-09-07 10:47:39 +000055#include <inttypes.h> /* C99 specifies this file */
vlm75021432004-09-07 10:47:39 +000056/*
vlm6534a8d2004-10-20 15:40:04 +000057 * 1. Earlier FreeBSD version didn't have <stdint.h>,
vlm75021432004-09-07 10:47:39 +000058 * but <inttypes.h> was present.
vlm6534a8d2004-10-20 15:40:04 +000059 * 2. Sun Solaris requires <alloca.h> for alloca(3),
60 * but does not have <stdint.h>.
vlm75021432004-09-07 10:47:39 +000061 */
vlm8d0d3962004-10-25 22:58:35 +000062#if (!defined(__FreeBSD__) || !defined(_SYS_INTTYPES_H_))
vlm6534a8d2004-10-20 15:40:04 +000063#if defined(sun)
64#include <alloca.h> /* For alloca(3) */
vlm8a09e0f2005-02-25 14:20:30 +000065#include <ieeefp.h> /* for finite(3) */
vlm9d6283e2006-03-16 22:29:55 +000066#elif defined(__hpux)
67#ifdef __GNUC__
68#include <alloca.h> /* For alloca(3) */
69#else /* !__GNUC__ */
70#define inline
71#endif /* __GNUC__ */
vlm6534a8d2004-10-20 15:40:04 +000072#else
vlma4294b72004-09-07 07:26:32 +000073#include <stdint.h> /* SUSv2+ and C99 specify this file, for uintXX_t */
vlm8a09e0f2005-02-25 14:20:30 +000074#endif /* defined(sun) */
vlm6534a8d2004-10-20 15:40:04 +000075#endif
vlmfa67ddc2004-06-03 03:38:44 +000076
vlmb5a69432006-05-02 18:55:41 +000077#endif /* defined(__vxworks) */
78
vlma4294b72004-09-07 07:26:32 +000079#endif /* WIN32 */
vlm6e73a042004-08-11 07:17:22 +000080
vlm8a463242006-09-15 18:52:36 +000081#if __GNUC__ >= 3
82#ifndef GCC_PRINTFLIKE
83#define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
84#endif
85#else
86#ifndef GCC_PRINTFLIKE
87#define GCC_PRINTFLIKE(fmt,var) /* nothing */
88#endif
vlm6e73a042004-08-11 07:17:22 +000089#endif
90
91#ifndef offsetof /* If not defined by <stddef.h> */
vlmfa67ddc2004-06-03 03:38:44 +000092#define offsetof(s, m) ((ptrdiff_t)&(((s *)0)->m) - (ptrdiff_t)((s *)0))
93#endif /* offsetof */
94
vlmfa67ddc2004-06-03 03:38:44 +000095#ifndef MIN /* Suitable for comparing primitive types (integers) */
96#if defined(__GNUC__)
97#define MIN(a,b) ({ __typeof a _a = a; __typeof b _b = b; \
98 ((_a)<(_b)?(_a):(_b)); })
99#else /* !__GNUC__ */
100#define MIN(a,b) ((a)<(b)?(a):(b)) /* Unsafe variant */
101#endif /* __GNUC__ */
102#endif /* MIN */
103
vlm9de248e2004-10-20 15:50:55 +0000104#endif /* _ASN_SYSTEM_H_ */