4
/*****************************************\
6
* TYPESIZE.H - Defines variable types *
7
* with a known memory size *
8
* Also defines macros for dealing *
11
* Copyright (C) 2000 by Josef Drexler *
12
* <jdrexler@julian.uwo.ca> *
14
* Permission granted to copy and redist- *
15
* ribute under the terms of the GNU GPL. *
16
* For more info please read the file *
17
* COPYING which should have come with *
20
\*****************************************/
22
#define maketype(type,size) \
23
typedef signed type S ## size; \
24
typedef unsigned type U ## size;
27
#define strnicmp strncasecmp
28
#define stricmp strcasecmp
41
// disable warnings for "condition is always false" and "unreachable code"
50
# define HAVE_LONGLONGS
53
maketype(short int,16)
55
maketype(long long,64)
62
# define HAVE_LONGLONGS
65
maketype(short int,16)
67
maketype(long long,64)
74
# define HAVE_LONGLONGS
77
maketype(short int,16)
82
# error Unknown variables sizes, please define.
86
// disable warnings: conversion from $LARGE_SIZE to $SMALL_SIZE
87
#pragma warning(disable:4267 4244)
88
// ... conditional expression is constant
89
#pragma warning(disable:4127)
100
(sizeof( U8) != 1) ||
103
(sizeof(S16) != 2) ||
104
(sizeof(U16) != 2) ||
107
(sizeof(S32) != 4) ||
108
(sizeof(U32) != 4) ||
110
#ifdef HAVE_LONGLONGS
111
(sizeof(S64) != 8) ||
112
(sizeof(U64) != 8) ||
114
(0) // the ||(0) is so that all previous lines can end in ||
117
printf("Fatal: Incorrectly sized variables.\n");
118
#define PRINT_SZ(t,s) printf("%s size = %d, expected = %d\n", #t, (int)sizeof(t), s)
131
#ifdef HAVE_LONGLONGS
151
#ifdef __BIG_ENDIAN__
152
# define BE_SWAP16(b) (*((U8*)(&b))+(*(((U8*)(&b))+1)<<8))
153
# define BE_SWAP32(b) (*((U8*)(&b))+(*(((U8*)(&b))+1)<<8)+(*(((U8*)(&b))+2)<<16)+(*(((U8*)(&b))+3)<<24))
157
# define BE_SWAP16(b) (b)
158
# define BE_SWAP32(b) (b)
164
#define BEGINC extern "C" {
172
#endif /* _TYPESIZE_H */