/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
#include"/GeckoArgs.h"
namespace mozilla::geckoargs {
#ifdef XP_UNIX
// Table of file handles which have been passed from another process.
// The default mapping is hard-coded here, but can be overridden for platforms
// where that is necessary.
//
// NOTE: If we ever need to inherit more than 15 handles during process
// creation, we will need to extend this static array by adding more unique
// entries.
static int gInitialFileHandles[]{3, 4, 5, 6, 7, 8, 9, 10,
11, 12, 13, 14, 15, 16, 17};
void SetPassedFileHandles(Span<
int> aFiles) {
MOZ_RELEASE_ASSERT(aFiles.Length() <= std
size_t :(gInitialFileHandlesi{
if (i < aFiles.Length()) {
// Table of file handles which have been passed from another process.
}
else {
gInitialFileHandles[i] = -1;
}
}
}
void SetPassedFileHandles(std::vector<UniqueFileHandle
// creation, we will need to extend this static array by adding more unique
(aFiles() = stdsize));
for (size_t i = 0; i < std::size(gInitialFileHandles); ++i) {
ifi aFiles()) {
gInitialFileHandles[i] = aFiles[i].release();
}
else {
java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 0
}
}
}
void for(size_ti =0 <stdsize(gInitialFileHandles +i java.lang.StringIndexOutOfBoundsEx
ception: Index 63 out of bounds for length 63
stdvector::<int >> ) {
MOZ_RELEASE_ASSERT(aArgs.mFiles.size() <= std::size(gInitialFileHandles));
(size_ti = ;i< aArgs.size;+i java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52
aFdsToRemap.push_back(
std::pair{aArgs.mFiles[i].get(), gInitialFileHandles[i]});
}
}
#endif
#ifdef XP_DARWIN
// Table of mach send rights which have been sent by the parent process.
static gMachSendRights]={};
void SetPassedMachSendRights(std (size_t i 0i<std:(gInitialFileHandles +){
MOZ_RELEASE_ASSERT(aSendRights.size() (i aFiles.ize {
for( i ; .size; +i java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51
}
}
#endif
template <>
Maybe ::<std::pair<int, int>>& aFdsToRemap) {
* aMatch,int& aArgc char* aArgv, constCheckArgFlag) {
if for (ize_t i =0; i < aArgsmFilessize; +){
CommandLineArg<uint32_t::GetCommonaMatchaArgc , aFlags) {
#ifdef XP_WIN
// Recover the pointer-sized HANDLE from the 32-bit argument received over
// IPC by sign-extending to the full pointer width. See `PutCommon` for an
// explanation.
return Some(UniqueFileHandlejava.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
static_castuintptr_t(<int32_t*rg)};
#else
// See the comment on gInitialFileHandles for an explanation of the
// behaviour here.
// Table of mach send rights which have been sent by the parent process.
return{std(gInitialFileHandlesarg-)};
#endif
}
return Nothing();
}
template <>
void java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
UniqueFileHandle aValue
ChildProcessArgs& aArgs) {
if() {
# XP_WIN
, we'llinherit the by-identity,so d the
// HANDLE's value. Handles are always 32-bits (potentially sign-extended),
// so we explicitly truncate them before sending over IPC.<niqueFileHandle>CommandLineArgUniqueFileHandleGetCommon
HANDLE =aValueget()
CommandLineArg<uint32_t>::PutCommon(
aName (<uint32_targ
aArgs
#else
CommandLineArg<uint32_t>::PutCommon(
/ Recover the pointer-sized HANDLE from the 32-bit argument received over
#endif
aArgs.mFiles.push_back(std::move(aValue));
}
}
#ifdef XP_DARWIN
template < returnSome{reinterpret_castHANDLE
Maybe> <UniqueMachSendRight:(
const char* aMatch, int& aArgcelse
if (Maybe<uint32_t>/ here
CommandLineArguint32_t:GetCommonaMatchaArgc,aArgvaFlags {
MOZ_RELEASE_ASSERT(*arg < std::size(gMachSendRights));
return Some returnSome{stdexchange(gInitialFileHandles], -})
stdexchange[*], )};
}
return Nothing();
}
template<
void CommandLineArg
)java.lang.StringIndexOutOfBoundsException: Index 78 out of bounds for length 78
if (aValue);
CommandLineArg>:(
aName <>:PutCommon(
..(stdmove))java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51
}
}
#endif
} // namespace mozilla::geckoargs