Skip to content

Commit 04a21a7

Browse files
committed
Cleanup / refactoring
1 parent aea98b7 commit 04a21a7

File tree

13 files changed

+31
-25
lines changed

13 files changed

+31
-25
lines changed

src/binary/elf.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#include "utils/io/file.hpp"
88
#include "utils/string_view.hpp"
99

10-
#if IS_LINUX && !defined(__CYGWIN__)
10+
#if IS_LINUX && !IS_CYGWIN
1111

1212
#include <array>
1313
#include <cstdint>

src/binary/elf.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#include "utils/span.hpp"
88
#include "utils/utils.hpp"
99

10-
#if IS_LINUX && !defined(__CYGWIN__)
10+
#if IS_LINUX && !IS_CYGWIN
1111

1212
#include <cstdint>
1313
#include <string>

src/binary/module_base.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,21 @@
77
#include <mutex>
88
#include <unordered_map>
99

10-
#if (IS_LINUX || IS_APPLE) && !defined(__CYGWIN__)
10+
#if (IS_LINUX || IS_APPLE) && !IS_CYGWIN
1111
#include <unistd.h>
1212
#include <dlfcn.h>
1313
#if IS_APPLE
1414
#include "binary/mach-o.hpp"
1515
#else
1616
#include "binary/elf.hpp"
1717
#endif
18-
#elif IS_WINDOWS || defined(__CYGWIN__)
18+
#elif IS_WINDOWS || IS_CYGWIN
1919
#include "binary/pe.hpp"
2020
#endif
2121

2222
CPPTRACE_BEGIN_NAMESPACE
2323
namespace detail {
24-
#if IS_LINUX && !defined(__CYGWIN__)
24+
#if IS_LINUX && !IS_CYGWIN
2525
Result<std::uintptr_t, internal_error> get_module_image_base(const std::string& object_path) {
2626
static std::mutex mutex;
2727
std::lock_guard<std::mutex> lock(mutex);

src/binary/object.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@
1111
#include <mutex>
1212
#include <unordered_map>
1313

14-
#if (IS_LINUX || IS_APPLE) && !defined(__CYGWIN__)
14+
#if (IS_LINUX || IS_APPLE) && !IS_CYGWIN
1515
#include <unistd.h>
1616
#include <dlfcn.h>
1717
#if IS_LINUX && (defined(CPPTRACE_HAS_DL_FIND_OBJECT) || defined(CPPTRACE_HAS_DLADDR1))
1818
#include <link.h> // needed for dladdr1's link_map info
1919
#endif
20-
#elif IS_WINDOWS || defined(__CYGWIN__)
20+
#elif IS_WINDOWS || IS_CYGWIN
2121
#ifndef WIN32_LEAN_AND_MEAN
2222
#define WIN32_LEAN_AND_MEAN
2323
#endif
@@ -26,7 +26,7 @@
2626

2727
CPPTRACE_BEGIN_NAMESPACE
2828
namespace detail {
29-
#if (IS_LINUX || IS_APPLE) && !defined(__CYGWIN__)
29+
#if (IS_LINUX || IS_APPLE) && !IS_CYGWIN
3030
#if defined(CPPTRACE_HAS_DL_FIND_OBJECT) || defined(CPPTRACE_HAS_DLADDR1)
3131
std::string resolve_l_name(const char* l_name) {
3232
if(l_name != nullptr && l_name[0] != 0) {

src/binary/pe.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include "utils/error.hpp"
55
#include "utils/utils.hpp"
66

7-
#if IS_WINDOWS || defined(__CYGWIN__)
7+
#if IS_WINDOWS || IS_CYGWIN
88
#include <array>
99
#include <cstdio>
1010
#include <cstring>
@@ -31,13 +31,13 @@ namespace detail {
3131
// https://drive.google.com/file/d/0B3_wGJkuWLytbnIxY1J5WUs4MEk/view?pli=1&resourcekey=0-n5zZ2UW39xVTH8ZSu6C2aQ
3232
// https://0xrick.github.io/win-internals/pe3/
3333
// Endianness should always be little for dos and pe headers
34+
std::FILE* file_ptr;
3435
#ifdef __CYGWIN__
35-
std::FILE* file_ptr = std::fopen(object_path.c_str(), "rb");
36+
file_ptr = std::fopen(object_path.c_str(), "rb");
3637
if(!file_ptr) {
3738
return internal_error("Unable to read object file {}", object_path);
3839
}
3940
#else
40-
std::FILE* file_ptr;
4141
errno_t ret = fopen_s(&file_ptr, object_path.c_str(), "rb");
4242
if(ret != 0 || file_ptr == nullptr) {
4343
return internal_error("Unable to read object file {}", object_path);

src/binary/pe.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include "platform/platform.hpp"
55
#include "utils/utils.hpp"
66

7-
#if IS_WINDOWS || defined(__CYGWIN__)
7+
#if IS_WINDOWS || IS_CYGWIN
88
#include <cstdint>
99
#include <string>
1010

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 || defined(__CYGWIN__)
297+
#if IS_WINDOWS || IS_CYGWIN
298298
auto old_protections = mprotect_page_and_return_old_protections(
299299
reinterpret_cast<void*>(page_addr),
300300
page_size,

src/jit/jit_objects.cpp

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

1616
CPPTRACE_BEGIN_NAMESPACE
1717
namespace detail {
18-
#if (IS_LINUX || IS_APPLE) && !defined(__CYGWIN__)
18+
#if (IS_LINUX || IS_APPLE) && !IS_CYGWIN
1919
class jit_object_manager {
2020
struct object_entry {
2121
const char* object_start;
@@ -135,7 +135,7 @@ namespace detail {
135135
manager.clear_all_jit_objects();
136136
}
137137

138-
#if (IS_LINUX || IS_APPLE) && !defined(__CYGWIN__)
138+
#if (IS_LINUX || IS_APPLE) && !IS_CYGWIN
139139
optional<jit_object_lookup_result> lookup_jit_object(frame_ptr pc) {
140140
return get_jit_object_manager().lookup(pc);
141141
}

src/jit/jit_objects.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ namespace detail {
1313
void unregister_jit_object(const char*);
1414
void clear_all_jit_objects();
1515

16-
#if (IS_LINUX || IS_APPLE) && !defined(__CYGWIN__)
16+
#if (IS_LINUX || IS_APPLE) && !IS_CYGWIN
1717
#if IS_LINUX
1818
using jit_object_type = elf;
1919
#elif IS_APPLE

src/platform/memory_mapping.cpp

Lines changed: 2 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 || defined(__CYGWIN__)
8+
#if IS_WINDOWS || IS_CYGWIN
99
#ifndef WIN32_LEAN_AND_MEAN
1010
#define WIN32_LEAN_AND_MEAN
1111
#endif
@@ -31,7 +31,7 @@
3131

3232
CPPTRACE_BEGIN_NAMESPACE
3333
namespace detail {
34-
#if IS_WINDOWS || defined(__CYGWIN__)
34+
#if IS_WINDOWS || IS_CYGWIN
3535
// Cygwin uses GCC/Itanium ABI but Cygwin's mprotect seems to require 64KB-aligned addresses (allocation
3636
// granularity returned by sysconf(_SC_PAGESIZE)) while we need actual page granularity for typeinfo surgery.
3737
// Using the windows API here works best.

0 commit comments

Comments
 (0)