aboutsummaryrefslogtreecommitdiff
path: root/libcody/fatal.cc
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@acm.org>2020-12-14 08:10:27 -0800
committerNathan Sidwell <nathan@acm.org>2020-12-15 07:09:59 -0800
commit362303298ac4c1f93bda87535df2b726481d54bb (patch)
treeb728e42aa7e93c1fd673e75ee0071b86b8ae9c6c /libcody/fatal.cc
parentc5271279d6e86df0d0203c11fc4c3e3c99a14bb7 (diff)
downloadgcc-362303298ac4c1f93bda87535df2b726481d54bb.zip
gcc-362303298ac4c1f93bda87535df2b726481d54bb.tar.gz
gcc-362303298ac4c1f93bda87535df2b726481d54bb.tar.bz2
Add libcody
In order to separate compiler from build system, C++ Modules, as implemented in GCC introduces a communication channel between those two entities. This is implemented by libcody. It is anticipated that other implementations will also implement this protocol, or use libcody to provide it. * Makefile.def: Add libcody. * configure.ac: Add libcody. * Makefile.in: Regenerated. * configure: Regenerated. gcc/ * Makefile.in (CODYINC, CODYLIB, CODYLIB_H): New. Use them. libcody/ * configure.ac: New. * CMakeLists.txt: New. * CODING.md: New. * CONTRIB.md: New. * LICENSE: New. * LICENSE.gcc: New. * Makefile.in: New. * Makesub.in: New. * README.md: New. * buffer.cc: New. * build-aux/config.guess: New. * build-aux/config.sub: New. * build-aux/install-sh: New. * client.cc: New. * cmake/libcody-config-ix.cmake * cody.hh: New. * config.h.in: New. * config.m4: New. * configure: New. * configure.ac: New. * dox.cfg.in: New. * fatal.cc: New. * gdbinit.in: New. * internal.hh: New. * netclient.cc: New. * netserver.cc: New. * packet.cc: New. * resolver.cc: New. * server.cc: New. * tests/01-serialize/connect.cc: New. * tests/01-serialize/decoder.cc: New. * tests/01-serialize/encoder.cc: New. * tests/02-comms/client-1.cc: New. * tests/02-comms/pivot-1.cc: New. * tests/02-comms/server-1.cc: New. * tests/Makesub.in: New. * tests/jouster: New.
Diffstat (limited to 'libcody/fatal.cc')
-rw-r--r--libcody/fatal.cc78
1 files changed, 78 insertions, 0 deletions
diff --git a/libcody/fatal.cc b/libcody/fatal.cc
new file mode 100644
index 0000000..b35094e
--- /dev/null
+++ b/libcody/fatal.cc
@@ -0,0 +1,78 @@
+// CODYlib -*- mode:c++ -*-
+// Copyright (C) 2019-2020 Nathan Sidwell, nathan@acm.org
+// License: Apache v2.0
+
+// Cody
+#include "internal.hh"
+// C
+#include <csignal>
+#include <cstdint>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+
+namespace Cody {
+
+#if NMS_CHECKING
+void (AssertFailed) (Location loc) noexcept
+{
+ (HCF) ("assertion failed", loc);
+}
+void (Unreachable) (Location loc) noexcept
+{
+ (HCF) ("unreachable reached", loc);
+}
+#endif
+
+void (HCF) (char const *msg
+#if NMS_CHECKING
+ , Location const loc
+#endif
+ ) noexcept
+{ // HCF - you goofed!
+ __asm__ volatile ("nop"); // HCF - you goofed!
+
+#if !NMS_CHECKING
+ constexpr Location loc (nullptr, 0);
+#endif
+
+ fprintf (stderr, "CODYlib: %s", msg ? msg : "internal error");
+ if (char const *file = loc.File ())
+ {
+ char const *src = SRCDIR;
+
+ if (src[0])
+ {
+ size_t l = strlen (src);
+
+ if (!strncmp (src, file, l) && file[l] == '/')
+ file += l + 1;
+ }
+ fprintf (stderr, " at %s:%u", file, loc.Line ());
+ }
+ fprintf (stderr, "\n");
+ raise (SIGABRT);
+ exit (2);
+}
+
+void BuildNote (FILE *stream) noexcept
+{
+ fprintf (stream, "Version %s.\n", PACKAGE_NAME " " PACKAGE_VERSION);
+ fprintf (stream, "Report bugs to %s.\n", BUGURL[0] ? BUGURL : "you");
+ if (PACKAGE_URL[0])
+ fprintf (stream, "See %s for more information.\n", PACKAGE_URL);
+ if (REVISION[0])
+ fprintf (stream, "Source %s.\n", REVISION);
+
+ fprintf (stream, "Build is %s & %s.\n",
+#if !NMS_CHECKING
+ "un"
+#endif
+ "checked",
+#if !__OPTIMIZE__
+ "un"
+#endif
+ "optimized");
+}
+
+}