Squashed 'third_party/upb/' changes from 2a25fd557e..d8f3d6f9d4

d8f3d6f9d4 Merge pull request #233 from annarev/add_port_dependencies
a27429f265 Add port_def.inc and port_undef.inc to generated code hdrs
3797ad2217 port should not be public
578dc32208 Set port visibility to public.
fc4941183f Add :port dependencies to libraries that include it
7d1abedbdd Merge pull request #232 from annarev/forward_assert_changes
1b131ca544 Merge pull request #231 from annarev/fix_build_for_sync
d2389ba261 Add correctness asserts to upb_addmsg
de1bc11663 Split port into its own target, add msg.h to :legacy_msg_reflection
abdf14937d Merge pull request #216 from XrXr/use-memcpy-to-do-unaligned-read
47ab661706 Merge pull request #227 from lizan/absl_workspace_name
0b63c75164 Do not strip :descriptor_upbreflection and make some headers public that are used outside of the their module
bcdfe6b1b0 bazel: use canonical repository name for absl
a73fd86c13 Use memcpy to perform unaligned reads

git-subtree-dir: third_party/upb
git-subtree-split: d8f3d6f9d415b31f3ce56d46791706c38fa311bc
pull/21645/head
Esun Kim 5 years ago
parent 01ca25b429
commit f9d27c0b8c
  1. 58
      BUILD
  2. 15
      CMakeLists.txt
  3. 3
      bazel/upb_proto_library.bzl
  4. 2
      bazel/workspace_deps.bzl
  5. 4
      upb/decode.c
  6. 1
      upb/port.c
  7. 4
      upb/port_def.inc
  8. 3
      upb/table.c

58
BUILD

@ -54,6 +54,17 @@ config_setting(
# Public C/C++ libraries #######################################################
cc_library(
name = "port",
textual_hdrs = [
"upb/port_def.inc",
"upb/port_undef.inc",
],
srcs = [
"upb/port.c",
],
)
cc_library(
name = "upb",
srcs = [
@ -62,9 +73,6 @@ cc_library(
"upb/generated_util.h",
"upb/msg.c",
"upb/msg.h",
"upb/port.c",
"upb/port_def.inc",
"upb/port_undef.inc",
"upb/table.c",
"upb/table.int.h",
"upb/upb.c",
@ -79,6 +87,7 @@ cc_library(
"//conditions:default": COPTS
}),
visibility = ["//visibility:public"],
deps = [":port"],
)
# Common support routines used by generated code. This library has no
@ -92,17 +101,17 @@ cc_library(
hdrs = [
"upb/generated_util.h",
"upb/msg.h",
"upb/port_def.inc",
"upb/port_undef.inc",
],
copts = select({
":windows": [],
"//conditions:default": COPTS
}),
textual_hdrs = [
"upb/port_def.inc",
"upb/port_undef.inc",
],
visibility = ["//visibility:public"],
deps = [":upb"],
deps = [
":upb",
],
)
upb_proto_library(
@ -128,6 +137,7 @@ cc_library(
visibility = ["//visibility:public"],
deps = [
":descriptor_upbproto",
":port",
":table",
":upb",
],
@ -138,7 +148,10 @@ cc_library(
cc_library(
name = "table",
hdrs = ["upb/table.int.h"],
deps = [":upb"],
deps = [
":port",
":upb",
],
)
# Legacy C/C++ Libraries (not recommended for new code) ########################
@ -146,6 +159,7 @@ cc_library(
cc_library(
name = "legacy_msg_reflection",
srcs = [
"upb/msg.h",
"upb/legacy_msg_reflection.c",
],
hdrs = ["upb/legacy_msg_reflection.h"],
@ -154,6 +168,7 @@ cc_library(
"//conditions:default": COPTS
}),
deps = [
":port",
":table",
":upb",
],
@ -176,6 +191,7 @@ cc_library(
}),
deps = [
":reflection",
":port",
":table",
":upb",
],
@ -205,6 +221,7 @@ cc_library(
":descriptor_upbproto",
":handlers",
":reflection",
":port",
":table",
":upb",
],
@ -240,6 +257,7 @@ cc_library(
deps = [
":descriptor_upbproto",
":handlers",
":port",
":upb",
],
)
@ -259,9 +277,9 @@ cc_library(
"//conditions:default": CPPOPTS
}),
deps = [
"@absl//absl/base:core_headers",
"@absl//absl/container:flat_hash_map",
"@absl//absl/strings",
"@com_google_absl//absl/base:core_headers",
"@com_google_absl//absl/container:flat_hash_map",
"@com_google_absl//absl/strings",
"@com_google_protobuf//:protobuf",
"@com_google_protobuf//:protoc_lib",
],
@ -286,6 +304,11 @@ cc_binary(
# C/C++ tests ##################################################################
upb_proto_reflection_library(
name = "descriptor_upbreflection",
deps = ["@com_google_protobuf//:descriptor_proto"],
)
cc_binary(
name = "benchmark",
testonly = 1,
@ -313,6 +336,7 @@ cc_library(
}),
deps = [
":handlers",
":port",
":upb",
],
)
@ -328,6 +352,7 @@ cc_test(
"//conditions:default": COPTS
}),
deps = [
":port",
":upb",
":upb_pb",
":upb_test",
@ -358,6 +383,7 @@ cc_test(
}),
deps = [
":handlers",
":port",
":test_decoder_upbproto",
":upb",
":upb_pb",
@ -386,6 +412,7 @@ cc_test(
}),
deps = [
":handlers",
":port",
":reflection",
":test_cpp_upbproto",
":upb",
@ -402,6 +429,7 @@ cc_test(
"//conditions:default": CPPOPTS
}),
deps = [
":port",
":table",
":upb",
":upb_test",
@ -431,11 +459,6 @@ cc_binary(
)
# copybara:strip_for_google3_begin
upb_proto_reflection_library(
name = "descriptor_upbreflection",
deps = ["@com_google_protobuf//:descriptor_proto"],
)
cc_test(
name = "test_encoder",
srcs = ["tests/pb/test_encoder.cc"],
@ -563,6 +586,7 @@ upb_amalgamation(
":descriptor_upbproto",
":reflection",
":handlers",
":port",
":upb_pb",
":upb_json",
],

@ -60,21 +60,22 @@ endif()
enable_testing()
add_library(port
upb/port.c)
add_library(upb
upb/decode.c
upb/encode.c
upb/generated_util.h
upb/msg.c
upb/msg.h
upb/port.c
upb/port_def.inc
upb/port_undef.inc
upb/table.c
upb/table.int.h
upb/upb.c
upb/decode.h
upb/encode.h
upb/upb.h)
target_link_libraries(upb
port)
add_library(generated_code_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me INTERFACE)
target_link_libraries(generated_code_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me INTERFACE
upb)
@ -85,15 +86,19 @@ add_library(reflection
upb/msgfactory.h)
target_link_libraries(reflection
descriptor_upbproto
port
table
upb)
add_library(table INTERFACE)
target_link_libraries(table INTERFACE
port
upb)
add_library(legacy_msg_reflection
upb/msg.h
upb/legacy_msg_reflection.c
upb/legacy_msg_reflection.h)
target_link_libraries(legacy_msg_reflection
port
table
upb)
add_library(handlers
@ -104,6 +109,7 @@ add_library(handlers
upb/sink.h)
target_link_libraries(handlers
reflection
port
table
upb)
add_library(upb_pb
@ -121,6 +127,7 @@ target_link_libraries(upb_pb
descriptor_upbproto
handlers
reflection
port
table
upb)
add_library(upb_json
@ -135,6 +142,7 @@ add_library(upb_cc_bindings INTERFACE)
target_link_libraries(upb_cc_bindings INTERFACE
descriptor_upbproto
handlers
port
upb)
add_library(upb_test
tests/testmain.cc
@ -142,6 +150,7 @@ add_library(upb_test
tests/upb_test.h)
target_link_libraries(upb_test
handlers
port
upb)

@ -238,7 +238,7 @@ _upb_proto_library_aspect = aspect(
),
"_upb": attr.label_list(default = [
"//:generated_code_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me",
"//:upb"
"//:upb",
]),
"_ext": attr.string(default = ".upb"),
}),
@ -279,6 +279,7 @@ _upb_proto_reflection_library_aspect = aspect(
),
"_upb": attr.label_list(
default = [
"//:generated_code_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me",
"//:upb",
"//:reflection",
],

@ -9,7 +9,7 @@ def upb_deps():
)
git_repository(
name = "absl",
name = "com_google_absl",
commit = "070f6e47b33a2909d039e620c873204f78809492",
remote = "https://github.com/abseil/abseil-cpp.git",
shallow_since = "1541627663 -0500",

@ -249,6 +249,10 @@ static upb_msg *upb_addmsg(upb_decframe *frame,
upb_msg *submsg;
upb_array *arr = upb_getorcreatearr(frame, field);
UPB_ASSERT(field->label == UPB_LABEL_REPEATED);
UPB_ASSERT(field->descriptortype == UPB_DESCRIPTOR_TYPE_MESSAGE ||
field->descriptortype == UPB_DESCRIPTOR_TYPE_GROUP);
*subm = frame->layout->submsgs[field->submsg_index];
submsg = upb_msg_new(*subm, frame->state->arena);
CHK(submsg);

@ -1,5 +1,4 @@
#include "upb/upb.h"
#include "upb/port_def.inc"
#ifdef UPB_MSVC_VSNPRINTF

@ -20,9 +20,7 @@
*
* This file is private and must not be included by users!
*/
#ifndef UINTPTR_MAX
#error must include stdint.h first
#endif
#include <stdint.h>
#if UINTPTR_MAX == 0xffffffff
#define UPB_SIZE(size32, size64) size32

@ -756,7 +756,8 @@ uint32_t upb_murmur_hash2(const void *key, size_t len, uint32_t seed) {
/* Mix 4 bytes at a time into the hash */
const uint8_t * data = (const uint8_t *)key;
while(len >= 4) {
uint32_t k = *(uint32_t *)data;
uint32_t k;
memcpy(&k, data, sizeof(k));
k *= m;
k ^= k >> r;

Loading…
Cancel
Save