yeptris 0.6.18.2-arm-linux-eabihf

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 (142) hide show
  1. checksums.yaml +7 -0
  2. data/README.adoc +141 -0
  3. data/ext/build_windows_native.rb +41 -0
  4. data/ext/libyeptris/extconf.rb +57 -0
  5. data/ext/yeptris_native/cbor_ruby.c +193 -0
  6. data/ext/yeptris_native/extconf.rb +47 -0
  7. data/ext/yeptris_native/json_ruby.c +354 -0
  8. data/ext/yeptris_native/yeptris_native.c +497 -0
  9. data/lib/yeptris/cbor.rb +130 -0
  10. data/lib/yeptris/document.rb +255 -0
  11. data/lib/yeptris/ffi.rb +426 -0
  12. data/lib/yeptris/json/descriptor.rb +266 -0
  13. data/lib/yeptris/json.rb +394 -0
  14. data/lib/yeptris/materializer.rb +354 -0
  15. data/lib/yeptris/native-3.4.so +0 -0
  16. data/lib/yeptris/node.rb +453 -0
  17. data/lib/yeptris/psych/class_loader.rb +24 -0
  18. data/lib/yeptris/psych/coder_shim.rb +55 -0
  19. data/lib/yeptris/psych/drop_in.rb +63 -0
  20. data/lib/yeptris/psych/encodable.rb +14 -0
  21. data/lib/yeptris/psych/handler.rb +90 -0
  22. data/lib/yeptris/psych/parser.rb +105 -0
  23. data/lib/yeptris/psych/scalar_scanner.rb +149 -0
  24. data/lib/yeptris/psych/visitors.rb +545 -0
  25. data/lib/yeptris/psych.rb +622 -0
  26. data/lib/yeptris/schema.rb +253 -0
  27. data/lib/yeptris/valueml.rb +455 -0
  28. data/lib/yeptris/yaml/descriptor.rb +56 -0
  29. data/lib/yeptris/yaml.rb +422 -0
  30. data/lib/yeptris.rb +113 -0
  31. data/libyeptris.so +0 -0
  32. data/vendor/libyeptris/CMakeLists.txt +254 -0
  33. data/vendor/libyeptris/cmake/yeptris-config.cmake.in +5 -0
  34. data/vendor/libyeptris/cmake/yeptris.pc.in +11 -0
  35. data/vendor/libyeptris/src/CMakeLists.txt +167 -0
  36. data/vendor/libyeptris/src/include/yeptris/api.h +32 -0
  37. data/vendor/libyeptris/src/include/yeptris/cbor.h +101 -0
  38. data/vendor/libyeptris/src/include/yeptris/dom.h +190 -0
  39. data/vendor/libyeptris/src/include/yeptris/emit.h +81 -0
  40. data/vendor/libyeptris/src/include/yeptris/error.h +41 -0
  41. data/vendor/libyeptris/src/include/yeptris/events.h +157 -0
  42. data/vendor/libyeptris/src/include/yeptris/json.h +45 -0
  43. data/vendor/libyeptris/src/include/yeptris/json.hpp +258 -0
  44. data/vendor/libyeptris/src/include/yeptris/jsonc_compat.h +115 -0
  45. data/vendor/libyeptris/src/include/yeptris/marshal.h +52 -0
  46. data/vendor/libyeptris/src/include/yeptris/parse.h +48 -0
  47. data/vendor/libyeptris/src/include/yeptris/plan.h +100 -0
  48. data/vendor/libyeptris/src/include/yeptris/resolve.h +71 -0
  49. data/vendor/libyeptris/src/include/yeptris/schema.h +121 -0
  50. data/vendor/libyeptris/src/include/yeptris/tape.h +123 -0
  51. data/vendor/libyeptris/src/include/yeptris/types.h +38 -0
  52. data/vendor/libyeptris/src/include/yeptris/values.h +102 -0
  53. data/vendor/libyeptris/src/include/yeptris/version.h.in +29 -0
  54. data/vendor/libyeptris/src/include/yeptris/visit.h +77 -0
  55. data/vendor/libyeptris/src/include/yeptris/yajl_compat.h +135 -0
  56. data/vendor/libyeptris/src/include/yeptris.h +23 -0
  57. data/vendor/libyeptris/src/yeptris/build.c +376 -0
  58. data/vendor/libyeptris/src/yeptris/cbor/cbor.h +25 -0
  59. data/vendor/libyeptris/src/yeptris/cbor/decode.c +981 -0
  60. data/vendor/libyeptris/src/yeptris/cbor/encode.c +835 -0
  61. data/vendor/libyeptris/src/yeptris/cbor/sink.h +58 -0
  62. data/vendor/libyeptris/src/yeptris/common/chartype.c +41 -0
  63. data/vendor/libyeptris/src/yeptris/common/chartype.h +77 -0
  64. data/vendor/libyeptris/src/yeptris/common/cpu.c +81 -0
  65. data/vendor/libyeptris/src/yeptris/common/cpu.h +40 -0
  66. data/vendor/libyeptris/src/yeptris/common/error.c +65 -0
  67. data/vendor/libyeptris/src/yeptris/common/error.h +79 -0
  68. data/vendor/libyeptris/src/yeptris/common/mutex.h +45 -0
  69. data/vendor/libyeptris/src/yeptris/common/nametab.c +275 -0
  70. data/vendor/libyeptris/src/yeptris/common/nametab.h +68 -0
  71. data/vendor/libyeptris/src/yeptris/common/port.h +74 -0
  72. data/vendor/libyeptris/src/yeptris/common/simd_text.c +49 -0
  73. data/vendor/libyeptris/src/yeptris/common/simd_text.h +295 -0
  74. data/vendor/libyeptris/src/yeptris/common/simd_text_avx2.c +534 -0
  75. data/vendor/libyeptris/src/yeptris/common/simd_text_neon.c +662 -0
  76. data/vendor/libyeptris/src/yeptris/common/simd_text_scalar.c +298 -0
  77. data/vendor/libyeptris/src/yeptris/common/string_view.c +34 -0
  78. data/vendor/libyeptris/src/yeptris/common/string_view.h +93 -0
  79. data/vendor/libyeptris/src/yeptris/doc.h +56 -0
  80. data/vendor/libyeptris/src/yeptris/dom/dom.c +1192 -0
  81. data/vendor/libyeptris/src/yeptris/dom/dom.h +312 -0
  82. data/vendor/libyeptris/src/yeptris/dom/hpool.c +107 -0
  83. data/vendor/libyeptris/src/yeptris/dom/mapindex.c +173 -0
  84. data/vendor/libyeptris/src/yeptris/dom/mapindex.h +61 -0
  85. data/vendor/libyeptris/src/yeptris/dom/mutate.c +431 -0
  86. data/vendor/libyeptris/src/yeptris/emit/emit.c +434 -0
  87. data/vendor/libyeptris/src/yeptris/emit/float/api.h +38 -0
  88. data/vendor/libyeptris/src/yeptris/emit/float/dragon.c +405 -0
  89. data/vendor/libyeptris/src/yeptris/emit/float/floatint.h +231 -0
  90. data/vendor/libyeptris/src/yeptris/emit/float/print.c +396 -0
  91. data/vendor/libyeptris/src/yeptris/emit/style.c +81 -0
  92. data/vendor/libyeptris/src/yeptris/emit/style.h +24 -0
  93. data/vendor/libyeptris/src/yeptris/emit/writer.c +816 -0
  94. data/vendor/libyeptris/src/yeptris/emit/writer.h +76 -0
  95. data/vendor/libyeptris/src/yeptris/encoding/bom.c +31 -0
  96. data/vendor/libyeptris/src/yeptris/encoding/encoding.h +63 -0
  97. data/vendor/libyeptris/src/yeptris/encoding/transcode.c +148 -0
  98. data/vendor/libyeptris/src/yeptris/encoding/utf8_validate.c +178 -0
  99. data/vendor/libyeptris/src/yeptris/events/capture.c +150 -0
  100. data/vendor/libyeptris/src/yeptris/events/capture.h +39 -0
  101. data/vendor/libyeptris/src/yeptris/events/iterparse.c +208 -0
  102. data/vendor/libyeptris/src/yeptris/events/pull.c +97 -0
  103. data/vendor/libyeptris/src/yeptris/events/push.c +104 -0
  104. data/vendor/libyeptris/src/yeptris/events/recorder.c +107 -0
  105. data/vendor/libyeptris/src/yeptris/events/values.c +527 -0
  106. data/vendor/libyeptris/src/yeptris/events/values_priv.h +51 -0
  107. data/vendor/libyeptris/src/yeptris/events/yaml_compat.c +86 -0
  108. data/vendor/libyeptris/src/yeptris/events/yaml_compat.h +90 -0
  109. data/vendor/libyeptris/src/yeptris/jsonapi/jsonc_compat.c +687 -0
  110. data/vendor/libyeptris/src/yeptris/jsonapi/yajl_compat.c +728 -0
  111. data/vendor/libyeptris/src/yeptris/marshal.c +782 -0
  112. data/vendor/libyeptris/src/yeptris/memory/allocator.c +20 -0
  113. data/vendor/libyeptris/src/yeptris/memory/allocator.h +43 -0
  114. data/vendor/libyeptris/src/yeptris/memory/arena.c +134 -0
  115. data/vendor/libyeptris/src/yeptris/memory/arena.h +52 -0
  116. data/vendor/libyeptris/src/yeptris/memory/pool.c +122 -0
  117. data/vendor/libyeptris/src/yeptris/memory/pool.h +36 -0
  118. data/vendor/libyeptris/src/yeptris/parse/engine.c +3698 -0
  119. data/vendor/libyeptris/src/yeptris/parse/engine.h +65 -0
  120. data/vendor/libyeptris/src/yeptris/parse/events.h +124 -0
  121. data/vendor/libyeptris/src/yeptris/parse/numbers.c +349 -0
  122. data/vendor/libyeptris/src/yeptris/parse/numbers.h +33 -0
  123. data/vendor/libyeptris/src/yeptris/parse/scalars.c +416 -0
  124. data/vendor/libyeptris/src/yeptris/parse/scalars.h +75 -0
  125. data/vendor/libyeptris/src/yeptris/parse.c +737 -0
  126. data/vendor/libyeptris/src/yeptris/plan.c +824 -0
  127. data/vendor/libyeptris/src/yeptris/resolve/compat11.c +334 -0
  128. data/vendor/libyeptris/src/yeptris/resolve/core12.c +143 -0
  129. data/vendor/libyeptris/src/yeptris/resolve/resolver.h +56 -0
  130. data/vendor/libyeptris/src/yeptris/resolve/tags.c +58 -0
  131. data/vendor/libyeptris/src/yeptris/scan/json.c +792 -0
  132. data/vendor/libyeptris/src/yeptris/scan/json.h +109 -0
  133. data/vendor/libyeptris/src/yeptris/scan/scan.c +463 -0
  134. data/vendor/libyeptris/src/yeptris/scan/scan.h +150 -0
  135. data/vendor/libyeptris/src/yeptris/schema.c +308 -0
  136. data/vendor/libyeptris/src/yeptris/tape.c +1308 -0
  137. data/vendor/libyeptris/src/yeptris/tape_in.h +19 -0
  138. data/vendor/libyeptris/src/yeptris/version.c +7 -0
  139. data/vendor/libyeptris/src/yeptris/visit/dom_visit.c +115 -0
  140. data/vendor/libyeptris/src/yeptris/visit/json_visit.c +293 -0
  141. data/vendor/libyeptris/src/yeptris/visit/yaml_visit.c +127 -0
  142. metadata +199 -0
@@ -0,0 +1,275 @@
1
+ /* nametab.c — open-addressing view→id interner (TODO.impl/18A).
2
+ *
3
+ * FNV-lineage word hash (murmur-style finalizer — FNV alone has weak
4
+ * low bits, fatal under power-of-two masking); linear probing. The
5
+ * slot is 16 bytes and carries the key's zero-padded first-8-byte
6
+ * prefix plus its length: for keys of <=8 bytes — the dominant
7
+ * anchor-name shape — prefix+length identify the key EXACTLY, the
8
+ * caller's value sits INLINE in the slot, and a probe touches ONE
9
+ * cache line (the previous layout paid a slot line plus a random
10
+ * keys[] line per get — nametab-GET misses were ~14% of anchor-heavy
11
+ * parse). Longer keys keep insertion-ordered keys[]/values[] side
12
+ * tables and confirm via a full compare, distinguished by klen1.
13
+ * No deletes; upsert of an existing key overwrites (last wins).
14
+ */
15
+
16
+ #include "common/nametab.h"
17
+
18
+ #include <string.h>
19
+
20
+ #define NT_MIN_CAP 64u
21
+ #define NT_LOAD_PCT 70u
22
+
23
+ static uint64_t hash_round(uint64_t h, uint64_t k) {
24
+ h ^= k;
25
+ h *= 0x9E3779B97F4A7C15ull;
26
+ h ^= h >> 29;
27
+ return h;
28
+ }
29
+
30
+ /* Word-at-a-time, constant-size loads only (a variable-length memcpy
31
+ * lowers to a memmove call — one per probe cost ~3% of anchor-heavy
32
+ * parse). Hash values are build-internal: nothing persists them. */
33
+ static uint64_t load_small(const char* p, uint32_t n) {
34
+ uint64_t k = 0;
35
+ if (n & 4) {
36
+ uint32_t v;
37
+ memcpy(&v, p, 4);
38
+ k = v;
39
+ p += 4;
40
+ }
41
+ if (n & 2) {
42
+ uint16_t v;
43
+ memcpy(&v, p, 2);
44
+ k = (k << 16) | v;
45
+ p += 2;
46
+ }
47
+ if (n & 1) {
48
+ k = (k << 8) | (unsigned char)*p;
49
+ }
50
+ return k;
51
+ }
52
+
53
+ uint32_t yep_view_hash(yep_view s) {
54
+ uint64_t h = 0x9E3779B97F4A7C15ull ^ (uint64_t)s.len;
55
+ if (s.len <= 8) {
56
+ h = hash_round(h, load_small(s.p, s.len));
57
+ } else if (s.len <= 16) {
58
+ uint64_t k0;
59
+ memcpy(&k0, s.p, 8);
60
+ h = hash_round(hash_round(h, k0), load_small(s.p + 8, s.len - 8));
61
+ } else {
62
+ uint64_t k0, kn;
63
+ memcpy(&k0, s.p, 8);
64
+ memcpy(&kn, s.p + s.len - 8, 8);
65
+ h = hash_round(hash_round(hash_round(h, k0), kn), (uint64_t)s.len * 0x85EBCA77ull);
66
+ }
67
+ h ^= h >> 32;
68
+ h *= 0xBF58476D1CE4E5B9ull;
69
+ h ^= h >> 29;
70
+ return (uint32_t)(h ^ (h >> 32));
71
+ }
72
+
73
+ /* The zero-padded first-8-byte prefix: with the length it identifies
74
+ * keys of <=8 bytes EXACTLY (no confirmation ever needed). */
75
+ static uint64_t key_prefix(yep_view k) {
76
+ return k.len >= 8 ? load_small(k.p, 8) : load_small(k.p, k.len);
77
+ }
78
+
79
+ int yep_nametab_init(yep_nametab* t, const yep_allocator* sys) {
80
+ if (t == NULL || sys == NULL) {
81
+ return 0;
82
+ }
83
+ t->sys = sys;
84
+ t->slots = yep_alloc(sys, NT_MIN_CAP * sizeof(*t->slots));
85
+ t->keys = NULL;
86
+ t->values = NULL;
87
+ if (t->slots == NULL) {
88
+ return 0;
89
+ }
90
+ memset(t->slots, 0, NT_MIN_CAP * sizeof(*t->slots));
91
+ t->ext_count = 0;
92
+ t->ext_cap = 0;
93
+ t->count = 0;
94
+ t->cap = NT_MIN_CAP;
95
+ return 1;
96
+ }
97
+
98
+ void yep_nametab_free(yep_nametab* t) {
99
+ if (t == NULL) {
100
+ return;
101
+ }
102
+ yep_free(t->sys, t->slots);
103
+ yep_free(t->sys, t->keys);
104
+ yep_free(t->sys, t->values);
105
+ memset(t, 0, sizeof(*t));
106
+ }
107
+
108
+ static int nt_ext_grow(yep_nametab* t, uint32_t need) {
109
+ if (need <= t->ext_cap) {
110
+ return 1;
111
+ }
112
+ uint32_t cap = t->ext_cap ? t->ext_cap * 2 : 16;
113
+ while (cap < need) {
114
+ cap *= 2;
115
+ }
116
+ yep_view* keys = yep_alloc(t->sys, cap * sizeof(*keys));
117
+ uint32_t* values = yep_alloc(t->sys, cap * sizeof(*values));
118
+ if (keys == NULL || values == NULL) {
119
+ yep_free(t->sys, keys);
120
+ yep_free(t->sys, values);
121
+ return 0;
122
+ }
123
+ if (t->ext_count > 0) {
124
+ memcpy(keys, t->keys, (size_t)t->ext_count * sizeof(*keys));
125
+ memcpy(values, t->values, (size_t)t->ext_count * sizeof(*values));
126
+ }
127
+ yep_free(t->sys, t->keys);
128
+ yep_free(t->sys, t->values);
129
+ t->keys = keys;
130
+ t->values = values;
131
+ t->ext_cap = cap;
132
+ return 1;
133
+ }
134
+
135
+ /* Replaces every entry into newcap slots. Inline entries rebuild
136
+ * their key bytes from the prefix (lossless for <=8-byte keys);
137
+ * external entries re-hash from keys[]. */
138
+ static int nt_rehash(yep_nametab* t, uint32_t newcap) {
139
+ yep_nt_slot* slots = yep_alloc(t->sys, newcap * sizeof(*slots));
140
+ if (slots == NULL) {
141
+ return 0;
142
+ }
143
+ memset(slots, 0, newcap * sizeof(*slots));
144
+ uint32_t mask = newcap - 1;
145
+ for (uint32_t i = 0; i < t->cap; i++) {
146
+ yep_nt_slot src = t->slots[i];
147
+ if (src.klen1 == 0) {
148
+ continue;
149
+ }
150
+ uint32_t h;
151
+ if (src.klen1 > 9) {
152
+ h = yep_view_hash(t->keys[src.val - 1]);
153
+ } else {
154
+ char buf[8];
155
+ uint64_t p = src.prefix;
156
+ uint32_t len = src.klen1 - 1;
157
+ memcpy(buf, &p, 8); /* same little-endian round-trip as load_small */
158
+ yep_view kb = {buf, len};
159
+ h = yep_view_hash(kb);
160
+ }
161
+ uint32_t j = h & mask;
162
+ while (slots[j].klen1 != 0) {
163
+ j = (j + 1) & mask;
164
+ }
165
+ slots[j] = src;
166
+ }
167
+ yep_free(t->sys, t->slots);
168
+ t->slots = slots;
169
+ t->cap = newcap;
170
+ return 1;
171
+ }
172
+
173
+ uint32_t yep_nametab_get(const yep_nametab* t, yep_view key) {
174
+ if (t == NULL || t->cap == 0) {
175
+ return YEP_NAMETAB_NIL;
176
+ }
177
+ uint32_t klen1 = key.len + 1;
178
+ uint64_t prefix = key_prefix(key);
179
+ uint32_t mask = t->cap - 1;
180
+ uint32_t j = yep_view_hash(key) & mask;
181
+ for (;;) {
182
+ const yep_nt_slot* s = &t->slots[j];
183
+ if (s->klen1 == 0) {
184
+ return YEP_NAMETAB_NIL;
185
+ }
186
+ if (s->klen1 == klen1 && s->prefix == prefix) {
187
+ if (klen1 <= 9) {
188
+ return s->val; /* inline: prefix+len identify the key */
189
+ }
190
+ /* external: confirm the full key (prefix collisions) */
191
+ if (yep_view_eq(t->keys[s->val - 1], key)) {
192
+ return t->values[s->val - 1];
193
+ }
194
+ }
195
+ j = (j + 1) & mask;
196
+ }
197
+ }
198
+
199
+ void yep_nametab_clear(yep_nametab* t) {
200
+ if (t == NULL || t->cap == 0) {
201
+ return;
202
+ }
203
+ memset(t->slots, 0, (size_t)t->cap * sizeof(*t->slots));
204
+ t->count = 0;
205
+ t->ext_count = 0;
206
+ }
207
+
208
+ int yep_nametab_set(yep_nametab* t, yep_view key, uint32_t value) {
209
+ if (t == NULL || t->cap == 0) {
210
+ return 0;
211
+ }
212
+ uint32_t klen1 = key.len + 1;
213
+ uint64_t prefix = key_prefix(key);
214
+ uint32_t mask = t->cap - 1;
215
+ uint32_t j = yep_view_hash(key) & mask;
216
+ for (;;) {
217
+ yep_nt_slot* s = &t->slots[j];
218
+ if (s->klen1 == 0) {
219
+ break; /* insert below */
220
+ }
221
+ if (s->klen1 == klen1 && s->prefix == prefix) {
222
+ if (klen1 <= 9) {
223
+ s->val = value; /* last definition wins */
224
+ return 1;
225
+ }
226
+ if (yep_view_eq(t->keys[s->val - 1], key)) {
227
+ t->values[s->val - 1] = value;
228
+ return 1;
229
+ }
230
+ }
231
+ j = (j + 1) & mask;
232
+ }
233
+ if ((uint64_t)(t->count + 1) * 100 > (uint64_t)t->cap * NT_LOAD_PCT) {
234
+ if (!nt_rehash(t, t->cap * 2)) {
235
+ return 0;
236
+ }
237
+ mask = t->cap - 1;
238
+ j = yep_view_hash(key) & mask;
239
+ while (t->slots[j].klen1 != 0) {
240
+ j = (j + 1) & mask;
241
+ }
242
+ }
243
+ if (klen1 > 9) {
244
+ if (!nt_ext_grow(t, t->ext_count + 1)) {
245
+ return 0;
246
+ }
247
+ t->keys[t->ext_count] = key;
248
+ t->values[t->ext_count] = value;
249
+ t->ext_count++;
250
+ t->slots[j].prefix = prefix;
251
+ t->slots[j].val = t->ext_count; /* entry index + 1 */
252
+ t->slots[j].klen1 = klen1;
253
+ } else {
254
+ t->slots[j].prefix = prefix;
255
+ t->slots[j].val = value; /* inline */
256
+ t->slots[j].klen1 = klen1;
257
+ }
258
+ t->count++;
259
+ return 1;
260
+ }
261
+
262
+ int yep_nametab_reserve(yep_nametab* t, uint32_t n) {
263
+ if (t == NULL || t->cap == 0) {
264
+ return 0;
265
+ }
266
+ if ((uint64_t)n * 100 <= (uint64_t)t->cap * NT_LOAD_PCT) {
267
+ return 1;
268
+ }
269
+ uint64_t need = ((uint64_t)n * 100 + NT_LOAD_PCT - 1) / NT_LOAD_PCT;
270
+ uint32_t newcap = NT_MIN_CAP;
271
+ while ((uint64_t)newcap < need) {
272
+ newcap *= 2;
273
+ }
274
+ return nt_rehash(t, newcap);
275
+ }
@@ -0,0 +1,68 @@
1
+ /* nametab.h — open-addressing view→id interner (TODO.impl/18A).
2
+ *
3
+ * The single primitive for name-keyed registries: engine anchor names,
4
+ * DOM anchor binding, mapping-key interning. Keys are borrowed views —
5
+ * the referenced storage must outlive the table (parse input or a
6
+ * document-owned pool). No deletes, so no tombstones; upsert of an
7
+ * existing key overwrites in place (last definition wins).
8
+ */
9
+ #ifndef YEP_NAMETAB_H
10
+ #define YEP_NAMETAB_H
11
+
12
+ #include <stdint.h>
13
+
14
+ #include "common/string_view.h"
15
+ #include "memory/allocator.h"
16
+
17
+ #ifdef __cplusplus
18
+ extern "C" {
19
+ #endif
20
+
21
+ /* get() miss sentinel; never a stored value (ids are array indices). */
22
+ #define YEP_NAMETAB_NIL UINT32_MAX
23
+
24
+ typedef struct yep_nt_slot {
25
+ uint64_t prefix; /* the key's first 8 bytes, zero-padded */
26
+ uint32_t val; /* <=8B keys: the value INLINE; longer: entry index+1 */
27
+ uint32_t klen1; /* key length + 1; 0 = empty slot */
28
+ } yep_nt_slot; /* 16 bytes: one cache line per probe */
29
+
30
+ typedef struct yep_nametab {
31
+ const yep_allocator* sys;
32
+ yep_nt_slot* slots;
33
+ yep_view* keys; /* >8-byte keys only, insertion-ordered */
34
+ uint32_t* values;
35
+ uint32_t ext_count; /* live entries in keys/values */
36
+ uint32_t ext_cap;
37
+ uint32_t count; /* live entries (inline + external) */
38
+ uint32_t cap; /* slot count, power of two */
39
+ } yep_nametab;
40
+
41
+ /* Returns 0 only on allocation failure (table unchanged). */
42
+ int yep_nametab_init(yep_nametab* t, const yep_allocator* sys);
43
+ void yep_nametab_free(yep_nametab* t);
44
+
45
+ /* Insert or overwrite. Returns 0 on allocation failure. */
46
+ int yep_nametab_set(yep_nametab* t, yep_view key, uint32_t value);
47
+
48
+ /* Drops all entries, keeping the allocations. */
49
+ void yep_nametab_clear(yep_nametab* t);
50
+
51
+ /* Pre-sizes for n inserts: no rehash while count stays <= n. The slots
52
+ * table is rebuilt (ids keep their insertion order); the keys/values
53
+ * arrays are only grown. Returns 0 only on allocation failure. */
54
+ int yep_nametab_reserve(yep_nametab* t, uint32_t n);
55
+
56
+ /* YEP_NAMETAB_NIL when absent. */
57
+ uint32_t yep_nametab_get(const yep_nametab* t, yep_view key);
58
+
59
+ /* The table's hash (FNV-1a + murmur-style finalizer): the ONE view
60
+ * hash — the map index and any future name-keyed structure reuse it,
61
+ * never a re-derivation. */
62
+ uint32_t yep_view_hash(yep_view s);
63
+
64
+ #ifdef __cplusplus
65
+ }
66
+ #endif
67
+
68
+ #endif /* YEP_NAMETAB_H */
@@ -0,0 +1,74 @@
1
+ /* port.h — portability shims only; nothing YAML-specific lives here.
2
+ *
3
+ * Naming law: public API symbols are yeptris_*; internal symbols are yep_*.
4
+ */
5
+ #ifndef YEP_PORT_H
6
+ #define YEP_PORT_H
7
+
8
+ #include <stddef.h>
9
+ #include <stdint.h>
10
+
11
+ #define YEP_UNUSED(x) ((void)(x))
12
+
13
+ #define YEP_ARRAY_LEN(a) (sizeof(a) / sizeof((a)[0]))
14
+
15
+ #if defined(_MSC_VER) && !defined(__clang__)
16
+ #include <intrin.h>
17
+ static inline unsigned yep_popcount32(uint32_t v) {
18
+ return (unsigned)__popcnt(v);
19
+ }
20
+ static inline unsigned yep_ctz32(uint32_t v) {
21
+ unsigned long i;
22
+ _BitScanForward(&i, v);
23
+ return (unsigned)i;
24
+ }
25
+ #else
26
+ static inline unsigned yep_popcount32(uint32_t v) {
27
+ return (unsigned)__builtin_popcount(v);
28
+ }
29
+ static inline unsigned yep_ctz32(uint32_t v) {
30
+ return (unsigned)__builtin_ctz(v);
31
+ }
32
+ #endif
33
+ /* Count-trailing-zeros of a nonzero u64. clang/gcc have the builtin;
34
+ * MSVC spells it _BitScanForward64 (the windows leg pinned this). */
35
+ static inline unsigned yep_ctz64(uint64_t v) {
36
+ #if defined(_MSC_VER) && !defined(__clang__)
37
+ unsigned long i;
38
+ _BitScanForward64(&i, v);
39
+ return (unsigned)i;
40
+ #else
41
+ return (unsigned)__builtin_ctzll(v);
42
+ #endif
43
+ }
44
+
45
+ #if defined(_WIN32)
46
+ #define WIN32_LEAN_AND_MEAN
47
+ #define NOMINMAX
48
+ #include <windows.h>
49
+ /* SRWLOCK: the pthread_mutex stand-in on Windows — one shared shape
50
+ * for the pool/mapindex locks (common/mutex.h wraps the calls). */
51
+ #include <synchapi.h>
52
+ typedef SRWLOCK yep_mutex_raw;
53
+ #else
54
+ #include <pthread.h>
55
+ typedef pthread_mutex_t yep_mutex_raw;
56
+ #endif
57
+
58
+ /* Architecture gates for the AOT SIMD TUs (TODO.impl/04). Both sides of
59
+ * every extern pairing (TU and dispatch) use the same guards, so the link
60
+ * always resolves regardless of which TUs CMake compiled. */
61
+ #if defined(__x86_64__) || defined(__i386__) || defined(_M_X64) || defined(_M_IX86)
62
+ #define YEP_ARCH_X86 1
63
+ #endif
64
+ /* _M_ARM64 excluded under MSVC: this TU family speaks GCC/clang NEON
65
+ * (vector initializers, __attribute__) — MSVC-ARM64 defines __ARM_NEON
66
+ * but cannot compile it, so Windows-ARM64 builds ride the scalar
67
+ * kernels (a clang-cl build is the follow-up). clang-cl keeps the
68
+ * NEON gate: it accepts the GNU-isms. */
69
+ #if (defined(__aarch64__) || defined(__ARM_NEON) || defined(_M_ARM64)) && \
70
+ !(defined(_MSC_VER) && !defined(__clang__))
71
+ #define YEP_ARCH_AARCH64 1
72
+ #endif
73
+
74
+ #endif /* YEP_PORT_H */
@@ -0,0 +1,49 @@
1
+ /* simd_text.c — dispatch: pick the best kernel table once (atomic-lazy,
2
+ * the yep_cpu_detect pattern). The ISA TUs are compiled by CMake with the
3
+ * right -m flags on their architectures; the guards here mirror theirs so
4
+ * every extern resolves on every platform.
5
+ */
6
+
7
+ #include <stdatomic.h>
8
+
9
+ #include "cpu.h"
10
+ #include "port.h"
11
+ #include "simd_text.h"
12
+
13
+ extern const yep_text_kernels yep_text_kernels_scalar;
14
+
15
+ #if defined(YEP_ARCH_X86)
16
+ extern const yep_text_kernels yep_text_kernels_avx2;
17
+ #endif
18
+ #if defined(YEP_ARCH_AARCH64)
19
+ extern const yep_text_kernels yep_text_kernels_neon;
20
+ #endif
21
+
22
+ static const yep_text_kernels* yep_text_pick(void) {
23
+ yep_cpu_features cpu = yep_cpu_detect();
24
+ /* arm64-MSVC has no ISA branch: port.h keeps MSVC off the
25
+ * GCC/clang NEON TUs, so it dispatches straight to scalar */
26
+ (void)cpu;
27
+ #if defined(YEP_ARCH_X86)
28
+ if (cpu.avx2) {
29
+ return &yep_text_kernels_avx2;
30
+ }
31
+ #endif
32
+ #if defined(YEP_ARCH_AARCH64)
33
+ if (cpu.neon) {
34
+ return &yep_text_kernels_neon;
35
+ }
36
+ #endif
37
+ return &yep_text_kernels_scalar;
38
+ }
39
+
40
+ static _Atomic(const yep_text_kernels*) yep_text_cached;
41
+
42
+ const yep_text_kernels* yep_text_active(void) {
43
+ const yep_text_kernels* k = atomic_load_explicit(&yep_text_cached, memory_order_acquire);
44
+ if (k == NULL) {
45
+ k = yep_text_pick();
46
+ atomic_store_explicit(&yep_text_cached, k, memory_order_release);
47
+ }
48
+ return k;
49
+ }