/* * Copyright (C) 2017 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "perfetto/protozero/message.h" #include <atomic> #include <type_traits> #include "perfetto/base/compiler.h" #include "perfetto/base/logging.h" #include "perfetto/protozero/message_arena.h" #include "perfetto/protozero/message_handle.h" #if !PERFETTO_IS_LITTLE_ENDIAN() // The memcpy() for float and double below needs to be adjusted if we want to // support big endian CPUs. There doesn't seem to be a compelling need today. #error Unimplemented for big endian archs. #endif namespace protozero { namespace { constexpr int kBytesToCompact = …; #if PERFETTO_DCHECK_IS_ON() std::atomic<uint32_t> g_generation; #endif } // namespace // Do NOT put any code in the constructor or use default initialization. // Use the Reset() method below instead. // This method is called to initialize both root and nested messages. void Message::Reset(ScatteredStreamWriter* stream_writer, MessageArena* arena) { … } void Message::AppendString(uint32_t field_id, const char* str) { … } void Message::AppendBytes(uint32_t field_id, const void* src, size_t size) { … } size_t Message::AppendScatteredBytes(uint32_t field_id, ContiguousMemoryRange* ranges, size_t num_ranges) { … } uint32_t Message::Finalize() { … } Message* Message::BeginNestedMessageInternal(uint32_t field_id) { … } void Message::EndNestedMessage() { … } } // namespace protozero