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.
- checksums.yaml +7 -0
- data/README.adoc +141 -0
- data/ext/build_windows_native.rb +41 -0
- data/ext/libyeptris/extconf.rb +57 -0
- data/ext/yeptris_native/cbor_ruby.c +193 -0
- data/ext/yeptris_native/extconf.rb +47 -0
- data/ext/yeptris_native/json_ruby.c +354 -0
- data/ext/yeptris_native/yeptris_native.c +497 -0
- data/lib/yeptris/cbor.rb +130 -0
- data/lib/yeptris/document.rb +255 -0
- data/lib/yeptris/ffi.rb +426 -0
- data/lib/yeptris/json/descriptor.rb +266 -0
- data/lib/yeptris/json.rb +394 -0
- data/lib/yeptris/materializer.rb +354 -0
- data/lib/yeptris/native-3.4.so +0 -0
- data/lib/yeptris/node.rb +453 -0
- data/lib/yeptris/psych/class_loader.rb +24 -0
- data/lib/yeptris/psych/coder_shim.rb +55 -0
- data/lib/yeptris/psych/drop_in.rb +63 -0
- data/lib/yeptris/psych/encodable.rb +14 -0
- data/lib/yeptris/psych/handler.rb +90 -0
- data/lib/yeptris/psych/parser.rb +105 -0
- data/lib/yeptris/psych/scalar_scanner.rb +149 -0
- data/lib/yeptris/psych/visitors.rb +545 -0
- data/lib/yeptris/psych.rb +622 -0
- data/lib/yeptris/schema.rb +253 -0
- data/lib/yeptris/valueml.rb +455 -0
- data/lib/yeptris/yaml/descriptor.rb +56 -0
- data/lib/yeptris/yaml.rb +422 -0
- data/lib/yeptris.rb +113 -0
- data/libyeptris.so +0 -0
- data/vendor/libyeptris/CMakeLists.txt +254 -0
- data/vendor/libyeptris/cmake/yeptris-config.cmake.in +5 -0
- data/vendor/libyeptris/cmake/yeptris.pc.in +11 -0
- data/vendor/libyeptris/src/CMakeLists.txt +167 -0
- data/vendor/libyeptris/src/include/yeptris/api.h +32 -0
- data/vendor/libyeptris/src/include/yeptris/cbor.h +101 -0
- data/vendor/libyeptris/src/include/yeptris/dom.h +190 -0
- data/vendor/libyeptris/src/include/yeptris/emit.h +81 -0
- data/vendor/libyeptris/src/include/yeptris/error.h +41 -0
- data/vendor/libyeptris/src/include/yeptris/events.h +157 -0
- data/vendor/libyeptris/src/include/yeptris/json.h +45 -0
- data/vendor/libyeptris/src/include/yeptris/json.hpp +258 -0
- data/vendor/libyeptris/src/include/yeptris/jsonc_compat.h +115 -0
- data/vendor/libyeptris/src/include/yeptris/marshal.h +52 -0
- data/vendor/libyeptris/src/include/yeptris/parse.h +48 -0
- data/vendor/libyeptris/src/include/yeptris/plan.h +100 -0
- data/vendor/libyeptris/src/include/yeptris/resolve.h +71 -0
- data/vendor/libyeptris/src/include/yeptris/schema.h +121 -0
- data/vendor/libyeptris/src/include/yeptris/tape.h +123 -0
- data/vendor/libyeptris/src/include/yeptris/types.h +38 -0
- data/vendor/libyeptris/src/include/yeptris/values.h +102 -0
- data/vendor/libyeptris/src/include/yeptris/version.h.in +29 -0
- data/vendor/libyeptris/src/include/yeptris/visit.h +77 -0
- data/vendor/libyeptris/src/include/yeptris/yajl_compat.h +135 -0
- data/vendor/libyeptris/src/include/yeptris.h +23 -0
- data/vendor/libyeptris/src/yeptris/build.c +376 -0
- data/vendor/libyeptris/src/yeptris/cbor/cbor.h +25 -0
- data/vendor/libyeptris/src/yeptris/cbor/decode.c +981 -0
- data/vendor/libyeptris/src/yeptris/cbor/encode.c +835 -0
- data/vendor/libyeptris/src/yeptris/cbor/sink.h +58 -0
- data/vendor/libyeptris/src/yeptris/common/chartype.c +41 -0
- data/vendor/libyeptris/src/yeptris/common/chartype.h +77 -0
- data/vendor/libyeptris/src/yeptris/common/cpu.c +81 -0
- data/vendor/libyeptris/src/yeptris/common/cpu.h +40 -0
- data/vendor/libyeptris/src/yeptris/common/error.c +65 -0
- data/vendor/libyeptris/src/yeptris/common/error.h +79 -0
- data/vendor/libyeptris/src/yeptris/common/mutex.h +45 -0
- data/vendor/libyeptris/src/yeptris/common/nametab.c +275 -0
- data/vendor/libyeptris/src/yeptris/common/nametab.h +68 -0
- data/vendor/libyeptris/src/yeptris/common/port.h +74 -0
- data/vendor/libyeptris/src/yeptris/common/simd_text.c +49 -0
- data/vendor/libyeptris/src/yeptris/common/simd_text.h +295 -0
- data/vendor/libyeptris/src/yeptris/common/simd_text_avx2.c +534 -0
- data/vendor/libyeptris/src/yeptris/common/simd_text_neon.c +662 -0
- data/vendor/libyeptris/src/yeptris/common/simd_text_scalar.c +298 -0
- data/vendor/libyeptris/src/yeptris/common/string_view.c +34 -0
- data/vendor/libyeptris/src/yeptris/common/string_view.h +93 -0
- data/vendor/libyeptris/src/yeptris/doc.h +56 -0
- data/vendor/libyeptris/src/yeptris/dom/dom.c +1192 -0
- data/vendor/libyeptris/src/yeptris/dom/dom.h +312 -0
- data/vendor/libyeptris/src/yeptris/dom/hpool.c +107 -0
- data/vendor/libyeptris/src/yeptris/dom/mapindex.c +173 -0
- data/vendor/libyeptris/src/yeptris/dom/mapindex.h +61 -0
- data/vendor/libyeptris/src/yeptris/dom/mutate.c +431 -0
- data/vendor/libyeptris/src/yeptris/emit/emit.c +434 -0
- data/vendor/libyeptris/src/yeptris/emit/float/api.h +38 -0
- data/vendor/libyeptris/src/yeptris/emit/float/dragon.c +405 -0
- data/vendor/libyeptris/src/yeptris/emit/float/floatint.h +231 -0
- data/vendor/libyeptris/src/yeptris/emit/float/print.c +396 -0
- data/vendor/libyeptris/src/yeptris/emit/style.c +81 -0
- data/vendor/libyeptris/src/yeptris/emit/style.h +24 -0
- data/vendor/libyeptris/src/yeptris/emit/writer.c +816 -0
- data/vendor/libyeptris/src/yeptris/emit/writer.h +76 -0
- data/vendor/libyeptris/src/yeptris/encoding/bom.c +31 -0
- data/vendor/libyeptris/src/yeptris/encoding/encoding.h +63 -0
- data/vendor/libyeptris/src/yeptris/encoding/transcode.c +148 -0
- data/vendor/libyeptris/src/yeptris/encoding/utf8_validate.c +178 -0
- data/vendor/libyeptris/src/yeptris/events/capture.c +150 -0
- data/vendor/libyeptris/src/yeptris/events/capture.h +39 -0
- data/vendor/libyeptris/src/yeptris/events/iterparse.c +208 -0
- data/vendor/libyeptris/src/yeptris/events/pull.c +97 -0
- data/vendor/libyeptris/src/yeptris/events/push.c +104 -0
- data/vendor/libyeptris/src/yeptris/events/recorder.c +107 -0
- data/vendor/libyeptris/src/yeptris/events/values.c +527 -0
- data/vendor/libyeptris/src/yeptris/events/values_priv.h +51 -0
- data/vendor/libyeptris/src/yeptris/events/yaml_compat.c +86 -0
- data/vendor/libyeptris/src/yeptris/events/yaml_compat.h +90 -0
- data/vendor/libyeptris/src/yeptris/jsonapi/jsonc_compat.c +687 -0
- data/vendor/libyeptris/src/yeptris/jsonapi/yajl_compat.c +728 -0
- data/vendor/libyeptris/src/yeptris/marshal.c +782 -0
- data/vendor/libyeptris/src/yeptris/memory/allocator.c +20 -0
- data/vendor/libyeptris/src/yeptris/memory/allocator.h +43 -0
- data/vendor/libyeptris/src/yeptris/memory/arena.c +134 -0
- data/vendor/libyeptris/src/yeptris/memory/arena.h +52 -0
- data/vendor/libyeptris/src/yeptris/memory/pool.c +122 -0
- data/vendor/libyeptris/src/yeptris/memory/pool.h +36 -0
- data/vendor/libyeptris/src/yeptris/parse/engine.c +3698 -0
- data/vendor/libyeptris/src/yeptris/parse/engine.h +65 -0
- data/vendor/libyeptris/src/yeptris/parse/events.h +124 -0
- data/vendor/libyeptris/src/yeptris/parse/numbers.c +349 -0
- data/vendor/libyeptris/src/yeptris/parse/numbers.h +33 -0
- data/vendor/libyeptris/src/yeptris/parse/scalars.c +416 -0
- data/vendor/libyeptris/src/yeptris/parse/scalars.h +75 -0
- data/vendor/libyeptris/src/yeptris/parse.c +737 -0
- data/vendor/libyeptris/src/yeptris/plan.c +824 -0
- data/vendor/libyeptris/src/yeptris/resolve/compat11.c +334 -0
- data/vendor/libyeptris/src/yeptris/resolve/core12.c +143 -0
- data/vendor/libyeptris/src/yeptris/resolve/resolver.h +56 -0
- data/vendor/libyeptris/src/yeptris/resolve/tags.c +58 -0
- data/vendor/libyeptris/src/yeptris/scan/json.c +792 -0
- data/vendor/libyeptris/src/yeptris/scan/json.h +109 -0
- data/vendor/libyeptris/src/yeptris/scan/scan.c +463 -0
- data/vendor/libyeptris/src/yeptris/scan/scan.h +150 -0
- data/vendor/libyeptris/src/yeptris/schema.c +308 -0
- data/vendor/libyeptris/src/yeptris/tape.c +1308 -0
- data/vendor/libyeptris/src/yeptris/tape_in.h +19 -0
- data/vendor/libyeptris/src/yeptris/version.c +7 -0
- data/vendor/libyeptris/src/yeptris/visit/dom_visit.c +115 -0
- data/vendor/libyeptris/src/yeptris/visit/json_visit.c +293 -0
- data/vendor/libyeptris/src/yeptris/visit/yaml_visit.c +127 -0
- metadata +199 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/* sink.h — the CBOR decode seam (#157).
|
|
2
|
+
*
|
|
3
|
+
* The grammar loop (decode.c's cbor_item machinery) is the single
|
|
4
|
+
* source of CBOR semantics; a sink implements the item constructors
|
|
5
|
+
* on top of it. Two sinks exist: the DOM builder (the default, the
|
|
6
|
+
* yeptris_cbor_decode public path) and the native ext's VALUE builder
|
|
7
|
+
* (one pass, no intermediate). Sinks receive the resolver's tag_id
|
|
8
|
+
* and the pending semantic-tag chain in its text form ("N N N",
|
|
9
|
+
* outermost first — NULL when the item carries no chain).
|
|
10
|
+
*/
|
|
11
|
+
#ifndef YEP_CBOR_SINK_H
|
|
12
|
+
#define YEP_CBOR_SINK_H
|
|
13
|
+
|
|
14
|
+
#include <stddef.h>
|
|
15
|
+
#include <stdint.h>
|
|
16
|
+
|
|
17
|
+
#include <yeptris/api.h> /* YEPTRIS_API (the ext links these) */
|
|
18
|
+
|
|
19
|
+
typedef struct yep_cbor_sink {
|
|
20
|
+
void* ctx;
|
|
21
|
+
/* All callbacks return 0 on sink failure (the decoder reports
|
|
22
|
+
* MEMORY). They may raise through host languages (longjmp): the
|
|
23
|
+
* decoder owns no host-managed state across them except the
|
|
24
|
+
* indefinite buffer, which its own exit paths free. */
|
|
25
|
+
/* is_key: 1 = the item lands in the enclosing map's key slot
|
|
26
|
+
* (sinks key-intern strings; the DOM ignores it). Rendered text:
|
|
27
|
+
* numbers-as-text, false/true/null/undefined, simple(N) — the
|
|
28
|
+
* exact bytes the DOM path stores. */
|
|
29
|
+
int (*text)(void* ctx, const char* s, uint32_t n, uint8_t tag_id, int is_key, const char* tag,
|
|
30
|
+
uint32_t tag_len);
|
|
31
|
+
/* Known integers: value = negative ? -(mag) : mag, mag <= 2^63. */
|
|
32
|
+
int (*int_val)(void* ctx, int negative, uint64_t mag, int is_key, const char* tag,
|
|
33
|
+
uint32_t tag_len);
|
|
34
|
+
int (*float_val)(void* ctx, double dv, int is_key, const char* tag, uint32_t tag_len);
|
|
35
|
+
/* Strings. borrowed: 1 = p is the input (a sink may record the
|
|
36
|
+
* offset), 0 = the decoder's scratch buffer (copy or take it). */
|
|
37
|
+
int (*str_val)(void* ctx, const unsigned char* p, uint32_t n, int borrowed, int is_key,
|
|
38
|
+
const char* tag, uint32_t tag_len);
|
|
39
|
+
int (*bytes_val)(void* ctx, const unsigned char* p, uint32_t n, int borrowed, int is_key,
|
|
40
|
+
const char* tag, uint32_t tag_len);
|
|
41
|
+
/* Containers. cap: expected item count (maps: pairs*2), UINT64_MAX
|
|
42
|
+
* for indefinite. close fires for BOTH the definite-complete and
|
|
43
|
+
* the break paths, after the last child. */
|
|
44
|
+
int (*open)(void* ctx, int is_map, uint64_t cap, const char* tag, uint32_t tag_len);
|
|
45
|
+
int (*close)(void* ctx, int is_map);
|
|
46
|
+
} yep_cbor_sink;
|
|
47
|
+
|
|
48
|
+
/* The generic engine: the grammar, driving `sink`. Same reject/
|
|
49
|
+
* encoding/depth semantics as the DOM entry. */
|
|
50
|
+
YEPTRIS_API int yep_cbor_decode_gen(const unsigned char* p, size_t len, int strict,
|
|
51
|
+
size_t* consumed, const yep_cbor_sink* sink);
|
|
52
|
+
|
|
53
|
+
/* The DOM sink: pairs yep_cbor_decode_gen with a yep_dom* (the
|
|
54
|
+
* yep_cbor_decode_dom public path's driver; d is a yep_dom*). */
|
|
55
|
+
YEPTRIS_API int yep_cbor_decode_dom_sink(void* d, const unsigned char* p, size_t len, int strict,
|
|
56
|
+
size_t* consumed);
|
|
57
|
+
|
|
58
|
+
#endif /* YEP_CBOR_SINK_H */
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/* chartype.c — the 256-entry byte classification table.
|
|
2
|
+
*
|
|
3
|
+
* Row macros (class combos actually used); the golden test
|
|
4
|
+
* (test/unit/test_chartype.cpp) re-derives every entry from the spec
|
|
5
|
+
* productions, so a typo here fails the suite.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
#include "chartype.h"
|
|
9
|
+
|
|
10
|
+
#define Z 0
|
|
11
|
+
#define BT (YEP_CT_TAB | YEP_CT_BLANK | YEP_CT_PRINTABLE)
|
|
12
|
+
#define BL (YEP_CT_LF | YEP_CT_LBREAK | YEP_CT_PRINTABLE)
|
|
13
|
+
#define BC (YEP_CT_CR | YEP_CT_LBREAK | YEP_CT_PRINTABLE)
|
|
14
|
+
#define BS (YEP_CT_SPACE | YEP_CT_BLANK | YEP_CT_PRINTABLE)
|
|
15
|
+
#define BI (YEP_CT_INDICATOR | YEP_CT_PRINTABLE)
|
|
16
|
+
#define BF (YEP_CT_FLOW_IND | YEP_CT_INDICATOR | YEP_CT_PRINTABLE)
|
|
17
|
+
#define BP (YEP_CT_PRINTABLE)
|
|
18
|
+
#define BD (YEP_CT_DIGIT | YEP_CT_HEXDIGIT | YEP_CT_PRINTABLE)
|
|
19
|
+
#define BA (YEP_CT_ALPHA | YEP_CT_PRINTABLE)
|
|
20
|
+
#define BX (YEP_CT_ALPHA | YEP_CT_HEXDIGIT | YEP_CT_PRINTABLE)
|
|
21
|
+
#define BH (YEP_CT_HIGH)
|
|
22
|
+
|
|
23
|
+
const uint16_t yep_chartype_table[256] = {
|
|
24
|
+
/* 0x00 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 0x0A 0x0B 0x0C 0x0D 0x0E 0x0F */
|
|
25
|
+
/* 0x00 */ Z, Z, Z, Z, Z, Z, Z, Z, Z, BT, BL, Z, Z, BC, Z, Z,
|
|
26
|
+
/* 0x10 */ Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z, Z,
|
|
27
|
+
/* 0x20 */ BS, BI, BI, BI, BP, BI, BI, BI, BP, BP, BI, BP, BF, BI, BP, BP,
|
|
28
|
+
/* 0x30 */ BD, BD, BD, BD, BD, BD, BD, BD, BD, BD, BI, BP, BP, BP, BI, BI,
|
|
29
|
+
/* 0x40 */ BI, BX, BX, BX, BX, BX, BX, BA, BA, BA, BA, BA, BA, BA, BA, BA,
|
|
30
|
+
/* 0x50 */ BA, BA, BA, BA, BA, BA, BA, BA, BA, BA, BA, BF, BP, BF, BP, BP,
|
|
31
|
+
/* 0x60 */ BI, BX, BX, BX, BX, BX, BX, BA, BA, BA, BA, BA, BA, BA, BA, BA,
|
|
32
|
+
/* 0x70 */ BA, BA, BA, BA, BA, BA, BA, BA, BA, BA, BA, BF, BI, BF, BP, Z,
|
|
33
|
+
/* 0x80 */ BH, BH, BH, BH, BH, BH, BH, BH, BH, BH, BH, BH, BH, BH, BH, BH,
|
|
34
|
+
/* 0x90 */ BH, BH, BH, BH, BH, BH, BH, BH, BH, BH, BH, BH, BH, BH, BH, BH,
|
|
35
|
+
/* 0xA0 */ BH, BH, BH, BH, BH, BH, BH, BH, BH, BH, BH, BH, BH, BH, BH, BH,
|
|
36
|
+
/* 0xB0 */ BH, BH, BH, BH, BH, BH, BH, BH, BH, BH, BH, BH, BH, BH, BH, BH,
|
|
37
|
+
/* 0xC0 */ BH, BH, BH, BH, BH, BH, BH, BH, BH, BH, BH, BH, BH, BH, BH, BH,
|
|
38
|
+
/* 0xD0 */ BH, BH, BH, BH, BH, BH, BH, BH, BH, BH, BH, BH, BH, BH, BH, BH,
|
|
39
|
+
/* 0xE0 */ BH, BH, BH, BH, BH, BH, BH, BH, BH, BH, BH, BH, BH, BH, BH, BH,
|
|
40
|
+
/* 0xF0 */ BH, BH, BH, BH, BH, BH, BH, BH, BH, BH, BH, BH, BH, BH, BH, BH,
|
|
41
|
+
};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/* chartype.h — THE byte classification truth table (MECE law: chartype
|
|
2
|
+
* answers "what class of byte is this" and nothing else; scan (06) answers
|
|
3
|
+
* "where structures start"; the SIMD kernels (04) implement these same
|
|
4
|
+
* classes with vector compares, proven equivalent by differential tests).
|
|
5
|
+
*
|
|
6
|
+
* Byte-level approximation of the YAML character productions:
|
|
7
|
+
* - Printability is decided per byte for ASCII (tab/LF/CR/0x20-0x7E are
|
|
8
|
+
* printable, C0 controls and DEL are not). Bytes >= 0x80 carry HIGH;
|
|
9
|
+
* their printability is decided by the encoding front-end (05), which
|
|
10
|
+
* validates the whole sequence.
|
|
11
|
+
* - YAML's Unicode line breaks (NEL U+0085, LS U+2028, PS U+2029) are
|
|
12
|
+
* multi-byte; they are recognized by the scan layer, not by this table.
|
|
13
|
+
* - c-indicator set (YAML 1.2 spec, 5.5): - ? : , [ ] { } # & * ! | >
|
|
14
|
+
* ' " % @ ` — of these, `, [ ] { }` are flow indicators.
|
|
15
|
+
*
|
|
16
|
+
* Derived classes are inline helpers, not table bits: ns-char is
|
|
17
|
+
* printable-and-not-whitespace (plus HIGH, pending encoding validation).
|
|
18
|
+
*/
|
|
19
|
+
#ifndef YEP_CHARTYPE_H
|
|
20
|
+
#define YEP_CHARTYPE_H
|
|
21
|
+
|
|
22
|
+
#include <stdbool.h>
|
|
23
|
+
#include <stdint.h>
|
|
24
|
+
|
|
25
|
+
#ifdef __cplusplus
|
|
26
|
+
extern "C" {
|
|
27
|
+
#endif
|
|
28
|
+
|
|
29
|
+
enum {
|
|
30
|
+
YEP_CT_SPACE = 1u << 0,
|
|
31
|
+
YEP_CT_TAB = 1u << 1,
|
|
32
|
+
YEP_CT_LF = 1u << 2,
|
|
33
|
+
YEP_CT_CR = 1u << 3,
|
|
34
|
+
YEP_CT_DIGIT = 1u << 4,
|
|
35
|
+
YEP_CT_ALPHA = 1u << 5,
|
|
36
|
+
YEP_CT_HEXDIGIT = 1u << 6,
|
|
37
|
+
YEP_CT_INDICATOR = 1u << 7, /* the 19-byte c-indicator set */
|
|
38
|
+
YEP_CT_FLOW_IND = 1u << 8, /* , [ ] { } */
|
|
39
|
+
YEP_CT_HIGH = 1u << 9, /* >= 0x80: UTF-8 sequence byte */
|
|
40
|
+
|
|
41
|
+
/* Composite (stored pre-computed in the table). */
|
|
42
|
+
YEP_CT_BLANK = YEP_CT_SPACE | YEP_CT_TAB,
|
|
43
|
+
YEP_CT_LBREAK = YEP_CT_LF | YEP_CT_CR,
|
|
44
|
+
YEP_CT_PRINTABLE = 1u << 10, /* byte-level: tab|LF|CR|0x20..0x7E */
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
/* The 256-entry truth table (const, rodata). */
|
|
48
|
+
extern const uint16_t yep_chartype_table[256];
|
|
49
|
+
|
|
50
|
+
static inline uint16_t yep_ct(unsigned char c) {
|
|
51
|
+
return yep_chartype_table[c];
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/* True when ALL of flags are set on c. */
|
|
55
|
+
static inline bool yep_ct_is(unsigned char c, uint16_t flags) {
|
|
56
|
+
return (yep_chartype_table[c] & flags) == flags;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
static inline bool yep_ct_any(unsigned char c, uint16_t flags) {
|
|
60
|
+
return (yep_chartype_table[c] & flags) != 0;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/* ns-char approximation: printable and not whitespace; high bytes defer to
|
|
64
|
+
* the encoding layer. */
|
|
65
|
+
static inline bool yep_ct_is_ns(unsigned char c) {
|
|
66
|
+
uint16_t t = yep_chartype_table[c];
|
|
67
|
+
if (t & YEP_CT_HIGH) {
|
|
68
|
+
return true;
|
|
69
|
+
}
|
|
70
|
+
return (t & YEP_CT_PRINTABLE) != 0 && (t & (YEP_CT_BLANK | YEP_CT_LBREAK)) == 0;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
#ifdef __cplusplus
|
|
74
|
+
}
|
|
75
|
+
#endif
|
|
76
|
+
|
|
77
|
+
#endif /* YEP_CHARTYPE_H */
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/* cpu.c — feature detection via compiler builtins (no inline asm, no
|
|
2
|
+
* platform headers). SSE2 is architectural on x86-64; NEON on AArch64.
|
|
3
|
+
* Advanced flags come from __builtin_cpu_supports where available.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
#include <stdatomic.h>
|
|
7
|
+
|
|
8
|
+
#include "cpu.h"
|
|
9
|
+
|
|
10
|
+
#if defined(__x86_64__) || defined(__i386__)
|
|
11
|
+
#define YEP_X86 1
|
|
12
|
+
#endif
|
|
13
|
+
|
|
14
|
+
#if defined(__aarch64__) || defined(__ARM_NEON)
|
|
15
|
+
#define YEP_ARM_NEON_OK 1
|
|
16
|
+
#endif
|
|
17
|
+
|
|
18
|
+
/* Raw CPUID (TODO.restructure/82): __builtin_cpu_supports returned 0
|
|
19
|
+
* for AVX/AVX2 on real CI Xeons (the bench artifact's kernels line
|
|
20
|
+
* said scalar(sse2) — the whole kernel campaign had never run there).
|
|
21
|
+
* The builtins depend on the runtime's __cpu_model initialization;
|
|
22
|
+
* cpuid has no such dependency. <cpuid.h> intrinsics need no -m
|
|
23
|
+
* flags; xgetbv is raw asm behind the OSXSAVE gate. */
|
|
24
|
+
#if defined(YEP_X86) && (defined(__GNUC__) || defined(__clang__))
|
|
25
|
+
#include <cpuid.h>
|
|
26
|
+
|
|
27
|
+
static uint64_t yep_xgetbv0(void) {
|
|
28
|
+
uint32_t lo, hi;
|
|
29
|
+
__asm__ volatile("xgetbv" : "=a"(lo), "=d"(hi) : "c"(0));
|
|
30
|
+
return ((uint64_t)hi << 32) | lo;
|
|
31
|
+
}
|
|
32
|
+
#endif
|
|
33
|
+
|
|
34
|
+
static yep_cpu_features yep_cpu_compute(void) {
|
|
35
|
+
yep_cpu_features f = {0};
|
|
36
|
+
|
|
37
|
+
#if defined(YEP_X86)
|
|
38
|
+
f.sse2 = 1; /* architectural on x86-64 */
|
|
39
|
+
#if defined(__GNUC__) || defined(__clang__)
|
|
40
|
+
{
|
|
41
|
+
uint32_t a, b, c, d;
|
|
42
|
+
if (__get_cpuid(1, &a, &b, &c, &d)) {
|
|
43
|
+
f.sse3 = (c & (1u << 0)) != 0;
|
|
44
|
+
f.ssse3 = (c & (1u << 9)) != 0;
|
|
45
|
+
f.sse41 = (c & (1u << 19)) != 0;
|
|
46
|
+
f.popcnt = (c & (1u << 23)) != 0;
|
|
47
|
+
int osxsave = (c & (1u << 27)) != 0;
|
|
48
|
+
int cpu_avx = (c & (1u << 28)) != 0;
|
|
49
|
+
if (osxsave && cpu_avx && (yep_xgetbv0() & 0x6u) == 0x6u) {
|
|
50
|
+
f.avx = 1;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
uint32_t a7, b7, c7, d7;
|
|
54
|
+
if (__get_cpuid_count(7, 0, &a7, &b7, &c7, &d7)) {
|
|
55
|
+
f.bmi1 = (b7 & (1u << 3)) != 0;
|
|
56
|
+
f.bmi2 = (b7 & (1u << 8)) != 0;
|
|
57
|
+
f.avx2 = f.avx && (b7 & (1u << 5)) != 0;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
#endif
|
|
61
|
+
#elif defined(YEP_ARM_NEON_OK)
|
|
62
|
+
f.neon = 1;
|
|
63
|
+
#if defined(__ARM_FEATURE_CRC32)
|
|
64
|
+
f.crc32 = 1;
|
|
65
|
+
#endif
|
|
66
|
+
#endif
|
|
67
|
+
|
|
68
|
+
return f;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
static _Atomic yep_cpu_features yep_cpu_cached;
|
|
72
|
+
|
|
73
|
+
yep_cpu_features yep_cpu_detect(void) {
|
|
74
|
+
yep_cpu_features f = atomic_load_explicit(&yep_cpu_cached, memory_order_acquire);
|
|
75
|
+
if (!f.detected) {
|
|
76
|
+
f = yep_cpu_compute();
|
|
77
|
+
f.detected = 1;
|
|
78
|
+
atomic_store_explicit(&yep_cpu_cached, f, memory_order_release);
|
|
79
|
+
}
|
|
80
|
+
return f;
|
|
81
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/* cpu.h — CPU feature facts for the SIMD dispatch table (TODO.impl/04).
|
|
2
|
+
*
|
|
3
|
+
* Detection is atomic-lazy: the first caller computes, later callers read.
|
|
4
|
+
* Concurrent first calls are benign — every writer stores identical bytes
|
|
5
|
+
* through atomic stores, so there is no data race under the C11 memory
|
|
6
|
+
* model (and none reported by TSAN).
|
|
7
|
+
*/
|
|
8
|
+
#ifndef YEP_CPU_H
|
|
9
|
+
#define YEP_CPU_H
|
|
10
|
+
|
|
11
|
+
#include <stdbool.h>
|
|
12
|
+
#include <stdint.h>
|
|
13
|
+
|
|
14
|
+
#ifdef __cplusplus
|
|
15
|
+
extern "C" {
|
|
16
|
+
#endif
|
|
17
|
+
|
|
18
|
+
typedef struct yep_cpu_features {
|
|
19
|
+
uint16_t sse2 : 1;
|
|
20
|
+
uint16_t sse3 : 1;
|
|
21
|
+
uint16_t ssse3 : 1;
|
|
22
|
+
uint16_t sse41 : 1;
|
|
23
|
+
uint16_t popcnt : 1;
|
|
24
|
+
uint16_t avx : 1;
|
|
25
|
+
uint16_t avx2 : 1;
|
|
26
|
+
uint16_t bmi1 : 1;
|
|
27
|
+
uint16_t bmi2 : 1;
|
|
28
|
+
uint16_t neon : 1;
|
|
29
|
+
uint16_t crc32 : 1;
|
|
30
|
+
uint16_t detected : 1; /* internal: set once computed */
|
|
31
|
+
} yep_cpu_features;
|
|
32
|
+
|
|
33
|
+
/* Returns the feature snapshot (computing it on first use). */
|
|
34
|
+
yep_cpu_features yep_cpu_detect(void);
|
|
35
|
+
|
|
36
|
+
#ifdef __cplusplus
|
|
37
|
+
}
|
|
38
|
+
#endif
|
|
39
|
+
|
|
40
|
+
#endif /* YEP_CPU_H */
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/* error.c — error channel implementation. printf-composition happens here,
|
|
2
|
+
* once, at error-creation time; nothing on any hot path formats strings.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
#include <stdio.h>
|
|
6
|
+
|
|
7
|
+
#include "error.h"
|
|
8
|
+
|
|
9
|
+
const char* yep_error_string(yep_err_code code) {
|
|
10
|
+
switch (code) {
|
|
11
|
+
#define YEP_ERROR_CASE(code, str) \
|
|
12
|
+
case code: \
|
|
13
|
+
return str;
|
|
14
|
+
YEP_ERROR_X(YEP_ERROR_CASE)
|
|
15
|
+
#undef YEP_ERROR_CASE
|
|
16
|
+
default:
|
|
17
|
+
return "unknown error code";
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
void yep_error_clear(yep_error* slot) {
|
|
22
|
+
if (slot == NULL) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
slot->code = YEP_ERR_NONE;
|
|
26
|
+
slot->line = 0;
|
|
27
|
+
slot->col = 0;
|
|
28
|
+
slot->offset = 0;
|
|
29
|
+
slot->msg[0] = '\0';
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
int yep_error_is_none(const yep_error* slot) {
|
|
33
|
+
return slot == NULL || slot->code == YEP_ERR_NONE;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
static void yep_error_vset(yep_error* slot, yep_err_code code, uint32_t line, uint32_t col,
|
|
37
|
+
size_t offset, const char* fmt, va_list ap) {
|
|
38
|
+
slot->code = code;
|
|
39
|
+
slot->line = line;
|
|
40
|
+
slot->col = col;
|
|
41
|
+
slot->offset = offset;
|
|
42
|
+
if (fmt == NULL) {
|
|
43
|
+
snprintf(slot->msg, sizeof(slot->msg), "%s", yep_error_string(code));
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
vsnprintf(slot->msg, sizeof(slot->msg), fmt, ap);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
int yep_error_set(yep_error* slot, yep_err_code code, uint32_t line, uint32_t col, size_t offset,
|
|
50
|
+
const char* fmt, ...) {
|
|
51
|
+
if (slot == NULL) {
|
|
52
|
+
return 0;
|
|
53
|
+
}
|
|
54
|
+
va_list ap;
|
|
55
|
+
va_start(ap, fmt);
|
|
56
|
+
yep_error_vset(slot, code, line, col, offset, fmt, ap);
|
|
57
|
+
va_end(ap);
|
|
58
|
+
return 0;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
static _Thread_local yep_error yep_tls_error = {YEP_ERR_NONE, 0, 0, 0, ""};
|
|
62
|
+
|
|
63
|
+
yep_error* yep_error_tls(void) {
|
|
64
|
+
return &yep_tls_error;
|
|
65
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/* error.h — the internal error channel.
|
|
2
|
+
*
|
|
3
|
+
* Codes and their strings are declared together in one X-macro — adding a
|
|
4
|
+
* code is one line (OCP). Public API entry points map these to the pinned
|
|
5
|
+
* YeptrisStatus codes (public error.h); this channel carries the detail:
|
|
6
|
+
* code + line/column/offset + composed message.
|
|
7
|
+
*
|
|
8
|
+
* Two channels (the libleptris contract):
|
|
9
|
+
* - thread-local slot: yep_error_tls() — most recent failure on the
|
|
10
|
+
* calling thread;
|
|
11
|
+
* - per-document slot: any yep_error* the owner (document, 11) embeds.
|
|
12
|
+
*/
|
|
13
|
+
#ifndef YEP_ERROR_H
|
|
14
|
+
#define YEP_ERROR_H
|
|
15
|
+
|
|
16
|
+
#include <stdarg.h>
|
|
17
|
+
#include <stddef.h>
|
|
18
|
+
|
|
19
|
+
#include "port.h"
|
|
20
|
+
|
|
21
|
+
#ifdef __cplusplus
|
|
22
|
+
extern "C" {
|
|
23
|
+
#endif
|
|
24
|
+
|
|
25
|
+
#define YEP_ERROR_X(X) \
|
|
26
|
+
X(YEP_ERR_NONE, "no error") \
|
|
27
|
+
X(YEP_ERR_UNEXPECTED, "unexpected parser state") \
|
|
28
|
+
X(YEP_ERR_MEMORY, "out of memory") \
|
|
29
|
+
X(YEP_ERR_DEPTH, "nesting depth exceeds the limit") \
|
|
30
|
+
X(YEP_ERR_ENCODING, "ill-formed or unsupported character encoding") \
|
|
31
|
+
X(YEP_ERR_TAB_IN_INDENT, "tab character used as indentation") \
|
|
32
|
+
X(YEP_ERR_UNTERMINATED_QUOTE, "unterminated quoted scalar") \
|
|
33
|
+
X(YEP_ERR_BAD_INDENT, "inconsistent indentation") \
|
|
34
|
+
X(YEP_ERR_KEY_TOO_LONG, "simple key exceeds 1024 characters") \
|
|
35
|
+
X(YEP_ERR_UNDEFINED_ALIAS, "alias references an undefined anchor") \
|
|
36
|
+
X(YEP_ERR_INVALID_ESCAPE, "invalid escape sequence in double-quoted scalar") \
|
|
37
|
+
X(YEP_ERR_BAD_DIRECTIVE, "invalid or unsupported directive") \
|
|
38
|
+
X(YEP_ERR_INTERNAL, "internal invariant violation") \
|
|
39
|
+
X(YEP_ERR_SCHEMA, "required descriptor node missing")
|
|
40
|
+
|
|
41
|
+
typedef enum {
|
|
42
|
+
#define YEP_ERROR_ENUM(code, str) code,
|
|
43
|
+
YEP_ERROR_X(YEP_ERROR_ENUM)
|
|
44
|
+
#undef YEP_ERROR_ENUM
|
|
45
|
+
YEP_ERR_CODE_COUNT
|
|
46
|
+
} yep_err_code;
|
|
47
|
+
|
|
48
|
+
#define YEP_ERROR_MSG_MAX 192
|
|
49
|
+
|
|
50
|
+
typedef struct yep_error {
|
|
51
|
+
yep_err_code code;
|
|
52
|
+
uint32_t line; /* 1-based; 0 = unknown */
|
|
53
|
+
uint32_t col; /* 1-based; 0 = unknown */
|
|
54
|
+
size_t offset; /* byte offset in the input */
|
|
55
|
+
char msg[YEP_ERROR_MSG_MAX];
|
|
56
|
+
} yep_error;
|
|
57
|
+
|
|
58
|
+
/* The string for a code (X-macro table; never NULL). */
|
|
59
|
+
const char* yep_error_string(yep_err_code code);
|
|
60
|
+
|
|
61
|
+
/* Clears a slot to the no-error state. */
|
|
62
|
+
void yep_error_clear(yep_error* slot);
|
|
63
|
+
|
|
64
|
+
/* True when the slot holds no error. */
|
|
65
|
+
int yep_error_is_none(const yep_error* slot);
|
|
66
|
+
|
|
67
|
+
/* Sets slot (printf-style message, truncated to fit). Returns 0 so callers
|
|
68
|
+
* can `return yep_error_set(...)` where convenient. */
|
|
69
|
+
int yep_error_set(yep_error* slot, yep_err_code code, uint32_t line, uint32_t col, size_t offset,
|
|
70
|
+
const char* fmt, ...);
|
|
71
|
+
|
|
72
|
+
/* The thread-local slot (one per thread; no cross-talk by construction). */
|
|
73
|
+
yep_error* yep_error_tls(void);
|
|
74
|
+
|
|
75
|
+
#ifdef __cplusplus
|
|
76
|
+
}
|
|
77
|
+
#endif
|
|
78
|
+
|
|
79
|
+
#endif /* YEP_ERROR_H */
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/* mutex.h — the one lock shape for internal short-critical-section
|
|
2
|
+
* mutexes (dom pool, mapindex). pthread on POSIX; SRWLOCK on Windows
|
|
3
|
+
* (no trylock consumer exists — SRWLOCK's shape is a superset of what
|
|
4
|
+
* we use: init/destroy/lock/unlock).
|
|
5
|
+
*
|
|
6
|
+
* Naming law: internal symbols are yep_*. */
|
|
7
|
+
#ifndef YEP_MUTEX_H
|
|
8
|
+
#define YEP_MUTEX_H
|
|
9
|
+
|
|
10
|
+
#include "port.h"
|
|
11
|
+
|
|
12
|
+
static inline int yep_mutex_init(yep_mutex_raw* m) {
|
|
13
|
+
#if defined(_WIN32)
|
|
14
|
+
InitializeSRWLock(m);
|
|
15
|
+
return 0;
|
|
16
|
+
#else
|
|
17
|
+
return pthread_mutex_init(m, NULL);
|
|
18
|
+
#endif
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
static inline void yep_mutex_destroy(yep_mutex_raw* m) {
|
|
22
|
+
#if !defined(_WIN32)
|
|
23
|
+
pthread_mutex_destroy(m);
|
|
24
|
+
#else
|
|
25
|
+
(void)m; /* SRWLOCK needs no destroy */
|
|
26
|
+
#endif
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
static inline void yep_mutex_lock(yep_mutex_raw* m) {
|
|
30
|
+
#if defined(_WIN32)
|
|
31
|
+
AcquireSRWLockExclusive(m);
|
|
32
|
+
#else
|
|
33
|
+
pthread_mutex_lock(m);
|
|
34
|
+
#endif
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
static inline void yep_mutex_unlock(yep_mutex_raw* m) {
|
|
38
|
+
#if defined(_WIN32)
|
|
39
|
+
ReleaseSRWLockExclusive(m);
|
|
40
|
+
#else
|
|
41
|
+
pthread_mutex_unlock(m);
|
|
42
|
+
#endif
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
#endif /* YEP_MUTEX_H */
|