summaryrefslogtreecommitdiff
path: root/support/cpp/libcpp/system.h
diff options
context:
space:
mode:
authorspth <spth@4a8a32a2-be11-0410-ad9d-d568d2c75423>2022-09-04 09:34:41 +0000
committerspth <spth@4a8a32a2-be11-0410-ad9d-d568d2c75423>2022-09-04 09:34:41 +0000
commit795fc855af6f2d613af293d5a4dd884310af4f91 (patch)
treeea7cc71a59e96085f25047468b492930d3ca8c93 /support/cpp/libcpp/system.h
parent24afdd60d4d9994f8f90a25fabe0a030b4ac186e (diff)
Merge cpp branch to trunk.
git-svn-id: http://svn.code.sourceforge.net/p/sdcc/code/trunk/sdcc@13690 4a8a32a2-be11-0410-ad9d-d568d2c75423
Diffstat (limited to 'support/cpp/libcpp/system.h')
-rw-r--r--support/cpp/libcpp/system.h65
1 files changed, 44 insertions, 21 deletions
diff --git a/support/cpp/libcpp/system.h b/support/cpp/libcpp/system.h
index 9dc83e66c..5a62ba029 100644
--- a/support/cpp/libcpp/system.h
+++ b/support/cpp/libcpp/system.h
@@ -1,6 +1,6 @@
/* Get common system includes and various definitions and declarations based
on autoconf macros.
- Copyright (C) 1998-2014 Free Software Foundation, Inc.
+ Copyright (C) 1998-2022 Free Software Foundation, Inc.
This file is part of GCC.
@@ -37,6 +37,10 @@ along with GCC; see the file COPYING3. If not see
#include <stdio.h>
+#ifdef __cplusplus
+#include <new>
+#endif
+
/* Define a generic NULL if one hasn't already been defined. */
#ifndef NULL
#define NULL 0
@@ -230,7 +234,7 @@ extern int errno;
/* The outer cast is needed to work around a bug in Cray C 5.0.3.0.
It is necessary at least when t == time_t. */
#define INTTYPE_MINIMUM(t) ((t) (INTTYPE_SIGNED (t) \
- ? ~ (t) 0 << (sizeof(t) * CHAR_BIT - 1) : (t) 0))
+ ? (t) 1 << (sizeof (t) * CHAR_BIT - 1) : (t) 0))
#define INTTYPE_MAXIMUM(t) ((t) (~ (t) 0 - INTTYPE_MINIMUM (t)))
/* Use that infrastructure to provide a few constants. */
@@ -375,9 +379,12 @@ extern void abort (void);
??? C99 designated initializers are not supported by most C++
compilers, including G++. -- gdr, 2005-05-18 */
#if !defined(HAVE_DESIGNATED_INITIALIZERS)
+#ifdef __cplusplus
+#define HAVE_DESIGNATED_INITIALIZERS 0
+#else
#define HAVE_DESIGNATED_INITIALIZERS \
- (!defined(__cplusplus) \
- && ((GCC_VERSION >= 2007) || (__STDC_VERSION__ >= 199901L)))
+ ((GCC_VERSION >= 2007) || (__STDC_VERSION__ >= 199901L))
+#endif
#endif
#ifndef offsetof
@@ -391,25 +398,41 @@ extern void abort (void);
#define __builtin_expect(a, b) (a)
#endif
-/* Provide a fake boolean type. We make no attempt to use the
- C99 _Bool, as it may not be available in the bootstrap compiler,
- and even if it is, it is liable to be buggy.
- This must be after all inclusion of system headers, as some of
- them will mess us up. */
-#undef bool
-#undef true
-#undef false
-#undef TRUE
-#undef FALSE
+/* Redefine abort to report an internal error w/o coredump, and
+ reporting the location of the error in the source file. */
+extern void fancy_abort (const char *, int, const char *) ATTRIBUTE_NORETURN;
+#define abort() fancy_abort (__FILE__, __LINE__, __FUNCTION__)
+
+/* 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
-#ifndef __cplusplus
-#define bool unsigned char
+#if CHECKING_P
+#define gcc_checking_assert(EXPR) gcc_assert (EXPR)
+#else
+/* N.B.: in release build EXPR is not evaluated. */
+#define gcc_checking_assert(EXPR) ((void)(0 && (EXPR)))
#endif
-#define true 1
-#define false 0
-/* Some compilers do not allow the use of unsigned char in bitfields. */
-#define BOOL_BITFIELD unsigned int
+#ifdef __has_cpp_attribute
+# if __has_cpp_attribute(likely)
+# define ATTR_LIKELY [[likely]]
+# elif __has_cpp_attribute(__likely__)
+# define ATTR_LIKELY [[__likely__]]
+# else
+# define ATTR_LIKELY
+# endif
+#else
+# define ATTR_LIKELY
+#endif
/* Poison identifiers we do not want to use. */
#if (GCC_VERSION >= 3000)
@@ -443,6 +466,6 @@ extern void abort (void);
#endif /* GCC >= 3.0 */
/* SDCC specific */
-#include "sdcpp.h"
+// #include "sdcpp.h"
#endif /* ! LIBCPP_SYSTEM_H */