vlm | fa67ddc | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 1 | /*- |
| 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 | */ |
| 8 | #ifndef _ASN_TYPES_H_ |
| 9 | #define _ASN_TYPES_H_ |
| 10 | |
vlm | 7502143 | 2004-09-07 10:47:39 +0000 | [diff] [blame] | 11 | #ifdef HAVE_CONFIG_H |
| 12 | #include "config.h" |
| 13 | #endif |
| 14 | |
vlm | fa67ddc | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 15 | #include <stdio.h> /* For fprintf() */ |
| 16 | #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 */ |
vlm | fa67ddc | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 20 | #include <stddef.h> /* for offsetof and ptrdiff_t */ |
vlm | 7502143 | 2004-09-07 10:47:39 +0000 | [diff] [blame] | 21 | |
| 22 | #include <inttypes.h> /* C99 specifies this file */ |
| 23 | |
| 24 | /* |
| 25 | * Earlier FreeBSD version didn't have <stdint.h>, |
| 26 | * but <inttypes.h> was present. |
| 27 | */ |
| 28 | #if !defined(__FreeBSD__) || !defined(_SYS_INTTYPES_H_) /* Workaround */ |
vlm | a4294b7 | 2004-09-07 07:26:32 +0000 | [diff] [blame] | 29 | #include <stdint.h> /* SUSv2+ and C99 specify this file, for uintXX_t */ |
vlm | 7502143 | 2004-09-07 10:47:39 +0000 | [diff] [blame] | 30 | #endif |
vlm | fa67ddc | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 31 | |
vlm | a4294b7 | 2004-09-07 07:26:32 +0000 | [diff] [blame] | 32 | #ifdef WIN32 |
vlm | f5202a5 | 2004-08-11 08:32:04 +0000 | [diff] [blame] | 33 | #define snprintf _snprintf |
| 34 | #define vsnprintf _vsnprintf |
vlm | 6e73a04 | 2004-08-11 07:17:22 +0000 | [diff] [blame] | 35 | #define alloca(size) _alloca(size) |
vlm | a4294b7 | 2004-09-07 07:26:32 +0000 | [diff] [blame] | 36 | #endif /* WIN32 */ |
vlm | 6e73a04 | 2004-08-11 07:17:22 +0000 | [diff] [blame] | 37 | |
| 38 | #ifndef __GNUC__ |
| 39 | #define __attribute__(ignore) |
| 40 | #endif |
| 41 | |
| 42 | #ifndef offsetof /* If not defined by <stddef.h> */ |
vlm | fa67ddc | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 43 | #define offsetof(s, m) ((ptrdiff_t)&(((s *)0)->m) - (ptrdiff_t)((s *)0)) |
| 44 | #endif /* offsetof */ |
| 45 | |
vlm | fa67ddc | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 46 | #ifndef MIN /* Suitable for comparing primitive types (integers) */ |
| 47 | #if defined(__GNUC__) |
| 48 | #define MIN(a,b) ({ __typeof a _a = a; __typeof b _b = b; \ |
| 49 | ((_a)<(_b)?(_a):(_b)); }) |
| 50 | #else /* !__GNUC__ */ |
| 51 | #define MIN(a,b) ((a)<(b)?(a):(b)) /* Unsafe variant */ |
| 52 | #endif /* __GNUC__ */ |
| 53 | #endif /* MIN */ |
| 54 | |
vlm | fa67ddc | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 55 | #endif /* _ASN_TYPES_H_ */ |