1 /*
2  *  Common macro definitions
3  *
4  *  ICRAR - International Centre for Radio Astronomy Research
5  *  (c) UWA - The University of Western Australia, 2014
6  *  Copyright by UWA (in the framework of the ICRAR)
7  *  All rights reserved
8  *
9  *  This library is free software; you can redistribute it and/or
10  *  modify it under the terms of the GNU Lesser General Public
11  *  License as published by the Free Software Foundation; either
12  *  version 2.1 of the License, or (at your option) any later version.
13  *
14  *  This library is distributed in the hope that it will be useful,
15  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  *  Lesser General Public License for more details.
18  *
19  *  You should have received a copy of the GNU Lesser General Public
20  *  License along with this library; if not, write to the Free Software
21  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
22  *  MA 02111-1307  USA
23  *
24  */
25 
26 #ifndef _COMMON_H_
27 #define _COMMON_H_
28 
29 /* inline support (it's not a keyword in MSVC for C code) */
30 #if defined(_MSC_VER)
31 # define CRC32C_INLINE __inline
32 #else
33 # define CRC32C_INLINE inline
34 #endif
35 
36 /* 32/64 bit detection */
37 #if defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || defined(__x86_64) ||\
38     (defined(_MSC_VER) && defined(_M_AMD64))
39 # define CRC32C_IS_64_BITS
40 #else
41 # undef CRC32C_IS_64_BITS
42 #endif
43 
44 /* uint64_t / uint32_t / uint16_t definitions */
45 #if !defined(_MSC_VER) || (MSC_VER >= 1800)
46 # include <stdint.h>
47 #else
48 # include <limits.h>
49   typedef unsigned __int64 uint64_t;
50 
51 # if ULONG_MAX == (0xffffffffUL)
52    typedef unsigned long uint32_t;
53 # elif UINT_MAX == (0xffffffffUL)
54    typedef unsigned int uint32_t;
55 # else
56 #  error "Unsupported platform"
57 # endif
58 
59 # if UINT_MAX == (0xffffUL)
60    typedef unsigned int uint16_t;
61 # elif USHRT_MAX == (0xffffUL)
62    typedef unsigned short uint16_t;
63 # else
64 #  error "Unsupported platform"
65 # endif
66 
67 #endif
68 
69 /* size_t definition */
70 #include <stdlib.h>
71 
72 /* crc32c function signature */
73 typedef uint32_t (* crc_function)(uint32_t crc, unsigned const char *data, unsigned long length);
74 
75 /* Are we big endian? */
76 extern int is_big_endian;
77 
78 #endif // _COMMON_H_
79