aboutsummaryrefslogtreecommitdiff
path: root/c++tools/server.cc
diff options
context:
space:
mode:
authorIain Sandoe <iain@sandoe.co.uk>2021-07-20 14:00:38 +0100
committerIain Sandoe <iain@sandoe.co.uk>2021-07-21 13:40:17 +0100
commite4d306cf706eef83f99d510c308eda1539d05875 (patch)
tree934b0b0a803e0edcbb5b815bd4104a482e891e5a /c++tools/server.cc
parentf8884b9c51faea329196bf5914bcd2d700622c38 (diff)
downloadgcc-e4d306cf706eef83f99d510c308eda1539d05875.zip
gcc-e4d306cf706eef83f99d510c308eda1539d05875.tar.gz
gcc-e4d306cf706eef83f99d510c308eda1539d05875.tar.bz2
c++tools, configury: Configure with C++; test checking status [PR98821].
The c++tools configure fragments need to be built with a C++ compiler. In addition, the stand-alone server uses diagnostic mechanisms in common with GCC, but needs to define implementations for gcc_assert and supporting output functions. Signed-off-by: Iain Sandoe <iain@sandoe.co.uk> PR c++/98821 - modules : c++tools configures with CC but code fragments assume CXX. PR c++/98821 c++tools/ChangeLog: * config.h.in: Regenerate. * configure: Regenerate. * configure.ac: Configure using C++. Pull logic to detect enabled checking modes; default to release checking. * server.cc (AI_NUMERICSERV): Define a fallback value. (gcc_assert): New. (gcc_unreachable): New. (fancy_abort): Only build when checking is enabled. Co-authored-by: Jakub Jelinek <jakub@redhat.com>
Diffstat (limited to 'c++tools/server.cc')
-rw-r--r--c++tools/server.cc28
1 files changed, 28 insertions, 0 deletions
diff --git a/c++tools/server.cc b/c++tools/server.cc
index fae3e78..a60eefe 100644
--- a/c++tools/server.cc
+++ b/c++tools/server.cc
@@ -61,6 +61,10 @@ along with GCC; see the file COPYING3. If not see
# define gai_strerror(X) ""
#endif
+#ifndef AI_NUMERICSERV
+#define AI_NUMERICSERV 0
+#endif
+
#include <getopt.h>
// Select or epoll
@@ -92,6 +96,28 @@ along with GCC; see the file COPYING3. If not see
#define DIR_SEPARATOR '/'
#endif
+/* Imported from libcpp/system.h
+ Use gcc_assert(EXPR) to test invariants. */
+#if ENABLE_ASSERT_CHECKING
+#define gcc_assert(EXPR) \
+ ((void)(!(EXPR) ? fancy_abort (__FILE__, __LINE__, __FUNCTION__), 0 : 0))
+#elif (GCC_VERSION >= 4005)
+#define gcc_assert(EXPR) \
+ ((void)(__builtin_expect (!(EXPR), 0) ? __builtin_unreachable (), 0 : 0))
+#else
+/* Include EXPR, so that unused variable warnings do not occur. */
+#define gcc_assert(EXPR) ((void)(0 && (EXPR)))
+#endif
+
+/* Use gcc_unreachable() to mark unreachable locations (like an
+ unreachable default case of a switch. Do not use gcc_assert(0). */
+#if (GCC_VERSION >= 4005) && !ENABLE_ASSERT_CHECKING
+#define gcc_unreachable() __builtin_unreachable ()
+#else
+#define gcc_unreachable() (fancy_abort (__FILE__, __LINE__, __FUNCTION__))
+#endif
+
+
#if NETWORKING
struct netmask {
in6_addr addr;
@@ -202,11 +228,13 @@ internal_error (const char *fmt, ...)
/* Hooked to from gcc_assert & gcc_unreachable. */
+#if ENABLE_ASSERT_CHECKING
void ATTRIBUTE_NORETURN ATTRIBUTE_COLD
fancy_abort (const char *file, int line, const char *func)
{
internal_error ("in %s, at %s:%d", func, trim_src_file (file), line);
}
+#endif
/* Exploded on a signal. */