summaryrefslogtreecommitdiffhomepage
path: root/include/stc/algo
diff options
context:
space:
mode:
authortylov <[email protected]>2023-07-18 01:36:51 +0200
committertylov <[email protected]>2023-07-18 01:36:51 +0200
commit313c1d7bb9b92e75801429c1f7f132589860292e (patch)
treeb68451b728c7e06275388348e8ccb90d5a1c5a7f /include/stc/algo
parent23eeedb3fc298602732f394adba6a43c876ca7d8 (diff)
downloadSTC-modified-313c1d7bb9b92e75801429c1f7f132589860292e.tar.gz
STC-modified-313c1d7bb9b92e75801429c1f7f132589860292e.zip
Renamed i_native_cmp => i_cmp_native
Added c_all_of(), c_any_of(), c_none_of() to algo/filter.h
Diffstat (limited to 'include/stc/algo')
-rw-r--r--include/stc/algo/coroutine.h13
-rw-r--r--include/stc/algo/filter.h16
2 files changed, 24 insertions, 5 deletions
diff --git a/include/stc/algo/coroutine.h b/include/stc/algo/coroutine.h
index 3a5382f3..e4c0915c 100644
--- a/include/stc/algo/coroutine.h
+++ b/include/stc/algo/coroutine.h
@@ -178,17 +178,22 @@ typedef struct { intptr_t count; } cco_sem;
#ifdef _WIN32
#ifdef __cplusplus
- #define _c_LINKC extern "C" __declspec(dllimport)
+ #define _c_LINKC extern "C" __declspec(dllimport)
#else
- #define _c_LINKC __declspec(dllimport)
+ #define _c_LINKC __declspec(dllimport)
+ #endif
+ #if _WIN32_WINNT < _WIN32_WINNT_WIN8 || defined __TINYC__
+ #define _c_getsystime GetSystemTimeAsFileTime
+ #else
+ #define _c_getsystime GetSystemTimePreciseAsFileTime
#endif
struct _FILETIME;
- _c_LINKC void GetSystemTimePreciseAsFileTime(struct _FILETIME*);
+ _c_LINKC void _c_getsystime(struct _FILETIME*);
_c_LINKC void Sleep(unsigned long);
static inline double cco_time(void) { /* seconds since epoch */
unsigned long long quad; /* 64-bit value representing 1/10th usecs since Jan 1 1601, 00:00 UTC */
- GetSystemTimePreciseAsFileTime((struct _FILETIME*)&quad);
+ _c_getsystime((struct _FILETIME*)&quad);
return (double)(quad - 116444736000000000ULL)*1e-7; /* time diff Jan 1 1601-Jan 1 1970 in 1/10th usecs */
}
diff --git a/include/stc/algo/filter.h b/include/stc/algo/filter.h
index 4a227927..1a62c3e1 100644
--- a/include/stc/algo/filter.h
+++ b/include/stc/algo/filter.h
@@ -85,6 +85,21 @@ int main(void)
if (it.ref == _endref) it.ref = NULL; \
} while (0)
+#define c_all_of(boolptr, it, C, cnt, pred) do { \
+ C##_iter it; \
+ c_find_if_4(it, C, cnt, !(pred)); \
+ *(boolptr) = it.ref == NULL; \
+} while (0)
+#define c_any_of(boolptr, it, C, cnt, pred) do { \
+ C##_iter it; \
+ c_find_if_4(it, C, cnt, pred); \
+ *(boolptr) = it.ref != NULL; \
+} while (0)
+#define c_none_of(boolptr, it, C, cnt, pred) do { \
+ C##_iter it; \
+ c_find_if_4(it, C, cnt, pred); \
+ *(boolptr) = it.ref == NULL; \
+} while (0)
// Use with: clist, cmap, cset, csmap, csset:
#define c_erase_if(it, C, cnt, pred) do { \
@@ -95,7 +110,6 @@ int main(void)
} \
} while (0)
-
// Use with: cstack, cvec, cdeq, cqueue:
#define c_eraseremove_if(it, C, cnt, pred) do { \
C* _cnt = &cnt; \