| 1 |
// rust-system.h -- Rust frontend inclusion of gcc header files -*- C++ -*- |
| 2 |
// Copyright (C) 2009-2025 Free Software Foundation, Inc. |
| 3 |
|
| 4 |
// This file is part of GCC. |
| 5 |
|
| 6 |
// GCC is free software; you can redistribute it and/or modify it under |
| 7 |
// the terms of the GNU General Public License as published by the Free |
| 8 |
// Software Foundation; either version 3, or (at your option) any later |
| 9 |
// version. |
| 10 |
|
| 11 |
// GCC is distributed in the hope that it will be useful, but WITHOUT ANY |
| 12 |
// WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 13 |
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 14 |
// for more details. |
| 15 |
|
| 16 |
// You should have received a copy of the GNU General Public License |
| 17 |
// along with GCC; see the file COPYING3. If not see |
| 18 |
// <http://www.gnu.org/licenses/>. |
| 19 |
|
| 20 |
#ifndef RUST_SYSTEM_H |
| 21 |
#define RUST_SYSTEM_H |
| 22 |
|
| 23 |
#define INCLUDE_ALGORITHM |
| 24 |
#include "config.h" |
| 25 |
|
| 26 |
/* Define this so that inttypes.h defines the PRI?64 macros even |
| 27 |
when compiling with a C++ compiler. Define it here so in the |
| 28 |
event inttypes.h gets pulled in by another header it is already |
| 29 |
defined. */ |
| 30 |
#define __STDC_FORMAT_MACROS |
| 31 |
|
| 32 |
// These must be included before the #poison declarations in system.h. |
| 33 |
|
| 34 |
#include <string> |
| 35 |
#include <list> |
| 36 |
#include <map> |
| 37 |
#include <set> |
| 38 |
#include <vector> |
| 39 |
#include <stack> |
| 40 |
#include <sstream> |
| 41 |
#include <string> |
| 42 |
#include <deque> |
| 43 |
#include <functional> |
| 44 |
#include <memory> |
| 45 |
#include <utility> |
| 46 |
#include <fstream> |
| 47 |
#include <array> |
| 48 |
#include <algorithm> |
| 49 |
#include <stack> |
| 50 |
#include <limits> |
| 51 |
#include <numeric> |
| 52 |
|
| 53 |
// Rust frontend requires C++11 minimum, so will have unordered_map and set |
| 54 |
#include <unordered_map> |
| 55 |
#include <unordered_set> |
| 56 |
|
| 57 |
/* We don't really need iostream, but some versions of gmp.h include |
| 58 |
* it when compiled with C++, which means that we need to include it |
| 59 |
* before the macro magic of safe-ctype.h, which is included by |
| 60 |
* system.h. */ |
| 61 |
#include <iostream> |
| 62 |
#include <iomanip> |
| 63 |
|
| 64 |
#include "system.h" |
| 65 |
#include "ansidecl.h" |
| 66 |
#include "coretypes.h" |
| 67 |
|
| 68 |
#include "diagnostic-core.h" /* For error_at and friends. */ |
| 69 |
#include "intl.h" /* For _(). */ |
| 70 |
|
| 71 |
#define RUST_ATTRIBUTE_NORETURN ATTRIBUTE_NORETURN |
| 72 |
|
| 73 |
// File separator to use based on whether or not the OS we're working with is |
| 74 |
// DOS-based |
| 75 |
#if defined(HAVE_DOS_BASED_FILE_SYSTEM) |
| 76 |
constexpr static const char *file_separator = "\\"; |
| 77 |
#else |
| 78 |
constexpr static const char *file_separator = "/"; |
| 79 |
#endif /* HAVE_DOS_BASED_FILE_SYSTEM */ |
| 80 |
|
| 81 |
// When using gcc, rust_assert is just gcc_assert. |
| 82 |
#define rust_assert(EXPR) gcc_assert (EXPR) |
| 83 |
|
| 84 |
/** |
| 85 |
* rust_unreachable is just a fancy abort which causes an internal compiler |
| 86 |
* error. This macro is not equivalent to `__builtin_unreachable` and does not |
| 87 |
* indicate optimizations for the compiler |
| 88 |
*/ |
| 89 |
#define rust_unreachable() (fancy_abort (__FILE__, __LINE__, __FUNCTION__)) |
| 90 |
|
| 91 |
extern void |
| 92 |
rust_preserve_from_gc (tree t); |
| 93 |
|
| 94 |
extern const char * |
| 95 |
rust_localize_identifier (const char *ident); |
| 96 |
|
| 97 |
#endif // !defined(RUST_SYSTEM_H) |