ruby_memprofiler_pprof 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/ext/ruby_memprofiler_pprof/backtrace.c +429 -0
- data/ext/ruby_memprofiler_pprof/collector.c +1055 -0
- data/ext/ruby_memprofiler_pprof/compat.c +182 -0
- data/ext/ruby_memprofiler_pprof/extconf.rb +72 -0
- data/ext/ruby_memprofiler_pprof/pprof.upb.c +170 -0
- data/ext/ruby_memprofiler_pprof/pprof.upb.h +848 -0
- data/ext/ruby_memprofiler_pprof/pprof_out.c +285 -0
- data/ext/ruby_memprofiler_pprof/ruby_memprofiler_pprof.c +11 -0
- data/ext/ruby_memprofiler_pprof/ruby_memprofiler_pprof.h +301 -0
- data/ext/ruby_memprofiler_pprof/strtab.c +391 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/BUILD +719 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/CONTRIBUTING.md +37 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/DESIGN.md +201 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/LICENSE +26 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/README.md +78 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/WORKSPACE +58 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/bazel/BUILD +53 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/bazel/amalgamate.py +129 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/bazel/build_defs.bzl +160 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/bazel/lua.BUILD +127 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/bazel/protobuf.patch +54 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/bazel/py_proto_library.bzl +137 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/bazel/python_downloads.bzl +84 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/bazel/system_python.bzl +101 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/bazel/upb_proto_library.bzl +388 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/bazel/workspace_deps.bzl +89 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/benchmarks/BUILD +252 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/benchmarks/BUILD.googleapis +54 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/benchmarks/benchmark.cc +333 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/benchmarks/build_defs.bzl +88 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/benchmarks/compare.py +118 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/benchmarks/descriptor.proto +888 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/benchmarks/descriptor_sv.proto +890 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/benchmarks/empty.proto +6 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/benchmarks/gen_protobuf_binary_cc.py +64 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/benchmarks/gen_synthetic_protos.py +118 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/benchmarks/gen_upb_binary_c.py +65 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/cmake/BUILD.bazel +102 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/cmake/README.md +23 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/cmake/build_defs.bzl +73 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/cmake/make_cmakelists.py +340 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/cmake/staleness_test.py +57 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/cmake/staleness_test_lib.py +186 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/docs/render.py +43 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/docs/style-guide.md +65 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/docs/vs-cpp-protos.md +255 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/docs/wrapping-upb.md +444 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/BUILD +216 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/convert.c +394 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/convert.h +63 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/descriptor.c +1694 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/descriptor.h +80 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/descriptor_containers.c +704 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/descriptor_containers.h +114 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/descriptor_pool.c +650 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/descriptor_pool.h +48 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/dist/BUILD.bazel +193 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/dist/dist.bzl +190 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/extension_dict.c +247 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/extension_dict.h +39 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/map.c +522 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/map.h +66 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/message.c +1909 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/message.h +101 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/minimal_test.py +183 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/BUILD +70 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/README.md +11 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/descriptor_database_test_wrapper.py +30 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/descriptor_pool_test_wrapper.py +45 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/descriptor_test_wrapper.py +46 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/generator_test_wrapper.py +30 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/json_format_test_wrapper.py +30 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/keywords_test_wrapper.py +30 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/message_factory_test_wrapper.py +37 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/message_test_wrapper.py +52 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/proto_builder_test_wrapper.py +32 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/pyproto_test_wrapper.bzl +36 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/reflection_test_wrapper.py +45 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/service_reflection_test_wrapper.py +30 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/symbol_database_test_wrapper.py +30 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/text_encoding_test_wrapper.py +30 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/text_format_test_wrapper.py +30 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/unknown_fields_test_wrapper.py +30 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/well_known_types_test_wrapper.py +36 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/pb_unit_tests/wire_format_test_wrapper.py +30 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/protobuf.c +350 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/protobuf.h +230 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/py_extension.bzl +55 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/python_api.h +61 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/repeated.c +828 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/repeated.h +69 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/unknown_fields.c +404 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/unknown_fields.h +39 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/python/version_script.lds +6 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/third_party/lunit/LICENSE +32 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/third_party/lunit/README.google +9 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/third_party/lunit/console.lua +156 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/third_party/lunit/lunit.lua +725 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/third_party/utf8_range/BUILD +19 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/third_party/utf8_range/LICENSE +21 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/third_party/utf8_range/naive.c +92 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/third_party/utf8_range/range2-neon.c +157 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/third_party/utf8_range/range2-sse.c +170 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/third_party/utf8_range/utf8_range.h +9 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/bindings/lua/BUILD.bazel +129 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/bindings/lua/README.md +8 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/bindings/lua/def.c +939 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/bindings/lua/lua_proto_library.bzl +138 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/bindings/lua/main.c +83 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/bindings/lua/msg.c +1118 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/bindings/lua/test.proto +69 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/bindings/lua/test_upb.lua +846 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/bindings/lua/upb.c +258 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/bindings/lua/upb.h +132 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/bindings/lua/upb.lua +58 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/bindings/lua/upbc.cc +134 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/collections.c +192 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/collections.h +174 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/conformance_upb.c +346 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/conformance_upb_failures.txt +1 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/decode.c +1221 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/decode.h +94 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/decode_fast.c +1055 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/decode_fast.h +153 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/decode_internal.h +211 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/def.c +3262 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/def.h +414 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/def.hpp +438 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/empty.proto +1 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/encode.c +604 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/encode.h +71 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/fuzz/BUILD +13 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/fuzz/file_descriptor_parsenew_fuzzer.cc +43 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/json_decode.c +1509 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/json_decode.h +47 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/json_encode.c +776 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/json_encode.h +62 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/mini_table.c +1147 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/mini_table.h +189 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/mini_table.hpp +112 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/mini_table_accessors.c +363 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/mini_table_accessors.h +263 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/mini_table_accessors_internal.h +59 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/mini_table_accessors_test.cc +425 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/mini_table_test.cc +230 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/msg.c +428 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/msg.h +114 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/msg_internal.h +836 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/msg_test.cc +491 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/msg_test.proto +195 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/port_def.inc +261 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/port_undef.inc +62 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/reflection.c +323 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/reflection.h +109 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/reflection.hpp +37 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/table.c +926 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/table_internal.h +385 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/test.proto +74 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/test_cpp.cc +186 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/test_cpp.proto +12 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/test_generated_code.cc +977 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/test_table.cc +580 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/text_encode.c +472 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/text_encode.h +64 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/upb.c +362 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/upb.h +378 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/upb.hpp +115 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/upb_internal.h +68 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/BUILD +121 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/README.md +7 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/compare.c +300 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/compare.h +66 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/compare_test.cc +236 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/def_to_proto.c +572 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/def_to_proto.h +62 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/def_to_proto_public_import_test.proto +32 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/def_to_proto_regular_import_test.proto +36 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/def_to_proto_test.cc +143 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/def_to_proto_test.proto +119 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/def_to_proto_weak_import_test.proto +28 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/def_to_proto_wweak_import_test.proto +28 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/required_fields.c +311 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/required_fields.h +94 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/required_fields_test.cc +202 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upb/util/required_fields_test.proto +48 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upbc/BUILD +78 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upbc/common.cc +77 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upbc/common.h +112 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upbc/protoc-gen-upb.cc +1997 -0
- data/ext/ruby_memprofiler_pprof/vendor/upb/upbc/protoc-gen-upbdefs.cc +193 -0
- data/lib/ruby_memprofiler_pprof/atfork.rb +77 -0
- data/lib/ruby_memprofiler_pprof/block_flusher.rb +61 -0
- data/lib/ruby_memprofiler_pprof/file_flusher.rb +45 -0
- data/lib/ruby_memprofiler_pprof/profile_app.rb +30 -0
- data/lib/ruby_memprofiler_pprof/profile_data.rb +18 -0
- data/lib/ruby_memprofiler_pprof/version.rb +5 -0
- data/lib/ruby_memprofiler_pprof.rb +8 -0
- data/libexec/ruby_memprofiler_pprof_profile +16 -0
- metadata +257 -0
@@ -0,0 +1,19 @@
|
|
1
|
+
|
2
|
+
# Pulled from: https://github.com/cyb70289/utf8
|
3
|
+
|
4
|
+
cc_library(
|
5
|
+
name = "utf8_range",
|
6
|
+
hdrs = ["utf8_range.h"],
|
7
|
+
srcs = [
|
8
|
+
"naive.c",
|
9
|
+
"range2-neon.c",
|
10
|
+
"range2-sse.c",
|
11
|
+
],
|
12
|
+
visibility = ["//:__pkg__"],
|
13
|
+
)
|
14
|
+
|
15
|
+
filegroup(
|
16
|
+
name = "cmake_files",
|
17
|
+
srcs = glob(["*"]),
|
18
|
+
visibility = ["//cmake:__pkg__"],
|
19
|
+
)
|
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2019 Yibo Cai
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
@@ -0,0 +1,92 @@
|
|
1
|
+
#include <stdio.h>
|
2
|
+
|
3
|
+
/*
|
4
|
+
* http://www.unicode.org/versions/Unicode6.0.0/ch03.pdf - page 94
|
5
|
+
*
|
6
|
+
* Table 3-7. Well-Formed UTF-8 Byte Sequences
|
7
|
+
*
|
8
|
+
* +--------------------+------------+-------------+------------+-------------+
|
9
|
+
* | Code Points | First Byte | Second Byte | Third Byte | Fourth Byte |
|
10
|
+
* +--------------------+------------+-------------+------------+-------------+
|
11
|
+
* | U+0000..U+007F | 00..7F | | | |
|
12
|
+
* +--------------------+------------+-------------+------------+-------------+
|
13
|
+
* | U+0080..U+07FF | C2..DF | 80..BF | | |
|
14
|
+
* +--------------------+------------+-------------+------------+-------------+
|
15
|
+
* | U+0800..U+0FFF | E0 | A0..BF | 80..BF | |
|
16
|
+
* +--------------------+------------+-------------+------------+-------------+
|
17
|
+
* | U+1000..U+CFFF | E1..EC | 80..BF | 80..BF | |
|
18
|
+
* +--------------------+------------+-------------+------------+-------------+
|
19
|
+
* | U+D000..U+D7FF | ED | 80..9F | 80..BF | |
|
20
|
+
* +--------------------+------------+-------------+------------+-------------+
|
21
|
+
* | U+E000..U+FFFF | EE..EF | 80..BF | 80..BF | |
|
22
|
+
* +--------------------+------------+-------------+------------+-------------+
|
23
|
+
* | U+10000..U+3FFFF | F0 | 90..BF | 80..BF | 80..BF |
|
24
|
+
* +--------------------+------------+-------------+------------+-------------+
|
25
|
+
* | U+40000..U+FFFFF | F1..F3 | 80..BF | 80..BF | 80..BF |
|
26
|
+
* +--------------------+------------+-------------+------------+-------------+
|
27
|
+
* | U+100000..U+10FFFF | F4 | 80..8F | 80..BF | 80..BF |
|
28
|
+
* +--------------------+------------+-------------+------------+-------------+
|
29
|
+
*/
|
30
|
+
|
31
|
+
/* Return 0 - success, >0 - index(1 based) of first error char */
|
32
|
+
int utf8_naive(const unsigned char *data, int len)
|
33
|
+
{
|
34
|
+
int err_pos = 1;
|
35
|
+
|
36
|
+
while (len) {
|
37
|
+
int bytes;
|
38
|
+
const unsigned char byte1 = data[0];
|
39
|
+
|
40
|
+
/* 00..7F */
|
41
|
+
if (byte1 <= 0x7F) {
|
42
|
+
bytes = 1;
|
43
|
+
/* C2..DF, 80..BF */
|
44
|
+
} else if (len >= 2 && byte1 >= 0xC2 && byte1 <= 0xDF &&
|
45
|
+
(signed char)data[1] <= (signed char)0xBF) {
|
46
|
+
bytes = 2;
|
47
|
+
} else if (len >= 3) {
|
48
|
+
const unsigned char byte2 = data[1];
|
49
|
+
|
50
|
+
/* Is byte2, byte3 between 0x80 ~ 0xBF */
|
51
|
+
const int byte2_ok = (signed char)byte2 <= (signed char)0xBF;
|
52
|
+
const int byte3_ok = (signed char)data[2] <= (signed char)0xBF;
|
53
|
+
|
54
|
+
if (byte2_ok && byte3_ok &&
|
55
|
+
/* E0, A0..BF, 80..BF */
|
56
|
+
((byte1 == 0xE0 && byte2 >= 0xA0) ||
|
57
|
+
/* E1..EC, 80..BF, 80..BF */
|
58
|
+
(byte1 >= 0xE1 && byte1 <= 0xEC) ||
|
59
|
+
/* ED, 80..9F, 80..BF */
|
60
|
+
(byte1 == 0xED && byte2 <= 0x9F) ||
|
61
|
+
/* EE..EF, 80..BF, 80..BF */
|
62
|
+
(byte1 >= 0xEE && byte1 <= 0xEF))) {
|
63
|
+
bytes = 3;
|
64
|
+
} else if (len >= 4) {
|
65
|
+
/* Is byte4 between 0x80 ~ 0xBF */
|
66
|
+
const int byte4_ok = (signed char)data[3] <= (signed char)0xBF;
|
67
|
+
|
68
|
+
if (byte2_ok && byte3_ok && byte4_ok &&
|
69
|
+
/* F0, 90..BF, 80..BF, 80..BF */
|
70
|
+
((byte1 == 0xF0 && byte2 >= 0x90) ||
|
71
|
+
/* F1..F3, 80..BF, 80..BF, 80..BF */
|
72
|
+
(byte1 >= 0xF1 && byte1 <= 0xF3) ||
|
73
|
+
/* F4, 80..8F, 80..BF, 80..BF */
|
74
|
+
(byte1 == 0xF4 && byte2 <= 0x8F))) {
|
75
|
+
bytes = 4;
|
76
|
+
} else {
|
77
|
+
return err_pos;
|
78
|
+
}
|
79
|
+
} else {
|
80
|
+
return err_pos;
|
81
|
+
}
|
82
|
+
} else {
|
83
|
+
return err_pos;
|
84
|
+
}
|
85
|
+
|
86
|
+
len -= bytes;
|
87
|
+
err_pos += bytes;
|
88
|
+
data += bytes;
|
89
|
+
}
|
90
|
+
|
91
|
+
return 0;
|
92
|
+
}
|
@@ -0,0 +1,157 @@
|
|
1
|
+
/*
|
2
|
+
* Process 2x16 bytes in each iteration.
|
3
|
+
* Comments removed for brevity. See range-neon.c for details.
|
4
|
+
*/
|
5
|
+
#if defined(__aarch64__) && defined(__ARM_NEON)
|
6
|
+
|
7
|
+
#include <stdio.h>
|
8
|
+
#include <stdint.h>
|
9
|
+
#include <arm_neon.h>
|
10
|
+
|
11
|
+
int utf8_naive(const unsigned char *data, int len);
|
12
|
+
|
13
|
+
static const uint8_t _first_len_tbl[] = {
|
14
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 3,
|
15
|
+
};
|
16
|
+
|
17
|
+
static const uint8_t _first_range_tbl[] = {
|
18
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 8, 8, 8,
|
19
|
+
};
|
20
|
+
|
21
|
+
static const uint8_t _range_min_tbl[] = {
|
22
|
+
0x00, 0x80, 0x80, 0x80, 0xA0, 0x80, 0x90, 0x80,
|
23
|
+
0xC2, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
24
|
+
};
|
25
|
+
static const uint8_t _range_max_tbl[] = {
|
26
|
+
0x7F, 0xBF, 0xBF, 0xBF, 0xBF, 0x9F, 0xBF, 0x8F,
|
27
|
+
0xF4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
28
|
+
};
|
29
|
+
|
30
|
+
static const uint8_t _range_adjust_tbl[] = {
|
31
|
+
2, 3, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0,
|
32
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0,
|
33
|
+
};
|
34
|
+
|
35
|
+
/* Return 0 on success, -1 on error */
|
36
|
+
int utf8_range2(const unsigned char *data, int len)
|
37
|
+
{
|
38
|
+
if (len >= 32) {
|
39
|
+
uint8x16_t prev_input = vdupq_n_u8(0);
|
40
|
+
uint8x16_t prev_first_len = vdupq_n_u8(0);
|
41
|
+
|
42
|
+
const uint8x16_t first_len_tbl = vld1q_u8(_first_len_tbl);
|
43
|
+
const uint8x16_t first_range_tbl = vld1q_u8(_first_range_tbl);
|
44
|
+
const uint8x16_t range_min_tbl = vld1q_u8(_range_min_tbl);
|
45
|
+
const uint8x16_t range_max_tbl = vld1q_u8(_range_max_tbl);
|
46
|
+
const uint8x16x2_t range_adjust_tbl = vld2q_u8(_range_adjust_tbl);
|
47
|
+
|
48
|
+
const uint8x16_t const_1 = vdupq_n_u8(1);
|
49
|
+
const uint8x16_t const_2 = vdupq_n_u8(2);
|
50
|
+
const uint8x16_t const_e0 = vdupq_n_u8(0xE0);
|
51
|
+
|
52
|
+
uint8x16_t error1 = vdupq_n_u8(0);
|
53
|
+
uint8x16_t error2 = vdupq_n_u8(0);
|
54
|
+
uint8x16_t error3 = vdupq_n_u8(0);
|
55
|
+
uint8x16_t error4 = vdupq_n_u8(0);
|
56
|
+
|
57
|
+
while (len >= 32) {
|
58
|
+
/******************* two blocks interleaved **********************/
|
59
|
+
|
60
|
+
#if defined(__GNUC__) && !defined(__clang__) && (__GNUC__ < 8)
|
61
|
+
/* gcc doesn't support vldq1_u8_x2 until version 8 */
|
62
|
+
const uint8x16_t input_a = vld1q_u8(data);
|
63
|
+
const uint8x16_t input_b = vld1q_u8(data + 16);
|
64
|
+
#else
|
65
|
+
/* Forces a double load on Clang */
|
66
|
+
const uint8x16x2_t input_pair = vld1q_u8_x2(data);
|
67
|
+
const uint8x16_t input_a = input_pair.val[0];
|
68
|
+
const uint8x16_t input_b = input_pair.val[1];
|
69
|
+
#endif
|
70
|
+
|
71
|
+
const uint8x16_t high_nibbles_a = vshrq_n_u8(input_a, 4);
|
72
|
+
const uint8x16_t high_nibbles_b = vshrq_n_u8(input_b, 4);
|
73
|
+
|
74
|
+
const uint8x16_t first_len_a =
|
75
|
+
vqtbl1q_u8(first_len_tbl, high_nibbles_a);
|
76
|
+
const uint8x16_t first_len_b =
|
77
|
+
vqtbl1q_u8(first_len_tbl, high_nibbles_b);
|
78
|
+
|
79
|
+
uint8x16_t range_a = vqtbl1q_u8(first_range_tbl, high_nibbles_a);
|
80
|
+
uint8x16_t range_b = vqtbl1q_u8(first_range_tbl, high_nibbles_b);
|
81
|
+
|
82
|
+
range_a =
|
83
|
+
vorrq_u8(range_a, vextq_u8(prev_first_len, first_len_a, 15));
|
84
|
+
range_b =
|
85
|
+
vorrq_u8(range_b, vextq_u8(first_len_a, first_len_b, 15));
|
86
|
+
|
87
|
+
uint8x16_t tmp1_a, tmp2_a, tmp1_b, tmp2_b;
|
88
|
+
tmp1_a = vextq_u8(prev_first_len, first_len_a, 14);
|
89
|
+
tmp1_a = vqsubq_u8(tmp1_a, const_1);
|
90
|
+
range_a = vorrq_u8(range_a, tmp1_a);
|
91
|
+
|
92
|
+
tmp1_b = vextq_u8(first_len_a, first_len_b, 14);
|
93
|
+
tmp1_b = vqsubq_u8(tmp1_b, const_1);
|
94
|
+
range_b = vorrq_u8(range_b, tmp1_b);
|
95
|
+
|
96
|
+
tmp2_a = vextq_u8(prev_first_len, first_len_a, 13);
|
97
|
+
tmp2_a = vqsubq_u8(tmp2_a, const_2);
|
98
|
+
range_a = vorrq_u8(range_a, tmp2_a);
|
99
|
+
|
100
|
+
tmp2_b = vextq_u8(first_len_a, first_len_b, 13);
|
101
|
+
tmp2_b = vqsubq_u8(tmp2_b, const_2);
|
102
|
+
range_b = vorrq_u8(range_b, tmp2_b);
|
103
|
+
|
104
|
+
uint8x16_t shift1_a = vextq_u8(prev_input, input_a, 15);
|
105
|
+
uint8x16_t pos_a = vsubq_u8(shift1_a, const_e0);
|
106
|
+
range_a = vaddq_u8(range_a, vqtbl2q_u8(range_adjust_tbl, pos_a));
|
107
|
+
|
108
|
+
uint8x16_t shift1_b = vextq_u8(input_a, input_b, 15);
|
109
|
+
uint8x16_t pos_b = vsubq_u8(shift1_b, const_e0);
|
110
|
+
range_b = vaddq_u8(range_b, vqtbl2q_u8(range_adjust_tbl, pos_b));
|
111
|
+
|
112
|
+
uint8x16_t minv_a = vqtbl1q_u8(range_min_tbl, range_a);
|
113
|
+
uint8x16_t maxv_a = vqtbl1q_u8(range_max_tbl, range_a);
|
114
|
+
|
115
|
+
uint8x16_t minv_b = vqtbl1q_u8(range_min_tbl, range_b);
|
116
|
+
uint8x16_t maxv_b = vqtbl1q_u8(range_max_tbl, range_b);
|
117
|
+
|
118
|
+
error1 = vorrq_u8(error1, vcltq_u8(input_a, minv_a));
|
119
|
+
error2 = vorrq_u8(error2, vcgtq_u8(input_a, maxv_a));
|
120
|
+
|
121
|
+
error3 = vorrq_u8(error3, vcltq_u8(input_b, minv_b));
|
122
|
+
error4 = vorrq_u8(error4, vcgtq_u8(input_b, maxv_b));
|
123
|
+
|
124
|
+
/************************ next iteration *************************/
|
125
|
+
prev_input = input_b;
|
126
|
+
prev_first_len = first_len_b;
|
127
|
+
|
128
|
+
data += 32;
|
129
|
+
len -= 32;
|
130
|
+
}
|
131
|
+
error1 = vorrq_u8(error1, error2);
|
132
|
+
error1 = vorrq_u8(error1, error3);
|
133
|
+
error1 = vorrq_u8(error1, error4);
|
134
|
+
|
135
|
+
if (vmaxvq_u8(error1))
|
136
|
+
return -1;
|
137
|
+
|
138
|
+
uint32_t token4;
|
139
|
+
vst1q_lane_u32(&token4, vreinterpretq_u32_u8(prev_input), 3);
|
140
|
+
|
141
|
+
const int8_t *token = (const int8_t *)&token4;
|
142
|
+
int lookahead = 0;
|
143
|
+
if (token[3] > (int8_t)0xBF)
|
144
|
+
lookahead = 1;
|
145
|
+
else if (token[2] > (int8_t)0xBF)
|
146
|
+
lookahead = 2;
|
147
|
+
else if (token[1] > (int8_t)0xBF)
|
148
|
+
lookahead = 3;
|
149
|
+
|
150
|
+
data -= lookahead;
|
151
|
+
len += lookahead;
|
152
|
+
}
|
153
|
+
|
154
|
+
return utf8_naive(data, len);
|
155
|
+
}
|
156
|
+
|
157
|
+
#endif
|
@@ -0,0 +1,170 @@
|
|
1
|
+
/*
|
2
|
+
* Process 2x16 bytes in each iteration.
|
3
|
+
* Comments removed for brevity. See range-sse.c for details.
|
4
|
+
*/
|
5
|
+
#ifdef __SSE4_1__
|
6
|
+
|
7
|
+
#include <stdio.h>
|
8
|
+
#include <stdint.h>
|
9
|
+
#include <x86intrin.h>
|
10
|
+
|
11
|
+
int utf8_naive(const unsigned char *data, int len);
|
12
|
+
|
13
|
+
static const int8_t _first_len_tbl[] = {
|
14
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 3,
|
15
|
+
};
|
16
|
+
|
17
|
+
static const int8_t _first_range_tbl[] = {
|
18
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 8, 8, 8,
|
19
|
+
};
|
20
|
+
|
21
|
+
static const int8_t _range_min_tbl[] = {
|
22
|
+
0x00, 0x80, 0x80, 0x80, 0xA0, 0x80, 0x90, 0x80,
|
23
|
+
0xC2, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F,
|
24
|
+
};
|
25
|
+
static const int8_t _range_max_tbl[] = {
|
26
|
+
0x7F, 0xBF, 0xBF, 0xBF, 0xBF, 0x9F, 0xBF, 0x8F,
|
27
|
+
0xF4, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
|
28
|
+
};
|
29
|
+
|
30
|
+
static const int8_t _df_ee_tbl[] = {
|
31
|
+
0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0,
|
32
|
+
};
|
33
|
+
static const int8_t _ef_fe_tbl[] = {
|
34
|
+
0, 3, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
35
|
+
};
|
36
|
+
|
37
|
+
/* Return 0 on success, -1 on error */
|
38
|
+
int utf8_range2(const unsigned char *data, int len)
|
39
|
+
{
|
40
|
+
if (len >= 32) {
|
41
|
+
__m128i prev_input = _mm_set1_epi8(0);
|
42
|
+
__m128i prev_first_len = _mm_set1_epi8(0);
|
43
|
+
|
44
|
+
const __m128i first_len_tbl =
|
45
|
+
_mm_loadu_si128((const __m128i *)_first_len_tbl);
|
46
|
+
const __m128i first_range_tbl =
|
47
|
+
_mm_loadu_si128((const __m128i *)_first_range_tbl);
|
48
|
+
const __m128i range_min_tbl =
|
49
|
+
_mm_loadu_si128((const __m128i *)_range_min_tbl);
|
50
|
+
const __m128i range_max_tbl =
|
51
|
+
_mm_loadu_si128((const __m128i *)_range_max_tbl);
|
52
|
+
const __m128i df_ee_tbl =
|
53
|
+
_mm_loadu_si128((const __m128i *)_df_ee_tbl);
|
54
|
+
const __m128i ef_fe_tbl =
|
55
|
+
_mm_loadu_si128((const __m128i *)_ef_fe_tbl);
|
56
|
+
|
57
|
+
__m128i error = _mm_set1_epi8(0);
|
58
|
+
|
59
|
+
while (len >= 32) {
|
60
|
+
/***************************** block 1 ****************************/
|
61
|
+
const __m128i input_a = _mm_loadu_si128((const __m128i *)data);
|
62
|
+
|
63
|
+
__m128i high_nibbles =
|
64
|
+
_mm_and_si128(_mm_srli_epi16(input_a, 4), _mm_set1_epi8(0x0F));
|
65
|
+
|
66
|
+
__m128i first_len_a = _mm_shuffle_epi8(first_len_tbl, high_nibbles);
|
67
|
+
|
68
|
+
__m128i range_a = _mm_shuffle_epi8(first_range_tbl, high_nibbles);
|
69
|
+
|
70
|
+
range_a = _mm_or_si128(
|
71
|
+
range_a, _mm_alignr_epi8(first_len_a, prev_first_len, 15));
|
72
|
+
|
73
|
+
__m128i tmp;
|
74
|
+
tmp = _mm_alignr_epi8(first_len_a, prev_first_len, 14);
|
75
|
+
tmp = _mm_subs_epu8(tmp, _mm_set1_epi8(1));
|
76
|
+
range_a = _mm_or_si128(range_a, tmp);
|
77
|
+
|
78
|
+
tmp = _mm_alignr_epi8(first_len_a, prev_first_len, 13);
|
79
|
+
tmp = _mm_subs_epu8(tmp, _mm_set1_epi8(2));
|
80
|
+
range_a = _mm_or_si128(range_a, tmp);
|
81
|
+
|
82
|
+
__m128i shift1, pos, range2;
|
83
|
+
shift1 = _mm_alignr_epi8(input_a, prev_input, 15);
|
84
|
+
pos = _mm_sub_epi8(shift1, _mm_set1_epi8(0xEF));
|
85
|
+
tmp = _mm_subs_epu8(pos, _mm_set1_epi8(0xF0));
|
86
|
+
range2 = _mm_shuffle_epi8(df_ee_tbl, tmp);
|
87
|
+
tmp = _mm_adds_epu8(pos, _mm_set1_epi8(0x70));
|
88
|
+
range2 = _mm_add_epi8(range2, _mm_shuffle_epi8(ef_fe_tbl, tmp));
|
89
|
+
|
90
|
+
range_a = _mm_add_epi8(range_a, range2);
|
91
|
+
|
92
|
+
__m128i minv = _mm_shuffle_epi8(range_min_tbl, range_a);
|
93
|
+
__m128i maxv = _mm_shuffle_epi8(range_max_tbl, range_a);
|
94
|
+
|
95
|
+
tmp = _mm_or_si128(
|
96
|
+
_mm_cmplt_epi8(input_a, minv),
|
97
|
+
_mm_cmpgt_epi8(input_a, maxv)
|
98
|
+
);
|
99
|
+
error = _mm_or_si128(error, tmp);
|
100
|
+
|
101
|
+
/***************************** block 2 ****************************/
|
102
|
+
const __m128i input_b = _mm_loadu_si128((const __m128i *)(data+16));
|
103
|
+
|
104
|
+
high_nibbles =
|
105
|
+
_mm_and_si128(_mm_srli_epi16(input_b, 4), _mm_set1_epi8(0x0F));
|
106
|
+
|
107
|
+
__m128i first_len_b = _mm_shuffle_epi8(first_len_tbl, high_nibbles);
|
108
|
+
|
109
|
+
__m128i range_b = _mm_shuffle_epi8(first_range_tbl, high_nibbles);
|
110
|
+
|
111
|
+
range_b = _mm_or_si128(
|
112
|
+
range_b, _mm_alignr_epi8(first_len_b, first_len_a, 15));
|
113
|
+
|
114
|
+
|
115
|
+
tmp = _mm_alignr_epi8(first_len_b, first_len_a, 14);
|
116
|
+
tmp = _mm_subs_epu8(tmp, _mm_set1_epi8(1));
|
117
|
+
range_b = _mm_or_si128(range_b, tmp);
|
118
|
+
|
119
|
+
tmp = _mm_alignr_epi8(first_len_b, first_len_a, 13);
|
120
|
+
tmp = _mm_subs_epu8(tmp, _mm_set1_epi8(2));
|
121
|
+
range_b = _mm_or_si128(range_b, tmp);
|
122
|
+
|
123
|
+
shift1 = _mm_alignr_epi8(input_b, input_a, 15);
|
124
|
+
pos = _mm_sub_epi8(shift1, _mm_set1_epi8(0xEF));
|
125
|
+
tmp = _mm_subs_epu8(pos, _mm_set1_epi8(0xF0));
|
126
|
+
range2 = _mm_shuffle_epi8(df_ee_tbl, tmp);
|
127
|
+
tmp = _mm_adds_epu8(pos, _mm_set1_epi8(0x70));
|
128
|
+
range2 = _mm_add_epi8(range2, _mm_shuffle_epi8(ef_fe_tbl, tmp));
|
129
|
+
|
130
|
+
range_b = _mm_add_epi8(range_b, range2);
|
131
|
+
|
132
|
+
minv = _mm_shuffle_epi8(range_min_tbl, range_b);
|
133
|
+
maxv = _mm_shuffle_epi8(range_max_tbl, range_b);
|
134
|
+
|
135
|
+
|
136
|
+
tmp = _mm_or_si128(
|
137
|
+
_mm_cmplt_epi8(input_b, minv),
|
138
|
+
_mm_cmpgt_epi8(input_b, maxv)
|
139
|
+
);
|
140
|
+
error = _mm_or_si128(error, tmp);
|
141
|
+
|
142
|
+
/************************ next iteration **************************/
|
143
|
+
prev_input = input_b;
|
144
|
+
prev_first_len = first_len_b;
|
145
|
+
|
146
|
+
data += 32;
|
147
|
+
len -= 32;
|
148
|
+
}
|
149
|
+
|
150
|
+
if (!_mm_testz_si128(error, error))
|
151
|
+
return -1;
|
152
|
+
|
153
|
+
int32_t token4 = _mm_extract_epi32(prev_input, 3);
|
154
|
+
const int8_t *token = (const int8_t *)&token4;
|
155
|
+
int lookahead = 0;
|
156
|
+
if (token[3] > (int8_t)0xBF)
|
157
|
+
lookahead = 1;
|
158
|
+
else if (token[2] > (int8_t)0xBF)
|
159
|
+
lookahead = 2;
|
160
|
+
else if (token[1] > (int8_t)0xBF)
|
161
|
+
lookahead = 3;
|
162
|
+
|
163
|
+
data -= lookahead;
|
164
|
+
len += lookahead;
|
165
|
+
}
|
166
|
+
|
167
|
+
return utf8_naive(data, len);
|
168
|
+
}
|
169
|
+
|
170
|
+
#endif
|
@@ -0,0 +1,9 @@
|
|
1
|
+
|
2
|
+
#if (defined(__ARM_NEON) && defined(__aarch64__)) || defined(__SSE4_1__)
|
3
|
+
int utf8_range2(const unsigned char* data, int len);
|
4
|
+
#else
|
5
|
+
int utf8_naive(const unsigned char* data, int len);
|
6
|
+
static inline int utf8_range2(const unsigned char* data, int len) {
|
7
|
+
return utf8_naive(data, len);
|
8
|
+
}
|
9
|
+
#endif
|
@@ -0,0 +1,129 @@
|
|
1
|
+
# Copyright (c) 2009-2021, Google LLC
|
2
|
+
# All rights reserved.
|
3
|
+
#
|
4
|
+
# Redistribution and use in source and binary forms, with or without
|
5
|
+
# modification, are permitted provided that the following conditions are met:
|
6
|
+
# * Redistributions of source code must retain the above copyright
|
7
|
+
# notice, this list of conditions and the following disclaimer.
|
8
|
+
# * Redistributions in binary form must reproduce the above copyright
|
9
|
+
# notice, this list of conditions and the following disclaimer in the
|
10
|
+
# documentation and/or other materials provided with the distribution.
|
11
|
+
# * Neither the name of Google LLC nor the
|
12
|
+
# names of its contributors may be used to endorse or promote products
|
13
|
+
# derived from this software without specific prior written permission.
|
14
|
+
#
|
15
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
16
|
+
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
17
|
+
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
18
|
+
# DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY
|
19
|
+
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
20
|
+
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
21
|
+
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
22
|
+
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
23
|
+
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
24
|
+
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
25
|
+
|
26
|
+
load(
|
27
|
+
"//bazel:build_defs.bzl",
|
28
|
+
"UPB_DEFAULT_COPTS",
|
29
|
+
"UPB_DEFAULT_CPPOPTS",
|
30
|
+
)
|
31
|
+
load(
|
32
|
+
"//upb/bindings/lua:lua_proto_library.bzl",
|
33
|
+
"lua_proto_library",
|
34
|
+
)
|
35
|
+
|
36
|
+
licenses(["notice"])
|
37
|
+
|
38
|
+
cc_library(
|
39
|
+
name = "lupb",
|
40
|
+
srcs = [
|
41
|
+
"def.c",
|
42
|
+
"msg.c",
|
43
|
+
"upb.c",
|
44
|
+
],
|
45
|
+
hdrs = [
|
46
|
+
"upb.h",
|
47
|
+
],
|
48
|
+
copts = UPB_DEFAULT_COPTS,
|
49
|
+
visibility = ["//visibility:public"],
|
50
|
+
deps = [
|
51
|
+
"//:json",
|
52
|
+
"//:reflection",
|
53
|
+
"//:textformat",
|
54
|
+
"//:upb",
|
55
|
+
"@lua//:liblua",
|
56
|
+
],
|
57
|
+
)
|
58
|
+
|
59
|
+
cc_binary(
|
60
|
+
name = "protoc-gen-lua",
|
61
|
+
srcs = ["upbc.cc"],
|
62
|
+
copts = UPB_DEFAULT_CPPOPTS,
|
63
|
+
visibility = ["//visibility:public"],
|
64
|
+
deps = [
|
65
|
+
"@com_google_absl//absl/strings",
|
66
|
+
"@com_google_protobuf//:protoc_lib",
|
67
|
+
],
|
68
|
+
)
|
69
|
+
|
70
|
+
exports_files(["upb.lua"])
|
71
|
+
|
72
|
+
cc_test(
|
73
|
+
name = "test_lua",
|
74
|
+
srcs = ["main.c"],
|
75
|
+
copts = UPB_DEFAULT_COPTS,
|
76
|
+
data = [
|
77
|
+
"test_upb.lua",
|
78
|
+
":descriptor_proto_lua",
|
79
|
+
":empty_proto_lua",
|
80
|
+
":test_messages_proto2_proto_lua",
|
81
|
+
":test_messages_proto3_proto_lua",
|
82
|
+
":test_proto_lua",
|
83
|
+
"//:third_party/lunit/console.lua",
|
84
|
+
"//:third_party/lunit/lunit.lua",
|
85
|
+
"//upb/bindings/lua:upb.lua",
|
86
|
+
"@com_google_protobuf//:descriptor_proto",
|
87
|
+
"@com_google_protobuf//conformance:conformance_proto",
|
88
|
+
],
|
89
|
+
linkstatic = 1,
|
90
|
+
deps = [
|
91
|
+
"//upb/bindings/lua:lupb",
|
92
|
+
"@lua//:liblua",
|
93
|
+
],
|
94
|
+
)
|
95
|
+
|
96
|
+
proto_library(
|
97
|
+
name = "test_proto",
|
98
|
+
testonly = 1,
|
99
|
+
srcs = ["test.proto"],
|
100
|
+
deps = ["@com_google_protobuf//:timestamp_proto"],
|
101
|
+
)
|
102
|
+
|
103
|
+
lua_proto_library(
|
104
|
+
name = "test_proto_lua",
|
105
|
+
testonly = 1,
|
106
|
+
deps = [":test_proto"],
|
107
|
+
)
|
108
|
+
|
109
|
+
lua_proto_library(
|
110
|
+
name = "descriptor_proto_lua",
|
111
|
+
deps = ["@com_google_protobuf//:descriptor_proto"],
|
112
|
+
)
|
113
|
+
|
114
|
+
lua_proto_library(
|
115
|
+
name = "empty_proto_lua",
|
116
|
+
deps = ["@com_google_protobuf//:empty_proto"],
|
117
|
+
)
|
118
|
+
|
119
|
+
lua_proto_library(
|
120
|
+
name = "test_messages_proto3_proto_lua",
|
121
|
+
testonly = 1,
|
122
|
+
deps = ["@com_google_protobuf//:test_messages_proto3_proto"],
|
123
|
+
)
|
124
|
+
|
125
|
+
lua_proto_library(
|
126
|
+
name = "test_messages_proto2_proto_lua",
|
127
|
+
testonly = 1,
|
128
|
+
deps = ["@com_google_protobuf//:test_messages_proto2_proto"],
|
129
|
+
)
|
@@ -0,0 +1,8 @@
|
|
1
|
+
|
2
|
+
# upb Lua bindings
|
3
|
+
|
4
|
+
These are some bare-bones upb bindings for Lua.
|
5
|
+
|
6
|
+
These bindings exist primarily for experimentation and testing. They are
|
7
|
+
incomplete and are not really intended for use in any application. This is by
|
8
|
+
no means a complete or supported protobuf library.
|