summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorTylo <[email protected]>2020-06-22 18:50:17 +0200
committerTylo <[email protected]>2020-06-22 18:50:17 +0200
commit664b5a6b227b2e8814a318b4de39820236e5efea (patch)
treebd9a8946cd892c9453e0e627766edf113cc58498
parentcae23dfe2ebf4c75efeacf0e908dc55cb113aa5b (diff)
downloadSTC-modified-664b5a6b227b2e8814a318b4de39820236e5efea.tar.gz
STC-modified-664b5a6b227b2e8814a318b4de39820236e5efea.zip
Restructure declare_CHash arguments (again)
Removed forced inlining. (-> regular inline)
-rw-r--r--examples/README.md6
-rw-r--r--examples/advanced.c2
-rw-r--r--examples/benchmark.c4
-rw-r--r--stc/cdefs.h7
-rw-r--r--stc/chash.h12
5 files changed, 16 insertions, 15 deletions
diff --git a/examples/README.md b/examples/README.md
index c9952317..938bcb24 100644
--- a/examples/README.md
+++ b/examples/README.md
@@ -73,8 +73,8 @@ size_t personview_hash(const struct PersonView* pv, size_t ignore) {
```
With this in place, we can declare the map Person -> int:
```
-declare_CHash(ex, map, struct Person, int, c_emptyDestroy, personview_hash, personview_compare,
- struct PersonView, person_destroy, person_getView, person_fromView);
+declare_CHash(ex, MAP, struct Person, int, c_emptyDestroy, personview_hash, personview_compare,
+ person_destroy, struct PersonView, person_getView, person_fromView);
```
Note we use struct PersonView to put keys in the map, but keys are stored as struct Person with proper dynamically allocated CStrings to store name and surname.
```
@@ -94,5 +94,5 @@ int main()
chash_ex_destroy(&m6);
}
```
-CHash map uses personview_hash() for hash value calculations, and the personview_compare() for equality checks. The chash_ex_destroy() function will free CStrings name, surname and the value for each item in the map, in addition to the CMap hash table itself.
+CHash map uses personview_hash() for hash value calculations, and the personview_compare() for equality checks. The chash_ex_destroy() function will free CStrings name, surname and the value for each item in the map, in addition to the CHash map table itself.
diff --git a/examples/advanced.c b/examples/advanced.c
index 37b67531..68d5b66a 100644
--- a/examples/advanced.c
+++ b/examples/advanced.c
@@ -65,7 +65,7 @@ size_t personview_hash(const struct PersonView* pv, size_t ignore) {
With this in place, we can declare the map Person -> int:
```*/
declare_CHash(ex, MAP, struct Person, int, c_emptyDestroy, personview_hash, personview_compare,
- struct PersonView, person_destroy, person_getView, person_fromView);
+ person_destroy, struct PersonView, person_getView, person_fromView);
/*```
Note we use struct PersonView to put keys in the map, but keys are stored as struct Person with proper dynamically allocated CStrings to store name and surname.
```*/
diff --git a/examples/benchmark.c b/examples/benchmark.c
index dd070ff4..b6e31a22 100644
--- a/examples/benchmark.c
+++ b/examples/benchmark.c
@@ -8,8 +8,8 @@
#ifdef __cplusplus
#include <unordered_map>
-#include "../others/bytell_hash_map.hpp"
-#include "../others/robin_hood.hpp"
+#include "others/bytell_hash_map.hpp"
+#include "others/robin_hood.hpp"
#endif
// Visual Studio: compile with -TP to force C++: cl -TP -EHsc -O2 benchmark.c
diff --git a/stc/cdefs.h b/stc/cdefs.h
index d8e3228d..ae707ec1 100644
--- a/stc/cdefs.h
+++ b/stc/cdefs.h
@@ -27,13 +27,14 @@
#include <stddef.h>
#include <stdbool.h>
-#if defined(_MSC_VER)
+#if 0 // defined(_MSC_VER)
# define STC_INLINE __forceinline
-#elif defined(__GNUC__)
+#elif 0 // defined(__GNUC__)
# define STC_INLINE inline __attribute((always_inline))
-#else
+#else // don't force
# define STC_INLINE inline
#endif
+
#if defined(STC_HEADER) || defined(STC_IMPLEMENTATION)
#define STC_API extern
#else
diff --git a/stc/chash.h b/stc/chash.h
index 33f3e02c..8157b2c2 100644
--- a/stc/chash.h
+++ b/stc/chash.h
@@ -79,7 +79,7 @@ enum {chash_HASH = 0x7f, chash_USED = 0x80};
#define declare_CHash_7(tag, type, Key, Value, valueDestroy, keyHash, keyEquals) \
declare_CHash_11(tag, type, Key, Value, valueDestroy, keyHash, keyEquals, \
- Key, c_emptyDestroy, c_defaultGetRaw, c_defaultInitRaw)
+ c_emptyDestroy, Key, c_defaultGetRaw, c_defaultInitRaw)
/* CHash<CString, Value>: */
#define declare_CHash_string(...) \
@@ -93,7 +93,7 @@ enum {chash_HASH = 0x7f, chash_USED = 0x80};
#define declare_CHash_string_4(tag, type, Value, valueDestroy) \
declare_CHash_11(tag, type, CString, Value, valueDestroy, cstring_hashRaw, cstring_equalsRaw, \
- const char*, cstring_destroy, cstring_getRaw, cstring_make)
+ cstring_destroy, const char*, cstring_getRaw, cstring_make)
#define _chash1_SET(x)
#define _chash2_SET(x, y) x
@@ -102,7 +102,7 @@ enum {chash_HASH = 0x7f, chash_USED = 0x80};
/* CHash full: */
#define declare_CHash_11(tag, type, Key, Value, valueDestroy, keyHashRaw, keyEqualsRaw, \
- RawKey, keyDestroy, keyGetRaw, keyInitRaw) \
+ keyDestroy, RawKey, keyGetRaw, keyInitRaw) \
typedef struct CHashEntry_##tag { \
Key key; \
_chash1_##type(Value value;) \
@@ -168,7 +168,7 @@ STC_API chash_##tag##_iter_t \
chash_##tag##_next(chash_##tag##_iter_t it); \
\
implement_CHash_11(tag, type, Key, Value, valueDestroy, keyHashRaw, keyEqualsRaw, \
- RawKey, keyDestroy, keyGetRaw, keyInitRaw) \
+ keyDestroy, RawKey, keyGetRaw, keyInitRaw) \
typedef Key CHashKey_##tag; \
typedef Value CHashValue_##tag
@@ -176,7 +176,7 @@ typedef Value CHashValue_##tag
#if !defined(STC_HEADER) || defined(STC_IMPLEMENTATION)
#define implement_CHash_11(tag, type, Key, Value, valueDestroy, keyHashRaw, keyEqualsRaw, \
- RawKey, keyDestroy, keyGetRaw, keyInitRaw) \
+ keyDestroy, RawKey, keyGetRaw, keyInitRaw) \
\
STC_API void \
chash_##tag##_destroy(CHash_##tag* self) { \
@@ -362,7 +362,7 @@ chash_##tag##_next(chash_##tag##_iter_t it) { \
#else
#define implement_CHash_11(tag, type, Key, Value, valueDestroy, keyHashRaw, keyEqualsRaw, \
- RawKey, keyDestroy, keyGetRaw, keyInitRaw)
+ keyDestroy, RawKey, keyGetRaw, keyInitRaw)
#endif
#endif