diff options
| author | Tyge Løvset <[email protected]> | 2020-03-29 22:43:41 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2020-03-29 22:43:41 +0200 |
| commit | 9305a3478b4db680ea1768960d2eef7418b83a5b (patch) | |
| tree | 7741b7bed3de35bea1f225625aaf0d470986d997 | |
| parent | a3162e91014e0dda7370a6a4fc165f231dcb9a64 (diff) | |
| download | STC-modified-9305a3478b4db680ea1768960d2eef7418b83a5b.tar.gz STC-modified-9305a3478b4db680ea1768960d2eef7418b83a5b.zip | |
Add files via upload
| -rw-r--r-- | c_lib/cmap.h | 14 | ||||
| -rw-r--r-- | c_lib/cvector.h | 4 |
2 files changed, 10 insertions, 8 deletions
diff --git a/c_lib/cmap.h b/c_lib/cmap.h index 153acb5b..b14f9e3b 100644 --- a/c_lib/cmap.h +++ b/c_lib/cmap.h @@ -26,6 +26,7 @@ #include "cvector.h"
+#define cmap_init {cvector_init, 0, 90, 0}
#define cmap_size(map) ((size_t) (map)._size)
#define cmap_bucketCount(map) cvector_capacity((map)._table)
@@ -52,11 +53,6 @@ typedef struct CMapEntry_##tag CMapEntry_##tag enum {cmapentry_HASH=0x7fff, cmapentry_USED=0x8000};
#define cmapentry_noCompare(x, y) (0)
-// https://lemire.me/blog/2016/06/27/a-fast-alternative-to-the-modulo-reduction/
-static inline uint32_t cmap_reduce(uint32_t x, uint32_t N) {
- return ((uint64_t) x * (uint64_t) N) >> 32 ;
-}
-
// CMap:
#define declare_CMap(...) c_MACRO_OVERLOAD(declare_CMap, __VA_ARGS__)
@@ -99,7 +95,7 @@ typedef struct CMap_##tag { \ uint8_t maxLoadPercent; \
uint8_t shrinkLimitPercent; \
} CMap_##tag; \
-static const CMap_##tag cmap_##tag##_init = {{NULL}, 0, 90, 0}; \
+static const CMap_##tag cmap_##tag##_init = cmap_init; \
\
typedef struct cmap_##tag##_iter_t { \
CMapEntry_##tag *item, *_end; \
@@ -252,4 +248,10 @@ static inline cmap_##tag##_iter_t cmap_##tag##_end(CMap_##tag map) { \ typedef Key cmap_##tag##_key_t; \
typedef Value cmap_##tag##_value_t
+
+// https://lemire.me/blog/2016/06/27/a-fast-alternative-to-the-modulo-reduction/
+static inline uint32_t cmap_reduce(uint32_t x, uint32_t N) {
+ return ((uint64_t) x * (uint64_t) N) >> 32 ;
+}
+
#endif
diff --git a/c_lib/cvector.h b/c_lib/cvector.h index 3297a076..93aaa550 100644 --- a/c_lib/cvector.h +++ b/c_lib/cvector.h @@ -27,7 +27,7 @@ #include <string.h>
#include "cdefs.h"
-
+#define cvector_init {NULL}
#define cvector_size(cv) _cvector_safe_size((cv).data)
#define cvector_capacity(cv) _cvector_safe_capacity((cv).data)
#define cvector_empty(cv) (_cvector_safe_size((cv).data) == 0)
@@ -46,7 +46,7 @@ typedef struct CVector_##tag { \
Value* data; \
} CVector_##tag; \
-static const CVector_##tag cvector_##tag##_init = {NULL}; \
+static const CVector_##tag cvector_##tag##_init = cvector_init; \
\
typedef struct cvector_##tag##_iter_t { \
Value* item; \
|
