From e55acd994c9d59f50f71db4ab170747af2883922 Mon Sep 17 00:00:00 2001 From: Andrew Savage Date: Tue, 7 May 2024 23:40:51 +0000 Subject: [PATCH] Call SB_NOTIMPLEMENTED in perfetto when necessary --- third_party/perfetto/buildtools/BUILD.gn | 10 ++++++++-- third_party/perfetto/buildtools/sqlite/sqlite3.c | 14 ++++++++------ third_party/perfetto/src/base/file_utils.cc | 1 + .../perfetto/src/base/getopt_compat_unittest.cc | 2 +- third_party/perfetto/src/base/pipe.cc | 8 +++++++- third_party/perfetto/src/base/temp_file.cc | 9 ++++++++- third_party/perfetto/src/base/threading/BUILD.gn | 3 +++ .../src/base/threading/channel_unittest.cc | 5 +++++ third_party/perfetto/src/base/unix_task_runner.cc | 8 +++++++- .../perfetto/src/trace_processor/sorter/BUILD.gn | 3 +++ .../src/trace_processor/sorter/trace_sorter.cc | 5 +++++ 11 files changed, 56 insertions(+), 12 deletions(-) diff --git a/third_party/perfetto/buildtools/BUILD.gn b/third_party/perfetto/buildtools/BUILD.gn index ddc92b181340..636b7c17a3f2 100644 --- a/third_party/perfetto/buildtools/BUILD.gn +++ b/third_party/perfetto/buildtools/BUILD.gn @@ -1094,7 +1094,7 @@ config("sqlite_config") { "-DSQLITE_OMIT_DEPRECATED", "-DSQLITE_OMIT_SHARED_CACHE", "-DHAVE_USLEEP", - # "-DHAVE_UTIME", + "-DHAVE_UTIME", "-DSQLITE_BYTEORDER=1234", "-DSQLITE_DEFAULT_AUTOVACUUM=0", "-DSQLITE_DEFAULT_MMAP_SIZE=0", @@ -1110,6 +1110,9 @@ config("sqlite_config") { # we specify this flag. cflags += [ "-Wno-language-extension-token" ] } + if (use_cobalt_customizations) { + cflags -= [ "-DHAVE_UTIME" ] + } } source_set("sqlite") { @@ -1130,7 +1133,10 @@ source_set("sqlite") { } public_configs = [ ":sqlite_config" ] if (use_cobalt_customizations) { - deps = [ "../gn:default_deps" ] + deps = [ + "../gn:default_deps", + "//starboard/common:common_headers_only", + ] } else { deps = [ "//gn:default_deps" ] } diff --git a/third_party/perfetto/buildtools/sqlite/sqlite3.c b/third_party/perfetto/buildtools/sqlite/sqlite3.c index d7df17705951..908452bbb958 100644 --- a/third_party/perfetto/buildtools/sqlite/sqlite3.c +++ b/third_party/perfetto/buildtools/sqlite/sqlite3.c @@ -162,9 +162,7 @@ /* This is not VxWorks. */ #define OS_VXWORKS 0 #if defined(STARBOARD) -// #define HAVE_FCHOWN 0 -// #define HAVE_READLINK 0 -// #define HAVE_LSTAT 0 +#include "starboard/common/log.h" #else #define HAVE_FCHOWN 1 #define HAVE_READLINK 1 @@ -35597,8 +35595,8 @@ SQLITE_PRIVATE const char *sqlite3OpcodeName(int i){ && (!defined(TARGET_OS_MACCATALYST) || (TARGET_OS_MACCATALYST==0)) # undef HAVE_GETHOSTUUID # define HAVE_GETHOSTUUID 1 -# else -// # warning "gethostuuid() is disabled." +# elif !defined(STARBOARD) +# warning "gethostuuid() is disabled." # endif # endif #endif @@ -39718,6 +39716,7 @@ static int unixDeviceCharacteristics(sqlite3_file *id){ */ static int unixGetpagesize(void){ #if defined(STARBOARD) + SB_NOTIMPLEMENTED(); return 0; #elif OS_VXWORKS return 1024; @@ -41305,7 +41304,9 @@ static const char *azTempDirs[] = { ** Initialize first two members of azTempDirs[] array. */ static void unixTempFileInit(void){ -#if !defined(STARBOARD) +#if defined(STARBOARD) + SB_NOTIMPLEMENTED(); +#else azTempDirs[0] = getenv("SQLITE_TMPDIR"); azTempDirs[1] = getenv("TMPDIR"); #endif @@ -41793,6 +41794,7 @@ static int unixOpen( #endif if( isAutoProxy && (zPath!=NULL) && (!noLock) && pVfs->xOpen ){ #if defined(STARBOARD) + SB_NOTIMPLEMENTED(); char *envforce = NULL; #else char *envforce = getenv("SQLITE_FORCE_PROXY_LOCKING"); diff --git a/third_party/perfetto/src/base/file_utils.cc b/third_party/perfetto/src/base/file_utils.cc index e0cc1004d17d..1cfedbb0c6ed 100644 --- a/third_party/perfetto/src/base/file_utils.cc +++ b/third_party/perfetto/src/base/file_utils.cc @@ -271,6 +271,7 @@ ScopedFstream OpenFstream(const char* path, const char* mode) { bool FileExists(const std::string& path) { #if defined(STARBOARD) + SB_NOTIMPLEMENTED(); return false; #elif PERFETTO_BUILDFLAG(PERFETTO_OS_WIN) return _access(path.c_str(), 0) == 0; diff --git a/third_party/perfetto/src/base/getopt_compat_unittest.cc b/third_party/perfetto/src/base/getopt_compat_unittest.cc index 54264ebf3da2..0ae372109fbb 100644 --- a/third_party/perfetto/src/base/getopt_compat_unittest.cc +++ b/third_party/perfetto/src/base/getopt_compat_unittest.cc @@ -52,7 +52,7 @@ struct OurGetopt { char*& optarg = getopt_compat::optarg; }; -#if !PERFETTO_BUILDFLAG(PERFETTO_OS_WIN) && !defined(STARBOARD) +#if !PERFETTO_BUILDFLAG(PERFETTO_OS_WIN) struct SystemGetopt { using LongOptionType = ::option; using GetoptFn = decltype(&::getopt); diff --git a/third_party/perfetto/src/base/pipe.cc b/third_party/perfetto/src/base/pipe.cc index 1b825fc0e5c1..aec9c407fa4f 100644 --- a/third_party/perfetto/src/base/pipe.cc +++ b/third_party/perfetto/src/base/pipe.cc @@ -30,6 +30,10 @@ #include "perfetto/base/logging.h" +#if defined(STARBOARD) +#include "starboard/common/log.h" +#endif + namespace perfetto { namespace base { @@ -39,7 +43,9 @@ Pipe& Pipe::operator=(Pipe&&) = default; Pipe Pipe::Create(Flags flags) { PlatformHandle fds[2]; -#if !defined(STARBOARD) +#if defined(STARBOARD) + SB_NOTIMPLEMENTED(); +#else #if PERFETTO_BUILDFLAG(PERFETTO_OS_WIN) PERFETTO_CHECK(::CreatePipe(&fds[0], &fds[1], /*lpPipeAttributes=*/nullptr, 0 /*default size*/)); diff --git a/third_party/perfetto/src/base/temp_file.cc b/third_party/perfetto/src/base/temp_file.cc index bdc81e17a1c9..815ba7a7cb0a 100644 --- a/third_party/perfetto/src/base/temp_file.cc +++ b/third_party/perfetto/src/base/temp_file.cc @@ -35,6 +35,10 @@ #include "perfetto/ext/base/file_utils.h" #include "perfetto/ext/base/string_utils.h" +#if defined(STARBOARD) +#include "starboard/common/log.h" +#endif + #if PERFETTO_BUILDFLAG(PERFETTO_OS_WIN) namespace { std::string GetTempName() { @@ -51,6 +55,7 @@ namespace base { std::string GetSysTempDir() { const char* tmpdir = nullptr; #if defined(STARBOARD) + SB_NOTIMPLEMENTED(); return ""; #elif PERFETTO_BUILDFLAG(PERFETTO_OS_WIN) if ((tmpdir = getenv("TMP"))) @@ -72,7 +77,9 @@ std::string GetSysTempDir() { // static TempFile TempFile::Create() { TempFile temp_file; -#if !defined(STARBOARD) +#if defined(STARBOARD) + SB_NOTIMPLEMENTED(); +#else #if PERFETTO_BUILDFLAG(PERFETTO_OS_WIN) temp_file.path_ = GetSysTempDir() + "\\" + GetTempName(); // Several tests want to read-back the temp file while still open. On Windows, diff --git a/third_party/perfetto/src/base/threading/BUILD.gn b/third_party/perfetto/src/base/threading/BUILD.gn index 23343bc98195..a83d4d32a60e 100644 --- a/third_party/perfetto/src/base/threading/BUILD.gn +++ b/third_party/perfetto/src/base/threading/BUILD.gn @@ -36,6 +36,9 @@ perfetto_unittest_source_set("unittests") { "../../../gn:default_deps", "../../../gn:gtest_and_gmock", ] + if (is_starboard) { + deps += [ "//starboard/common:common_headers_only" ] + } sources = [ "channel_unittest.cc", "future_unittest.cc", diff --git a/third_party/perfetto/src/base/threading/channel_unittest.cc b/third_party/perfetto/src/base/threading/channel_unittest.cc index a5f1a263dac8..f527363b83b7 100644 --- a/third_party/perfetto/src/base/threading/channel_unittest.cc +++ b/third_party/perfetto/src/base/threading/channel_unittest.cc @@ -32,6 +32,10 @@ #include #endif +#if defined(STARBOARD) +#include "starboard/common/log.h" +#endif + namespace perfetto { namespace base { namespace { @@ -41,6 +45,7 @@ using WriteResult = Channel::WriteResult; bool IsReady(base::PlatformHandle fd) { #if defined(STARBOARD) + SB_NOTIMPLEMENTED(); return false; #elif PERFETTO_BUILDFLAG(PERFETTO_OS_WIN) std::array poll_fds{fd}; diff --git a/third_party/perfetto/src/base/unix_task_runner.cc b/third_party/perfetto/src/base/unix_task_runner.cc index 9228f6f8ab9f..9cb8f7b3a578 100644 --- a/third_party/perfetto/src/base/unix_task_runner.cc +++ b/third_party/perfetto/src/base/unix_task_runner.cc @@ -34,6 +34,10 @@ #include "perfetto/ext/base/watchdog.h" +#if defined(STARBOARD) +#include "starboard/common/log.h" +#endif + namespace perfetto { namespace base { @@ -64,7 +68,9 @@ void UnixTaskRunner::Run() { UpdateWatchTasksLocked(); } -#if !defined(STARBOARD) +#if defined(STARBOARD) + SB_NOTIMPLEMENTED(); +#else #if PERFETTO_BUILDFLAG(PERFETTO_OS_WIN) DWORD timeout = poll_timeout_ms >= 0 ? static_cast(poll_timeout_ms) : INFINITE; diff --git a/third_party/perfetto/src/trace_processor/sorter/BUILD.gn b/third_party/perfetto/src/trace_processor/sorter/BUILD.gn index 5d27204efe40..9f4827cac7d9 100644 --- a/third_party/perfetto/src/trace_processor/sorter/BUILD.gn +++ b/third_party/perfetto/src/trace_processor/sorter/BUILD.gn @@ -37,6 +37,9 @@ source_set("sorter") { "../types", "../util:bump_allocator", ] + if (is_starboard) { + deps += [ "//starboard/common:common_headers_only" ] + } } perfetto_unittest_source_set("unittests") { diff --git a/third_party/perfetto/src/trace_processor/sorter/trace_sorter.cc b/third_party/perfetto/src/trace_processor/sorter/trace_sorter.cc index 9b2fc6a852ec..fb1ac76a8213 100644 --- a/third_party/perfetto/src/trace_processor/sorter/trace_sorter.cc +++ b/third_party/perfetto/src/trace_processor/sorter/trace_sorter.cc @@ -25,6 +25,10 @@ #include "src/trace_processor/storage/trace_storage.h" #include "src/trace_processor/util/bump_allocator.h" +#if defined(STARBOARD) +#include "starboard/common/log.h" +#endif + namespace perfetto { namespace trace_processor { @@ -35,6 +39,7 @@ TraceSorter::TraceSorter(TraceProcessorContext* context, parser_(std::move(parser)), sorting_mode_(sorting_mode) { #if defined(STARBOARD) + SB_NOTIMPLEMENTED(); const char* env = nullptr; #else const char* env = getenv("TRACE_PROCESSOR_SORT_ONLY");