Merge branch 'docker-compat' into gha-test

pull/13171/head
Joshua Haberman 3 years ago
commit 8852c4016c
  1. 7
      WORKSPACE
  2. 8
      bazel/workspace_deps.bzl
  3. 2
      benchmarks/gen_protobuf_binary_cc.py
  4. 2
      benchmarks/gen_synthetic_protos.py
  5. 2
      benchmarks/gen_upb_binary_c.py
  6. 18
      tests/test_generated_code.c
  7. 8
      upb/upb.c

@ -1,7 +1,6 @@
workspace(name = "upb")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@bazel_tools//tools/build_defs/repo:git.bzl", "new_git_repository")
load("//bazel:workspace_deps.bzl", "upb_deps")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
@ -32,11 +31,11 @@ http_archive(
sha256 = "59f918c8ccd4d74b6ac43484467b500f1d64b40cc1010daa055375b322a43ba3",
)
new_git_repository(
http_archive(
name = "com_google_googleapis",
remote = "https://github.com/googleapis/googleapis.git",
branch = "master",
urls = ["https://github.com/googleapis/googleapis/archive/refs/heads/master.zip"],
build_file = "//benchmarks:BUILD.googleapis",
strip_prefix = "googleapis-master",
patch_cmds = ["find google -type f -name BUILD.bazel -delete"],
)

@ -1,14 +1,12 @@
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
def upb_deps():
maybe(
git_repository,
http_archive,
name = "com_google_absl",
commit = "998805a4c79d5d7a771f7e5a8ee3cbbbcba04f94",
remote = "https://github.com/abseil/abseil-cpp.git",
shallow_since = "1583355457 -0500",
url = "https://github.com/abseil/abseil-cpp/archive/refs/heads/master.zip",
strip_prefix = "abseil-cpp-master",
)
maybe(

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3
#
# Copyright (c) 2009-2021, Google LLC
# All rights reserved.

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3
#
# Copyright (c) 2009-2021, Google LLC
# All rights reserved.

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3
#
# Copyright (c) 2009-2021, Google LLC
# All rights reserved.

@ -532,6 +532,23 @@ void test_arena_decode(void) {
upb_arena_free(tmp);
}
void test_arena_unaligned(void) {
char buf1[1024];
// Force the pointer to be unaligned.
char *unaligned_buf_ptr = (char*)((uintptr_t)buf1 | 7);
upb_arena *arena = upb_arena_init(
unaligned_buf_ptr, &buf1[sizeof(buf1)] - unaligned_buf_ptr, NULL);
char *mem = upb_arena_malloc(arena, 5);
ASSERT(((uintptr_t)mem & 15) == 0);
upb_arena_free(arena);
// Try the same, but with a size so small that aligning up will overflow.
arena = upb_arena_init(unaligned_buf_ptr, 5, &upb_alloc_global);
mem = upb_arena_malloc(arena, 5);
ASSERT(((uintptr_t)mem & 15) == 0);
upb_arena_free(arena);
}
int run_tests(int argc, char *argv[]) {
test_scalars();
test_utf8();
@ -544,5 +561,6 @@ int run_tests(int argc, char *argv[]) {
test_arena_fuse();
test_arena_fuse_with_initial_block();
test_arena_decode();
test_arena_unaligned();
return 0;
}

@ -210,6 +210,14 @@ upb_arena *arena_initslow(void *mem, size_t n, upb_alloc *alloc) {
upb_arena *upb_arena_init(void *mem, size_t n, upb_alloc *alloc) {
upb_arena *a;
if (n) {
/* Align initial pointer up so that we return properly-aligned pointers. */
void *aligned = (void*)UPB_ALIGN_UP((uintptr_t)mem, 16);
size_t delta = (uintptr_t)aligned - (uintptr_t)mem;
n = delta <= n ? n - delta : 0;
mem = aligned;
}
/* Round block size down to alignof(*a) since we will allocate the arena
* itself at the end. */
n = UPB_ALIGN_DOWN(n, UPB_ALIGN_OF(upb_arena));

Loading…
Cancel
Save