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