Skip to content

Commit 6c6b244

Browse files
committed
build: Replace MAC_OSX macro with existing __APPLE__
Adopting `__APPLE__` aligns our project with broader industry practices, including those in prominent projects such as the Linux kernel (and even our own code). See: https://sourceforge.net/p/predef/wiki/OperatingSystems/#macos
1 parent d94adc7 commit 6c6b244

File tree

6 files changed

+9
-12
lines changed

6 files changed

+9
-12
lines changed

CMakeLists.txt

+1-4
Original file line numberDiff line numberDiff line change
@@ -324,10 +324,7 @@ if (CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_SIZEOF_VOID_P EQUAL 4)
324324
endif()
325325

326326
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
327-
target_compile_definitions(core_interface INTERFACE
328-
MAC_OSX
329-
OBJC_OLD_DISPATCH_PROTOTYPES=0
330-
)
327+
target_compile_definitions(core_interface INTERFACE OBJC_OLD_DISPATCH_PROTOTYPES=0)
331328
# These flags are specific to ld64, and may cause issues with other linkers.
332329
# For example: GNU ld will interpret -dead_strip as -de and then try and use
333330
# "ad_strip" as the symbol for the entry point.

src/common/args.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ bool ArgsManager::ParseParameters(int argc, const char* const argv[], std::strin
184184
for (int i = 1; i < argc; i++) {
185185
std::string key(argv[i]);
186186

187-
#ifdef MAC_OSX
187+
#ifdef __APPLE__
188188
// At the first time when a user gets the "App downloaded from the
189189
// internet" warning, and clicks the Open button, macOS passes
190190
// a unique process serial number (PSN) as -psn_... command-line
@@ -741,7 +741,7 @@ fs::path GetDefaultDataDir()
741741
pathRet = fs::path("/");
742742
else
743743
pathRet = fs::path(pszHome);
744-
#ifdef MAC_OSX
744+
#ifdef __APPLE__
745745
// macOS
746746
return pathRet / "Library/Application Support/Bitcoin";
747747
#else

src/common/system.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ void SetupEnvironment()
7070
#endif
7171
// On most POSIX systems (e.g. Linux, but not BSD) the environment's locale
7272
// may be invalid, in which case the "C.UTF-8" locale is used as fallback.
73-
#if !defined(WIN32) && !defined(MAC_OSX) && !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__NetBSD__)
73+
#if !defined(WIN32) && !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__NetBSD__)
7474
try {
7575
std::locale(""); // Raises a runtime error if current locale is invalid
7676
} catch (const std::runtime_error&) {

src/random.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
#include <sys/time.h>
3535
#endif
3636

37-
#if defined(HAVE_GETRANDOM) || (defined(HAVE_GETENTROPY_RAND) && defined(MAC_OSX))
37+
#if defined(HAVE_GETRANDOM) || (defined(HAVE_GETENTROPY_RAND) && defined(__APPLE__))
3838
#include <sys/random.h>
3939
#endif
4040

@@ -387,7 +387,7 @@ void GetOSRand(unsigned char *ent32)
387387
The function call is always successful.
388388
*/
389389
arc4random_buf(ent32, NUM_OS_RANDOM_BYTES);
390-
#elif defined(HAVE_GETENTROPY_RAND) && defined(MAC_OSX)
390+
#elif defined(HAVE_GETENTROPY_RAND) && defined(__APPLE__)
391391
if (getentropy(ent32, NUM_OS_RANDOM_BYTES) != 0) {
392392
RandFailure();
393393
}

src/util/fs_helpers.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ bool FileCommit(FILE* file)
117117
LogPrintf("FlushFileBuffers failed: %s\n", Win32ErrorString(GetLastError()));
118118
return false;
119119
}
120-
#elif defined(MAC_OSX) && defined(F_FULLFSYNC)
120+
#elif defined(__APPLE__) && defined(F_FULLFSYNC)
121121
if (fcntl(fileno(file), F_FULLFSYNC, 0) == -1) { // Manpage says "value other than -1" is returned on success
122122
LogPrintf("fcntl F_FULLFSYNC failed: %s\n", SysErrorString(errno));
123123
return false;
@@ -195,7 +195,7 @@ void AllocateFileRange(FILE* file, unsigned int offset, unsigned int length)
195195
nFileSize.u.HighPart = nEndPos >> 32;
196196
SetFilePointerEx(hFile, nFileSize, 0, FILE_BEGIN);
197197
SetEndOfFile(hFile);
198-
#elif defined(MAC_OSX)
198+
#elif defined(__APPLE__)
199199
// OSX specific version
200200
// NOTE: Contrary to other OS versions, the OSX version assumes that
201201
// NOTE: offset is the size of the file.

src/util/threadnames.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ static void SetThreadName(const char* name)
2929
::prctl(PR_SET_NAME, name, 0, 0, 0);
3030
#elif (defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__DragonFly__))
3131
pthread_set_name_np(pthread_self(), name);
32-
#elif defined(MAC_OSX)
32+
#elif defined(__APPLE__)
3333
pthread_setname_np(name);
3434
#else
3535
// Prevent warnings for unused parameters...

0 commit comments

Comments
 (0)