]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/common: implement singleton_ec.
authorRadoslaw Zarzynski <rzarzyns@redhat.com>
Tue, 21 Sep 2021 22:58:56 +0000 (22:58 +0000)
committerRadoslaw Zarzynski <rzarzyns@redhat.com>
Tue, 21 Sep 2021 22:59:09 +0000 (22:59 +0000)
Unfortunately, GCC explodes when it sees that.

```
[rzarzynski@o06 build]$ ninja crimson-osd vstart
[1/3] Building CXX object src/crimson/os/cyanstore/CMakeFiles/crimson-cyanstore.dir/cyan_store.cc.o
FAILED: src/crimson/os/cyanstore/CMakeFiles/crimson-cyanstore.dir/cyan_store.cc.o
/usr/bin/ccache /opt/rh/gcc-toolset-9/root/usr/bin/c++ -DBOOST_ASIO_DISABLE_THREAD_KEYWORD_EXTENSION -DBOOST_ASIO_USE_TS_EXECUTOR_AS_DEFAULT -DHAVE_CONFIG_H -DSEASTAR_API_LEVEL=6 -DWITH_SEASTAR=1 -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE -D_REENTRANT -D_THREAD_SAFE -D__CEPH__ -D__STDC_FORMAT_MACROS -D__linux__ -Isrc/include -I../src -I../src/seastar/include -Isrc/seastar/gen/include -isystem boost/include -isystem include -isystem ../src/xxHash -isystem ../src/rapidjson/include -O2 -g -DNDEBUG -fPIC   -U_FORTIFY_SOURCE -Wall -fno-strict-aliasing -fsigned-char -Wtype-limits -Wignored-qualifiers -Wpointer-arith -Werror=format-security -Winit-self -Wno-unknown-pragmas -Wnon-virtual-dtor -Wno-ignored-qualifiers -ftemplate-depth-1024 -Wpessimizing-move -Wredundant-move -Wstrict-null-sentinel -Woverloaded-virtual -fno-new-ttp-matching -fstack-protector-strong -fdiagnostics-color=auto -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free -ftemplate-backtrace-limit=0 -Wno-non-virtual-dtor -std=gnu++17 -U_FORTIFY_SOURCE -Wno-maybe-uninitialized -DSEASTAR_SSTRING -Wno-error=unused-result -std=c++17 -MD -MT src/crimson/os/cyanstore/CMakeFiles/crimson-cyanstore.dir/cyan_store.cc.o -MF src/crimson/os/cyanstore/CMakeFiles/crimson-cyanstore.dir/cyan_store.cc.o.d -o src/crimson/os/cyanstore/CMakeFiles/crimson-cyanstore.dir/cyan_store.cc.o -c ../src/crimson/os/cyanstore/cyan_store.cc
during IPA pass: inline
../src/crimson/os/cyanstore/cyan_store.cc: In member function ‘std::string crimson::os::singleton_ec<MsgV>::this_error_category::message(int) const [with const char* MsgV = (& msg)]’:
../src/crimson/os/cyanstore/cyan_store.cc:97:17: internal compiler error: Segmentation fault
   97 |     std::string message([[maybe_unused]] const int ev) const final {
      |                 ^~~~~~~
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://bugzilla.redhat.com/bugzilla> for instructions.
Preprocessed source stored into /tmp/ccFi4GGw.out file, please attach this to your bugreport.
ninja: build stopped: subcommand failed.
```

Signed-off-by: Radoslaw Zarzynski <rzarzyns@redhat.com>
src/crimson/os/cyanstore/cyan_store.cc

index dbefe007471bb1476ad0da130804cf9315e47438..fdf24d906079163f3eb78ed86f34d0a2c4acd3bd 100644 (file)
@@ -82,6 +82,25 @@ seastar::future<> CyanStore::umount()
   });
 }
 
+template <const char* MsgV>
+struct singleton_ec : std::error_code {
+  singleton_ec()
+    : error_code(42, this_error_category{}) {
+  };
+private:
+  struct this_error_category : std::error_category {
+    const char* name() const noexcept final {
+      // XXX: we could concatenate with MsgV at compile-time but the burden
+      // isn't worth the benefit.
+      return "singleton_ec";
+    }
+    std::string message([[maybe_unused]] const int ev) const final {
+      assert(ev == 42);
+      return MsgV;
+    }
+  };
+};
+
 seastar::future<> CyanStore::mkfs(uuid_d new_osd_fsid)
 {
   return read_meta("fsid").then([=](auto&& ret) {