aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/rust-system.h
diff options
context:
space:
mode:
authorPhilip Herron <philip.herron@embecosm.com>2022-08-24 12:08:58 +0100
committerArthur Cohen <arthur.cohen@embecosm.com>2022-12-13 14:00:07 +0100
commitfe6264fa28a37ccbfb0e03798d1cbb11e09d1971 (patch)
treed93f66bbc9f58c59dcd51ecc61cc50e155007bec /gcc/rust/rust-system.h
parentcfbda2f78baac4f329efe1838401b4ae2ed5b6a5 (diff)
downloadgcc-fe6264fa28a37ccbfb0e03798d1cbb11e09d1971.zip
gcc-fe6264fa28a37ccbfb0e03798d1cbb11e09d1971.tar.gz
gcc-fe6264fa28a37ccbfb0e03798d1cbb11e09d1971.tar.bz2
gccrs: These are wrappers ported from reusing gccgo
The wrappers over linemap and location will eventually disappear here but served as a useful starting point for us. We have wrappers over the diagnostics system which we might be able to get rid of as well. gcc/rust/ * rust-diagnostics.cc: New. * rust-diagnostics.h: New. * rust-gcc-diagnostics.cc: New. * rust-linemap.cc: New. * rust-linemap.h: New. * rust-location.h: New. * rust-system.h: New.
Diffstat (limited to 'gcc/rust/rust-system.h')
-rw-r--r--gcc/rust/rust-system.h86
1 files changed, 86 insertions, 0 deletions
diff --git a/gcc/rust/rust-system.h b/gcc/rust/rust-system.h
new file mode 100644
index 0000000..3a60023
--- /dev/null
+++ b/gcc/rust/rust-system.h
@@ -0,0 +1,86 @@
+// rust-system.h -- Rust frontend inclusion of gcc header files -*- C++ -*-
+// Copyright (C) 2009-2022 Free Software Foundation, Inc.
+
+// This file is part of GCC.
+
+// GCC is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 3, or (at your option) any later
+// version.
+
+// GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with GCC; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#ifndef RUST_SYSTEM_H
+#define RUST_SYSTEM_H
+
+#define INCLUDE_ALGORITHM
+#include "config.h"
+
+/* Define this so that inttypes.h defines the PRI?64 macros even
+ when compiling with a C++ compiler. Define it here so in the
+ event inttypes.h gets pulled in by another header it is already
+ defined. */
+#define __STDC_FORMAT_MACROS
+
+// These must be included before the #poison declarations in system.h.
+
+#include <string>
+#include <list>
+#include <map>
+#include <set>
+#include <vector>
+#include <sstream>
+#include <string>
+#include <deque>
+#include <functional>
+#include <memory>
+#include <utility>
+#include <fstream>
+
+// Rust frontend requires C++11 minimum, so will have unordered_map and set
+#include <unordered_map>
+#include <unordered_set>
+
+/* We don't really need iostream, but some versions of gmp.h include
+ * it when compiled with C++, which means that we need to include it
+ * before the macro magic of safe-ctype.h, which is included by
+ * system.h. */
+#include <iostream>
+
+#include "system.h"
+#include "ansidecl.h"
+#include "coretypes.h"
+
+#include "diagnostic-core.h" /* For error_at and friends. */
+#include "intl.h" /* For _(). */
+
+#define RUST_ATTRIBUTE_NORETURN ATTRIBUTE_NORETURN
+
+// File separator to use based on whether or not the OS we're working with is
+// DOS-based
+#if defined(HAVE_DOS_BASED_FILE_SYSTEM)
+constexpr static const char *file_separator = "\\";
+#else
+constexpr static const char *file_separator = "/";
+#endif /* HAVE_DOS_BASED_FILE_SYSTEM */
+
+// When using gcc, rust_assert is just gcc_assert.
+#define rust_assert(EXPR) gcc_assert (EXPR)
+
+// When using gcc, rust_unreachable is just gcc_unreachable.
+#define rust_unreachable() gcc_unreachable ()
+
+extern void
+rust_preserve_from_gc (tree t);
+
+extern const char *
+rust_localize_identifier (const char *ident);
+
+#endif // !defined(RUST_SYSTEM_H)