Issue #1751 -- Remove XP_MACOSX conditionals and support files from /xpcom

This commit is contained in:
Moonchild 2021-05-03 11:35:41 +00:00 committed by roytam1
commit df94ccb22c
40 changed files with 27 additions and 2812 deletions

View file

@ -87,7 +87,7 @@ public:
// Use the system default in ASAN builds, because the default is assumed to be
// larger than the size we want to use and is hopefully sufficient for ASAN.
static const uint32_t kStackSize = nsIThreadManager::DEFAULT_STACK_SIZE;
#elif defined(XP_WIN) || defined(XP_MACOSX) || defined(LINUX)
#elif defined(XP_WIN) || defined(LINUX)
static const uint32_t kStackSize = (256 * 1024);
#else
// All other platforms use their system defaults.

View file

@ -41,7 +41,7 @@
# pragma GCC diagnostic pop // -Wshadow
#endif
#if defined(XP_LINUX) || defined(XP_MACOSX)
#if defined(XP_LINUX)
#include <pthread.h>
#endif
@ -97,8 +97,6 @@ ThreadStackHelper::ThreadStackHelper()
THREAD_SUSPEND_RESUME
, FALSE, 0);
MOZ_ASSERT(mInitialized);
#elif defined(XP_MACOSX)
mThreadID = mach_thread_self();
#endif
}
@ -176,26 +174,6 @@ ThreadStackHelper::GetStack(Stack& aStack)
}
MOZ_ALWAYS_TRUE(::ResumeThread(mThreadID) != DWORD(-1));
#elif defined(XP_MACOSX)
# if defined(MOZ_VALGRIND) && defined(RUNNING_ON_VALGRIND)
if (RUNNING_ON_VALGRIND) {
/* thread_suspend and thread_resume sometimes hang runs on Valgrind,
for unknown reasons. So, just avoid them. See bug 1100911. */
return;
}
# endif
if (::thread_suspend(mThreadID) != KERN_SUCCESS) {
MOZ_ASSERT(false);
return;
}
FillStackBuffer();
FillThreadContext();
MOZ_ALWAYS_TRUE(::thread_resume(mThreadID) == KERN_SUCCESS);
#endif
}

View file

@ -18,8 +18,6 @@
#include <sys/types.h>
#elif defined(XP_WIN)
#include <windows.h>
#elif defined(XP_MACOSX)
#include <mach/mach.h>
#endif
namespace mozilla {
@ -94,10 +92,6 @@ private:
bool mInitialized;
HANDLE mThreadID;
#elif defined(XP_MACOSX)
private:
thread_act_t mThreadID;
#endif
};

View file

@ -19,9 +19,7 @@
#include "nsIWeakReferenceUtils.h"
#include "nsIObserver.h"
#include "nsString.h"
#ifndef XP_MACOSX
#include "prproces.h"
#endif
#if defined(PROCESSMODEL_WINAPI)
#include <windows.h>
#include <shellapi.h>
@ -73,7 +71,7 @@ private:
int32_t mExitValue;
#if defined(PROCESSMODEL_WINAPI)
HANDLE mProcess;
#elif !defined(XP_MACOSX)
#else
PRProcess* mProcess;
#endif
};

View file

@ -33,31 +33,12 @@
#include "nsLiteralString.h"
#include "nsReadableUtils.h"
#else
#ifdef XP_MACOSX
#include <crt_externs.h>
#include <spawn.h>
#include <sys/wait.h>
#include <sys/errno.h>
#endif
#include <sys/types.h>
#include <signal.h>
#endif
using namespace mozilla;
#ifdef XP_MACOSX
cpu_type_t pref_cpu_types[2] = {
#if defined(__i386__)
CPU_TYPE_X86,
#elif defined(__x86_64__)
CPU_TYPE_X86_64,
#elif defined(__ppc__)
CPU_TYPE_POWERPC,
#endif
CPU_TYPE_ANY
};
#endif
//-------------------------------------------------------------------//
// nsIProcess implementation
//-------------------------------------------------------------------//
@ -74,9 +55,7 @@ nsProcess::nsProcess()
, mObserver(nullptr)
, mWeakObserver(nullptr)
, mExitValue(-1)
#if !defined(XP_MACOSX)
, mProcess(nullptr)
#endif
{
}
@ -261,34 +240,16 @@ nsProcess::Monitor(void* aArg)
return;
}
}
#else
#ifdef XP_MACOSX
int exitCode = -1;
int status = 0;
pid_t result;
do {
result = waitpid(process->mPid, &status, 0);
} while (result == -1 && errno == EINTR);
if (result == process->mPid) {
if (WIFEXITED(status)) {
exitCode = WEXITSTATUS(status);
} else if (WIFSIGNALED(status)) {
exitCode = 256; // match NSPR's signal exit status
}
}
#else
int32_t exitCode = -1;
if (PR_WaitProcess(process->mProcess, &exitCode) != PR_SUCCESS) {
exitCode = -1;
}
#endif
// Lock in case Kill or GetExitCode are called during this
{
MutexAutoLock lock(process->mLock);
#if !defined(XP_MACOSX)
process->mProcess = nullptr;
#endif
process->mExitValue = exitCode;
if (process->mShutdown) {
return;
@ -499,34 +460,6 @@ nsProcess::RunProcess(bool aBlocking, char** aMyArgv, nsIObserver* aObserver,
}
mPid = GetProcessId(mProcess);
#elif defined(XP_MACOSX)
// Initialize spawn attributes.
posix_spawnattr_t spawnattr;
if (posix_spawnattr_init(&spawnattr) != 0) {
return NS_ERROR_FAILURE;
}
// Set spawn attributes.
size_t attr_count = ArrayLength(pref_cpu_types);
size_t attr_ocount = 0;
if (posix_spawnattr_setbinpref_np(&spawnattr, attr_count, pref_cpu_types,
&attr_ocount) != 0 ||
attr_ocount != attr_count) {
posix_spawnattr_destroy(&spawnattr);
return NS_ERROR_FAILURE;
}
// Note: |aMyArgv| is already null-terminated as required by posix_spawnp.
pid_t newPid = 0;
int result = posix_spawnp(&newPid, aMyArgv[0], nullptr, &spawnattr, aMyArgv,
*_NSGetEnviron());
mPid = static_cast<int32_t>(newPid);
posix_spawnattr_destroy(&spawnattr);
if (result != 0) {
return NS_ERROR_FAILURE;
}
#else
mProcess = PR_CreateProcess(aMyArgv[0], aMyArgv, nullptr, nullptr);
if (!mProcess) {
@ -605,10 +538,6 @@ nsProcess::Kill()
if (TerminateProcess(mProcess, 0) == 0) {
return NS_ERROR_FAILURE;
}
#elif defined(XP_MACOSX)
if (kill(mPid, SIGKILL) != 0) {
return NS_ERROR_FAILURE;
}
#else
if (!mProcess || (PR_KillProcess(mProcess) != PR_SUCCESS)) {
return NS_ERROR_FAILURE;

View file

@ -52,11 +52,6 @@
#define HAVE_SCHED_SETAFFINITY
#endif
#ifdef XP_MACOSX
#include <mach/mach.h>
#include <mach/thread_policy.h>
#endif
#ifdef MOZ_CANARY
# include <unistd.h>
# include <execinfo.h>
@ -375,16 +370,6 @@ SetThreadAffinity(unsigned int cpu)
sched_setaffinity(0, sizeof(cpus), &cpus);
// Don't assert sched_setaffinity's return value because it intermittently (?)
// fails with EINVAL on Linux x64 try runs.
#elif defined(XP_MACOSX)
// OS X does not provide APIs to pin threads to specific processors, but you
// can tag threads as belonging to the same "affinity set" and the OS will try
// to run them on the same processor. To run threads on different processors,
// tag them as belonging to different affinity sets. Tag 0, the default, means
// "no affinity" so let's pretend each CPU has its own tag `cpu+1`.
thread_affinity_policy_data_t policy;
policy.affinity_tag = cpu + 1;
MOZ_ALWAYS_TRUE(thread_policy_set(mach_thread_self(), THREAD_AFFINITY_POLICY,
&policy.affinity_tag, 1) == KERN_SUCCESS);
#elif defined(XP_WIN)
MOZ_ALWAYS_TRUE(SetThreadIdealProcessor(GetCurrentThread(), cpu) != -1);
#endif