diff options
| -rw-r--r-- | include/stc/alt/clist.h | 2 | ||||
| -rw-r--r-- | include/stc/alt/csmap.h | 2 | ||||
| -rw-r--r-- | include/stc/alt/cstr.h | 2 | ||||
| -rw-r--r-- | include/stc/carr2.h | 2 | ||||
| -rw-r--r-- | include/stc/carr3.h | 2 | ||||
| -rw-r--r-- | include/stc/cbits.h | 2 | ||||
| -rw-r--r-- | include/stc/ccommon.h | 47 | ||||
| -rw-r--r-- | include/stc/cdeq.h | 2 | ||||
| -rw-r--r-- | include/stc/clist.h | 6 | ||||
| -rw-r--r-- | include/stc/cmap.h | 2 | ||||
| -rw-r--r-- | include/stc/cpque.h | 2 | ||||
| -rw-r--r-- | include/stc/crandom.h | 2 | ||||
| -rw-r--r-- | include/stc/csmap.h | 2 | ||||
| -rw-r--r-- | include/stc/cstr.h | 2 | ||||
| -rw-r--r-- | include/stc/csview.h | 2 | ||||
| -rw-r--r-- | include/stc/cvec.h | 2 |
16 files changed, 37 insertions, 44 deletions
diff --git a/include/stc/alt/clist.h b/include/stc/alt/clist.h index 38b722a4..7530ef5b 100644 --- a/include/stc/alt/clist.h +++ b/include/stc/alt/clist.h @@ -148,7 +148,7 @@ STC_API size_t _clist_count(const clist_VOID* self); /* -------------------------- IMPLEMENTATION ------------------------- */
-#if !defined(STC_HEADER) || defined(STC_IMPLEMENTATION)
+#if !defined(STC_SHARED) || defined(STC_IMPLEMENTATION)
#define _c_implement_clist(_cx_self, i_val, i_cmp, i_valdrop, i_valfrom, i_valto, i_valraw) \
\
STC_DEF _cx_self \
diff --git a/include/stc/alt/csmap.h b/include/stc/alt/csmap.h index 9be41054..0f5b59cc 100644 --- a/include/stc/alt/csmap.h +++ b/include/stc/alt/csmap.h @@ -197,7 +197,7 @@ int main(void) { /* -------------------------- IMPLEMENTATION ------------------------- */
-#if !defined(STC_HEADER) || defined(STC_IMPLEMENTATION)
+#if !defined(STC_SHARED) || defined(STC_IMPLEMENTATION)
_c_aatree_types(csmap_SENTINEL, csmap_, int, int);
_c_aatree_complete_types(csmap_SENTINEL, csmap_);
diff --git a/include/stc/alt/cstr.h b/include/stc/alt/cstr.h index b9a4ceee..8a2c2bd7 100644 --- a/include/stc/alt/cstr.h +++ b/include/stc/alt/cstr.h @@ -262,7 +262,7 @@ STC_INLINE bool cstr_getline(cstr *self, FILE *fp) { /* -------------------------- IMPLEMENTATION ------------------------- */
-#if !defined(STC_HEADER) || defined(STC_IMPLEMENTATION)
+#if !defined(STC_SHARED) || defined(STC_IMPLEMENTATION)
STC_DEF void cstr_internal_move_(cstr* self, size_t pos1, size_t pos2) {
if (pos1 == pos2)
diff --git a/include/stc/carr2.h b/include/stc/carr2.h index 92964d4d..9d49253a 100644 --- a/include/stc/carr2.h +++ b/include/stc/carr2.h @@ -97,7 +97,7 @@ STC_INLINE void _cx_memb(_next)(_cx_iter* it) { ++it->ref; } /* -------------------------- IMPLEMENTATION ------------------------- */ -#if !defined(STC_HEADER) || defined(STC_IMPLEMENTATION) || defined(i_imp) +#if !defined(STC_SHARED) || c_option(c_static) || defined(STC_IMPLEMENTATION) STC_DEF _cx_self _cx_memb(_with_storage)(size_t xdim, size_t ydim, _cx_value* block) { _cx_self _arr = {c_alloc_n(_cx_value*, xdim), xdim, ydim}; diff --git a/include/stc/carr3.h b/include/stc/carr3.h index 31df5bdf..957cda81 100644 --- a/include/stc/carr3.h +++ b/include/stc/carr3.h @@ -101,7 +101,7 @@ STC_INLINE void _cx_memb(_next)(_cx_iter* it) { ++it->ref; } /* -------------------------- IMPLEMENTATION ------------------------- */ -#if !defined(STC_HEADER) || defined(STC_IMPLEMENTATION) || defined(i_imp) +#if !defined(STC_SHARED) || c_option(c_static) || defined(STC_IMPLEMENTATION) STC_DEF _cx_self _cx_memb(_with_storage)(size_t xdim, size_t ydim, size_t zdim, _cx_value* block) { _cx_self _arr = {c_alloc_n(_cx_value**, xdim*(ydim + 1)), xdim, ydim, zdim}; diff --git a/include/stc/cbits.h b/include/stc/cbits.h index 4fa8c146..b4ff287d 100644 --- a/include/stc/cbits.h +++ b/include/stc/cbits.h @@ -168,7 +168,7 @@ STC_INLINE void cbits_xor(cbits *self, cbits other) { }
#endif
-#if !defined(STC_HEADER) || defined(STC_IMPLEMENTATION)
+#if !defined(STC_SHARED) || defined(STC_IMPLEMENTATION)
STC_DEF cbits* cbits_copy(cbits* self, cbits other) {
if (self->data64 == other.data64) return self;
diff --git a/include/stc/ccommon.h b/include/stc/ccommon.h index 3bdc35c4..1d760348 100644 --- a/include/stc/ccommon.h +++ b/include/stc/ccommon.h @@ -39,18 +39,6 @@ #endif
#define STC_INLINE static inline
-#if defined(STC_HEADER) || defined(STC_IMPLEMENTATION) || defined(i_imp)
-# define STC_API extern
-# define STC_DEF
-# define STC_LIBRARY_ONLY(...) __VA_ARGS__
-# define STC_STATIC_ONLY(...)
-#else
-# define STC_API static inline
-# define STC_DEF static inline
-# define STC_LIBRARY_ONLY(...)
-# define STC_STATIC_ONLY(...) __VA_ARGS__
-#endif
-
/* Macro overloading feature support based on: https://rextester.com/ONP80107 */
#define c_MACRO_OVERLOAD(name, ...) \
c_PASTE3(name, _, c_NUM_ARGS(__VA_ARGS__))(__VA_ARGS__)
@@ -112,6 +100,7 @@ typedef const char c_strlit[]; #define c_no_atomic 2
#define c_no_clone 4
#define c_no_cmp 8
+#define c_static 16
/* Generic algorithms */
@@ -206,21 +195,6 @@ STC_INLINE uint64_t c_default_hash(const void* key, size_t len) { } while (0)
#define c_pair(v) (v).first, (v).second
-// [deprecated]
-#define c_apply_OLD(C, method, cx, ...) do { \
- const C##_raw _c_arr[] = __VA_ARGS__; \
- C* _c_cx = cx; \
- for (size_t _c_i = 0; _c_i < c_arraylen(_c_arr); ++_c_i) \
- C##_##method(_c_cx, _c_arr[_c_i]); \
-} while (0)
-// [deprecated]
-#define c_apply_pair_OLD(C, method, cx, ...) do { \
- const C##_raw _c_arr[] = __VA_ARGS__; \
- C* _c_cx = cx; \
- for (size_t _c_i = 0; _c_i < c_arraylen(_c_arr); ++_c_i) \
- C##_##method(_c_cx, _c_arr[_c_i].first, _c_arr[_c_i].second); \
-} while (0)
-
#define c_drop(C, ...) do { \
C* _c_arr[] = {__VA_ARGS__}; \
for (size_t _c_i = 0; _c_i < c_arraylen(_c_arr); ++_c_i) \
@@ -239,3 +213,22 @@ STC_INLINE uint64_t c_default_hash(const void* key, size_t len) { asm("mulq %3" : "=a"(*(lo)), "=d"(*(hi)) : "a"(a), "rm"(b))
#endif
#endif
+
+#undef STC_API
+#undef STC_DEF
+#undef STC_LIBRARY_ONLY
+#undef STC_STATIC_ONLY
+#ifdef STC_HEADER // [deprecated]
+# define STC_SHARED
+#endif
+#if !c_option(c_static) && (defined(STC_SHARED) || defined(STC_IMPLEMENTATION))
+# define STC_API extern
+# define STC_DEF
+# define STC_LIBRARY_ONLY(...) __VA_ARGS__
+# define STC_STATIC_ONLY(...)
+#else
+# define STC_API static inline
+# define STC_DEF static inline
+# define STC_LIBRARY_ONLY(...)
+# define STC_STATIC_ONLY(...) __VA_ARGS__
+#endif
diff --git a/include/stc/cdeq.h b/include/stc/cdeq.h index 97a19311..2de4f69b 100644 --- a/include/stc/cdeq.h +++ b/include/stc/cdeq.h @@ -211,7 +211,7 @@ _cx_memb(_sort)(_cx_self* self) { #endif // _i_queue
/* -------------------------- IMPLEMENTATION ------------------------- */
-#if !defined(STC_HEADER) || defined(STC_IMPLEMENTATION) || defined(i_imp)
+#if !defined(STC_SHARED) || c_option(c_static) || defined(STC_IMPLEMENTATION)
#ifndef CDEQ_H_INCLUDED
static struct cdeq_rep _cdeq_sentinel = {0, 0};
diff --git a/include/stc/clist.h b/include/stc/clist.h index e2ff694e..b9a3df24 100644 --- a/include/stc/clist.h +++ b/include/stc/clist.h @@ -185,7 +185,7 @@ _cx_memb(_get_mut)(_cx_self* self, i_valraw val) { // -------------------------- IMPLEMENTATION -------------------------
-#if !defined(STC_HEADER) || defined(STC_IMPLEMENTATION) || defined(i_imp)
+#if !defined(STC_SHARED) || c_option(c_static) || defined(STC_IMPLEMENTATION)
#if !c_option(c_no_clone)
STC_DEF _cx_self
@@ -332,7 +332,8 @@ _cx_memb(_value_cmp)(const _cx_value* x, const _cx_value* y) { #endif // TEMPLATE IMPLEMENTATION
-#if !defined(STC_HEADER) && !defined(CLIST_H_INCLUDED) || defined(i_imp) && i_imp == 2
+#if !defined(CLIST_H_INCLUDED) && \
+ (!defined(STC_SHARED) || c_option(c_static) || defined(STC_IMPLEMENTATION))
STC_DEF size_t
_clist_count(const clist_VOID* self) {
@@ -344,7 +345,6 @@ _clist_count(const clist_VOID* self) { }
#if !c_option(c_no_cmp)
-
// Singly linked list Mergesort implementation by Simon Tatham. O(n*log n).
// https://www.chiark.greenend.org.uk/~sgtatham/algorithms/listsort.html
STC_DEF clist_VOID_node *
diff --git a/include/stc/cmap.h b/include/stc/cmap.h index 730fd95e..2cd42bc6 100644 --- a/include/stc/cmap.h +++ b/include/stc/cmap.h @@ -231,7 +231,7 @@ _cx_memb(_erase_at)(_cx_self* self, _cx_iter it) { /* -------------------------- IMPLEMENTATION ------------------------- */
-#if !defined(STC_HEADER) || defined(STC_IMPLEMENTATION) || defined(i_imp)
+#if !defined(STC_SHARED) || c_option(c_static) || defined(STC_IMPLEMENTATION)
#ifndef CMAP_H_INCLUDED
//STC_INLINE size_t fastrange_uint64_t(uint64_t x, uint64_t n)
diff --git a/include/stc/cpque.h b/include/stc/cpque.h index 73494cbd..2347fc55 100644 --- a/include/stc/cpque.h +++ b/include/stc/cpque.h @@ -105,7 +105,7 @@ STC_INLINE void _cx_memb(_emplace)(_cx_self* self, _cx_raw raw) #endif
/* -------------------------- IMPLEMENTATION ------------------------- */
-#if !defined(STC_HEADER) || defined(STC_IMPLEMENTATION) || defined(i_imp)
+#if !defined(STC_SHARED) || c_option(c_static) || defined(STC_IMPLEMENTATION)
STC_DEF void
_cx_memb(_sift_down_)(_cx_value* arr, const size_t idx, const size_t n) {
diff --git a/include/stc/crandom.h b/include/stc/crandom.h index 5b4e9f3a..2861f6cd 100644 --- a/include/stc/crandom.h +++ b/include/stc/crandom.h @@ -141,7 +141,7 @@ STC_INLINE int32_t stc32_uniform(stc32_t* rng, stc32_uniform_t* d) { /* -------------------------- IMPLEMENTATION ------------------------- */
-#if !defined(STC_HEADER) || defined(STC_IMPLEMENTATION)
+#if !defined(STC_SHARED) || defined(STC_IMPLEMENTATION)
/* Global random() */
static stc64_t stc64_global = {{
diff --git a/include/stc/csmap.h b/include/stc/csmap.h index fb8c868e..0d03f176 100644 --- a/include/stc/csmap.h +++ b/include/stc/csmap.h @@ -223,7 +223,7 @@ _cx_memb(_advance)(_cx_iter it, size_t n) { }
/* -------------------------- IMPLEMENTATION ------------------------- */
-#if !defined(STC_HEADER) || defined(STC_IMPLEMENTATION) || defined(i_imp)
+#if !defined(STC_SHARED) || c_option(c_static) || defined(STC_IMPLEMENTATION)
#ifndef CSMAP_H_INCLUDED
static struct csmap_rep _csmap_sentinel = {0, 0, 0, 0, 0};
diff --git a/include/stc/cstr.h b/include/stc/cstr.h index cfb2dfef..67bbf56c 100644 --- a/include/stc/cstr.h +++ b/include/stc/cstr.h @@ -173,7 +173,7 @@ cstr_ends_with(cstr s, const char* sub) { /* -------------------------- IMPLEMENTATION ------------------------- */
-#if !defined(STC_HEADER) || defined(STC_IMPLEMENTATION)
+#if !defined(STC_SHARED) || c_option(c_static) || defined(STC_IMPLEMENTATION)
STC_LIBRARY_ONLY( static _cstr_rep_t _cstr_nullrep = {0, 0, {0}};
const cstr cstr_null = {_cstr_nullrep.str}; )
diff --git a/include/stc/csview.h b/include/stc/csview.h index c8d8eda5..2536c274 100644 --- a/include/stc/csview.h +++ b/include/stc/csview.h @@ -123,7 +123,7 @@ STC_INLINE int csview_cmp(const csview* x, const csview* y) { /* -------------------------- IMPLEMENTATION ------------------------- */
-#if !defined(STC_HEADER) || defined(STC_IMPLEMENTATION)
+#if !defined(STC_SHARED) || defined(STC_IMPLEMENTATION)
STC_DEF csview
csview_substr(csview sv, intptr_t pos, size_t n) {
diff --git a/include/stc/cvec.h b/include/stc/cvec.h index 1faa16c3..4bd1cd23 100644 --- a/include/stc/cvec.h +++ b/include/stc/cvec.h @@ -233,7 +233,7 @@ _cx_memb(_sort)(_cx_self* self) { }
#endif // !c_no_cmp
/* -------------------------- IMPLEMENTATION ------------------------- */
-#if !defined(STC_HEADER) || defined(STC_IMPLEMENTATION) || defined(i_imp)
+#if !defined(STC_SHARED) || c_option(c_static) || defined(STC_IMPLEMENTATION)
#ifndef CVEC_H_INCLUDED
static struct cvec_rep _cvec_sentinel = {0, 0};
|
