[clang] [Cygwin] Cygwin general (PR #74936)
εΎζζ Xu Chiheng via cfe-commits
cfe-commits at lists.llvm.org
Sun Dec 31 12:42:30 PST 2023
https://github.com/xu-chiheng updated https://github.com/llvm/llvm-project/pull/74936
>From c9cffe8c188d32a9edd1b6316db065bbcc479c97 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=BE=90=E6=8C=81=E6=81=92=20Xu=20Chiheng?=
<chiheng.xu at gmail.com>
Date: Sun, 10 Dec 2023 00:34:27 +0800
Subject: [PATCH] 1
---
clang/lib/Headers/mm_malloc.h | 6 +++---
clang/tools/libclang/CIndexer.cpp | 10 ++--------
2 files changed, 5 insertions(+), 11 deletions(-)
diff --git a/clang/lib/Headers/mm_malloc.h b/clang/lib/Headers/mm_malloc.h
index d32fe594162774..6f46f10ee50f31 100644
--- a/clang/lib/Headers/mm_malloc.h
+++ b/clang/lib/Headers/mm_malloc.h
@@ -12,7 +12,7 @@
#include <stdlib.h>
-#ifdef _WIN32
+#if defined(_WIN32) && !defined(__CYGWIN__)
#include <malloc.h>
#else
#ifndef __cplusplus
@@ -41,7 +41,7 @@ _mm_malloc(size_t __size, size_t __align) {
void *__mallocedMemory;
#if defined(__MINGW32__)
__mallocedMemory = __mingw_aligned_malloc(__size, __align);
-#elif defined(_WIN32)
+#elif defined(_WIN32) && !defined(__CYGWIN__)
__mallocedMemory = _aligned_malloc(__size, __align);
#else
if (posix_memalign(&__mallocedMemory, __align, __size))
@@ -56,7 +56,7 @@ _mm_free(void *__p)
{
#if defined(__MINGW32__)
__mingw_aligned_free(__p);
-#elif defined(_WIN32)
+#elif defined(_WIN32) && !defined(__CYGWIN__)
_aligned_free(__p);
#else
free(__p);
diff --git a/clang/tools/libclang/CIndexer.cpp b/clang/tools/libclang/CIndexer.cpp
index 12d9d418dea51d..e7c1bed8b740fd 100644
--- a/clang/tools/libclang/CIndexer.cpp
+++ b/clang/tools/libclang/CIndexer.cpp
@@ -27,12 +27,10 @@
#include <mutex>
#ifdef __CYGWIN__
-#include <cygwin/version.h>
#include <sys/cygwin.h>
-#define _WIN32 1
#endif
-#ifdef _WIN32
+#if defined(_WIN32) || defined(__CYGWIN__)
#include <windows.h>
#elif defined(_AIX)
#include <errno.h>
@@ -105,7 +103,7 @@ const std::string &CIndexer::getClangResourcesPath() {
SmallString<128> LibClangPath;
// Find the location where this library lives (libclang.dylib).
-#ifdef _WIN32
+#if defined(_WIN32) || defined(__CYGWIN__)
MEMORY_BASIC_INFORMATION mbi;
char path[MAX_PATH];
VirtualQuery((void *)(uintptr_t)clang_createTranslationUnit, &mbi,
@@ -115,11 +113,7 @@ const std::string &CIndexer::getClangResourcesPath() {
#ifdef __CYGWIN__
char w32path[MAX_PATH];
strcpy(w32path, path);
-#if CYGWIN_VERSION_API_MAJOR > 0 || CYGWIN_VERSION_API_MINOR >= 181
cygwin_conv_path(CCP_WIN_A_TO_POSIX, w32path, path, MAX_PATH);
-#else
- cygwin_conv_to_full_posix_path(w32path, path);
-#endif
#endif
LibClangPath += path;
More information about the cfe-commits
mailing list