Skip to content

Commit 1434fce

Browse files
committed
[RemoteMirrors] Switch #ifdef __APPLE__ to #if defined(__APPLE__) && defined(__MACH__) to be more specific about the fact that this code is for MachO.
1 parent e1f232d commit 1434fce

File tree

5 files changed

+14
-14
lines changed

5 files changed

+14
-14
lines changed

include/swift/Reflection/ReflectionContext.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#ifndef SWIFT_REFLECTION_REFLECTIONCONTEXT_H
1919
#define SWIFT_REFLECTION_REFLECTIONCONTEXT_H
2020

21-
#ifdef __APPLE__
21+
#if defined(__APPLE__) && defined(__MACH__)
2222
#include <mach-o/getsect.h>
2323
#endif
2424

@@ -35,15 +35,15 @@
3535
#include <vector>
3636
#include <unordered_map>
3737

38-
#ifdef __APPLE__
38+
#if defined(__APPLE__) && defined(__MACH__)
3939
#ifndef __LP64__
4040
typedef const struct mach_header MachHeader;
4141
#else
4242
typedef const struct mach_header_64 MachHeader;
4343
#endif
4444
#endif
4545

46-
#ifdef __APPLE__
46+
#if defined(__APPLE__) && defined(__MACH__)
4747
template <typename Section>
4848
static std::pair<Section, bool> findSection(MachHeader *Header,
4949
const char *Name) {
@@ -58,7 +58,7 @@ static std::pair<Section, bool> findSection(MachHeader *Header,
5858
reinterpret_cast<const void *>(End)},
5959
true};
6060
}
61-
#endif // __APPLE__
61+
#endif
6262

6363
namespace swift {
6464
namespace reflection {
@@ -113,7 +113,7 @@ class ReflectionContext
113113
getBuilder().dumpAllSections();
114114
}
115115

116-
#ifdef __APPLE__
116+
#if defined(__APPLE__) && defined(__MACH__)
117117
bool addImage(RemoteAddress ImageStart) {
118118
const void *Buf;
119119
std::function<void()> FreeFunc;
@@ -207,7 +207,7 @@ class ReflectionContext
207207
}
208208
return true;
209209
}
210-
#endif // __APPLE__
210+
#endif // defined(__APPLE__) && defined(__MACH__)
211211

212212
void addReflectionInfo(ReflectionInfo I) {
213213
getBuilder().addReflectionInfo(I);

include/swift/SwiftRemoteMirror/SwiftRemoteMirror.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ void
5959
swift_reflection_addReflectionInfo(SwiftReflectionContextRef ContextRef,
6060
swift_reflection_info_t Info);
6161

62-
#ifdef __APPLE__
62+
#if defined(__APPLE__) && defined(__MACH__)
6363
/// Add reflection information from a loaded Swift image.
6464
/// Returns true on success, false if the image's memory couldn't be read.
6565
int

include/swift/SwiftRemoteMirror/SwiftRemoteMirrorLegacyInterop.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#ifndef SWIFT_REMOTE_MIRROR_LEGACY_INTEROP_H
2121
#define SWIFT_REMOTE_MIRROR_LEGACY_INTEROP_H
2222

23-
#ifdef __APPLE__
23+
#if defined(__APPLE__) && defined(__MACH__)
2424

2525
#include "SwiftRemoteMirror.h"
2626

@@ -880,7 +880,7 @@ size_t swift_reflection_interop_demangle(SwiftReflectionInteropContextRef Contex
880880

881881
/// @}
882882

883-
#endif // __APPLE__
883+
#endif // defined(__APPLE__) && defined(__MACH__)
884884

885885
#endif // SWIFT_REMOTE_MIRROR_LEGACY_INTEROP_H
886886

stdlib/public/SwiftRemoteMirror/SwiftRemoteMirror.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#include "swift/Runtime/Unreachable.h"
1717
#include "swift/SwiftRemoteMirror/SwiftRemoteMirror.h"
1818

19-
#ifdef __APPLE__
19+
#if defined(__APPLE__) && defined(__MACH__)
2020
#include <mach-o/getsect.h>
2121
#endif
2222

@@ -89,7 +89,7 @@ swift_reflection_addReflectionInfo(SwiftReflectionContextRef ContextRef,
8989
Context->addReflectionInfo(*reinterpret_cast<ReflectionInfo *>(&Info));
9090
}
9191

92-
#ifdef __APPLE__
92+
#if defined(__APPLE__) && defined(__MACH__)
9393
#ifndef __LP64__
9494
typedef const struct mach_header MachHeader;
9595
#else

tools/swift-reflection-dump/swift-reflection-dump.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ static T unwrap(llvm::Expected<T> value) {
8383
exit(EXIT_FAILURE);
8484
}
8585

86-
#ifndef __APPLE__
86+
#if !(defined(__APPLE__) && defined(__MACH__))
8787
static SectionRef getSectionRef(const ObjectFile *objectFile,
8888
ArrayRef<StringRef> anySectionNames) {
8989
for (auto section : objectFile->sections()) {
@@ -150,7 +150,7 @@ static ReflectionInfo findReflectionInfo(const ObjectFile *objectFile) {
150150
/*RemoteStartAddress*/ startAddress,
151151
};
152152
}
153-
#endif // __APPLE__
153+
#endif // defined(__APPLE__) && defined(__MACH__)
154154

155155
using NativeReflectionContext
156156
= ReflectionContext<External<RuntimeTarget<sizeof(uintptr_t)>>>;
@@ -255,7 +255,7 @@ static int doDumpReflectionSections(ArrayRef<std::string> binaryFilenames,
255255
objectOwners.push_back(std::move(objectOwner));
256256
objectFiles.push_back(objectFile);
257257

258-
#ifdef __APPLE__
258+
#if defined(__APPLE__) && defined(__MACH__)
259259
context.addImage(RemoteAddress((uint64_t)(objectFile->getData().begin())));
260260
#else
261261
context.addReflectionInfo(findReflectionInfo(objectFile));

0 commit comments

Comments
 (0)