-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathECL_config.h
More file actions
130 lines (102 loc) · 3.65 KB
/
Copy pathECL_config.h
File metadata and controls
130 lines (102 loc) · 3.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#ifndef ECL_CONFIG_H_
#define ECL_CONFIG_H_
#include <stdint.h>
#include <stdlib.h>
#include <string.h> /* memcpy, memset */
/* see runtime version in ECL_utils.h */
#define ECL_VERSION_MAJOR 1
#define ECL_VERSION_MINOR 2
#define ECL_VERSION_PATCH 0
#define ECL_VERSION_NUMBER (ECL_VERSION_MAJOR*10000 + ECL_VERSION_MINOR*100 + ECL_VERSION_PATCH)
#define ECL_VERSION_BRANCH "master"
/* user setup part --------------------------------------------- */
/*
Add your own definitions here if you don't have available:
- uint8_t
- uint16_t
- uint32_t
*/
#ifndef ECL_USE_BITNESS_16
#ifndef ECL_USE_BITNESS_32
#ifndef ECL_USE_BITNESS_64
/* none of these is defined with force for compilation, use 32 bits by default */
#define ECL_USE_BITNESS_32
#endif
#endif
#endif
/*#define ECL_USE_ASSERT */
/*#define ECL_USE_BRANCHLESS */
/*#define ECL_USE_STAT_COUNTERS */
/*#define ECL_DISABLE_MALLOC */
/*#define ECL_USE_DLL */
#ifndef ECL_NANO_LZ_ONLY_SCHEME
/* set to 0 to unlock all schemes, set to 1 to have only scheme1, 2 = scheme2 etc. Having single scheme allows compiler to inline for better performance */
/* default is 1 since most likely you will use only scheme1 and want better performance */
#define ECL_NANO_LZ_ONLY_SCHEME 1
#endif
/* non-user part ------------------------------------------ */
#define ECL_NANO_LZ_IS_SCHEME_ENABLED(scheme_num) ((ECL_NANO_LZ_ONLY_SCHEME == 0) || (ECL_NANO_LZ_ONLY_SCHEME == scheme_num))
/* size types --------------------------------------------- */
#ifdef ECL_USE_BITNESS_16
typedef uint16_t ECL_usize;
typedef int16_t ECL_ssize;
#define ECL_SIZE_TYPE_BITS_COUNT 16
#elif defined ECL_USE_BITNESS_32
typedef uint32_t ECL_usize;
typedef int32_t ECL_ssize;
#define ECL_SIZE_TYPE_BITS_COUNT 32
#elif defined ECL_USE_BITNESS_64
typedef uint64_t ECL_usize;
typedef int64_t ECL_ssize;
#define ECL_SIZE_TYPE_BITS_COUNT 64
#endif
#define ECL_POINTER_BITS_COUNT (sizeof(void*) * 8)
/*
Helper paranoid macro to ensure that estimated compression bound doesn't overflow ECL_usize.
Results in bool. Makes sense for ECL_USE_BITNESS_16.
Usage: assert( ECL_VALIDATE_BOUND_OK( ECL_NANO_LZ_GET_BOUND(src_size), src_size ) );
*/
#define ECL_VALIDATE_BOUND_OK(estimated_max_compressed_size, src_size) (( (ECL_usize)(estimated_max_compressed_size) ) > ( (ECL_usize)(src_size) ))
/* asserts --------------------------------------------- */
#ifdef ECL_USE_ASSERT
#include <assert.h>
#define ECL_ASSERT(expr) assert(expr)
#else
#define ECL_ASSERT(expr)
#endif
/* malloc/free can be disabled (stubbed). useful if those functions don't compile on some particular platform */
#ifdef ECL_DISABLE_MALLOC
#define ECL_MEM_ALLOC(size) 0
#define ECL_MEM_FREE(ptr)
#else
#define ECL_MEM_ALLOC(size) malloc(size)
#define ECL_MEM_FREE(ptr) free(ptr)
#endif
/* helpful */
#define ECL_MIN(a, b) ((a) < (b) ? (a) : (b))
#define ECL_MAX(a, b) ((a) > (b) ? (a) : (b))
/* dyn library macros, etc */
#ifndef ECL_API_VISIBILITY
#if defined(__GNUC__) && (__GNUC__ >= 4)
#define ECL_API_VISIBILITY __attribute__ ((visibility ("default")))
#else
#define ECL_API_VISIBILITY
#endif
#endif
#if defined(ECL_USE_DLL)
#if defined(ECL_DLL_EXPORT)
#define ECL_EXPORTED_API __declspec(dllexport) ECL_API_VISIBILITY
#else
#define ECL_EXPORTED_API __declspec(dllimport) ECL_API_VISIBILITY
#endif
#else
#define ECL_EXPORTED_API ECL_API_VISIBILITY
#endif
#endif
/* compiler quirks */
#ifdef __XC8 /* more like an example check actually. XC8 compiler */
#define ECL_SCOPED_CONST /* local const isn't supported */
#endif
#ifndef ECL_SCOPED_CONST
#define ECL_SCOPED_CONST const
#endif