Skip to content

Commit aea98b7

Browse files
committed
Final cygwin support updates
1 parent 15714ac commit aea98b7

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

src/from_current.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ namespace detail {
294294
if(type_info_addr - page_addr + sizeof(void*) > static_cast<unsigned>(page_size)) {
295295
throw internal_error("pointer crosses page boundaries");
296296
}
297-
#if IS_WINDOWS
297+
#if IS_WINDOWS || defined(__CYGWIN__)
298298
auto old_protections = mprotect_page_and_return_old_protections(
299299
reinterpret_cast<void*>(page_addr),
300300
page_size,

src/platform/memory_mapping.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
#ifndef _MSC_VER
77

8-
#if IS_WINDOWS
8+
#if IS_WINDOWS || defined(__CYGWIN__)
99
#ifndef WIN32_LEAN_AND_MEAN
1010
#define WIN32_LEAN_AND_MEAN
1111
#endif
@@ -31,7 +31,10 @@
3131

3232
CPPTRACE_BEGIN_NAMESPACE
3333
namespace detail {
34-
#if IS_WINDOWS
34+
#if IS_WINDOWS || defined(__CYGWIN__)
35+
// Cygwin uses GCC/Itanium ABI but Cygwin's mprotect seems to require 64KB-aligned addresses (allocation
36+
// granularity returned by sysconf(_SC_PAGESIZE)) while we need actual page granularity for typeinfo surgery.
37+
// Using the windows API here works best.
3538
int get_page_size() {
3639
SYSTEM_INFO info;
3740
GetSystemInfo(&info);

src/platform/memory_mapping.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
#ifndef _MSC_VER
44

5-
#if IS_WINDOWS
5+
#if IS_WINDOWS || defined(__CYGWIN__)
66
#ifndef WIN32_LEAN_AND_MEAN
77
#define WIN32_LEAN_AND_MEAN
88
#endif
@@ -13,15 +13,15 @@
1313

1414
CPPTRACE_BEGIN_NAMESPACE
1515
namespace detail {
16-
#if IS_WINDOWS
16+
#if IS_WINDOWS || defined(__CYGWIN__)
1717
constexpr auto memory_readonly = PAGE_READONLY;
1818
constexpr auto memory_readwrite = PAGE_READWRITE;
1919
#else
2020
constexpr auto memory_readonly = PROT_READ;
2121
constexpr auto memory_readwrite = PROT_READ | PROT_WRITE;
2222
#endif
2323
int get_page_size();
24-
#if !IS_WINDOWS
24+
#if !IS_WINDOWS && !defined(__CYGWIN__)
2525
int get_page_protections(void* page);
2626
#endif
2727
int mprotect_page_and_return_old_protections(void* page, int page_size, int protections);

0 commit comments

Comments
 (0)