@based/db 0.2.5 → 0.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/darwin_aarch64/include/selva/db.h +1 -1
- package/dist/lib/darwin_aarch64/include/selva/fields.h +6 -3
- package/dist/lib/darwin_aarch64/include/selva/types.h +2 -1
- package/dist/lib/darwin_aarch64/libnode-v22.node +0 -0
- package/dist/lib/darwin_aarch64/libnode-v23.node +0 -0
- package/dist/lib/darwin_aarch64/libnode-v24.node +0 -0
- package/dist/lib/darwin_aarch64/libnode-v25.node +0 -0
- package/dist/lib/darwin_aarch64/libselva.dylib +0 -0
- package/dist/lib/linux_aarch64/include/cdefs.h +324 -0
- package/dist/lib/linux_aarch64/include/jemalloc.h +468 -0
- package/dist/lib/linux_aarch64/include/libdeflate.h +345 -0
- package/dist/lib/linux_aarch64/include/libdeflate_strings.h +35 -0
- package/dist/lib/linux_aarch64/include/linker_set.h +109 -0
- package/dist/lib/linux_aarch64/include/queue.h +627 -0
- package/dist/lib/linux_aarch64/include/selva/_export.h +7 -0
- package/dist/lib/linux_aarch64/include/selva/align.h +9 -0
- package/dist/lib/linux_aarch64/include/selva/backoff_timeout.h +29 -0
- package/dist/lib/linux_aarch64/include/selva/bitmap.h +95 -0
- package/dist/lib/linux_aarch64/include/selva/colvec.h +71 -0
- package/dist/lib/linux_aarch64/include/selva/crc32c.h +17 -0
- package/dist/lib/linux_aarch64/include/selva/ctime.h +135 -0
- package/dist/lib/linux_aarch64/include/selva/db.h +450 -0
- package/dist/lib/linux_aarch64/include/selva/endian.h +301 -0
- package/dist/lib/linux_aarch64/include/selva/fast_linear_search.h +27 -0
- package/dist/lib/linux_aarch64/include/selva/fast_memcmp.h +18 -0
- package/dist/lib/linux_aarch64/include/selva/fast_memmem.h +11 -0
- package/dist/lib/linux_aarch64/include/selva/fast_parsei.h +36 -0
- package/dist/lib/linux_aarch64/include/selva/fields.h +344 -0
- package/dist/lib/linux_aarch64/include/selva/gmtime.h +137 -0
- package/dist/lib/linux_aarch64/include/selva/hll.h +85 -0
- package/dist/lib/linux_aarch64/include/selva/lpf.h +28 -0
- package/dist/lib/linux_aarch64/include/selva/mblen.h +40 -0
- package/dist/lib/linux_aarch64/include/selva/membar.h +32 -0
- package/dist/lib/linux_aarch64/include/selva/node_id_set.h +43 -0
- package/dist/lib/linux_aarch64/include/selva/poptop.h +114 -0
- package/dist/lib/linux_aarch64/include/selva/selva_hash128.h +49 -0
- package/dist/lib/linux_aarch64/include/selva/selva_lang.h +112 -0
- package/dist/lib/linux_aarch64/include/selva/selva_math.h +37 -0
- package/dist/lib/linux_aarch64/include/selva/selva_string.h +683 -0
- package/dist/lib/linux_aarch64/include/selva/sort.h +140 -0
- package/dist/lib/linux_aarch64/include/selva/strsearch.h +43 -0
- package/dist/lib/linux_aarch64/include/selva/thread.h +37 -0
- package/dist/lib/linux_aarch64/include/selva/timestamp.h +25 -0
- package/dist/lib/linux_aarch64/include/selva/types.h +116 -0
- package/dist/lib/linux_aarch64/include/selva/vector.h +35 -0
- package/dist/lib/linux_aarch64/include/selva_error.h +140 -0
- package/dist/lib/linux_aarch64/include/selva_lang_code.h +160 -0
- package/dist/lib/linux_aarch64/include/tree.h +852 -0
- package/dist/lib/linux_aarch64/libdeflate.so +0 -0
- package/dist/lib/linux_aarch64/libjemalloc_selva.so.2 +0 -0
- package/dist/lib/linux_aarch64/libnode-v22.node +0 -0
- package/dist/lib/linux_aarch64/libnode-v23.node +0 -0
- package/dist/lib/linux_aarch64/libnode-v24.node +0 -0
- package/dist/lib/linux_aarch64/libnode-v25.node +0 -0
- package/dist/lib/linux_aarch64/libselva.so +0 -0
- package/dist/lib/linux_aarch64/libxxhash.so.0 +0 -0
- package/dist/lib/linux_x86_64/include/cdefs.h +324 -0
- package/dist/lib/linux_x86_64/include/jemalloc.h +468 -0
- package/dist/lib/linux_x86_64/include/libdeflate.h +345 -0
- package/dist/lib/linux_x86_64/include/libdeflate_strings.h +35 -0
- package/dist/lib/linux_x86_64/include/linker_set.h +109 -0
- package/dist/lib/linux_x86_64/include/queue.h +627 -0
- package/dist/lib/linux_x86_64/include/selva/_export.h +7 -0
- package/dist/lib/linux_x86_64/include/selva/align.h +9 -0
- package/dist/lib/linux_x86_64/include/selva/backoff_timeout.h +29 -0
- package/dist/lib/linux_x86_64/include/selva/bitmap.h +95 -0
- package/dist/lib/linux_x86_64/include/selva/colvec.h +71 -0
- package/dist/lib/linux_x86_64/include/selva/crc32c.h +17 -0
- package/dist/lib/linux_x86_64/include/selva/ctime.h +135 -0
- package/dist/lib/linux_x86_64/include/selva/db.h +450 -0
- package/dist/lib/linux_x86_64/include/selva/endian.h +301 -0
- package/dist/lib/linux_x86_64/include/selva/fast_linear_search.h +27 -0
- package/dist/lib/linux_x86_64/include/selva/fast_memcmp.h +18 -0
- package/dist/lib/linux_x86_64/include/selva/fast_memmem.h +11 -0
- package/dist/lib/linux_x86_64/include/selva/fast_parsei.h +36 -0
- package/dist/lib/linux_x86_64/include/selva/fields.h +344 -0
- package/dist/lib/linux_x86_64/include/selva/gmtime.h +137 -0
- package/dist/lib/linux_x86_64/include/selva/hll.h +85 -0
- package/dist/lib/linux_x86_64/include/selva/lpf.h +28 -0
- package/dist/lib/linux_x86_64/include/selva/mblen.h +40 -0
- package/dist/lib/linux_x86_64/include/selva/membar.h +32 -0
- package/dist/lib/linux_x86_64/include/selva/node_id_set.h +43 -0
- package/dist/lib/linux_x86_64/include/selva/poptop.h +114 -0
- package/dist/lib/linux_x86_64/include/selva/selva_hash128.h +49 -0
- package/dist/lib/linux_x86_64/include/selva/selva_lang.h +112 -0
- package/dist/lib/linux_x86_64/include/selva/selva_math.h +37 -0
- package/dist/lib/linux_x86_64/include/selva/selva_string.h +683 -0
- package/dist/lib/linux_x86_64/include/selva/sort.h +140 -0
- package/dist/lib/linux_x86_64/include/selva/strsearch.h +43 -0
- package/dist/lib/linux_x86_64/include/selva/thread.h +37 -0
- package/dist/lib/linux_x86_64/include/selva/timestamp.h +25 -0
- package/dist/lib/linux_x86_64/include/selva/types.h +116 -0
- package/dist/lib/linux_x86_64/include/selva/vector.h +35 -0
- package/dist/lib/linux_x86_64/include/selva_error.h +140 -0
- package/dist/lib/linux_x86_64/include/selva_lang_code.h +160 -0
- package/dist/lib/linux_x86_64/include/tree.h +852 -0
- package/dist/lib/linux_x86_64/libdeflate.so +0 -0
- package/dist/lib/linux_x86_64/libjemalloc_selva.so.2 +0 -0
- package/dist/lib/linux_x86_64/libnode-v22.node +0 -0
- package/dist/lib/linux_x86_64/libnode-v23.node +0 -0
- package/dist/lib/linux_x86_64/libnode-v24.node +0 -0
- package/dist/lib/linux_x86_64/libnode-v25.node +0 -0
- package/dist/lib/linux_x86_64/libselva.so +0 -0
- package/dist/lib/linux_x86_64/libxxhash.so.0 +0 -0
- package/dist/src/client/modify/props/fixed.js +1 -1
- package/dist/src/client/modify/types.d.ts +1 -0
- package/dist/src/client/modify/types.js +1 -0
- package/dist/src/client/query/BasedDbQuery.d.ts +1 -0
- package/dist/src/client/query/BasedDbQuery.js +14 -0
- package/dist/src/client/query/BasedQueryResponse.js +1 -1
- package/dist/src/client/query/filter/filter.js +26 -17
- package/dist/src/client/query/filter/toByteCode.js +18 -9
- package/dist/src/client/query/include/utils.d.ts +2 -2
- package/dist/src/client/query/include/utils.js +7 -6
- package/dist/src/client/query/include/walk.js +20 -2
- package/dist/src/client/query/queryDefToReadSchema.js +1 -1
- package/dist/src/client/query/subscription/index.js +6 -6
- package/dist/src/client/query/subscription/toByteCode.js +11 -6
- package/dist/src/client/query/types.d.ts +17 -1
- package/dist/src/client/query/types.js +23 -0
- package/dist/src/server/schemaSelvaBuffer.js +8 -11
- package/dist/src/server/subscription.js +0 -12
- package/package.json +7 -7
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2021, 2023, 2025 SAULX
|
|
3
|
+
* SPDX-License-Identifier: BSD-2-Clause
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
#pragma once
|
|
7
|
+
|
|
8
|
+
#include <stddef.h>
|
|
9
|
+
#include <stdint.h>
|
|
10
|
+
#include "selva/_export.h"
|
|
11
|
+
|
|
12
|
+
#if __SIZEOF_INT128__ != 16
|
|
13
|
+
#error The compiler and architecture must have Tetra-Integer support
|
|
14
|
+
#endif
|
|
15
|
+
|
|
16
|
+
typedef unsigned __int128 bitmap_t;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* A flexible bitmap.
|
|
20
|
+
*/
|
|
21
|
+
struct bitmap {
|
|
22
|
+
size_t nbits;
|
|
23
|
+
bitmap_t d[];
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
#define BITMAP_CEILING(x, y) \
|
|
27
|
+
(((x) + (y) - (size_t)1) / (y))
|
|
28
|
+
|
|
29
|
+
/*
|
|
30
|
+
* We use this instead of max() to avoid GCC compound statements that don't work
|
|
31
|
+
* outside of functions. C23 constexpr might make compound statements available
|
|
32
|
+
* for initialization but compound statements are currently only supported in
|
|
33
|
+
* GCC 13 and there is no support in Clang.
|
|
34
|
+
*/
|
|
35
|
+
#define BITMAP_MAX(a, b) \
|
|
36
|
+
((a) > (b) ? (a) : (b))
|
|
37
|
+
|
|
38
|
+
#define BITMAP_D_SIZE(nbits) \
|
|
39
|
+
(BITMAP_CEILING(BITMAP_MAX((size_t)(nbits), (size_t)8) / (size_t)8, sizeof(bitmap_t)) * sizeof(bitmap_t))
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Byte size of a bitmap struct passable to a malloc()-like function.
|
|
43
|
+
* nbits must be a literal or variable.
|
|
44
|
+
*/
|
|
45
|
+
#define BITMAP_ALLOC_SIZE(nbits) \
|
|
46
|
+
(sizeof(struct bitmap) + BITMAP_D_SIZE(nbits))
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Get the status of a bit in a bitmap pointed by bitmap.
|
|
50
|
+
* @param bitmap is a pointer to a bitmap.
|
|
51
|
+
* @param pos is the bit position to be checked.
|
|
52
|
+
* @return Boolean value or -1.
|
|
53
|
+
*/
|
|
54
|
+
SELVA_EXPORT
|
|
55
|
+
int bitmap_get(const struct bitmap *bitmap, size_t pos)
|
|
56
|
+
__attribute__((pure, access(read_only, 1)));
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Set a bit in a bitmap pointed by bitmap.
|
|
60
|
+
* @param bitmap is a pointer to a bitmap.
|
|
61
|
+
* @param pos is the bit position to be set.
|
|
62
|
+
* @return 0 or -1.
|
|
63
|
+
*/
|
|
64
|
+
SELVA_EXPORT
|
|
65
|
+
int bitmap_set(struct bitmap *bitmap, size_t pos)
|
|
66
|
+
__attribute__((access(read_write, 1)));
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Clear a bit in a bitmap pointed by bitmap.
|
|
70
|
+
* @param bitmap is a pointer to a bitmap.
|
|
71
|
+
* @param pos is the bit position to be cleared.
|
|
72
|
+
* @return 0 or -1.
|
|
73
|
+
*/
|
|
74
|
+
SELVA_EXPORT
|
|
75
|
+
int bitmap_clear(struct bitmap *bitmap, size_t pos)
|
|
76
|
+
__attribute__((access(read_write, 1)));
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Erase the whole bitmap.
|
|
80
|
+
* @param bitmap is a pointer to a bitmap.
|
|
81
|
+
*/
|
|
82
|
+
SELVA_EXPORT
|
|
83
|
+
void bitmap_erase(struct bitmap *bitmap)
|
|
84
|
+
__attribute__((access(read_write, 1)));
|
|
85
|
+
|
|
86
|
+
SELVA_EXPORT
|
|
87
|
+
long long bitmap_popcount(const struct bitmap *bitmap)
|
|
88
|
+
__attribute__((pure, access(read_only, 1)));
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Find first set.
|
|
92
|
+
*/
|
|
93
|
+
SELVA_EXPORT
|
|
94
|
+
int bitmap_ffs(const struct bitmap *bitmap)
|
|
95
|
+
__attribute__((pure, access(read_only, 1)));
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025 SAULX
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
#pragma once
|
|
6
|
+
|
|
7
|
+
#include <stddef.h>
|
|
8
|
+
#include <stdint.h>
|
|
9
|
+
#include "selva/types.h"
|
|
10
|
+
#include "selva/selva_hash128.h"
|
|
11
|
+
#include "selva/_export.h"
|
|
12
|
+
|
|
13
|
+
struct SelvaColvec {
|
|
14
|
+
field_t field;
|
|
15
|
+
uint16_t vec_size;
|
|
16
|
+
size_t slab_size; /* Size of each slab in v. */
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Array of pointers to vector slabs.
|
|
20
|
+
* te->blocks->len number of pointers to vector blocks each containing
|
|
21
|
+
* te->blocks->block_capacity vectors.
|
|
22
|
+
*/
|
|
23
|
+
void **v;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Initialize colvec record keeping under te->col_fields.
|
|
28
|
+
*/
|
|
29
|
+
void colvec_init_te(struct SelvaTypeEntry *te);
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Deinitialize colvec record keeping and col slabs under te->col_fields.
|
|
33
|
+
*/
|
|
34
|
+
void colvec_deinit_te(struct SelvaTypeEntry *te);
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Initialize a slab at block_i if not already Initialized.
|
|
38
|
+
*/
|
|
39
|
+
void *colvec_init_slab(struct SelvaColvec *colvec, block_id_t block_i);
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Initialize all columnar fields of node.
|
|
43
|
+
* This function will also initialize the slab(s) if it's not allocated.
|
|
44
|
+
*/
|
|
45
|
+
void colvec_init_node(struct SelvaTypeEntry *te, struct SelvaNode *node);
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Compute the hash for a node_id in colvec.
|
|
49
|
+
*/
|
|
50
|
+
void colvec_hash_update(struct SelvaTypeEntry *te, node_id_t node_id, struct SelvaColvec *colvec, selva_hash_state_t *hash_state);
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Get the whole column for fs.
|
|
54
|
+
*/
|
|
55
|
+
SELVA_EXPORT
|
|
56
|
+
struct SelvaColvec *colvec_get(struct SelvaTypeEntry *te, const struct SelvaFieldSchema *fs);
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Get a single vector in a colvec field by node_id.
|
|
60
|
+
*/
|
|
61
|
+
SELVA_EXPORT
|
|
62
|
+
void *colvec_get_vec(struct SelvaTypeEntry *te, node_id_t node_id, const struct SelvaFieldSchema *fs);
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Set a single vector in a colvec field.
|
|
66
|
+
*/
|
|
67
|
+
SELVA_EXPORT
|
|
68
|
+
void colvec_set_vec(struct SelvaTypeEntry *te, node_id_t node_id, const struct SelvaFieldSchema *fs, const void *vec);
|
|
69
|
+
|
|
70
|
+
SELVA_EXPORT
|
|
71
|
+
int colvec_foreach(struct SelvaTypeEntry *te, const struct SelvaFieldSchema *fs, node_id_t start, uint32_t len, void (*cb)(node_id_t node_id, void *vec, void *arg), void *arg);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025 SAULX
|
|
3
|
+
* Copyright (C) 2013, 2021 Mark Adler <madler@alumni.caltech.edu>
|
|
4
|
+
* SPDX-License-Identifier: Zlib
|
|
5
|
+
*/
|
|
6
|
+
#pragma once
|
|
7
|
+
|
|
8
|
+
#include <stddef.h>
|
|
9
|
+
#include <stdint.h>
|
|
10
|
+
#include "selva/_export.h"
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Compute CRC-32C.
|
|
14
|
+
*/
|
|
15
|
+
SELVA_EXPORT
|
|
16
|
+
uint32_t crc32c(uint32_t crc, void const *buf, size_t len)
|
|
17
|
+
__attribute__((pure, access(read_only, 2, 3)));
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*******************************************************************************
|
|
3
|
+
* @file ctime.h
|
|
4
|
+
* @author Olli Vanhoja
|
|
5
|
+
* @brief time types.
|
|
6
|
+
* @section LICENSE
|
|
7
|
+
* Copyright (c) 2022-2025 Saulx
|
|
8
|
+
* Copyright (c) 2020 Olli Vanhoja <olli.vanhoja@alumni.helsinki.fi>
|
|
9
|
+
* Copyright (c) 2014 - 2016 Olli Vanhoja <olli.vanhoja@cs.helsinki.fi>
|
|
10
|
+
* All rights reserved.
|
|
11
|
+
*
|
|
12
|
+
* Redistribution and use in source and binary forms, with or without
|
|
13
|
+
* modification, are permitted provided that the following conditions are met:
|
|
14
|
+
*
|
|
15
|
+
* 1. Redistributions of source code must retain the above copyright notice,
|
|
16
|
+
* this list of conditions and the following disclaimer.
|
|
17
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
18
|
+
* this list of conditions and the following disclaimer in the documentation
|
|
19
|
+
* and/or other materials provided with the distribution.
|
|
20
|
+
*
|
|
21
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
22
|
+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
23
|
+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
24
|
+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
25
|
+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
26
|
+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
27
|
+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
28
|
+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
29
|
+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
30
|
+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
31
|
+
* POSSIBILITY OF SUCH DAMAGE.
|
|
32
|
+
* SPDX-License-Identifier: BSD-2-Clause
|
|
33
|
+
*******************************************************************************
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
#pragma once
|
|
37
|
+
|
|
38
|
+
#include <stdint.h>
|
|
39
|
+
#include <time.h>
|
|
40
|
+
#include "selva/_export.h"
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Conver an msec value to a timespec struct.
|
|
44
|
+
* @param[out] ts is a pointer to the destination struct.
|
|
45
|
+
* @param[in] nsec is the value in milliseconds.
|
|
46
|
+
*/
|
|
47
|
+
SELVA_EXPORT
|
|
48
|
+
struct timespec *msec2timespec(struct timespec * ts, int64_t msec);
|
|
49
|
+
|
|
50
|
+
#define MSEC2TIMESPEC(msec) \
|
|
51
|
+
({ struct timespec _ts; (void)msec2timespec(&_ts, msec); _ts; })
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Convert a nsec value to a timespec struct.
|
|
55
|
+
* @param[out] ts is a pointer to the destination struct.
|
|
56
|
+
* @param[in] nsec is the value in nanoseconds.
|
|
57
|
+
*/
|
|
58
|
+
SELVA_EXPORT
|
|
59
|
+
struct timespec *nsec2timespec(struct timespec * ts, int64_t nsec);
|
|
60
|
+
|
|
61
|
+
#define NSEC2TIMESPEC(nsec) \
|
|
62
|
+
({ struct timespec _ts; (void)NSEC2TIMESPEC(&_ts, nsec); _ts; })
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Compare two timespec structs.
|
|
66
|
+
* @param[in] left is a pointer to the left value.
|
|
67
|
+
* @param[in] right is a pointer to the right value.
|
|
68
|
+
* @param[in] cmp is the operator (<, >, ==, <=, or >=).
|
|
69
|
+
* @returns a boolean value.
|
|
70
|
+
*/
|
|
71
|
+
#define timespec_cmp(left_tsp, right_tsp, cmp) ({ \
|
|
72
|
+
(((left_tsp)->tv_sec == (right_tsp)->tv_sec) \
|
|
73
|
+
? ((left_tsp)->tv_nsec cmp (right_tsp)->tv_nsec) \
|
|
74
|
+
: ((left_tsp)->tv_sec cmp (right_tsp)->tv_sec)); \
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Calculate the sum of two timespec structs.
|
|
79
|
+
* @param[out] sum is a pointer to the destination struct.
|
|
80
|
+
* @param[in] left is a pointer to the left value.
|
|
81
|
+
* @param[in] right is a pointer to the right value.
|
|
82
|
+
*/
|
|
83
|
+
SELVA_EXPORT
|
|
84
|
+
void timespec_add(struct timespec * sum, const struct timespec * left,
|
|
85
|
+
const struct timespec * right)
|
|
86
|
+
__attribute__((access(write_only, 1), access(read_only, 2), access(read_only, 3)));
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Calculate the difference of two timespec structs.
|
|
90
|
+
* @param[out] sum is a pointer to the destination struct.
|
|
91
|
+
* @param[in] left is a pointer to the left value.
|
|
92
|
+
* @param[in] right is a pointer to the right value.
|
|
93
|
+
*/
|
|
94
|
+
SELVA_EXPORT
|
|
95
|
+
void timespec_sub(struct timespec * diff, const struct timespec * left,
|
|
96
|
+
const struct timespec * right)
|
|
97
|
+
__attribute__((access(write_only, 1), access(read_only, 2), access(read_only, 3)));
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Calculate the product of two timespec structs.
|
|
101
|
+
* @param[out] sum is a pointer to the destination struct.
|
|
102
|
+
* @param[in] left is a pointer to the left value.
|
|
103
|
+
* @param[in] right is a pointer to the right value.
|
|
104
|
+
*/
|
|
105
|
+
SELVA_EXPORT
|
|
106
|
+
void timespec_mul(struct timespec * prod, const struct timespec * left,
|
|
107
|
+
const struct timespec * right)
|
|
108
|
+
__attribute__((access(write_only, 1), access(read_only, 2), access(read_only, 3)));
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Calculate the quotient of two timespec structs.
|
|
112
|
+
* @param[out] sum is a pointer to the destination struct.
|
|
113
|
+
* @param[in] left is a pointer to the left value.
|
|
114
|
+
* @param[in] right is a pointer to the right value.
|
|
115
|
+
*/
|
|
116
|
+
SELVA_EXPORT
|
|
117
|
+
void timespec_div(struct timespec * quot, const struct timespec * left,
|
|
118
|
+
const struct timespec * right)
|
|
119
|
+
__attribute__((access(write_only, 1), access(read_only, 2), access(read_only, 3)));
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Calculate the modulo of two timespec structs.
|
|
123
|
+
* @param[out] sum is a pointer to the destination struct.
|
|
124
|
+
* @param[in] left is a pointer to the left value.
|
|
125
|
+
* @param[in] right is a pointer to the right value.
|
|
126
|
+
*/
|
|
127
|
+
void timespec_mod(struct timespec * rem, const struct timespec * left,
|
|
128
|
+
const struct timespec * right)
|
|
129
|
+
__attribute__((access(write_only, 1), access(read_only, 2), access(read_only, 3)));
|
|
130
|
+
|
|
131
|
+
static inline double timespec2ms(const struct timespec *ts)
|
|
132
|
+
{
|
|
133
|
+
return (double)ts->tv_sec * 1000.0 + (double)ts->tv_nsec / 1.0e6;
|
|
134
|
+
}
|
|
135
|
+
|