asn1c/skeletons/asn_system.h

83 lines
2.1 KiB
C
Raw Normal View History

2004-06-03 03:38:44 +00:00
/*-
* Copyright (c) 2003, 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
* Redistribution and modifications are permitted subject to BSD license.
*/
/*
* Miscellaneous system-dependent types.
*/
2004-10-20 15:50:55 +00:00
#ifndef _ASN_SYSTEM_H_
#define _ASN_SYSTEM_H_
2004-06-03 03:38:44 +00:00
2004-09-07 10:47:39 +00:00
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdio.h> /* For snprintf(3) */
2004-06-03 03:38:44 +00:00
#include <stdlib.h> /* For *alloc(3) */
#include <string.h> /* For memcpy(3) */
#include <sys/types.h> /* For size_t */
#include <stdarg.h> /* For va_start */
#include <stddef.h> /* for offsetof and ptrdiff_t */
2004-09-07 10:47:39 +00:00
2005-02-25 14:20:30 +00:00
#ifdef WIN32
2004-09-07 10:47:39 +00:00
2005-02-25 14:20:30 +00:00
#define snprintf _snprintf
#define vsnprintf _vsnprintf
#define alloca(size) _alloca(size)
2005-05-27 20:56:08 +00:00
#ifdef _MSC_VER /* MSVS.Net */
#define ssize_t SSIZE_T
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;
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <float.h>
#define isnan _isnan
#define finite _finite
#define copysign _copysign
#define ilogb _logb
2005-05-27 20:56:08 +00:00
#endif /* _MSC_VER */
2005-02-25 14:20:30 +00:00
#else /* !WIN32 */
#include <inttypes.h> /* C99 specifies this file */
2004-09-07 10:47:39 +00:00
/*
* 1. Earlier FreeBSD version didn't have <stdint.h>,
2004-09-07 10:47:39 +00:00
* but <inttypes.h> was present.
* 2. Sun Solaris requires <alloca.h> for alloca(3),
* but does not have <stdint.h>.
2004-09-07 10:47:39 +00:00
*/
2004-10-25 22:58:35 +00:00
#if (!defined(__FreeBSD__) || !defined(_SYS_INTTYPES_H_))
#if defined(sun)
#include <alloca.h> /* For alloca(3) */
2005-02-25 14:20:30 +00:00
#include <ieeefp.h> /* for finite(3) */
#else
2004-09-07 07:26:32 +00:00
#include <stdint.h> /* SUSv2+ and C99 specify this file, for uintXX_t */
2005-02-25 14:20:30 +00:00
#endif /* defined(sun) */
#endif
2004-08-11 07:17:22 +00:00
2004-09-07 07:26:32 +00:00
#endif /* WIN32 */
2004-08-11 07:17:22 +00:00
#ifndef __GNUC__
#define __attribute__(ignore)
#endif
2004-06-03 03:38:44 +00:00
2004-08-11 07:17:22 +00:00
#ifndef offsetof /* If not defined by <stddef.h> */
2004-06-03 03:38:44 +00:00
#define offsetof(s, m) ((ptrdiff_t)&(((s *)0)->m) - (ptrdiff_t)((s *)0))
#endif /* offsetof */
#ifndef MIN /* Suitable for comparing primitive types (integers) */
#if defined(__GNUC__)
#define MIN(a,b) ({ __typeof a _a = a; __typeof b _b = b; \
((_a)<(_b)?(_a):(_b)); })
#else /* !__GNUC__ */
#define MIN(a,b) ((a)<(b)?(a):(b)) /* Unsafe variant */
#endif /* __GNUC__ */
#endif /* MIN */
2004-10-20 15:50:55 +00:00
#endif /* _ASN_SYSTEM_H_ */