Skip to content

Commit 7c7ea1e

Browse files
authored
[llvm] Add managarm support (#138854)
This PR is part of a series to upstream managarm support, as laid out in the [RFC](https://discourse.llvm.org/t/rfc-new-proposed-managarm-support-for-llvm-and-clang-87845/85884/1). This PR is a follow-up to #87845. The intention here is to add the managarm target to the LLVM support lib, in preparation for a follow-up that would add the missing clang driver bits.
1 parent 8e895b5 commit 7c7ea1e

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

llvm/include/llvm/ADT/bit.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
#if defined(__linux__) || defined(__GNU__) || defined(__HAIKU__) || \
3232
defined(__Fuchsia__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__) || \
33-
defined(__OpenBSD__) || defined(__DragonFly__)
33+
defined(__OpenBSD__) || defined(__DragonFly__) || defined(__managarm__)
3434
#include <endian.h>
3535
#elif defined(_AIX)
3636
#include <sys/machine.h>

llvm/lib/Support/Unix/Path.inc

+12-8
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ extern char **environ;
6969

7070
#include <sys/types.h>
7171
#if !defined(__APPLE__) && !defined(__OpenBSD__) && !defined(__FreeBSD__) && \
72-
!defined(__linux__) && !defined(__FreeBSD_kernel__) && !defined(_AIX)
72+
!defined(__linux__) && !defined(__FreeBSD_kernel__) && !defined(_AIX) && \
73+
!defined(__managarm__)
7374
#include <sys/statvfs.h>
7475
#define STATVFS statvfs
7576
#define FSTATVFS fstatvfs
@@ -78,7 +79,7 @@ extern char **environ;
7879
#if defined(__OpenBSD__) || defined(__FreeBSD__)
7980
#include <sys/mount.h>
8081
#include <sys/param.h>
81-
#elif defined(__linux__)
82+
#elif defined(__linux__) || defined(__managarm__)
8283
#if defined(HAVE_LINUX_MAGIC_H)
8384
#include <linux/magic.h>
8485
#else
@@ -121,10 +122,12 @@ namespace fs {
121122

122123
const file_t kInvalidFile = -1;
123124

124-
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || \
125-
defined(__FreeBSD_kernel__) || defined(__linux__) || defined(__CYGWIN__) || \
126-
defined(__DragonFly__) || defined(_AIX) || defined(__GNU__) || \
127-
(defined(__sun__) && defined(__svr4__) || defined(__HAIKU__))
125+
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || \
126+
defined(__FreeBSD_kernel__) || defined(__linux__) || \
127+
defined(__CYGWIN__) || defined(__DragonFly__) || defined(_AIX) || \
128+
defined(__GNU__) || \
129+
(defined(__sun__) && defined(__svr4__) || defined(__HAIKU__)) || \
130+
defined(__managarm__)
128131
static int test_dir(char ret[PATH_MAX], const char *dir, const char *bin) {
129132
struct stat sb;
130133
char fullpath[PATH_MAX];
@@ -245,7 +248,8 @@ std::string getMainExecutable(const char *argv0, void *MainAddr) {
245248
// If we don't have procfs mounted, fall back to argv[0]
246249
if (getprogpath(exe_path, argv0) != NULL)
247250
return exe_path;
248-
#elif defined(__linux__) || defined(__CYGWIN__) || defined(__gnu_hurd__)
251+
#elif defined(__linux__) || defined(__CYGWIN__) || defined(__gnu_hurd__) || \
252+
defined(__managarm__)
249253
char exe_path[PATH_MAX];
250254
const char *aPath = "/proc/self/exe";
251255
if (sys::fs::exists(aPath)) {
@@ -472,7 +476,7 @@ std::error_code remove(const Twine &path, bool IgnoreNonExisting) {
472476
}
473477

474478
static bool is_local_impl(struct STATVFS &Vfs) {
475-
#if defined(__linux__) || defined(__GNU__)
479+
#if defined(__linux__) || defined(__GNU__) || defined(__managarm__)
476480
#ifndef NFS_SUPER_MAGIC
477481
#define NFS_SUPER_MAGIC 0x6969
478482
#endif

0 commit comments

Comments
 (0)