summaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2023-06-06 11:42:18 +0200
committerTyge Løvset <[email protected]>2023-06-06 11:42:18 +0200
commit8e6e1d2b266e46e3920edf7cc6eaad33c1312880 (patch)
tree0dae1efe2342f8ad9d8bf1a968050d24068dfd44 /include
parentf2d90c87590133547e474da4ea9d5dd1b834043e (diff)
downloadSTC-modified-8e6e1d2b266e46e3920edf7cc6eaad33c1312880.tar.gz
STC-modified-8e6e1d2b266e46e3920edf7cc6eaad33c1312880.zip
Warning fixes and docs update.
Diffstat (limited to 'include')
-rw-r--r--include/stc/algo/coroutine.h10
-rw-r--r--include/stc/algo/sort.h10
2 files changed, 10 insertions, 10 deletions
diff --git a/include/stc/algo/coroutine.h b/include/stc/algo/coroutine.h
index 79819c55..1ac30fff 100644
--- a/include/stc/algo/coroutine.h
+++ b/include/stc/algo/coroutine.h
@@ -139,11 +139,11 @@ typedef struct {
_c_LINKC void GetSystemTimePreciseAsFileTime(struct _FILETIME*);
_c_LINKC void Sleep(unsigned long);
- static inline double cco_time(void) {
+ static inline double cco_time(void) { /* seconds since epoch */
static const unsigned long long epoch_offset = 116444736000000000ULL; /* 1/10th usecs betweeen Jan 1,1601 - Jan 1,1970 */
unsigned long long quad; /* 64-bit value, 100-nanosecond intervals since January 1, 1601 00:00 UTC */
GetSystemTimePreciseAsFileTime((struct _FILETIME*)&quad);
- return (double)(quad - epoch_offset)*1e-7; /* usecs since epoch */
+ return (double)(quad - epoch_offset)*1e-7;
}
static inline void cco_sleep(double sec) {
@@ -151,16 +151,16 @@ typedef struct {
}
#else
#include <sys/time.h>
- static inline double cco_time(void) {
+ static inline double cco_time(void) { /* seconds since epoch */
struct timeval tv;
gettimeofday(&tv, NULL);
- return tv.tv_sec + tv.tv_usec*1e-6;
+ return (double)tv.tv_sec + (double)tv.tv_usec*1e-6;
}
static inline void cco_sleep(double sec) {
struct timeval tv;
tv.tv_sec = (time_t)sec;
- tv.tv_usec = (suseconds_t)(1e6*(sec - tv.tv_sec));
+ tv.tv_usec = (suseconds_t)((sec - (double)(long)sec)*1e6);
select(0, NULL, NULL, NULL, &tv);
}
#endif
diff --git a/include/stc/algo/sort.h b/include/stc/algo/sort.h
index 20b7e1b3..bbd58427 100644
--- a/include/stc/algo/sort.h
+++ b/include/stc/algo/sort.h
@@ -24,7 +24,7 @@
template params:
#define i_val - value type [required]
#define i_less - less function. default: *x < *y
-#define i_tag name - define namearray_qsort(). i_tag defaults {i_val}
+#define i_type name - define {{name}}_sort_n(), else {{i_val}}array_sort_n().
// test:
#include <stdio.h>
@@ -32,12 +32,12 @@ template params:
#include <stc/algo/sort.h>
int main() {
- int arr[] = {23, 321, 5434, 25, 245, 1, 654, 33, 543, 21};
+ int nums[] = {23, 321, 5434, 25, 245, 1, 654, 33, 543, 21};
- intarray_qsort(arr, c_arraylen(arr));
+ intarray_sort_n(nums, c_arraylen(arr));
- for (int i = 0; i < c_arraylen(arr); i++)
- printf(" %d", arr[i]);
+ for (int i = 0; i < c_arraylen(nums); i++)
+ printf(" %d", nums[i]);
puts("");
}
*/