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
pull/29450/head
Lőrinc 9 months ago
parent d94adc7270
commit 6c6b2442ed

@ -324,10 +324,7 @@ if (CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_SIZEOF_VOID_P EQUAL 4)
endif() endif()
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
target_compile_definitions(core_interface INTERFACE target_compile_definitions(core_interface INTERFACE OBJC_OLD_DISPATCH_PROTOTYPES=0)
MAC_OSX
OBJC_OLD_DISPATCH_PROTOTYPES=0
)
# These flags are specific to ld64, and may cause issues with other linkers. # These flags are specific to ld64, and may cause issues with other linkers.
# For example: GNU ld will interpret -dead_strip as -de and then try and use # For example: GNU ld will interpret -dead_strip as -de and then try and use
# "ad_strip" as the symbol for the entry point. # "ad_strip" as the symbol for the entry point.

@ -184,7 +184,7 @@ bool ArgsManager::ParseParameters(int argc, const char* const argv[], std::strin
for (int i = 1; i < argc; i++) { for (int i = 1; i < argc; i++) {
std::string key(argv[i]); std::string key(argv[i]);
#ifdef MAC_OSX #ifdef __APPLE__
// At the first time when a user gets the "App downloaded from the // At the first time when a user gets the "App downloaded from the
// internet" warning, and clicks the Open button, macOS passes // internet" warning, and clicks the Open button, macOS passes
// a unique process serial number (PSN) as -psn_... command-line // a unique process serial number (PSN) as -psn_... command-line
@ -741,7 +741,7 @@ fs::path GetDefaultDataDir()
pathRet = fs::path("/"); pathRet = fs::path("/");
else else
pathRet = fs::path(pszHome); pathRet = fs::path(pszHome);
#ifdef MAC_OSX #ifdef __APPLE__
// macOS // macOS
return pathRet / "Library/Application Support/Bitcoin"; return pathRet / "Library/Application Support/Bitcoin";
#else #else

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

@ -34,7 +34,7 @@
#include <sys/time.h> #include <sys/time.h>
#endif #endif
#if defined(HAVE_GETRANDOM) || (defined(HAVE_GETENTROPY_RAND) && defined(MAC_OSX)) #if defined(HAVE_GETRANDOM) || (defined(HAVE_GETENTROPY_RAND) && defined(__APPLE__))
#include <sys/random.h> #include <sys/random.h>
#endif #endif
@ -387,7 +387,7 @@ void GetOSRand(unsigned char *ent32)
The function call is always successful. The function call is always successful.
*/ */
arc4random_buf(ent32, NUM_OS_RANDOM_BYTES); arc4random_buf(ent32, NUM_OS_RANDOM_BYTES);
#elif defined(HAVE_GETENTROPY_RAND) && defined(MAC_OSX) #elif defined(HAVE_GETENTROPY_RAND) && defined(__APPLE__)
if (getentropy(ent32, NUM_OS_RANDOM_BYTES) != 0) { if (getentropy(ent32, NUM_OS_RANDOM_BYTES) != 0) {
RandFailure(); RandFailure();
} }

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

@ -29,7 +29,7 @@ static void SetThreadName(const char* name)
::prctl(PR_SET_NAME, name, 0, 0, 0); ::prctl(PR_SET_NAME, name, 0, 0, 0);
#elif (defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)) #elif (defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__DragonFly__))
pthread_set_name_np(pthread_self(), name); pthread_set_name_np(pthread_self(), name);
#elif defined(MAC_OSX) #elif defined(__APPLE__)
pthread_setname_np(name); pthread_setname_np(name);
#else #else
// Prevent warnings for unused parameters... // Prevent warnings for unused parameters...

Loading…
Cancel
Save