llvm.org GIT mirror llvm / 63033d3
s/LLVM_ON_WIN32/_WIN32/, llvm LLVM_ON_WIN32 is set exactly with MSVC and MinGW (but not Cygwin) in HandleLLVMOptions.cmake, which is where _WIN32 defined too. Just use the default macro instead of a reinvented one. See thread "Replacing LLVM_ON_WIN32 with just _WIN32" on llvm-dev and cfe-dev. No intended behavior change. This moves over all uses of the macro, but doesn't remove the definition of it in (llvm-)config.h yet. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331127 91177308-0d34-0410-b5e6-96231b3b80d8 Nico Weber 1 year, 4 months ago
46 changed file(s) with 98 addition(s) and 99 deletion(s). Raw diff Collapse all Expand all
208208 class of operating system. Currently only Unix and Win32 classes are defined
209209 but more could be added for other operating system classifications. To
210210 distinguish which implementation to compile, the code in ``lib/System`` uses
211 the ``LLVM_ON_UNIX`` and ``LLVM_ON_WIN32`` ``#defines`` provided via configure
212 through the ``llvm/Config/config.h`` file. Each source file in ``lib/System``,
213 after implementing the generic (operating system independent) functionality
214 needs to include the correct implementation using a set of
211 the ``LLVM_ON_UNIX`` and ``_WIN32`` ``#defines``. Each source file in
212 ``lib/System``, after implementing the generic (operating system independent)
213 functionality needs to include the correct implementation using a set of
215214 ``#if defined(LLVM_ON_XYZ)`` directives. For example, if we had
216215 ``lib/System/File.cpp``, we'd expect to see in that file:
217216
220219 #if defined(LLVM_ON_UNIX)
221220 #include "Unix/File.cpp"
222221 #endif
223 #if defined(LLVM_ON_WIN32)
222 #if defined(_WIN32)
224223 #include "Win32/File.cpp"
225224 #endif
226225
596596
597597 .. code-block:: c++
598598
599 #ifdef LLVM_ON_WIN32
599 #ifdef _WIN32
600600 #define DLLEXPORT __declspec(dllexport)
601601 #else
602602 #define DLLEXPORT
650650 // "Library" functions that can be "extern'd" from user code.
651651 //===----------------------------------------------------------------------===//
652652
653 #ifdef LLVM_ON_WIN32
653 #ifdef _WIN32
654654 #define DLLEXPORT __declspec(dllexport)
655655 #else
656656 #define DLLEXPORT
924924 // "Library" functions that can be "extern'd" from user code.
925925 //===----------------------------------------------------------------------===//
926926
927 #ifdef LLVM_ON_WIN32
927 #ifdef _WIN32
928928 #define DLLEXPORT __declspec(dllexport)
929929 #else
930930 #define DLLEXPORT
10431043 // "Library" functions that can be "extern'd" from user code.
10441044 //===----------------------------------------------------------------------===//
10451045
1046 #ifdef LLVM_ON_WIN32
1046 #ifdef _WIN32
10471047 #define DLLEXPORT __declspec(dllexport)
10481048 #else
10491049 #define DLLEXPORT
12131213 // "Library" functions that can be "extern'd" from user code.
12141214 //===----------------------------------------------------------------------===//
12151215
1216 #ifdef LLVM_ON_WIN32
1216 #ifdef _WIN32
12171217 #define DLLEXPORT __declspec(dllexport)
12181218 #else
12191219 #define DLLEXPORT
11721172 // "Library" functions that can be "extern'd" from user code.
11731173 //===----------------------------------------------------------------------===//
11741174
1175 #ifdef LLVM_ON_WIN32
1175 #ifdef _WIN32
11761176 #define DLLEXPORT __declspec(dllexport)
11771177 #else
11781178 #define DLLEXPORT
13781378 // "Library" functions that can be "extern'd" from user code.
13791379 //===----------------------------------------------------------------------===//
13801380
1381 #ifdef LLVM_ON_WIN32
1381 #ifdef _WIN32
13821382 #define DLLEXPORT __declspec(dllexport)
13831383 #else
13841384 #define DLLEXPORT
8787 }
8888
8989 JITSymbol findMangledSymbol(const std::string &Name) {
90 #ifdef LLVM_ON_WIN32
90 #ifdef _WIN32
9191 // The symbol lookup of ObjectLinkingLayer uses the SymbolRef::SF_Exported
9292 // flag to decide whether a symbol will be visible or not, when we call
9393 // IRCompileLayer::findSymbolIn with ExportedSymbolsOnly set to true.
111111 if (auto SymAddr = RTDyldMemoryManager::getSymbolAddressInProcess(Name))
112112 return JITSymbol(SymAddr, JITSymbolFlags::Exported);
113113
114 #ifdef LLVM_ON_WIN32
114 #ifdef _WIN32
115115 // For Windows retry without "_" at beginning, as RTDyldMemoryManager uses
116116 // GetProcAddress and standard libraries like msvcrt.dll use names
117117 // with and without "_" (for example "_itoa" but "sin").
152152 uid_t fs_st_uid = 0;
153153 gid_t fs_st_gid = 0;
154154 off_t fs_st_size = 0;
155 #elif defined (LLVM_ON_WIN32)
155 #elif defined (_WIN32)
156156 uint32_t LastAccessedTimeHigh = 0;
157157 uint32_t LastAccessedTimeLow = 0;
158158 uint32_t LastWriteTimeHigh = 0;
173173 uid_t UID, gid_t GID, off_t Size)
174174 : fs_st_atime(ATime), fs_st_mtime(MTime), fs_st_uid(UID), fs_st_gid(GID),
175175 fs_st_size(Size), Type(Type), Perms(Perms) {}
176 #elif defined(LLVM_ON_WIN32)
176 #elif defined(_WIN32)
177177 basic_file_status(file_type Type, perms Perms, uint32_t LastAccessTimeHigh,
178178 uint32_t LastAccessTimeLow, uint32_t LastWriteTimeHigh,
179179 uint32_t LastWriteTimeLow, uint32_t FileSizeHigh,
195195 uint32_t getUser() const { return fs_st_uid; }
196196 uint32_t getGroup() const { return fs_st_gid; }
197197 uint64_t getSize() const { return fs_st_size; }
198 #elif defined (LLVM_ON_WIN32)
198 #elif defined (_WIN32)
199199 uint32_t getUser() const {
200200 return 9999; // Not applicable to Windows, so...
201201 }
222222 dev_t fs_st_dev = 0;
223223 nlink_t fs_st_nlinks = 0;
224224 ino_t fs_st_ino = 0;
225 #elif defined (LLVM_ON_WIN32)
225 #elif defined (_WIN32)
226226 uint32_t NumLinks = 0;
227227 uint32_t VolumeSerialNumber = 0;
228228 uint32_t FileIndexHigh = 0;
239239 time_t ATime, time_t MTime, uid_t UID, gid_t GID, off_t Size)
240240 : basic_file_status(Type, Perms, ATime, MTime, UID, GID, Size),
241241 fs_st_dev(Dev), fs_st_nlinks(Links), fs_st_ino(Ino) {}
242 #elif defined(LLVM_ON_WIN32)
242 #elif defined(_WIN32)
243243 file_status(file_type Type, perms Perms, uint32_t LinkCount,
244244 uint32_t LastAccessTimeHigh, uint32_t LastAccessTimeLow,
245245 uint32_t LastWriteTimeHigh, uint32_t LastWriteTimeLow,
3030 #define BYTE_ORDER LITTLE_ENDIAN
3131 #endif
3232 #else
33 #if !defined(BYTE_ORDER) && !defined(LLVM_ON_WIN32)
33 #if !defined(BYTE_ORDER) && !defined(_WIN32)
3434 #include
3535 #endif
3636 #endif
2626 // a colon on Unix or a semicolon on Windows.
2727 #if defined(LLVM_ON_UNIX)
2828 const char EnvPathSeparator = ':';
29 #elif defined (LLVM_ON_WIN32)
29 #elif defined (_WIN32)
3030 const char EnvPathSeparator = ';';
3131 #endif
3232
3434 struct ProcessInfo {
3535 #if defined(LLVM_ON_UNIX)
3636 typedef pid_t ProcessId;
37 #elif defined(LLVM_ON_WIN32)
37 #elif defined(_WIN32)
3838 typedef unsigned long ProcessId; // Must match the type of DWORD on Windows.
3939 typedef void * HANDLE; // Must match the type of HANDLE on Windows.
4040 /// The handle to the process (available on Windows only).
206206 for (auto ToE = sys::path::end(To); ToI != ToE; ++ToI)
207207 sys::path::append(Relative, *ToI);
208208
209 #ifdef LLVM_ON_WIN32
209 #ifdef _WIN32
210210 // Replace backslashes with slashes so that the path is portable between *nix
211211 // and Windows.
212212 std::replace(Relative.begin(), Relative.end(), '\\', '/');
1717 // Include the platform-specific parts of this class.
1818 #ifdef LLVM_ON_UNIX
1919 #include "Unix/COM.inc"
20 #elif LLVM_ON_WIN32
20 #elif _WIN32
2121 #include "Windows/COM.inc"
2222 #endif
3131 assert(LT);
3232 (void)LT;
3333 #endif
34 #if defined(LLVM_ON_WIN32)
34 #if defined(_WIN32)
3535 int Error = ::localtime_s(&Storage, &OurTime);
3636 assert(!Error);
3737 (void)Error;
2121
2222 #if LLVM_ON_UNIX
2323 #include
24 #elif LLVM_ON_WIN32
24 #elif _WIN32
2525 #include
2626 #endif
2727
9292 std::string Pid =
9393 #if LLVM_ON_UNIX
9494 llvm::to_string(::getpid());
95 #elif LLVM_ON_WIN32
95 #elif _WIN32
9696 llvm::to_string(::GetCurrentProcessId());
9797 #else
9898 "";
188188
189189 #else // !_MSC_VER
190190
191 #if defined(LLVM_ON_WIN32)
191 #if defined(_WIN32)
192192 // This is a non-MSVC compiler, probably mingw gcc or clang without
193193 // -fms-extensions. Use vectored exception handling (VEH).
194194 //
271271 }
272272 }
273273
274 #else // !LLVM_ON_WIN32
274 #else // !_WIN32
275275
276276 // Generic POSIX implementation.
277277 //
341341 sigaction(Signals[i], &PrevActions[i], nullptr);
342342 }
343343
344 #endif // !LLVM_ON_WIN32
344 #endif // !_WIN32
345345
346346 bool CrashRecoveryContext::RunSafely(function_ref Fn) {
347347 // If crash recovery is disabled, do nothing.
4848 }
4949
5050 bool AddLibrary(void *Handle, bool IsProcess = false, bool CanClose = true) {
51 #ifdef LLVM_ON_WIN32
51 #ifdef _WIN32
5252 assert((Handle == this ? IsProcess : !IsProcess) && "Bad Handle.");
5353 #endif
5454
6060 }
6161 Handles.push_back(Handle);
6262 } else {
63 #ifndef LLVM_ON_WIN32
63 #ifndef _WIN32
6464 if (Process) {
6565 if (CanClose)
6666 DLClose(Process);
120120 static llvm::ManagedStatic> SymbolsMutex;
121121 }
122122
123 #ifdef LLVM_ON_WIN32
123 #ifdef _WIN32
124124
125125 #include "Windows/DynamicLibrary.inc"
126126
242242 remove_fatal_error_handler();
243243 }
244244
245 #ifdef LLVM_ON_WIN32
245 #ifdef _WIN32
246246
247247 #include
248248
114114 return FileOrErr.takeError();
115115 fs::TempFile File = std::move(*FileOrErr);
116116
117 #ifndef LLVM_ON_WIN32
117 #ifndef _WIN32
118118 // On Windows, CreateFileMapping (the mmap function on Windows)
119119 // automatically extends the underlying file. We don't need to
120120 // extend the file beforehand. _chsize (ftruncate on Windows) is
220220 Viewer = VK_Ghostview;
221221 if (!Viewer && S.TryFindProgram("xdg-open", ViewerPath))
222222 Viewer = VK_XDGOpen;
223 #ifdef LLVM_ON_WIN32
223 #ifdef _WIN32
224224 if (!Viewer && S.TryFindProgram("cmd", ViewerPath)) {
225225 Viewer = VK_CmdStart;
226226 }
295295 args.push_back(nullptr);
296296
297297 // Dotty spawns another app and doesn't wait until it returns
298 #ifdef LLVM_ON_WIN32
298 #ifdef _WIN32
299299 wait = false;
300300 #endif
301301 errs() << "Running 'dotty' program... ";
2929 #ifdef LLVM_ON_UNIX
3030 #include "Unix/Host.inc"
3131 #endif
32 #ifdef LLVM_ON_WIN32
32 #ifdef _WIN32
3333 #include "Windows/Host.inc"
3434 #endif
3535 #ifdef _MSC_VER
77 namespace locale {
88
99 int columnWidth(StringRef Text) {
10 #if LLVM_ON_WIN32
10 #if _WIN32
1111 return Text.size();
1212 #else
1313 return llvm::sys::unicode::columnWidthUTF8(Text);
1515 }
1616
1717 bool isPrint(int UCS) {
18 #if LLVM_ON_WIN32
18 #if _WIN32
1919 // Restrict characters that we'll try to print to the lower part of ASCII
2020 // except for the control characters (0x20 - 0x7E). In general one can not
2121 // reliably output code points U+0080 and higher using narrow character C/C++
2424 #include
2525 #include
2626 #include
27 #if LLVM_ON_WIN32
27 #if _WIN32
2828 #include
2929 #endif
3030 #if LLVM_ON_UNIX
257257 if (getState() != LFS_Shared)
258258 return Res_Success;
259259
260 #if LLVM_ON_WIN32
260 #if _WIN32
261261 unsigned long Interval = 1;
262262 #else
263263 struct timespec Interval;
272272 // finish up and remove the lock file.
273273 // FIXME: Should we hook in to system APIs to get a notification when the
274274 // lock file is deleted?
275 #if LLVM_ON_WIN32
275 #if _WIN32
276276 Sleep(Interval);
277277 #else
278278 nanosleep(&Interval, nullptr);
291291 return Res_OwnerDied;
292292
293293 // Exponentially increase the time we wait for the lock to be removed.
294 #if LLVM_ON_WIN32
294 #if _WIN32
295295 Interval *= 2;
296296 #else
297297 Interval.tv_sec *= 2;
302302 }
303303 #endif
304304 } while (
305 #if LLVM_ON_WIN32
305 #if _WIN32
306306 Interval < MaxSeconds * 1000
307307 #else
308308 Interval.tv_sec < (time_t)MaxSeconds
1919 #ifdef LLVM_ON_UNIX
2020 #include "Unix/Memory.inc"
2121 #endif
22 #ifdef LLVM_ON_WIN32
22 #ifdef _WIN32
2323 #include "Windows/Memory.inc"
2424 #endif
118118
119119 #elif defined(LLVM_ON_UNIX)
120120 #include "Unix/Mutex.inc"
121 #elif defined( LLVM_ON_WIN32)
121 #elif defined( _WIN32)
122122 #include "Windows/Mutex.inc"
123123 #else
124 #warning Neither LLVM_ON_UNIX nor LLVM_ON_WIN32 was set in Support/Mutex.cpp
124 #warning Neither LLVM_ON_UNIX nor _WIN32 was set in Support/Mutex.cpp
125125 #endif
126126 #endif
3636 using llvm::sys::path::Style;
3737
3838 inline Style real_style(Style style) {
39 #ifdef LLVM_ON_WIN32
39 #ifdef _WIN32
4040 return (style == Style::posix) ? Style::posix : Style::windows;
4141 #else
4242 return (style == Style::windows) ? Style::windows : Style::posix;
10721072 #if defined(LLVM_ON_UNIX)
10731073 #include "Unix/Path.inc"
10741074 #endif
1075 #if defined(LLVM_ON_WIN32)
1075 #if defined(_WIN32)
10761076 #include "Windows/Path.inc"
10771077 #endif
10781078
10941094 Done = true;
10951095 std::error_code RemoveEC;
10961096 // On windows closing will remove the file.
1097 #ifndef LLVM_ON_WIN32
1097 #ifndef _WIN32
10981098 // Always try to close and remove.
10991099 if (!TmpName.empty()) {
11001100 RemoveEC = fs::remove(TmpName);
11181118 assert(!Done);
11191119 Done = true;
11201120 // Always try to close and rename.
1121 #ifdef LLVM_ON_WIN32
1121 #ifdef _WIN32
11221122 // If we cant't cancel the delete don't rename.
11231123 std::error_code RenameEC = cancelDeleteOnClose(FD);
11241124 if (!RenameEC)
11501150 assert(!Done);
11511151 Done = true;
11521152
1153 #ifdef LLVM_ON_WIN32
1153 #ifdef _WIN32
11541154 if (std::error_code EC = cancelDeleteOnClose(FD))
11551155 return errorCodeToError(EC);
11561156 #else
11761176 return errorCodeToError(EC);
11771177
11781178 TempFile Ret(ResultPath, FD);
1179 #ifndef LLVM_ON_WIN32
1179 #ifndef _WIN32
11801180 if (sys::RemoveFileOnSignal(ResultPath)) {
11811181 // Make sure we delete the file when RemoveFileOnSignal fails.
11821182 consumeError(Ret.discard());
9292 #ifdef LLVM_ON_UNIX
9393 #include "Unix/Process.inc"
9494 #endif
95 #ifdef LLVM_ON_WIN32
95 #ifdef _WIN32
9696 #include "Windows/Process.inc"
9797 #endif
6666 #ifdef LLVM_ON_UNIX
6767 #include "Unix/Program.inc"
6868 #endif
69 #ifdef LLVM_ON_WIN32
69 #ifdef _WIN32
7070 #include "Windows/Program.inc"
7171 #endif
116116
117117 #elif defined(LLVM_ON_UNIX)
118118 #include "Unix/RWMutex.inc"
119 #elif defined( LLVM_ON_WIN32)
119 #elif defined( _WIN32)
120120 #include "Windows/RWMutex.inc"
121121 #else
122 #warning Neither LLVM_ON_UNIX nor LLVM_ON_WIN32 was set in Support/Mutex.cpp
122 #warning Neither LLVM_ON_UNIX nor _WIN32 was set in Support/Mutex.cpp
123123 #endif
124124 #endif
1616 #include "llvm/Support/CommandLine.h"
1717 #include "llvm/Support/Debug.h"
1818 #include "llvm/Support/raw_ostream.h"
19 #ifdef LLVM_ON_WIN32
19 #ifdef _WIN32
2020 #include "Windows/WindowsSupport.h"
2121 #else
2222 #include "Unix/Unix.h"
6262
6363 // Get random vector of specified size
6464 std::error_code llvm::getRandomBytes(void *Buffer, size_t Size) {
65 #ifdef LLVM_ON_WIN32
65 #ifdef _WIN32
6666 HCRYPTPROV hProvider;
6767 if (CryptAcquireContext(&hProvider, 0, 0, PROV_RSA_FULL,
6868 CRYPT_VERIFYCONTEXT | CRYPT_SILENT)) {
124124
125125 Optional Redirects[] = {InputFile.str(), OutputFile.str(), llvm::None};
126126 const char *Args[] = {"llvm-symbolizer", "--functions=linkage", "--inlining",
127 #ifdef LLVM_ON_WIN32
127 #ifdef _WIN32
128128 // Pass --relative-address on Windows so that we don't
129129 // have to add ImageBase from PE file.
130130 // FIXME: Make this the default for llvm-symbolizer.
179179 #ifdef LLVM_ON_UNIX
180180 #include "Unix/Signals.inc"
181181 #endif
182 #ifdef LLVM_ON_WIN32
182 #ifdef _WIN32
183183 #include "Windows/Signals.inc"
184184 #endif
4040 }
4141 #elif defined(LLVM_ON_UNIX)
4242 #include "Unix/ThreadLocal.inc"
43 #elif defined( LLVM_ON_WIN32)
43 #elif defined( _WIN32)
4444 #include "Windows/ThreadLocal.inc"
4545 #else
46 #warning Neither LLVM_ON_UNIX nor LLVM_ON_WIN32 set in Support/ThreadLocal.cpp
46 #warning Neither LLVM_ON_UNIX nor _WIN32 set in Support/ThreadLocal.cpp
4747 #endif
3636 }
3737
3838 #if LLVM_ENABLE_THREADS == 0 || \
39 (!defined(LLVM_ON_WIN32) && !defined(HAVE_PTHREAD_H))
39 (!defined(_WIN32) && !defined(HAVE_PTHREAD_H))
4040 // Support for non-Win32, non-pthread implementation.
4141 void llvm::llvm_execute_on_thread(void (*Fn)(void *), void *UserData,
4242 unsigned RequestedStackSize) {
8888 #ifdef LLVM_ON_UNIX
8989 #include "Unix/Threading.inc"
9090 #endif
91 #ifdef LLVM_ON_WIN32
91 #ifdef _WIN32
9292 #include "Windows/Threading.inc"
9393 #endif
9494
9797 return uint64_t(gettid());
9898 #elif defined(__linux__)
9999 return uint64_t(syscall(SYS_gettid));
100 #elif defined(LLVM_ON_WIN32)
100 #elif defined(_WIN32)
101101 return uint64_t(::GetCurrentThreadId());
102102 #else
103103 return uint64_t(pthread_self());
1717 #ifdef LLVM_ON_UNIX
1818 #include "Unix/Watchdog.inc"
1919 #endif
20 #ifdef LLVM_ON_WIN32
20 #ifdef _WIN32
2121 #include "Windows/Watchdog.inc"
2222 #endif
5858 #endif
5959 #endif
6060
61 #ifdef LLVM_ON_WIN32
61 #ifdef _WIN32
6262 #include "Windows/WindowsSupport.h"
6363 #endif
6464
532532
533533 // Get the starting position.
534534 off_t loc = ::lseek(FD, 0, SEEK_CUR);
535 #ifdef LLVM_ON_WIN32
535 #ifdef _WIN32
536536 // MSVCRT's _lseek(SEEK_CUR) doesn't return -1 for pipes.
537537 sys::fs::file_status Status;
538538 std::error_code EC = status(FD, Status);
585585 // It is observed that Linux returns EINVAL for a very large write (>2G).
586586 // Make it a reasonably small value.
587587 MaxWriteSize = 1024 * 1024 * 1024;
588 #elif defined(LLVM_ON_WIN32)
588 #elif defined(_WIN32)
589589 // Writing a large size of output to Windows console returns ENOMEM. It seems
590590 // that, prior to Windows 8, WriteFile() is redirecting to WriteConsole(), and
591591 // the latter has a size limit (66000 bytes or less, depending on heap usage).
638638 uint64_t raw_fd_ostream::seek(uint64_t off) {
639639 assert(SupportsSeeking && "Stream does not support seeking!");
640640 flush();
641 #ifdef LLVM_ON_WIN32
641 #ifdef _WIN32
642642 pos = ::_lseeki64(FD, off, SEEK_SET);
643643 #elif defined(HAVE_LSEEK64)
644644 pos = ::lseek64(FD, off, SEEK_SET);
205205
206206 #if defined(LLVM_ON_UNIX)
207207 const char EXESuffix[] = "";
208 #elif defined(LLVM_ON_WIN32)
208 #elif defined(_WIN32)
209209 const char EXESuffix[] = "exe";
210210 #endif
211211
9595 // Initialize the configured targets if they have not been initialized.
9696 static void lto_initialize() {
9797 if (!initialized) {
98 #ifdef LLVM_ON_WIN32
98 #ifdef _WIN32
9999 // Dialog box on crash disabling doesn't work across DLL boundaries, so do
100100 // it here.
101101 llvm::sys::DisableSystemDialogsOnCrash();
4545 // fail to initialize the AssumptionCacheTracker.
4646 initializeAssumptionCacheTrackerPass(*PassRegistry::getPassRegistry());
4747
48 #ifdef LLVM_ON_WIN32
48 #ifdef _WIN32
4949 // On Windows, generate ELF objects by specifying "-elf" in triple
5050 HostTriple += "-elf";
51 #endif // LLVM_ON_WIN32
51 #endif // _WIN32
5252 HostTriple = Triple::normalize(HostTriple);
5353 }
5454
194194 static MutexT *getMutex(const ExtraData &Data) { return Data.M; }
195195 };
196196 // FIXME: These tests started failing on Windows.
197 #if LLVM_ENABLE_THREADS && !defined(LLVM_ON_WIN32)
197 #if LLVM_ENABLE_THREADS && !defined(_WIN32)
198198 TYPED_TEST(ValueMapTest, LocksMutex) {
199199 sys::Mutex M(false); // Not recursive.
200200 bool CalledRAUW = false, CalledDeleted = false;
1010 #include "llvm/Support/CrashRecoveryContext.h"
1111 #include "gtest/gtest.h"
1212
13 #ifdef LLVM_ON_WIN32
13 #ifdef _WIN32
1414 #define WIN32_LEAN_AND_MEAN
1515 #define NOGDI
1616 #include
6060 EXPECT_EQ(1, GlobalInt);
6161 }
6262
63 #ifdef LLVM_ON_WIN32
63 #ifdef _WIN32
6464 static void raiseIt() {
6565 RaiseException(123, EXCEPTION_NONCONTINUABLE, 0, NULL);
6666 }
2222 #include "gtest/gtest.h"
2323 #include "gmock/gmock.h"
2424
25 #ifdef LLVM_ON_WIN32
25 #ifdef _WIN32
2626 #include "llvm/ADT/ArrayRef.h"
2727 #include
2828 #include
5858 EXPECT_TRUE(path::is_separator('\\', path::Style::windows));
5959 EXPECT_FALSE(path::is_separator('\\', path::Style::posix));
6060
61 #ifdef LLVM_ON_WIN32
61 #ifdef _WIN32
6262 EXPECT_TRUE(path::is_separator('\\'));
6363 #else
6464 EXPECT_FALSE(path::is_separator('\\'));
258258
259259 TEST(Support, HomeDirectory) {
260260 std::string expected;
261 #ifdef LLVM_ON_WIN32
261 #ifdef _WIN32
262262 if (wchar_t const *path = ::_wgetenv(L"USERPROFILE")) {
263263 auto pathLen = ::wcslen(path);
264264 ArrayRef ref{reinterpret_cast(path),
347347 EXPECT_TRUE(!TempDir.empty());
348348 }
349349
350 #ifdef LLVM_ON_WIN32
350 #ifdef _WIN32
351351 static std::string path2regex(std::string Path) {
352352 size_t Pos = 0;
353353 while ((Pos = Path.find('\\', Pos)) != std::string::npos) {
616616 ASSERT_EQ(fs::access(Twine(TempPath), sys::fs::AccessMode::Exist),
617617 errc::no_such_file_or_directory);
618618
619 #ifdef LLVM_ON_WIN32
619 #ifdef _WIN32
620620 // Path name > 260 chars should get an error.
621621 const char *Path270 =
622622 "abcdefghijklmnopqrstuvwxyz9abcdefghijklmnopqrstuvwxyz8"
664664 ::umask(OldUmask);
665665 #endif
666666
667 #ifdef LLVM_ON_WIN32
667 #ifdef _WIN32
668668 // Prove that create_directories() can handle a pathname > 248 characters,
669669 // which is the documented limit for CreateDirectory().
670670 // (248 is MAX_PATH subtracting room for an 8.3 filename.)
957957 ASSERT_FALSE(fs::exists(BaseDir));
958958 }
959959
960 #ifdef LLVM_ON_WIN32
960 #ifdef _WIN32
961961 TEST_F(FileSystemTest, CarriageReturn) {
962962 SmallString<128> FilePathname(TestDirectory);
963963 std::error_code EC;
10751075 EXPECT_EQ(std::get<2>(T), Posix);
10761076 }
10771077
1078 #if defined(LLVM_ON_WIN32)
1078 #if defined(_WIN32)
10791079 SmallString<64> PathHome;
10801080 path::home_directory(PathHome);
10811081
12551255 EXPECT_EQ(fs::setPermissions(TempPath, fs::all_read | fs::all_exe), NoError);
12561256 EXPECT_TRUE(CheckPermissions(fs::all_read | fs::all_exe));
12571257
1258 #if defined(LLVM_ON_WIN32)
1258 #if defined(_WIN32)
12591259 fs::perms ReadOnly = fs::all_read | fs::all_exe;
12601260 EXPECT_EQ(fs::setPermissions(TempPath, fs::no_perms), NoError);
12611261 EXPECT_TRUE(CheckPermissions(ReadOnly));
99 #include "llvm/Support/Process.h"
1010 #include "gtest/gtest.h"
1111
12 #ifdef LLVM_ON_WIN32
12 #ifdef _WIN32
1313 #include
1414 #endif
1515
4444 }
4545 #endif
4646
47 #ifdef LLVM_ON_WIN32
47 #ifdef _WIN32
4848
4949 TEST(ProcessTest, EmptyVal) {
5050 SetEnvironmentVariableA("__LLVM_TEST_ENVIRON_VAR__", "");
2525 void sleep_for(unsigned int seconds) {
2626 sleep(seconds);
2727 }
28 #elif defined(LLVM_ON_WIN32)
28 #elif defined(_WIN32)
2929 #include
3030 void sleep_for(unsigned int seconds) {
3131 Sleep(seconds * 1000);
6464 protected:
6565 void SetUp() override {
6666 auto EnvP = [] {
67 #if defined(LLVM_ON_WIN32)
67 #if defined(_WIN32)
6868 _wgetenv(L"TMP"); // Populate _wenviron, initially is null
6969 return _wenviron;
7070 #elif defined(__APPLE__)
7676 ASSERT_TRUE(EnvP);
7777
7878 auto prepareEnvVar = [this](decltype(*EnvP) Var) {
79 #if defined(LLVM_ON_WIN32)
79 #if defined(_WIN32)
8080 // On Windows convert UTF16 encoded variable to UTF8
8181 auto Len = wcslen(Var);
8282 ArrayRef Ref{reinterpret_cast(Var),
114114 }
115115 };
116116
117 #ifdef LLVM_ON_WIN32
117 #ifdef _WIN32
118118 TEST_F(ProgramEnvTest, CreateProcessLongPath) {
119119 if (getenv("LLVM_PROGRAM_TEST_LONG_PATH"))
120120 exit(0);
185185 std::string error;
186186 bool ExecutionFailed;
187187 // Redirect stdout and stdin to NUL, but let stderr through.
188 #ifdef LLVM_ON_WIN32
188 #ifdef _WIN32
189189 StringRef nul("NUL");
190190 #else
191191 StringRef nul("/dev/null");
311311
312312 }
313313
314 #ifdef LLVM_ON_WIN32
314 #ifdef _WIN32
315315 const char utf16le_text[] =
316316 "\x6c\x00\x69\x00\x6e\x00\x67\x00\xfc\x00\x69\x00\xe7\x00\x61\x00";
317317 const char utf16be_text[] =
331331 sys::WEM_UTF16));
332332 int fd = 0;
333333 ASSERT_NO_ERROR(fs::openFileForRead(file_pathname.c_str(), fd));
334 #if defined(LLVM_ON_WIN32)
334 #if defined(_WIN32)
335335 char buf[18];
336336 ASSERT_EQ(::read(fd, buf, 18), 18);
337337 if (strncmp(buf, "\xfe\xff", 2) == 0) { // UTF16-BE
99 #include "llvm/Support/Timer.h"
1010 #include "gtest/gtest.h"
1111
12 #if LLVM_ON_WIN32
12 #if _WIN32
1313 #include
1414 #else
1515 #include
2121
2222 // FIXME: Put this somewhere in Support, it's also used in LockFileManager.
2323 void SleepMS() {
24 #if LLVM_ON_WIN32
24 #if _WIN32
2525 Sleep(1);
2626 #else
2727 struct timespec Interval;