upb: create upb/mem/BUILD

The next in a series of CLs to split upb/BUILD into subdirs.

Create mem/internal/
Delete the deprecated upb/arena.h and upb/alloc.h stub headers

PiperOrigin-RevId: 552864952
pull/13675/head^2
Eric Salo 2 years ago committed by Copybara-Service
parent 8a4752a455
commit 3817bbb572
  1. 78
      BUILD
  2. 2
      benchmarks/BUILD
  3. 1
      cmake/BUILD.bazel
  4. 3
      protos/BUILD
  5. 2
      protos/protos_internal_test.cc
  6. 1
      python/dist/BUILD.bazel
  7. 36
      upb/alloc.h
  8. 36
      upb/arena.h
  9. 1
      upb/io/BUILD
  10. 87
      upb/mem/BUILD
  11. 5
      upb/mem/arena.c
  12. 6
      upb/mem/internal/arena.h
  13. 1
      upb/test/BUILD
  14. 2
      upb/wire/decode.c
  15. 2
      upb/wire/internal/decode.h

78
BUILD

@ -127,13 +127,9 @@ cc_library(
cc_library(
name = "upb",
hdrs = [
"upb/alloc.h",
"upb/arena.h",
"upb/collections/array.h",
"upb/decode.h",
"upb/encode.h",
"upb/mem/alloc.h",
"upb/mem/arena.h",
"upb/message/extension_internal.h",
"upb/message/message.h",
"upb/msg.h",
@ -285,6 +281,7 @@ cc_library(
visibility = ["//visibility:public"],
deps = [
":collections_internal",
":mem",
":message_accessors",
":message_internal",
":port",
@ -367,10 +364,11 @@ cc_test(
deps = [
":base",
":collections",
":mem",
":message_accessors",
":message_copy",
":mini_table",
":upb",
"//upb/mini_table",
"//upb/test:test_messages_proto2_upb_proto",
"//upb/test:test_messages_proto3_upb_proto",
"//upb/test:test_upb_proto",
@ -389,9 +387,9 @@ cc_library(
":hash",
":mem_internal",
":message_internal",
":mini_table",
":port",
":wire",
"//upb/mini_table",
],
)
@ -414,13 +412,14 @@ cc_library(
":base",
":base_internal",
":collections_internal",
":mem",
":message_accessors",
":message_accessors_internal",
":message_internal",
":mini_table",
":upb",
":wire_internal",
"//upb/mini_descriptor",
"//upb/mini_table",
],
)
@ -442,9 +441,10 @@ cc_library(
":base",
":collections_internal",
":hash",
":mem",
":message_copy",
":mini_table",
":upb",
"//upb/mini_table",
],
)
@ -459,6 +459,7 @@ cc_library(
copts = UPB_DEFAULT_COPTS,
visibility = ["//visibility:public"],
deps = [
":mem",
":reflection_internal",
"//upb/mini_descriptor",
],
@ -640,6 +641,7 @@ bootstrap_cc_library(
":base",
":collections",
":hash",
":mem",
":message_accessors",
":port",
":upb",
@ -692,6 +694,18 @@ alias(
visibility = ["//visibility:public"],
)
alias(
name = "mem",
actual = "//upb/mem",
visibility = ["//visibility:public"],
)
alias(
name = "mem_internal",
actual = "//upb/mem:internal",
visibility = ["//:__subpackages__"],
)
alias(
name = "mini_table",
actual = "//upb/mini_table",
@ -797,51 +811,6 @@ cc_test(
# Internal C/C++ libraries #####################################################
cc_library(
name = "mem",
hdrs = [
"upb/mem/alloc.h",
"upb/mem/arena.h",
],
copts = UPB_DEFAULT_COPTS,
visibility = ["//:__subpackages__"],
deps = [
":mem_internal",
":port",
],
)
cc_test(
name = "arena_test",
srcs = ["upb/mem/arena_test.cc"],
deps = [
":port",
":upb",
"@com_google_absl//absl/random",
"@com_google_absl//absl/random:distributions",
"@com_google_absl//absl/synchronization",
"@com_google_googletest//:gtest_main",
],
)
cc_library(
name = "mem_internal",
srcs = [
"upb/mem/alloc.c",
"upb/mem/arena.c",
],
hdrs = [
"upb/mem/alloc.h",
"upb/mem/arena.h",
"upb/mem/arena_internal.h",
],
copts = UPB_DEFAULT_COPTS,
visibility = [
"//visibility:private", # Only private by automation, not intent. Owner may accept CLs adding visibility. See go/scheuklappen#explicit-private.
],
deps = [":port"],
)
cc_library(
name = "wire",
hdrs = [
@ -1013,6 +982,7 @@ upb_amalgamation(
":generated_code_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me",
":hash",
":lex",
":mem",
":mem_internal",
":message_accessors",
":message_internal",
@ -1061,6 +1031,7 @@ upb_amalgamation(
":hash",
":json",
":lex",
":mem",
":mem_internal",
":message_accessors",
":message_internal",
@ -1110,6 +1081,7 @@ upb_amalgamation(
":hash",
":json",
":lex",
":mem",
":mem_internal",
":message_accessors",
":message_internal",

@ -92,10 +92,10 @@ cc_test(
":benchmark_descriptor_upb_proto",
":benchmark_descriptor_upb_proto_reflection",
"//:base",
"//:base_internal",
"//:descriptor_upb_proto",
"//:mem",
"//:reflection",
"//upb/base:internal",
"@com_github_google_benchmark//:benchmark_main",
"@com_google_absl//absl/container:flat_hash_set",
"@com_google_protobuf//:protobuf",

@ -101,6 +101,7 @@ sh_test(
":gen_cmakelists",
"//:source_files",
"//upb/base:source_files",
"//upb/mem:source_files",
"//upb/mini_descriptor:source_files",
"//upb/mini_table:source_files",
"@utf8_range//:utf8_range_srcs",

@ -51,6 +51,7 @@ cc_library(
":protos_traits",
"//:base",
"//:collections_internal",
"//:mem",
"//:message_copy",
"//:mini_table",
"//:port",
@ -71,6 +72,7 @@ cc_library(
copts = UPB_DEFAULT_CPPOPTS,
visibility = ["//visibility:public"],
deps = [
"//:mem",
"//:message_copy",
"//:message_promote",
"//:mini_table",
@ -128,6 +130,7 @@ cc_test(
copts = UPB_DEFAULT_CPPOPTS,
deps = [
":protos_internal",
"//:mem",
"//:upb",
"//protos_generator/tests:test_model_upb_cc_proto",
"//protos_generator/tests:test_model_upb_proto",

@ -29,7 +29,7 @@
#include "gtest/gtest.h"
#include "protos_generator/tests/test_model.upb.h"
#include "protos_generator/tests/test_model.upb.proto.h"
#include "upb/arena.h"
#include "upb/mem/arena.h"
namespace protos::testing {
namespace {

@ -215,6 +215,7 @@ pkg_tar(
"//:source_files",
"//python:message_srcs",
"//upb/base:source_files",
"//upb/mem:source_files",
"//upb/mini_descriptor:source_files",
"//upb/mini_table:source_files",
"//upb/util:source_files",

@ -1,36 +0,0 @@
/*
* Copyright (c) 2009-2021, Google LLC
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Google LLC nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
// This header is deprecated, use upb/mem/alloc.h instead
// IWYU pragma: private, include "upb/mem/alloc.h"
#ifndef UPB_ALLOC_H_
#define UPB_ALLOC_H_
#include "upb/mem/alloc.h"
#endif /* UPB_ALLOC_H_ */

@ -1,36 +0,0 @@
/*
* Copyright (c) 2009-2021, Google LLC
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Google LLC nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
// This header is deprecated, use upb/mem/arena.h instead
// IWYU pragma: private, include "upb/mem/arena.h"
#ifndef UPB_ARENA_H_
#define UPB_ARENA_H_
#include "upb/mem/arena.h"
#endif /* UPB_ARENA_H_ */

@ -54,6 +54,7 @@ cc_library(
deps = [
":zero_copy_stream",
"//:upb",
"//:mem",
"//:port",
],
)

@ -0,0 +1,87 @@
# Copyright (c) 2009-2021, Google LLC
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of Google LLC nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
load("//bazel:build_defs.bzl", "UPB_DEFAULT_COPTS")
cc_library(
name = "mem",
hdrs = [
"alloc.h",
"arena.h",
],
copts = UPB_DEFAULT_COPTS,
visibility = ["//visibility:public"],
deps = [
":internal",
"//:port",
],
)
cc_library(
name = "internal",
srcs = [
"alloc.c",
"arena.c",
],
hdrs = [
"alloc.h",
"arena.h",
"internal/arena.h",
],
copts = UPB_DEFAULT_COPTS,
visibility = ["//:__subpackages__"],
deps = ["//:port"],
)
cc_test(
name = "arena_test",
srcs = ["arena_test.cc"],
deps = [
"//:mem",
"//:port",
"//:upb",
"@com_google_absl//absl/random",
"@com_google_absl//absl/random:distributions",
"@com_google_absl//absl/synchronization",
"@com_google_googletest//:gtest_main",
],
)
# begin:github_only
filegroup(
name = "source_files",
srcs = glob(
[
"**/*.c",
"**/*.h",
],
exclude = ["arena_test.cc"],
),
visibility = [
"//cmake:__pkg__",
"//python/dist:__pkg__",
]
)
# end:github_only

@ -25,7 +25,8 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "upb/mem/arena_internal.h"
#include "upb/mem/internal/arena.h"
#include "upb/port/atomic.h"
// Must be last.
@ -67,7 +68,7 @@ static _upb_ArenaRoot _upb_Arena_FindRoot(upb_Arena* a) {
//
// This is true because:
// - If no fuses occur, this will eventually become the root.
// - If fuses are actively occuring, the root may change, but the
// - If fuses are actively occurring, the root may change, but the
// invariant is that `parent_or_count` merely points to *a* parent.
//
// In other words, it is moving towards "the" root, and that root may move

@ -25,8 +25,8 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef UPB_MEM_ARENA_INTERNAL_H_
#define UPB_MEM_ARENA_INTERNAL_H_
#ifndef UPB_MEM_INTERNAL_ARENA_H_
#define UPB_MEM_INTERNAL_ARENA_H_
#include "upb/mem/arena.h"
@ -111,4 +111,4 @@ UPB_INLINE bool upb_Arena_HasInitialBlock(upb_Arena* arena) {
#include "upb/port/undef.inc"
#endif /* UPB_MEM_ARENA_INTERNAL_H_ */
#endif /* UPB_MEM_INTERNAL_ARENA_H_ */

@ -188,6 +188,7 @@ cc_test(
":test_upb_proto",
"//:upb",
"//:base",
"//:mem",
"//:port",
"@com_google_googletest//:gtest_main",
],

@ -32,7 +32,7 @@
#include "upb/base/descriptor_constants.h"
#include "upb/collections/array_internal.h"
#include "upb/collections/map_internal.h"
#include "upb/mem/arena_internal.h"
#include "upb/mem/internal/arena.h"
#include "upb/message/accessors_internal.h"
#include "upb/message/internal/map_entry.h"
#include "upb/mini_table/sub.h"

@ -33,7 +33,7 @@
#ifndef UPB_WIRE_INTERNAL_DECODE_H_
#define UPB_WIRE_INTERNAL_DECODE_H_
#include "upb/mem/arena_internal.h"
#include "upb/mem/internal/arena.h"
#include "upb/message/internal.h"
#include "upb/wire/decode.h"
#include "upb/wire/eps_copy_input_stream.h"

Loading…
Cancel
Save