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,295 @@
1
+ /* simd_text.h — SIMD-accelerated text scan primitives (TODO.impl/04).
2
+ *
3
+ * AOT framework (the libleptris pattern): a scalar reference TU is always
4
+ * compiled; AVX2 / NEON TUs are compiled separately with the right -m
5
+ * flags; dispatch picks the best table once via cpu detection. Callers go
6
+ * through yep_text_active() — never call an ISA table directly.
7
+ *
8
+ * Contract (every implementation, every ISA):
9
+ * - functions read AT MOST len bytes; no faults past the end
10
+ * (length-guarded chunking, never full-width loads beyond len);
11
+ * - len == 0 is valid: contains/count/find_not-style predicates return
12
+ * their empty answer, finds return -1;
13
+ * - results are bit-identical to the scalar reference — enforced by the
14
+ * differential suite (test_simd_text.cpp), which compares against naive
15
+ * test-local references, not against our own scalar TU.
16
+ */
17
+ #ifndef YEP_SIMD_TEXT_H
18
+ #define YEP_SIMD_TEXT_H
19
+
20
+ #include <stddef.h>
21
+ #include <stdint.h>
22
+
23
+ #include "port.h" /* yep_ctz64: the SWAR walks' first-set-lane extraction */
24
+
25
+ #ifdef __cplusplus
26
+ extern "C" {
27
+ #endif
28
+
29
+ /* One-pass pre-scan statistics: the ten occurrence counts every
30
+ * content-derived sizing rule needs (arena/node pre-reserve, engine
31
+ * anchor pre-reserve) plus the ASCII/printable flags that gate the
32
+ * UTF-8 validator. Fills the role of four separate full-buffer
33
+ * passes (printable_validate's SWAR loop + three count3 calls). */
34
+ typedef struct yep_text_stats {
35
+ size_t nl, comma, dash, colon, bracket, brace, dq, sq, pipe, amp;
36
+ int nonascii; /* any byte >= 0x80 present */
37
+ int bad_printable; /* an ASCII byte violating c-printable (not 9/10/13/0x20..0x7E) */
38
+ } yep_text_stats;
39
+
40
+ /* A byte-class stop set. The 256-bit bitmap is the truth (the scalar
41
+ * fallback reads it); lo/hi are derived nibble-class tables the vector
42
+ * kernels classify lanes with — member #k of group g sets bit k in
43
+ * lo[g][b&15] and hi[g][b>>4], so a lane matches iff some member has
44
+ * both nibbles of the lane byte: exact, no false positives (the
45
+ * SIMD/scalar differential suite pins it). Constant sets embed
46
+ * prebuilt literals (pinned against this init by StopsetLiterals). */
47
+ #define YEP_STOPSET_GROUPS 4 /* 32 members — every YAML stop class fits */
48
+
49
+ typedef struct yep_stopset {
50
+ unsigned char bitmap[32];
51
+ uint8_t groups; /* nibble-class groups in use; >GROUPS = vector kernels
52
+ decline (scalar bitmap walk stays correct) */
53
+ unsigned char lo[YEP_STOPSET_GROUPS][16];
54
+ unsigned char hi[YEP_STOPSET_GROUPS][16];
55
+ } yep_stopset;
56
+
57
+ static inline void yep_stopset_init(yep_stopset* ss, const unsigned char bitmap[32]) {
58
+ for (size_t i = 0; i < sizeof(*ss); i++) {
59
+ ((unsigned char*)ss)[i] = 0;
60
+ }
61
+ unsigned n = 0;
62
+ for (unsigned b = 0; b < 256; b++) {
63
+ if ((bitmap[b >> 3] >> (b & 7)) & 1) {
64
+ ss->bitmap[b >> 3] |= (unsigned char)(1u << (b & 7));
65
+ if (n < YEP_STOPSET_GROUPS * 8) {
66
+ ss->lo[n >> 3][b & 15] |= (unsigned char)(1u << (n & 7));
67
+ ss->hi[n >> 3][b >> 4] |= (unsigned char)(1u << (n & 7));
68
+ }
69
+ n++;
70
+ }
71
+ }
72
+ ss->groups = (uint8_t)((n + 7) >> 3);
73
+ }
74
+
75
+ /* The line-facts sweep's output (one `key: value` line's positions).
76
+ * end is the first \n/\r at/after pos (or len); indent the first
77
+ * byte != ' ' (spaces only — tabs are the caller's rule, as in
78
+ * yep_scan_line); stop the first block-plain stop byte at/after the
79
+ * indent and strictly before end, stop_set=0 when none exists. */
80
+ typedef struct yep_line_facts {
81
+ uint32_t end;
82
+ uint32_t indent;
83
+ uint32_t stop;
84
+ uint32_t stop_set;
85
+ } yep_line_facts;
86
+
87
+ /* The flow-kernel chunk classifier's output (one <=32-byte chunk):
88
+ * bit i of each mask = byte i of the chunk. The five classes — quote,
89
+ * backslash, structural ({,},[,],,:), value-start (0-9,-,t,f,n), and
90
+ * raw C0 — give the token walk every class it dispatches on; valid
91
+ * marks the bytes that exist (partial tail chunk). Bit-identical
92
+ * across ISAs. */
93
+ typedef struct yep_chunk_masks {
94
+ uint32_t quote;
95
+ uint32_t bs;
96
+ uint32_t structurals;
97
+ uint32_t valstart; /* 0-9, '-', 't', 'f', 'n' — scalar-token starts */
98
+ uint32_t c0; /* bytes < 0x20 (raw controls) */
99
+ uint32_t valid; /* 1-bits for the bytes that exist (tails) */
100
+ } yep_chunk_masks;
101
+
102
+ /* The kernel table. One struct = one dispatch point (OCP: a new ISA is a
103
+ * new TU exporting a new table; nothing else changes). */
104
+ typedef struct yep_text_kernels {
105
+ /* nonzero iff c occurs in [s, s+len) */
106
+ int (*contains)(const char* s, size_t len, char c);
107
+
108
+ /* offset of the first c, or -1 */
109
+ ptrdiff_t (*find)(const char* s, size_t len, char c);
110
+
111
+ /* offset of the first c0c1c2 run, or -1; len < 3 -> -1 */
112
+ ptrdiff_t (*find3)(const char* s, size_t len, char c0, char c1, char c2);
113
+
114
+ /* occurrences of c */
115
+ size_t (*count_char)(const char* s, size_t len, char c);
116
+
117
+ /* three counts in one memory pass (arena sizing pre-scan, 06) */
118
+ void (*count3)(const char* s, size_t len, char c0, char c1, char c2, size_t* n0, size_t* n1,
119
+ size_t* n2);
120
+
121
+ /* memcpy + count3 fused: one traversal (TODO 188 pattern) */
122
+ void (*copy_count3)(char* dst, const char* src, size_t len, char c0, char c1, char c2,
123
+ size_t* n0, size_t* n1, size_t* n2);
124
+
125
+ /* offset of the first byte != c, or -1 (indentation column scan) */
126
+ ptrdiff_t (*find_not)(const char* s, size_t len, char c);
127
+
128
+ /* offset of the first byte in the stop set, or -1 (plain-scalar
129
+ * end detection: ": " / " #" / line-break / flow stops) */
130
+ ptrdiff_t (*stopset_find)(const yep_stopset* ss, const char* s, size_t len);
131
+
132
+ /* Given the content AFTER an opening quote: offset of the closing
133
+ * quote q honoring backslash escapes, or -1 if unterminated.
134
+ * *has_escape is set to 1 iff a backslash occurred (0 otherwise). */
135
+ ptrdiff_t (*quote_scan)(const char* s, size_t len, char q, int* has_escape);
136
+
137
+ /* the fused pre-scan above (results bit-identical across ISAs) */
138
+ void (*scan_stats)(const char* s, size_t len, yep_text_stats* out);
139
+
140
+ /* offset of the first byte that is a double quote, a backslash,
141
+ * or a C0 control — the JSON string-stop set (scan/json.c owns
142
+ * the grammar; simd_text owns the finding). One SIMD pass,
143
+ * three compares OR'd; bit-identical across ISAs. */
144
+ ptrdiff_t (*qbc_find)(const char* s, size_t len);
145
+
146
+ /* 0 iff EVERY byte is gate-safe (0x20-0x7E, 09, 0A, 0D) — the
147
+ * encoding gate's fast answer; 1 means the authoritative validator
148
+ * must rule (non-ASCII may still be valid UTF-8). Replaces the
149
+ * multi-class stats sweep at parse entry (TODO.restructure/66).
150
+ * Bit-identical across ISAs. */
151
+ int (*gate_scan)(const char* s, size_t len);
152
+
153
+ /* The fused line-facts sweep (TODO.restructure/76): one pass
154
+ * yields the four positions a block line needs — first break,
155
+ * first non-space (indent), and the first block-plain stop byte
156
+ * ({\n \r # :}) at or after the indent. scan.c derives every
157
+ * line/shape fact from these; the old paths re-walked the same
158
+ * bytes per fact. Bit-identical across ISAs. */
159
+ void (*line_facts)(const char* s, size_t len, size_t pos, yep_line_facts* out);
160
+
161
+ /* The flow-kernel chunk classifier (the JSON tape's stage 1
162
+ * foundation): five byte-class masks for one <=32-byte chunk
163
+ * (quote, backslash, structurals, value-starts, C0). n must be
164
+ * <= 32; reads exactly n bytes. Bit-identical across ISAs. */
165
+ yep_chunk_masks (*json_chunk)(const char* p, size_t n);
166
+
167
+ /* The JSON structural indexer (the simdjson stage-1 shape, the
168
+ * token-contract front): walks the whole buffer in 64-byte blocks
169
+ * and writes, in position order, the u32 offsets of every token
170
+ * stage 2 dispatches on — operators ([]{}:,), string OPEN quotes
171
+ * (escape-aware, the borrow-trick scanner), and scalar-run starts
172
+ * (a non-operator non-whitespace byte whose predecessor was not
173
+ * one). String interiors and close quotes never appear; ws bytes
174
+ * are never touched by stage 2. No grammar validation: the only
175
+ * hard error is an unterminated string (odd final parity) ->
176
+ * return 0. idx must hold len+2 entries. Bit-identical across
177
+ * ISAs (the differential suite pins it); scan/json.c owns the
178
+ * scalar reference and the grammar contract. */
179
+ int (*json_stage1)(const char* p, size_t len, uint32_t* idx, size_t* nidx);
180
+ } yep_text_kernels;
181
+
182
+ /* The structural indexer's mask resolver — the SSOT identity set for
183
+ * every json_stage1 implementation (scalar in scan/json.c, the ISA
184
+ * twins in the SIMD TUs). Given one 64-byte block's QUOTE/BS/OP/WS
185
+ * masks (bit k = byte k, valid masking tail bytes) plus the three
186
+ * carried bits (string parity, escape parity, scalar-follows), it
187
+ * derives the token mask and appends positions to idx:
188
+ *
189
+ * escaped = the simdjson escape scanner's ODD_BITS borrow trick
190
+ * (real escapes + odd-run terminals ^ bs|carry)
191
+ * in_string = prefix_xor(live quotes) ^ prev parity
192
+ * string_tail= in_string ^ live quotes (interiors + closes)
193
+ * starts = ~(op|ws) & ~follows (scalar-run heads; quotes
194
+ * are scalars, a non-quote scalar extends a run)
195
+ * tokens = (op | starts) & ~string_tail
196
+ *
197
+ * Returns the block's contribution; carries update in place. */
198
+ static inline size_t yep_json_stage1_resolve(uint64_t q, uint64_t bs, uint64_t op, uint64_t ws,
199
+ uint64_t valid, uint64_t* prev_in_string,
200
+ uint64_t* esc_carry, uint64_t* follows_carry,
201
+ size_t off, uint32_t* idx, size_t n) {
202
+ uint64_t potential = bs & ~*esc_carry;
203
+ uint64_t s = (((potential << 1) | 0xAAAAAAAAAAAAAAAAull) - potential) ^ 0xAAAAAAAAAAAAAAAAull;
204
+ uint64_t esc_bs = s & bs;
205
+ uint64_t escaped = s ^ (bs | *esc_carry);
206
+ *esc_carry = esc_bs >> 63;
207
+ uint64_t quote_live = q & ~escaped;
208
+ uint64_t ps = quote_live; /* sequential prefix-xor — a flat
209
+ * one-expression xor of shifts misses
210
+ * the cross terms (the naive caught it) */
211
+ ps ^= ps << 1;
212
+ ps ^= ps << 2;
213
+ ps ^= ps << 4;
214
+ ps ^= ps << 8;
215
+ ps ^= ps << 16;
216
+ ps ^= ps << 32;
217
+ uint64_t in_string = ps ^ *prev_in_string;
218
+ *prev_in_string = (uint64_t)((int64_t)in_string >> 63);
219
+ uint64_t string_tail = (in_string ^ quote_live) & valid;
220
+ uint64_t scalar_nq = (~(op | ws) & ~q) & valid; /* non-quote scalars */
221
+ uint64_t follows = ((scalar_nq & ~(1ull << 63)) << 1) | *follows_carry;
222
+ *follows_carry = scalar_nq >> 63;
223
+ uint64_t tokens = ((op | (~(op | ws) & ~follows)) & ~string_tail) & valid;
224
+ while (tokens != 0) {
225
+ idx[n++] = (uint32_t)(off + (size_t)yep_ctz64(tokens));
226
+ tokens &= tokens - 1;
227
+ }
228
+ (void)escaped;
229
+ return n;
230
+ }
231
+
232
+ /* The best table for this CPU (atomic-lazy, like yep_cpu_detect). */
233
+ const yep_text_kernels* yep_text_active(void);
234
+
235
+ /* Scalar reference implementations — callable directly for differential
236
+ * testing and as fallbacks. The active() table never points here on CPUs
237
+ * with a vector ISA we compiled. */
238
+ int yep_text_contains_scalar(const char* s, size_t len, char c);
239
+ ptrdiff_t yep_text_find_scalar(const char* s, size_t len, char c);
240
+ ptrdiff_t yep_text_find3_scalar(const char* s, size_t len, char c0, char c1, char c2);
241
+ size_t yep_text_count_char_scalar(const char* s, size_t len, char c);
242
+ void yep_text_count3_scalar(const char* s, size_t len, char c0, char c1, char c2, size_t* n0,
243
+ size_t* n1, size_t* n2);
244
+ void yep_text_copy_count3_scalar(char* dst, const char* src, size_t len, char c0, char c1, char c2,
245
+ size_t* n0, size_t* n1, size_t* n2);
246
+ ptrdiff_t yep_text_qbc_find_scalar(const char* s, size_t len);
247
+ ptrdiff_t yep_text_find_not_scalar(const char* s, size_t len, char c);
248
+ ptrdiff_t yep_text_stopset_find_scalar(const yep_stopset* ss, const char* s, size_t len);
249
+ ptrdiff_t yep_text_quote_scan_scalar(const char* s, size_t len, char q, int* has_escape);
250
+ void yep_text_scan_stats_scalar(const char* s, size_t len, yep_text_stats* out);
251
+ int yep_text_gate_scan_scalar(const char* s, size_t len);
252
+ void yep_text_line_facts_scalar(const char* s, size_t len, size_t pos, yep_line_facts* out);
253
+ yep_chunk_masks yep_text_json_chunk_scalar(const char* p, size_t n);
254
+ /* The SWAR walk bounded: settles the facts when the line's break sits
255
+ * within cap bytes (or the buffer ends) — 0 means a longer line, the
256
+ * caller sweeps. The ISA kernels use it as BOTH the short-line test
257
+ * and the short-line answer (no probe-then-rescan). */
258
+ int yep_text_line_facts_capped(const char* s, size_t len, size_t pos, size_t cap,
259
+ yep_line_facts* out);
260
+
261
+ /* SWAR byte flags: 0x80 at every byte equal to k (little-endian
262
+ * lanes — every supported target is LE). The subtract-based zero
263
+ * test is NOT exact: a 0x01 byte under a borrow chain from zero
264
+ * bytes below false-flags ('!' = 0x21 ^ ' ' = 0x01 read as a space —
265
+ * the corpus caught it); this form is carry-free per byte. */
266
+ #define YEP_SWAR_FLAGS 0x8080808080808080ull
267
+
268
+ static inline uint64_t yep_swar_eq8(uint64_t x, uint64_t k) {
269
+ uint64_t v = x ^ k;
270
+ uint64_t low = (v & 0x7F7F7F7F7F7F7F7Full) + 0x7F7F7F7F7F7F7F7Full;
271
+ uint64_t nz = (low | v) & YEP_SWAR_FLAGS;
272
+ return ~nz & YEP_SWAR_FLAGS;
273
+ }
274
+
275
+ /* Stopset bitmap helpers: a 256-bit bitmap is the wire form of a byte
276
+ * class; build with yep_stopset_clear + yep_stopset_add. */
277
+ static inline void yep_stopset_clear(unsigned char set[32]) {
278
+ for (int i = 0; i < 32; i++) {
279
+ set[i] = 0;
280
+ }
281
+ }
282
+
283
+ static inline void yep_stopset_add(unsigned char set[32], unsigned char c) {
284
+ set[c >> 3] |= (unsigned char)(1u << (c & 7));
285
+ }
286
+
287
+ static inline int yep_stopset_test(const unsigned char set[32], unsigned char c) {
288
+ return (set[c >> 3] >> (c & 7)) & 1;
289
+ }
290
+
291
+ #ifdef __cplusplus
292
+ }
293
+ #endif
294
+
295
+ #endif /* YEP_SIMD_TEXT_H */