diff options
author | Moonchild <moonchild@palemoon.org> | 2021-05-03 11:35:41 +0000 |
---|---|---|
committer | Moonchild <moonchild@palemoon.org> | 2021-05-03 11:35:41 +0000 |
commit | 1bf0734a7249eb0dc1a96d825e7310eb46cac6dc (patch) | |
tree | 1f941b9822dabf5301601c83b3ac8ab91d8a622e /xpcom/glue | |
parent | b1eb04d3f0fde242edb8e9b8b11d00539ceeade7 (diff) | |
download | uxp-1bf0734a7249eb0dc1a96d825e7310eb46cac6dc.tar.gz |
Issue #1751 -- Remove XP_MACOSX conditionals and support files from /xpcom
Diffstat (limited to 'xpcom/glue')
-rw-r--r-- | xpcom/glue/FileUtils.cpp | 153 | ||||
-rw-r--r-- | xpcom/glue/nsCRTGlue.h | 4 | ||||
-rw-r--r-- | xpcom/glue/nsThreadUtils.cpp | 12 | ||||
-rw-r--r-- | xpcom/glue/nsThreadUtils.h | 3 | ||||
-rw-r--r-- | xpcom/glue/standalone/nsXPCOMGlue.cpp | 38 |
5 files changed, 6 insertions, 204 deletions
diff --git a/xpcom/glue/FileUtils.cpp b/xpcom/glue/FileUtils.cpp index 8057cf8cb1..04bba85cb4 100644 --- a/xpcom/glue/FileUtils.cpp +++ b/xpcom/glue/FileUtils.cpp @@ -12,16 +12,7 @@ #include "mozilla/Assertions.h" #include "mozilla/FileUtils.h" -#if defined(XP_MACOSX) -#include <fcntl.h> -#include <unistd.h> -#include <mach/machine.h> -#include <mach-o/fat.h> -#include <mach-o/loader.h> -#include <sys/mman.h> -#include <sys/stat.h> -#include <limits.h> -#elif defined(XP_UNIX) +#if defined(XP_UNIX) #include <fcntl.h> #include <unistd.h> #if defined(LINUX) @@ -56,20 +47,6 @@ mozilla::fallocate(PRFileDesc* aFD, int64_t aLength) PR_Seek64(aFD, oldpos, PR_SEEK_SET); return retval; -#elif defined(XP_MACOSX) - int fd = PR_FileDesc2NativeHandle(aFD); - fstore_t store = {F_ALLOCATECONTIG, F_PEOFPOSMODE, 0, aLength}; - // Try to get a continous chunk of disk space - int ret = fcntl(fd, F_PREALLOCATE, &store); - if (ret == -1) { - // OK, perhaps we are too fragmented, allocate non-continuous - store.fst_flags = F_ALLOCATEALL; - ret = fcntl(fd, F_PREALLOCATE, &store); - if (ret == -1) { - return false; - } - } - return ftruncate(fd, aLength) == 0; #elif defined(XP_UNIX) // The following is copied from fcntlSizeHint in sqlite /* If the OS does not have posix_fallocate(), fake it. First use @@ -225,7 +202,7 @@ mozilla::ReadAheadLib(nsIFile* aFile) return; } ReadAheadLib(path.get()); -#elif defined(LINUX) || defined(XP_MACOSX) +#elif defined(LINUX) nsAutoCString nativePath; if (!aFile || NS_FAILED(aFile->GetNativePath(nativePath))) { return; @@ -244,7 +221,7 @@ mozilla::ReadAheadFile(nsIFile* aFile, const size_t aOffset, return; } ReadAheadFile(path.get(), aOffset, aCount, aOutFd); -#elif defined(LINUX) || defined(XP_MACOSX) +#elif defined(LINUX) nsAutoCString nativePath; if (!aFile || NS_FAILED(aFile->GetNativePath(nativePath))) { return; @@ -271,64 +248,6 @@ static const unsigned char ELFCLASS = ELFCLASS32; typedef Elf32_Off Elf_Off; #endif -#elif defined(XP_MACOSX) - -#if defined(__i386__) -static const uint32_t CPU_TYPE = CPU_TYPE_X86; -#elif defined(__x86_64__) -static const uint32_t CPU_TYPE = CPU_TYPE_X86_64; -#elif defined(__ppc__) -static const uint32_t CPU_TYPE = CPU_TYPE_POWERPC; -#elif defined(__ppc64__) -static const uint32_t CPU_TYPE = CPU_TYPE_POWERPC64; -#else -#error Unsupported CPU type -#endif - -#ifdef __LP64__ -#undef LC_SEGMENT -#define LC_SEGMENT LC_SEGMENT_64 -#undef MH_MAGIC -#define MH_MAGIC MH_MAGIC_64 -#define cpu_mach_header mach_header_64 -#define segment_command segment_command_64 -#else -#define cpu_mach_header mach_header -#endif - -class ScopedMMap -{ -public: - explicit ScopedMMap(const char* aFilePath) - : buf(nullptr) - { - fd = open(aFilePath, O_RDONLY); - if (fd < 0) { - return; - } - struct stat st; - if (fstat(fd, &st) < 0) { - return; - } - size = st.st_size; - buf = (char*)mmap(nullptr, size, PROT_READ, MAP_PRIVATE, fd, 0); - } - ~ScopedMMap() - { - if (buf) { - munmap(buf, size); - } - if (fd >= 0) { - close(fd); - } - } - operator char*() { return buf; } - int getFd() { return fd; } -private: - int fd; - char* buf; - size_t size; -}; #endif void @@ -385,14 +304,6 @@ mozilla::ReadAhead(mozilla::filedesc_t aFd, const size_t aOffset, readahead(aFd, aOffset, aCount); -#elif defined(XP_MACOSX) - - struct radvisory ra; - ra.ra_offset = aOffset; - ra.ra_count = aCount; - // The F_RDADVISE fcntl is equivalent to Linux' readahead() system call. - fcntl(aFd, F_RDADVISE, &ra); - #endif } @@ -449,62 +360,6 @@ mozilla::ReadAheadLib(mozilla::pathstr_t aFilePath) ReadAhead(fd, 0, end); } close(fd); -#elif defined(XP_MACOSX) - ScopedMMap buf(aFilePath); - char* base = buf; - if (!base) { - return; - } - - // An OSX binary might either be a fat (universal) binary or a - // Mach-O binary. A fat binary actually embeds several Mach-O - // binaries. If we have a fat binary, find the offset where the - // Mach-O binary for our CPU type can be found. - struct fat_header* fh = (struct fat_header*)base; - - if (OSSwapBigToHostInt32(fh->magic) == FAT_MAGIC) { - uint32_t nfat_arch = OSSwapBigToHostInt32(fh->nfat_arch); - struct fat_arch* arch = (struct fat_arch*)&buf[sizeof(struct fat_header)]; - for (; nfat_arch; arch++, nfat_arch--) { - if (OSSwapBigToHostInt32(arch->cputype) == CPU_TYPE) { - base += OSSwapBigToHostInt32(arch->offset); - break; - } - } - if (base == buf) { - return; - } - } - - // Check Mach-O magic in the Mach header - struct cpu_mach_header* mh = (struct cpu_mach_header*)base; - if (mh->magic != MH_MAGIC) { - return; - } - - // The Mach header is followed by a sequence of load commands. - // Each command has a header containing the command type and the - // command size. LD_SEGMENT commands describes how the dynamic - // loader is going to map the file in memory. We use that - // information to find the biggest offset from the library that - // will be mapped in memory. - char* cmd = &base[sizeof(struct cpu_mach_header)]; - uint32_t end = 0; - for (uint32_t ncmds = mh->ncmds; ncmds; ncmds--) { - struct segment_command* sh = (struct segment_command*)cmd; - if (sh->cmd != LC_SEGMENT) { - continue; - } - if (end < sh->fileoff + sh->filesize) { - end = sh->fileoff + sh->filesize; - } - cmd += sh->cmdsize; - } - // Let the kernel read ahead what the dynamic loader is going to - // map in memory soon after. - if (end > 0) { - ReadAhead(buf.getFd(), base - buf, end); - } #endif } @@ -531,7 +386,7 @@ mozilla::ReadAheadFile(mozilla::pathstr_t aFilePath, const size_t aOffset, if (!aOutFd) { CloseHandle(fd); } -#elif defined(LINUX) || defined(XP_MACOSX) || defined(XP_SOLARIS) +#elif defined(LINUX) || defined(XP_SOLARIS) if (!aFilePath) { if (aOutFd) { *aOutFd = -1; diff --git a/xpcom/glue/nsCRTGlue.h b/xpcom/glue/nsCRTGlue.h index d3c666d05c..6eda4bf8df 100644 --- a/xpcom/glue/nsCRTGlue.h +++ b/xpcom/glue/nsCRTGlue.h @@ -124,9 +124,7 @@ void NS_MakeRandomString(char* aBuf, int32_t aBufLen); // identify or replace all known path separators. #define KNOWN_PATH_SEPARATORS "\\/" -#if defined(XP_MACOSX) - #define FILE_PATH_SEPARATOR "/" -#elif defined(XP_WIN) +#if defined(XP_WIN) #define FILE_PATH_SEPARATOR "\\" #elif defined(XP_UNIX) #define FILE_PATH_SEPARATOR "/" diff --git a/xpcom/glue/nsThreadUtils.cpp b/xpcom/glue/nsThreadUtils.cpp index b6a37a7b83..8743c0d5fb 100644 --- a/xpcom/glue/nsThreadUtils.cpp +++ b/xpcom/glue/nsThreadUtils.cpp @@ -19,8 +19,6 @@ #ifdef XP_WIN #include <windows.h> -#elif defined(XP_MACOSX) -#include <sys/resource.h> #endif using namespace mozilla; @@ -439,12 +437,6 @@ nsAutoLowPriorityIO::nsAutoLowPriorityIO() #if defined(XP_WIN) lowIOPrioritySet = SetThreadPriority(GetCurrentThread(), THREAD_MODE_BACKGROUND_BEGIN); -#elif defined(XP_MACOSX) - oldPriority = getiopolicy_np(IOPOL_TYPE_DISK, IOPOL_SCOPE_THREAD); - lowIOPrioritySet = oldPriority != -1 && - setiopolicy_np(IOPOL_TYPE_DISK, - IOPOL_SCOPE_THREAD, - IOPOL_THROTTLE) != -1; #else lowIOPrioritySet = false; #endif @@ -457,9 +449,5 @@ nsAutoLowPriorityIO::~nsAutoLowPriorityIO() // On Windows the old thread priority is automatically restored SetThreadPriority(GetCurrentThread(), THREAD_MODE_BACKGROUND_END); } -#elif defined(XP_MACOSX) - if (MOZ_LIKELY(lowIOPrioritySet)) { - setiopolicy_np(IOPOL_TYPE_DISK, IOPOL_SCOPE_THREAD, oldPriority); - } #endif } diff --git a/xpcom/glue/nsThreadUtils.h b/xpcom/glue/nsThreadUtils.h index 01270c1e94..9942a1060a 100644 --- a/xpcom/glue/nsThreadUtils.h +++ b/xpcom/glue/nsThreadUtils.h @@ -1037,9 +1037,6 @@ public: private: bool lowIOPrioritySet; -#if defined(XP_MACOSX) - int oldPriority; -#endif }; void diff --git a/xpcom/glue/standalone/nsXPCOMGlue.cpp b/xpcom/glue/standalone/nsXPCOMGlue.cpp index 68dd58d1ed..e4a5d8bd44 100644 --- a/xpcom/glue/standalone/nsXPCOMGlue.cpp +++ b/xpcom/glue/standalone/nsXPCOMGlue.cpp @@ -97,11 +97,7 @@ static LibHandleType GetLibHandle(pathstr_t aDependentLib) { LibHandleType libHandle = dlopen(aDependentLib, - RTLD_GLOBAL | RTLD_LAZY -#ifdef XP_MACOSX - | RTLD_FIRST -#endif - ); + RTLD_GLOBAL | RTLD_LAZY); if (!libHandle) { fprintf(stderr, "XPCOMGlueLoad error for file %s:\n%s\n", aDependentLib, dlerror()); @@ -235,22 +231,6 @@ XPCOMGlueLoad(const char* aXPCOMFile) char xpcomDir[MAXPATHLEN]; #ifdef XP_WIN const char* lastSlash = ns_strrpbrk(aXPCOMFile, "/\\"); -#elif XP_MACOSX - // On OSX, the dependentlibs.list file lives under Contents/Resources. - // However, the actual libraries listed in dependentlibs.list live under - // Contents/MacOS. We want to read the list from Contents/Resources, then - // load the libraries from Contents/MacOS. - const char *tempSlash = strrchr(aXPCOMFile, '/'); - size_t tempLen = size_t(tempSlash - aXPCOMFile); - if (tempLen > MAXPATHLEN) { - return nullptr; - } - char tempBuffer[MAXPATHLEN]; - memcpy(tempBuffer, aXPCOMFile, tempLen); - tempBuffer[tempLen] = '\0'; - const char *slash = strrchr(tempBuffer, '/'); - tempLen = size_t(slash - tempBuffer); - const char *lastSlash = aXPCOMFile + tempLen; #else const char* lastSlash = strrchr(aXPCOMFile, '/'); #endif @@ -259,19 +239,11 @@ XPCOMGlueLoad(const char* aXPCOMFile) size_t len = size_t(lastSlash - aXPCOMFile); if (len > MAXPATHLEN - sizeof(XPCOM_FILE_PATH_SEPARATOR -#ifdef XP_MACOSX - "Resources" - XPCOM_FILE_PATH_SEPARATOR -#endif XPCOM_DEPENDENT_LIBS_LIST)) { return nullptr; } memcpy(xpcomDir, aXPCOMFile, len); strcpy(xpcomDir + len, XPCOM_FILE_PATH_SEPARATOR -#ifdef XP_MACOSX - "Resources" - XPCOM_FILE_PATH_SEPARATOR -#endif XPCOM_DEPENDENT_LIBS_LIST); cursor = xpcomDir + len + 1; } else { @@ -289,14 +261,6 @@ XPCOMGlueLoad(const char* aXPCOMFile) return nullptr; } -#ifdef XP_MACOSX - tempLen = size_t(cursor - xpcomDir); - if (tempLen > MAXPATHLEN - sizeof("MacOS" XPCOM_FILE_PATH_SEPARATOR) - 1) { - return nullptr; - } - strcpy(cursor, "MacOS" XPCOM_FILE_PATH_SEPARATOR); - cursor += strlen(cursor); -#endif *cursor = '\0'; char buffer[MAXPATHLEN]; |