@based/db 0.1.2 → 0.1.3-alpha.1

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.
Files changed (99) hide show
  1. package/dist/lib/darwin_aarch64/libnode-v22.node +0 -0
  2. package/dist/lib/darwin_aarch64/libnode-v23.node +0 -0
  3. package/dist/lib/darwin_aarch64/libnode-v24.node +0 -0
  4. package/dist/lib/darwin_aarch64/libselva.dylib +0 -0
  5. package/dist/lib/linux_aarch64/include/cdefs.h +317 -0
  6. package/dist/lib/linux_aarch64/include/jemalloc.h +468 -0
  7. package/dist/lib/linux_aarch64/include/libdeflate.h +345 -0
  8. package/dist/lib/linux_aarch64/include/libdeflate_strings.h +35 -0
  9. package/dist/lib/linux_aarch64/include/linker_set.h +109 -0
  10. package/dist/lib/linux_aarch64/include/queue.h +627 -0
  11. package/dist/lib/linux_aarch64/include/selva/_export.h +7 -0
  12. package/dist/lib/linux_aarch64/include/selva/align.h +9 -0
  13. package/dist/lib/linux_aarch64/include/selva/backoff_timeout.h +29 -0
  14. package/dist/lib/linux_aarch64/include/selva/bitmap.h +95 -0
  15. package/dist/lib/linux_aarch64/include/selva/colvec.h +71 -0
  16. package/dist/lib/linux_aarch64/include/selva/crc32c.h +17 -0
  17. package/dist/lib/linux_aarch64/include/selva/ctime.h +135 -0
  18. package/dist/lib/linux_aarch64/include/selva/db.h +407 -0
  19. package/dist/lib/linux_aarch64/include/selva/endian.h +301 -0
  20. package/dist/lib/linux_aarch64/include/selva/fast_linear_search.h +27 -0
  21. package/dist/lib/linux_aarch64/include/selva/fast_memcmp.h +18 -0
  22. package/dist/lib/linux_aarch64/include/selva/fast_memmem.h +11 -0
  23. package/dist/lib/linux_aarch64/include/selva/fast_parsei.h +36 -0
  24. package/dist/lib/linux_aarch64/include/selva/fields.h +407 -0
  25. package/dist/lib/linux_aarch64/include/selva/gmtime.h +137 -0
  26. package/dist/lib/linux_aarch64/include/selva/hll.h +85 -0
  27. package/dist/lib/linux_aarch64/include/selva/lpf.h +28 -0
  28. package/dist/lib/linux_aarch64/include/selva/mblen.h +40 -0
  29. package/dist/lib/linux_aarch64/include/selva/membar.h +32 -0
  30. package/dist/lib/linux_aarch64/include/selva/node_id_set.h +43 -0
  31. package/dist/lib/linux_aarch64/include/selva/poptop.h +114 -0
  32. package/dist/lib/linux_aarch64/include/selva/selva_hash128.h +49 -0
  33. package/dist/lib/linux_aarch64/include/selva/selva_lang.h +105 -0
  34. package/dist/lib/linux_aarch64/include/selva/selva_math.h +37 -0
  35. package/dist/lib/linux_aarch64/include/selva/selva_string.h +679 -0
  36. package/dist/lib/linux_aarch64/include/selva/sort.h +140 -0
  37. package/dist/lib/linux_aarch64/include/selva/strsearch.h +43 -0
  38. package/dist/lib/linux_aarch64/include/selva/thread.h +37 -0
  39. package/dist/lib/linux_aarch64/include/selva/timestamp.h +25 -0
  40. package/dist/lib/linux_aarch64/include/selva/types.h +129 -0
  41. package/dist/lib/linux_aarch64/include/selva/vector.h +35 -0
  42. package/dist/lib/linux_aarch64/include/selva_error.h +140 -0
  43. package/dist/lib/linux_aarch64/include/selva_lang_code.h +160 -0
  44. package/dist/lib/linux_aarch64/include/tree.h +852 -0
  45. package/dist/lib/linux_aarch64/libdeflate.so +0 -0
  46. package/dist/lib/linux_aarch64/libjemalloc_selva.so.2 +0 -0
  47. package/dist/lib/linux_aarch64/libnode-v22.node +0 -0
  48. package/dist/lib/linux_aarch64/libnode-v23.node +0 -0
  49. package/dist/lib/linux_aarch64/libnode-v24.node +0 -0
  50. package/dist/lib/linux_aarch64/libselva.so +0 -0
  51. package/dist/lib/linux_aarch64/libxxhash.so.0 +0 -0
  52. package/dist/lib/linux_x86_64/include/cdefs.h +317 -0
  53. package/dist/lib/linux_x86_64/include/jemalloc.h +468 -0
  54. package/dist/lib/linux_x86_64/include/libdeflate.h +345 -0
  55. package/dist/lib/linux_x86_64/include/libdeflate_strings.h +35 -0
  56. package/dist/lib/linux_x86_64/include/linker_set.h +109 -0
  57. package/dist/lib/linux_x86_64/include/queue.h +627 -0
  58. package/dist/lib/linux_x86_64/include/selva/_export.h +7 -0
  59. package/dist/lib/linux_x86_64/include/selva/align.h +9 -0
  60. package/dist/lib/linux_x86_64/include/selva/backoff_timeout.h +29 -0
  61. package/dist/lib/linux_x86_64/include/selva/bitmap.h +95 -0
  62. package/dist/lib/linux_x86_64/include/selva/colvec.h +71 -0
  63. package/dist/lib/linux_x86_64/include/selva/crc32c.h +17 -0
  64. package/dist/lib/linux_x86_64/include/selva/ctime.h +135 -0
  65. package/dist/lib/linux_x86_64/include/selva/db.h +407 -0
  66. package/dist/lib/linux_x86_64/include/selva/endian.h +301 -0
  67. package/dist/lib/linux_x86_64/include/selva/fast_linear_search.h +27 -0
  68. package/dist/lib/linux_x86_64/include/selva/fast_memcmp.h +18 -0
  69. package/dist/lib/linux_x86_64/include/selva/fast_memmem.h +11 -0
  70. package/dist/lib/linux_x86_64/include/selva/fast_parsei.h +36 -0
  71. package/dist/lib/linux_x86_64/include/selva/fields.h +407 -0
  72. package/dist/lib/linux_x86_64/include/selva/gmtime.h +137 -0
  73. package/dist/lib/linux_x86_64/include/selva/hll.h +85 -0
  74. package/dist/lib/linux_x86_64/include/selva/lpf.h +28 -0
  75. package/dist/lib/linux_x86_64/include/selva/mblen.h +40 -0
  76. package/dist/lib/linux_x86_64/include/selva/membar.h +32 -0
  77. package/dist/lib/linux_x86_64/include/selva/node_id_set.h +43 -0
  78. package/dist/lib/linux_x86_64/include/selva/poptop.h +114 -0
  79. package/dist/lib/linux_x86_64/include/selva/selva_hash128.h +49 -0
  80. package/dist/lib/linux_x86_64/include/selva/selva_lang.h +105 -0
  81. package/dist/lib/linux_x86_64/include/selva/selva_math.h +37 -0
  82. package/dist/lib/linux_x86_64/include/selva/selva_string.h +679 -0
  83. package/dist/lib/linux_x86_64/include/selva/sort.h +140 -0
  84. package/dist/lib/linux_x86_64/include/selva/strsearch.h +43 -0
  85. package/dist/lib/linux_x86_64/include/selva/thread.h +37 -0
  86. package/dist/lib/linux_x86_64/include/selva/timestamp.h +25 -0
  87. package/dist/lib/linux_x86_64/include/selva/types.h +129 -0
  88. package/dist/lib/linux_x86_64/include/selva/vector.h +35 -0
  89. package/dist/lib/linux_x86_64/include/selva_error.h +140 -0
  90. package/dist/lib/linux_x86_64/include/selva_lang_code.h +160 -0
  91. package/dist/lib/linux_x86_64/include/tree.h +852 -0
  92. package/dist/lib/linux_x86_64/libdeflate.so +0 -0
  93. package/dist/lib/linux_x86_64/libjemalloc_selva.so.2 +0 -0
  94. package/dist/lib/linux_x86_64/libnode-v22.node +0 -0
  95. package/dist/lib/linux_x86_64/libnode-v23.node +0 -0
  96. package/dist/lib/linux_x86_64/libnode-v24.node +0 -0
  97. package/dist/lib/linux_x86_64/libselva.so +0 -0
  98. package/dist/lib/linux_x86_64/libxxhash.so.0 +0 -0
  99. package/package.json +1 -1
@@ -0,0 +1,317 @@
1
+ /*
2
+ * Copyright (c) 2020-2024 SAULX
3
+ * SPDX-License-Identifier: BSD-2-Clause
4
+ */
5
+
6
+ #pragma once
7
+ #ifndef _UTIL_CDEFS_H_
8
+ #define _UTIL_CDEFS_H_
9
+
10
+ #if __STDC_VERSION__ < 202311L
11
+ #define static_assert _Static_assert
12
+ #if defined(__clang__) && !defined(unreachable)
13
+ #define unreachable __builtin_unreachable
14
+ #endif
15
+ #endif
16
+
17
+ #if defined(__linux__)
18
+ /**
19
+ * Force linking against a specific version of a GLIBC symbol.
20
+ * Use this at the top-level of a source file.
21
+ */
22
+ #define GLIBC_COMPAT_SYMBOL(SYM, VER) \
23
+ __asm__(".symver " #SYM "," #SYM "@GLIBC_" #VER);
24
+ #else
25
+ #define GLIBC_COMPAT_SYMBOL(SYM, VER)
26
+ #endif
27
+
28
+ #if defined(__GNUC__) && !defined(__clang__)
29
+ /**
30
+ * The char array isn't a NUL terminated C-string.
31
+ * Using this attribute will help to get better warnings at compilation time.
32
+ */
33
+ #define __nonstring __attribute__((nonstring))
34
+ /**
35
+ * Annotate a pure function.
36
+ * The function has no side effects and the value returned depends on the
37
+ * arguments and the state of global variables. Therefore it is safe for
38
+ * the optimizer to eliminate repeated calls with unchanged arguments.
39
+ */
40
+ #define __purefn __attribute__((pure))
41
+ /**
42
+ * Annotate a const function.
43
+ * The return value of the function is solely a function of its arguments,
44
+ * and if any of the arguments are pointers, then the pointers are not be
45
+ * dereferenced.
46
+ */
47
+ #define __constfn __attribute__((const))
48
+ #else
49
+ #define __nonstring
50
+ #define __purefn
51
+ #define __constfn
52
+ #endif
53
+
54
+ #define __sentinel __attribute__((sentinel))
55
+
56
+ #if __has_c_attribute(noreturn)
57
+ #define __noreturn [[noreturn]]
58
+ #else
59
+ #define __noreturn __attribute__((noreturn))
60
+ #endif
61
+
62
+ #define __transparent_union __attribute__((__transparent_union__))
63
+
64
+ #define CONCATENATE(arg1, arg2) CONCATENATE1(arg1, arg2)
65
+ #define CONCATENATE1(arg1, arg2) CONCATENATE2(arg1, arg2)
66
+ #define CONCATENATE2(arg1, arg2) arg1##arg2
67
+
68
+ #define UTIL_NARG(...) \
69
+ UTIL_NARG_(__VA_ARGS__, UTIL_RSEQ_N())
70
+ #define UTIL_NARG_(...) UTIL_ARG_N(__VA_ARGS__)
71
+ #define UTIL_ARG_N( \
72
+ _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, \
73
+ _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, \
74
+ _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, \
75
+ _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, \
76
+ _57, _58, _59, _60, _61, _62, _63, N, ...) N
77
+ # define UTIL_RSEQ_N() \
78
+ 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, \
79
+ 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, \
80
+ 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, \
81
+ 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0
82
+
83
+ #define _S__LINE__S(x) #x
84
+ #define _S__LINE__S2(x) _S__LINE__S(x)
85
+ /**
86
+ * Current line number as a string.
87
+ */
88
+ #define S__LINE__ _S__LINE__S2(__LINE__)
89
+
90
+ #ifndef __GLOBL1
91
+ #define __GLOBL1(sym) __asm__(".globl " #sym)
92
+ /**
93
+ * Make the symbol `sym` visible to the linker.
94
+ */
95
+ #define __GLOBL(sym) __GLOBL1(sym)
96
+ #endif
97
+
98
+ #ifndef __weak_sym
99
+ /**
100
+ * Emit the declaration as a weak symbol.
101
+ * A weak symbol can be overridden at linking. This is particularly useful for
102
+ * functions.
103
+ *
104
+ */
105
+ #define __weak_sym __attribute__((weak))
106
+ #endif
107
+
108
+ #ifndef __used
109
+ /**
110
+ * The function or variable is used.
111
+ * Inform the compiler that the fuction is used and the code must be emitted
112
+ * even if the function name is not referenced.
113
+ */
114
+ #define __used __attribute__((__used__))
115
+ #endif
116
+
117
+ #ifndef __unused
118
+ /**
119
+ * The function or variable is unused on purpose.
120
+ */
121
+ #define __unused __attribute__((__unused__))
122
+ #endif
123
+
124
+ #ifndef __section
125
+ /**
126
+ * Store the variable or function in a named section.
127
+ */
128
+ #define __section(x) __attribute__((__section__(x)))
129
+ #endif
130
+
131
+ #if defined(__APPLE__)
132
+ #define __lazy_alloc_glob
133
+ #else
134
+ /**
135
+ * Lazy alloc global variable.
136
+ * On many system (especially Linux) user defined sections are not zeroed on
137
+ * startup and thus implicitly neither allocated until accessed. This allows
138
+ * us to create global variables that are allocated lazily.
139
+ */
140
+ #define __lazy_alloc_glob __attribute__((__section__("lazy")))
141
+ #endif
142
+
143
+ /**
144
+ * A function that must be called before `main()`.
145
+ * The function is called automatically before executing `main()`.
146
+ */
147
+ #define __constructor __attribute__((constructor))
148
+
149
+ /**
150
+ * A function that must be called after `main()` exits.
151
+ * The function is called automatically after `main()` exits.
152
+ */
153
+ #define __destructor __attribute__((destructor))
154
+
155
+ #ifndef __hot
156
+ /**
157
+ * Inform the compiler that the function is a hotspot.
158
+ * Hot functions might be placed closely together in memory to improve locality.
159
+ */
160
+ #define __hot __attribute__((hot))
161
+ #endif
162
+
163
+ #ifndef __cold
164
+ /**
165
+ * Inform the compiler that the function is unlikely to be executed.
166
+ */
167
+ #define __cold __attribute__((cold))
168
+ #endif
169
+
170
+ #ifndef __packed
171
+ /**
172
+ * Use the minimum required memory to represent the type.
173
+ * The enum, union, structure, or a structure member should have the smallest
174
+ * possible alignment.
175
+ */
176
+ #define __packed __attribute__((packed))
177
+ #endif
178
+
179
+ #ifndef __counted_by
180
+ #if __has_attribute(__counted_by__)
181
+ /**
182
+ * struct foo {
183
+ * unsigned int len;
184
+ * char buf[] __counted_by(len);
185
+ * };
186
+ * __builtin_dynamic_object_size(p->buf) == p->len * sizeof(*p->buf)
187
+ */
188
+ #define __counted_by(member) __attribute__((__counted_by__(member)))
189
+ #else
190
+ #define __counted_by(member)
191
+ #endif
192
+ #endif
193
+
194
+ #ifndef __pcounted_by
195
+ #if __has_attribute(__counted_by__) && !defined(__clang__)
196
+ /**
197
+ * struct foo {
198
+ * unsigned int len;
199
+ * char *buf __pcounted_by(len);
200
+ * };
201
+ * __builtin_dynamic_object_size(p->buf) == p->len * sizeof(*p->buf)
202
+ */
203
+ #define __pcounted_by(member) __attribute__((__counted_by__(member)))
204
+ #else
205
+ #define __pcounted_by(member)
206
+ #endif
207
+ #endif
208
+
209
+ #ifndef __designated_init
210
+ #if __has_attribute(__designated_init__)
211
+ /**
212
+ * Must use a designated initializer with a struct.
213
+ */
214
+ #define __designated_init __attribute__((__designated_init__))
215
+ #else
216
+ #define __designated_init
217
+ #endif
218
+ #endif
219
+
220
+ /* This should come with C23 */
221
+ #ifndef alignas
222
+ #define alignas(x) _Alignas(x)
223
+ #endif
224
+
225
+ /* This should come with C23 */
226
+ #ifndef alignof
227
+ #define alignof(x) _Alignof(x)
228
+ #endif
229
+
230
+ /**
231
+ * It's likely that `x` is always truthy in runtime.
232
+ */
233
+ #define likely(x) __builtin_expect(!!(x), 1)
234
+ #define unlikely(x) __builtin_expect(!!(x), 0)
235
+
236
+ #if __has_builtin(__builtin_speculation_safe_value)
237
+ #define speculation_safe_value(x) __builtin_speculation_safe_value(x)
238
+ #else
239
+ #define speculation_safe_value(x) x
240
+ #endif
241
+
242
+ #define same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b))
243
+
244
+ /**
245
+ * Statically assert that VAR is compatible with the type TYPE.
246
+ */
247
+ #define ASSERT_TYPE(TYPE, VAR) \
248
+ static_assert(__builtin_types_compatible_p(TYPE, typeof(VAR)))
249
+
250
+ /**
251
+ * Returns the smaller of the given values.
252
+ */
253
+ #define min(a, b) \
254
+ ({ __typeof__ (a) _a = (a); \
255
+ __typeof__ (b) _b = (b); \
256
+ _a < _b ? _a : _b; })
257
+
258
+ /**
259
+ * Returns the greater of the given values.
260
+ */
261
+ #define max(a, b) \
262
+ ({ __typeof__ (a) _a = (a); \
263
+ __typeof__ (b) _b = (b); \
264
+ _a > _b ? _a : _b; })
265
+
266
+ /**
267
+ * Get the struct that contains `m`.
268
+ * This macro can be only used if we know for certain that `x` is a pointer to
269
+ * the member `m` in type `s`.
270
+ * @param x is a pointer to the member `m` in a struct of type `s`.
271
+ * @param s is a struct type.
272
+ * @param m is the name of the member in `s`.
273
+ */
274
+ #define containerof(x, s, m) ({ \
275
+ const __typeof(((s *)0)->m) *__x = (x); \
276
+ ((s *)((uint8_t *)(__x) - offsetof(s, m))); \
277
+ })
278
+
279
+ /**
280
+ * Get the number of elements in an array.
281
+ */
282
+ #define num_elem(x) (sizeof(x) / sizeof(*(x)))
283
+
284
+ /**
285
+ * Size of struct field.
286
+ */
287
+ #define typeof_field(t, f) typeof(((t*)0)->f)
288
+
289
+ /**
290
+ * Size of struct field.
291
+ */
292
+ #define sizeof_field(t, f) (sizeof(((t*)0)->f))
293
+
294
+ /**
295
+ * Size of a struct with its flexible array member.
296
+ */
297
+ #define sizeof_wflex(t, f, count) \
298
+ max(sizeof(t), offsetof(t, f[0]) + (count) * sizeof(((t*)0)->f[0]))
299
+
300
+ /**
301
+ * Check if pointer has a const qualifier.
302
+ */
303
+ #define IS_POINTER_CONST(P) \
304
+ _Generic(1 ? (P) : (void *)(P), \
305
+ void const *: 1, \
306
+ default : 0)
307
+
308
+ /**
309
+ * Static ternary if.
310
+ * Selects either T or E depending on P.
311
+ */
312
+ #define STATIC_IF(P, T, E) \
313
+ _Generic (&(char [!!(P) + 1]) {0}, \
314
+ char (*) [2] : T, \
315
+ char (*) [1] : E)
316
+
317
+ #endif /* _UTIL_CDEFS_H_ */