diff --git a/FEXCore/Source/Interface/Core/Core.cpp b/FEXCore/Source/Interface/Core/Core.cpp index 27af56b5d..a888f89ce 100644 --- a/FEXCore/Source/Interface/Core/Core.cpp +++ b/FEXCore/Source/Interface/Core/Core.cpp @@ -985,21 +985,21 @@ void ContextImpl::AddThunkTrampolineIRHandler(uintptr_t Entrypoint, uintptr_t Gu auto Result = AddCustomIREntrypoint( Entrypoint, [this, GuestThunkEntrypoint](uintptr_t Entrypoint, FEXCore::IR::IREmitter* emit) { - auto IRHeader = emit->_IRHeader(emit->Invalid(), Entrypoint, 0, 0, 0, 0); - auto Block = emit->CreateCodeNode(true, 0); - IRHeader.first->Blocks = emit->WrapNode(Block); - emit->SetCurrentCodeBlock(Block); + auto IRHeader = emit->_IRHeader(emit->Invalid(), Entrypoint, 0, 0, 0, 0); + auto Block = emit->CreateCodeNode(true, 0); + IRHeader.first->Blocks = emit->WrapNode(Block); + emit->SetCurrentCodeBlock(Block); - const auto GPRSize = GetGPROpSize(); + const auto GPRSize = GetGPROpSize(); - if (GPRSize == IR::OpSize::i64Bit) { - IR::Ref R = emit->_StoreRegister(emit->_Constant(Entrypoint), GPRSize); - R->Reg = IR::PhysicalRegister(IR::GPRFixedClass, X86State::REG_R11).Raw; - } else { - emit->_StoreContext(GPRSize, IR::FPRClass, emit->_VCastFromGPR(IR::OpSize::i64Bit, IR::OpSize::i64Bit, emit->_Constant(Entrypoint)), - offsetof(Core::CPUState, mm[0][0])); - } - emit->_ExitFunction(IR::OpSize::i64Bit, emit->_Constant(GuestThunkEntrypoint)); + if (GPRSize == IR::OpSize::i64Bit) { + IR::Ref R = emit->_StoreRegister(emit->_Constant(Entrypoint), GPRSize); + R->Reg = IR::PhysicalRegister(IR::GPRFixedClass, X86State::REG_R11).Raw; + } else { + emit->_StoreContext(GPRSize, IR::FPRClass, emit->_VCastFromGPR(IR::OpSize::i64Bit, IR::OpSize::i64Bit, emit->_Constant(Entrypoint)), + offsetof(Core::CPUState, mm[0][0])); + } + emit->_ExitFunction(IR::OpSize::i64Bit, emit->_Constant(GuestThunkEntrypoint)); }, ThunkHandler, (void*)GuestThunkEntrypoint); diff --git a/FEXCore/Source/Interface/Core/Frontend.cpp b/FEXCore/Source/Interface/Core/Frontend.cpp index 911d21c1d..ed6d7cc29 100644 --- a/FEXCore/Source/Interface/Core/Frontend.cpp +++ b/FEXCore/Source/Interface/Core/Frontend.cpp @@ -1331,7 +1331,8 @@ void Decoder::DecodeInstructionsAtEntry(const uint8_t* _InstStream, uint64_t PC, InstStream -= PCOffset; EraseBlock = true; } else { - LogMan::Msg::EFmt("{} instruction in entry block: {:X}", BlockIt->BlockStatus == DecodedBlockStatus::INVALID_INST ? "Invalid" : "NoExec", OpAddress); + LogMan::Msg::EFmt("{} instruction in entry block: {:X}", + BlockIt->BlockStatus == DecodedBlockStatus::INVALID_INST ? "Invalid" : "NoExec", OpAddress); } break; } diff --git a/FEXCore/Source/Interface/Core/JIT/VectorOps.cpp b/FEXCore/Source/Interface/Core/JIT/VectorOps.cpp index 187e4f79a..fb138c97b 100644 --- a/FEXCore/Source/Interface/Core/JIT/VectorOps.cpp +++ b/FEXCore/Source/Interface/Core/JIT/VectorOps.cpp @@ -193,29 +193,29 @@ namespace FEXCore::CPU { VFScalarOperation(IROp->Size, ElementSize, Op->ZeroUpperBits, ScalarEmit, Dst, Vector1, Vector2); \ } -#define DEF_FMAOP_SCALAR_INSERT(FEXOp, ARMOp) \ - DEF_OP(FEXOp) { \ - const auto Op = IROp->C(); \ - const auto ElementSize = Op->Header.ElementSize; \ - \ - auto ScalarEmit = \ - [this, ElementSize](ARMEmitter::VRegister Dst, ARMEmitter::VRegister Src1, ARMEmitter::VRegister Src2, ARMEmitter::VRegister Src3) { \ - if (ElementSize == IR::OpSize::i16Bit) { \ - ARMOp(Dst.H(), Src1.H(), Src2.H(), Src3.H()); \ - } else if (ElementSize == IR::OpSize::i32Bit) { \ - ARMOp(Dst.S(), Src1.S(), Src2.S(), Src3.S()); \ - } else if (ElementSize == IR::OpSize::i64Bit) { \ - ARMOp(Dst.D(), Src1.D(), Src2.D(), Src3.D()); \ - } \ - }; \ - \ - const auto Dst = GetVReg(Node); \ - const auto Upper = GetVReg(Op->Upper); \ - const auto Vector1 = GetVReg(Op->Vector1); \ - const auto Vector2 = GetVReg(Op->Vector2); \ - const auto Addend = GetVReg(Op->Addend); \ - \ - VFScalarFMAOperation(IROp->Size, ElementSize, ScalarEmit, Dst, Upper, Vector1, Vector2, Addend); \ +#define DEF_FMAOP_SCALAR_INSERT(FEXOp, ARMOp) \ + DEF_OP(FEXOp) { \ + const auto Op = IROp->C(); \ + const auto ElementSize = Op->Header.ElementSize; \ + \ + auto ScalarEmit = [this, ElementSize](ARMEmitter::VRegister Dst, ARMEmitter::VRegister Src1, ARMEmitter::VRegister Src2, \ + ARMEmitter::VRegister Src3) { \ + if (ElementSize == IR::OpSize::i16Bit) { \ + ARMOp(Dst.H(), Src1.H(), Src2.H(), Src3.H()); \ + } else if (ElementSize == IR::OpSize::i32Bit) { \ + ARMOp(Dst.S(), Src1.S(), Src2.S(), Src3.S()); \ + } else if (ElementSize == IR::OpSize::i64Bit) { \ + ARMOp(Dst.D(), Src1.D(), Src2.D(), Src3.D()); \ + } \ + }; \ + \ + const auto Dst = GetVReg(Node); \ + const auto Upper = GetVReg(Op->Upper); \ + const auto Vector1 = GetVReg(Op->Vector1); \ + const auto Vector2 = GetVReg(Op->Vector2); \ + const auto Addend = GetVReg(Op->Addend); \ + \ + VFScalarFMAOperation(IROp->Size, ElementSize, ScalarEmit, Dst, Upper, Vector1, Vector2, Addend); \ } DEF_UNOP(VAbs, abs, true) @@ -803,8 +803,8 @@ DEF_OP(VFCMPScalarInsert) { default: break; } }; - auto ScalarEmitUNO = - [this, SubRegSize, ZeroUpperBits, Is256Bit](ARMEmitter::VRegister Dst, ARMEmitter::VRegister Src1, ARMEmitter::VRegister Src2) { + auto ScalarEmitUNO = [this, SubRegSize, ZeroUpperBits, Is256Bit](ARMEmitter::VRegister Dst, ARMEmitter::VRegister Src1, + ARMEmitter::VRegister Src2) { switch (SubRegSize.Scalar) { case ARMEmitter::ScalarRegSize::i16Bit: { fcmge(VTMP1.H(), Src1.H(), Src2.H()); @@ -838,8 +838,8 @@ DEF_OP(VFCMPScalarInsert) { } } }; - auto ScalarEmitNEQ = - [this, SubRegSize, ZeroUpperBits, Is256Bit](ARMEmitter::VRegister Dst, ARMEmitter::VRegister Src1, ARMEmitter::VRegister Src2) { + auto ScalarEmitNEQ = [this, SubRegSize, ZeroUpperBits, Is256Bit](ARMEmitter::VRegister Dst, ARMEmitter::VRegister Src1, + ARMEmitter::VRegister Src2) { switch (SubRegSize.Scalar) { case ARMEmitter::ScalarRegSize::i16Bit: { fcmeq(VTMP1.H(), Src2.H(), Src1.H()); @@ -868,8 +868,8 @@ DEF_OP(VFCMPScalarInsert) { } } }; - auto ScalarEmitORD = - [this, SubRegSize, ZeroUpperBits, Is256Bit](ARMEmitter::VRegister Dst, ARMEmitter::VRegister Src1, ARMEmitter::VRegister Src2) { + auto ScalarEmitORD = [this, SubRegSize, ZeroUpperBits, Is256Bit](ARMEmitter::VRegister Dst, ARMEmitter::VRegister Src1, + ARMEmitter::VRegister Src2) { switch (SubRegSize.Scalar) { case ARMEmitter::ScalarRegSize::i16Bit: { fcmge(VTMP1.H(), Src1.H(), Src2.H()); diff --git a/FEXCore/Source/Interface/Core/OpcodeDispatcher.cpp b/FEXCore/Source/Interface/Core/OpcodeDispatcher.cpp index b35f11484..3d7b8c3e7 100644 --- a/FEXCore/Source/Interface/Core/OpcodeDispatcher.cpp +++ b/FEXCore/Source/Interface/Core/OpcodeDispatcher.cpp @@ -2024,41 +2024,41 @@ void OpDispatchBuilder::RCROp(OpcodeArgs) { Calculate_ShiftVariable( Op, SrcMasked, [this, Op, Size, OpSize]() { - // Rematerialize loads to avoid crossblock liveness - Ref Src = LoadSource(GPRClass, Op, Op->Src[1], Op->Flags, {.AllowUpperGarbage = true}); - Ref Dest = LoadSource(GPRClass, Op, Op->Dest, Op->Flags, {.AllowUpperGarbage = true}); + // Rematerialize loads to avoid crossblock liveness + Ref Src = LoadSource(GPRClass, Op, Op->Src[1], Op->Flags, {.AllowUpperGarbage = true}); + Ref Dest = LoadSource(GPRClass, Op, Op->Dest, Op->Flags, {.AllowUpperGarbage = true}); - // Res = Src >> Shift - Ref Res = _Lshr(OpSize, Dest, Src); - auto CF = GetRFLAG(FEXCore::X86State::RFLAG_CF_RAW_LOC); + // Res = Src >> Shift + Ref Res = _Lshr(OpSize, Dest, Src); + auto CF = GetRFLAG(FEXCore::X86State::RFLAG_CF_RAW_LOC); - auto One = _Constant(OpSizeFromSrc(Op), 1); + auto One = _Constant(OpSizeFromSrc(Op), 1); - // Res |= (Dest << (Size - Shift + 1)); - // Expressed as Res | ((Src << (Size - Shift)) << 1) to get correct - // behaviour for Shift without clobbering NZCV. Then observe that modulo - // Size, Size - Shift = -Shift so we can use a simple Neg. - // - // The masking of Lshl means we don't need mask the source, since: - // - // -(x & Mask) & Mask = (-x) & Mask - Ref NegSrc = _Neg(OpSize, Src); - Res = _Orlshl(OpSize, Res, _Lshl(OpSize, Dest, NegSrc), 1); + // Res |= (Dest << (Size - Shift + 1)); + // Expressed as Res | ((Src << (Size - Shift)) << 1) to get correct + // behaviour for Shift without clobbering NZCV. Then observe that modulo + // Size, Size - Shift = -Shift so we can use a simple Neg. + // + // The masking of Lshl means we don't need mask the source, since: + // + // -(x & Mask) & Mask = (-x) & Mask + Ref NegSrc = _Neg(OpSize, Src); + Res = _Orlshl(OpSize, Res, _Lshl(OpSize, Dest, NegSrc), 1); - // Our new CF will be bit (Shift - 1) of the source. this is hoisted up to - // avoid the need to copy the source. Again, the Lshr absorbs the masking. - auto NewCF = _Lshr(OpSize, Dest, _Sub(OpSize, Src, One)); - SetCFDirect(NewCF, 0, true); + // Our new CF will be bit (Shift - 1) of the source. this is hoisted up to + // avoid the need to copy the source. Again, the Lshr absorbs the masking. + auto NewCF = _Lshr(OpSize, Dest, _Sub(OpSize, Src, One)); + SetCFDirect(NewCF, 0, true); - // Since shift != 0 we can inject the CF - Res = _Or(OpSize, Res, _Lshl(OpSize, CF, NegSrc)); + // Since shift != 0 we can inject the CF + Res = _Or(OpSize, Res, _Lshl(OpSize, CF, NegSrc)); - // OF is the top two MSBs XOR'd together - // Only when Shift == 1, it is undefined otherwise - auto Xor = _XorShift(OpSize, Res, Res, ShiftType::LSR, 1); - SetRFLAG(Xor, Size - 2, true); + // OF is the top two MSBs XOR'd together + // Only when Shift == 1, it is undefined otherwise + auto Xor = _XorShift(OpSize, Res, Res, ShiftType::LSR, 1); + SetRFLAG(Xor, Size - 2, true); - StoreResult(GPRClass, Op, Res, OpSize::iInvalid); + StoreResult(GPRClass, Op, Res, OpSize::iInvalid); }, OpSizeFromSrc(Op) == OpSize::i32Bit ? std::make_optional(&OpDispatchBuilder::ZeroShiftResult) : std::nullopt); } @@ -2243,38 +2243,38 @@ void OpDispatchBuilder::RCLOp(OpcodeArgs) { Calculate_ShiftVariable( Op, SrcMasked, [this, Op, Size, OpSize]() { - // Rematerialized to avoid crossblock liveness - Ref Src = LoadSource(GPRClass, Op, Op->Src[1], Op->Flags, {.AllowUpperGarbage = true}); + // Rematerialized to avoid crossblock liveness + Ref Src = LoadSource(GPRClass, Op, Op->Src[1], Op->Flags, {.AllowUpperGarbage = true}); - // Res = Src << Shift - Ref Dest = LoadSource(GPRClass, Op, Op->Dest, Op->Flags, {.AllowUpperGarbage = true}); - Ref Res = _Lshl(OpSize, Dest, Src); - auto CF = GetRFLAG(FEXCore::X86State::RFLAG_CF_RAW_LOC); + // Res = Src << Shift + Ref Dest = LoadSource(GPRClass, Op, Op->Dest, Op->Flags, {.AllowUpperGarbage = true}); + Ref Res = _Lshl(OpSize, Dest, Src); + auto CF = GetRFLAG(FEXCore::X86State::RFLAG_CF_RAW_LOC); - // Res |= (Dest >> (Size - Shift + 1)), expressed as - // Res | ((Dest >> (-Shift)) >> 1), since Size - Shift = -Shift mod - // Size. The shift aborbs the masking. - auto NegSrc = _Neg(OpSize, Src); - Res = _Orlshr(OpSize, Res, _Lshr(OpSize, Dest, NegSrc), 1); + // Res |= (Dest >> (Size - Shift + 1)), expressed as + // Res | ((Dest >> (-Shift)) >> 1), since Size - Shift = -Shift mod + // Size. The shift aborbs the masking. + auto NegSrc = _Neg(OpSize, Src); + Res = _Orlshr(OpSize, Res, _Lshr(OpSize, Dest, NegSrc), 1); - // Our new CF will be bit (Shift - 1) of the source - auto NewCF = _Lshr(OpSize, Dest, NegSrc); - SetCFDirect(NewCF, 0, true); + // Our new CF will be bit (Shift - 1) of the source + auto NewCF = _Lshr(OpSize, Dest, NegSrc); + SetCFDirect(NewCF, 0, true); - // Since Shift != 0 we can inject the CF. Shift absorbs the masking. - Ref CFShl = _Sub(OpSize, Src, _InlineConstant(1)); - auto TmpCF = _Lshl(OpSize, CF, CFShl); - Res = _Or(OpSize, Res, TmpCF); + // Since Shift != 0 we can inject the CF. Shift absorbs the masking. + Ref CFShl = _Sub(OpSize, Src, _InlineConstant(1)); + auto TmpCF = _Lshl(OpSize, CF, CFShl); + Res = _Or(OpSize, Res, TmpCF); - // OF is the top two MSBs XOR'd together - // Only when Shift == 1, it is undefined otherwise - // - // Note that NewCF has garbage in the upper bits, but we ignore them here - // and mask as part of the set after. - auto NewOF = _XorShift(OpSize, Res, NewCF, ShiftType::LSL, Size - 1); - SetRFLAG(NewOF, Size - 1, true); + // OF is the top two MSBs XOR'd together + // Only when Shift == 1, it is undefined otherwise + // + // Note that NewCF has garbage in the upper bits, but we ignore them here + // and mask as part of the set after. + auto NewOF = _XorShift(OpSize, Res, NewCF, ShiftType::LSL, Size - 1); + SetRFLAG(NewOF, Size - 1, true); - StoreResult(GPRClass, Op, Res, OpSize::iInvalid); + StoreResult(GPRClass, Op, Res, OpSize::iInvalid); }, OpSizeFromSrc(Op) == OpSize::i32Bit ? std::make_optional(&OpDispatchBuilder::ZeroShiftResult) : std::nullopt); } @@ -4664,8 +4664,7 @@ void OpDispatchBuilder::CLWBOrTPause(OpcodeArgs) { if (DestIsMem(Op)) { Ref DestMem = MakeSegmentAddress(Op, Op->Dest); _CacheLineClean(DestMem); - } - else { + } else { if (!CTX->HostFeatures.SupportsWFXT) { UnimplementedOp(Op); } else { @@ -4721,8 +4720,7 @@ void OpDispatchBuilder::UMonitorOrCLRSSBSY(OpcodeArgs) { if (DestIsMem(Op) || !CTX->HostFeatures.SupportsWFXT) { // CLRSSBSY UnimplementedOp(Op); - } - else { + } else { // Explicit NOP implementation of umonitor. } } @@ -4730,8 +4728,7 @@ void OpDispatchBuilder::UMonitorOrCLRSSBSY(OpcodeArgs) { void OpDispatchBuilder::UMWaitOp(OpcodeArgs) { if (DestIsMem(Op) || !CTX->HostFeatures.SupportsWFXT) { UnimplementedOp(Op); - } - else { + } else { // Explicit NOP implementation of umwait. // Still zero flags. // diff --git a/FEXCore/Source/Interface/Core/OpcodeDispatcher/H0F3ATables.h b/FEXCore/Source/Interface/Core/OpcodeDispatcher/H0F3ATables.h index 16178edc2..e0ab881f6 100644 --- a/FEXCore/Source/Interface/Core/OpcodeDispatcher/H0F3ATables.h +++ b/FEXCore/Source/Interface/Core/OpcodeDispatcher/H0F3ATables.h @@ -42,8 +42,8 @@ constexpr auto OpDispatchTableGenH0F3A = []() consteval { auto REX0 = OpDispatchTableGenH0F3AREX.template operator()<0>(); auto REX1 = OpDispatchTableGenH0F3AREX.template operator()<1>(); - auto concat = [](std::array const& lhs, - std::array const& rhs) consteval -> std::array { + auto concat = [](const std::array& lhs, + const std::array& rhs) consteval -> std::array { std::array Table {}; for (size_t i = 0; i < N1; ++i) { Table[i] = lhs[i]; diff --git a/FEXCore/Source/Interface/Core/OpcodeDispatcher/Vector.cpp b/FEXCore/Source/Interface/Core/OpcodeDispatcher/Vector.cpp index 930c457ff..1bcb6e047 100644 --- a/FEXCore/Source/Interface/Core/OpcodeDispatcher/Vector.cpp +++ b/FEXCore/Source/Interface/Core/OpcodeDispatcher/Vector.cpp @@ -2539,8 +2539,7 @@ void OpDispatchBuilder::XSaveOpImpl(OpcodeArgs) { // We need to save MXCSR and MXCSR_MASK if either SSE or AVX are requested to be saved { - StoreIfFlagSet( - 1, [this, Op] { SaveMXCSRState(XSaveBase(Op)); }, 2); + StoreIfFlagSet(1, [this, Op] { SaveMXCSRState(XSaveBase(Op)); }, 2); } // Update XSTATE_BV region of the XSAVE header @@ -2715,13 +2714,11 @@ void OpDispatchBuilder::XRstorOpImpl(OpcodeArgs) { // x87 { - RestoreIfFlagSetOrDefault( - 0, [this, Op] { RestoreX87State(XSaveBase(Op)); }, [this, Op] { DefaultX87State(Op); }); + RestoreIfFlagSetOrDefault(0, [this, Op] { RestoreX87State(XSaveBase(Op)); }, [this, Op] { DefaultX87State(Op); }); } // SSE { - RestoreIfFlagSetOrDefault( - 1, [this, Op] { RestoreSSEState(XSaveBase(Op)); }, [this] { DefaultSSEState(); }); + RestoreIfFlagSetOrDefault(1, [this, Op] { RestoreSSEState(XSaveBase(Op)); }, [this] { DefaultSSEState(); }); } // AVX if (CTX->HostFeatures.SupportsAVX) { @@ -2734,9 +2731,9 @@ void OpDispatchBuilder::XRstorOpImpl(OpcodeArgs) { RestoreIfFlagSetOrDefault( 1, [this, Op] { - Ref Base = XSaveBase(Op); - Ref MXCSR = _LoadMem(GPRClass, OpSize::i32Bit, Base, _Constant(24), OpSize::i32Bit, MEM_OFFSET_SXTX, 1); - RestoreMXCSRState(MXCSR); + Ref Base = XSaveBase(Op); + Ref MXCSR = _LoadMem(GPRClass, OpSize::i32Bit, Base, _Constant(24), OpSize::i32Bit, MEM_OFFSET_SXTX, 1); + RestoreMXCSRState(MXCSR); }, [] { /* Intentionally do nothing*/ }, 2); } diff --git a/FEXCore/Source/Interface/IR/IR.h b/FEXCore/Source/Interface/IR/IR.h index b4a1cb5a5..85dca4dbc 100644 --- a/FEXCore/Source/Interface/IR/IR.h +++ b/FEXCore/Source/Interface/IR/IR.h @@ -54,23 +54,19 @@ struct NodeID final { [[nodiscard]] friend constexpr bool operator==(NodeID, NodeID) noexcept = default; [[nodiscard]] - friend constexpr bool - operator<(NodeID lhs, NodeID rhs) noexcept { + friend constexpr bool operator<(NodeID lhs, NodeID rhs) noexcept { return lhs.Value < rhs.Value; } [[nodiscard]] - friend constexpr bool - operator>(NodeID lhs, NodeID rhs) noexcept { + friend constexpr bool operator>(NodeID lhs, NodeID rhs) noexcept { return operator<(rhs, lhs); } [[nodiscard]] - friend constexpr bool - operator<=(NodeID lhs, NodeID rhs) noexcept { + friend constexpr bool operator<=(NodeID lhs, NodeID rhs) noexcept { return !operator>(lhs, rhs); } [[nodiscard]] - friend constexpr bool - operator>=(NodeID lhs, NodeID rhs) noexcept { + friend constexpr bool operator>=(NodeID lhs, NodeID rhs) noexcept { return !operator<(lhs, rhs); } @@ -183,8 +179,7 @@ struct FEX_PACKED NodeWrapperBase final { } [[nodiscard]] - friend constexpr bool - operator==(const NodeWrapperBase&, const NodeWrapperBase&) = default; + friend constexpr bool operator==(const NodeWrapperBase&, const NodeWrapperBase&) = default; [[nodiscard]] static NodeWrapperBase FromImmediate(uint32_t Immediate) { @@ -423,8 +418,7 @@ struct FEX_PACKED RegisterClassType final { return Val; } [[nodiscard]] - friend constexpr bool - operator==(const RegisterClassType&, const RegisterClassType&) = default; + friend constexpr bool operator==(const RegisterClassType&, const RegisterClassType&) = default; }; struct FEX_PACKED CondClassType final { @@ -433,8 +427,7 @@ struct FEX_PACKED CondClassType final { return Val; } [[nodiscard]] - friend constexpr bool - operator==(const CondClassType&, const CondClassType&) = default; + friend constexpr bool operator==(const CondClassType&, const CondClassType&) = default; }; struct FEX_PACKED MemOffsetType final { @@ -443,8 +436,7 @@ struct FEX_PACKED MemOffsetType final { return Val; } [[nodiscard]] - friend constexpr bool - operator==(const MemOffsetType&, const MemOffsetType&) = default; + friend constexpr bool operator==(const MemOffsetType&, const MemOffsetType&) = default; }; struct FEX_PACKED TypeDefinition final { @@ -479,8 +471,7 @@ struct FEX_PACKED TypeDefinition final { } [[nodiscard]] - friend constexpr bool - operator==(const TypeDefinition&, const TypeDefinition&) = default; + friend constexpr bool operator==(const TypeDefinition&, const TypeDefinition&) = default; }; static_assert(std::is_trivially_copyable_v); @@ -493,8 +484,7 @@ struct FEX_PACKED FenceType final { return Val; } [[nodiscard]] - friend constexpr bool - operator==(const FenceType&, const FenceType&) = default; + friend constexpr bool operator==(const FenceType&, const FenceType&) = default; }; struct FEX_PACKED RoundType final { @@ -503,8 +493,7 @@ struct FEX_PACKED RoundType final { return Val; } [[nodiscard]] - friend constexpr bool - operator==(const RoundType&, const RoundType&) = default; + friend constexpr bool operator==(const RoundType&, const RoundType&) = default; }; class NodeIterator; @@ -537,14 +526,12 @@ public: , Node {Ptr} {} [[nodiscard]] - bool - operator==(const NodeIterator& rhs) const { + bool operator==(const NodeIterator& rhs) const { return Node.NodeOffset == rhs.Node.NodeOffset; } [[nodiscard]] - bool - operator!=(const NodeIterator& rhs) const { + bool operator!=(const NodeIterator& rhs) const { return !operator==(rhs); } @@ -561,15 +548,13 @@ public: } [[nodiscard]] - value_type - operator*() { + value_type operator*() { OrderedNode* RealNode = Node.GetNode(BaseList); return {RealNode, RealNode->Op(IRList)}; } [[nodiscard]] - value_type - operator()() { + value_type operator()() { OrderedNode* RealNode = Node.GetNode(BaseList); return {RealNode, RealNode->Op(IRList)}; } diff --git a/FEXCore/Source/Utils/Profiler.cpp b/FEXCore/Source/Utils/Profiler.cpp index 8dfebd3ce..6f290d30e 100644 --- a/FEXCore/Source/Utils/Profiler.cpp +++ b/FEXCore/Source/Utils/Profiler.cpp @@ -48,7 +48,7 @@ static inline uint64_t GetTime() { #endif namespace FEXCore::Profiler { -ProfilerBlock::ProfilerBlock(std::string_view const Format) +ProfilerBlock::ProfilerBlock(const std::string_view Format) : DurationBegin {GetTime()} , Format {Format} {} @@ -92,7 +92,7 @@ void Shutdown() { } } -void TraceObject(std::string_view const Format, uint64_t Duration) { +void TraceObject(const std::string_view Format, uint64_t Duration) { if (TraceFD != -1) { // Print the duration as something that began negative duration ago const auto StringSize = Format.size() + strlen(" (lduration=-)\n") + 22; @@ -102,7 +102,7 @@ void TraceObject(std::string_view const Format, uint64_t Duration) { } } -void TraceObject(std::string_view const Format) { +void TraceObject(const std::string_view Format) { if (TraceFD != -1) { const auto StringSize = Format.size() + 1; auto Event = reinterpret_cast(alloca(StringSize)); @@ -164,9 +164,9 @@ void Shutdown() { } } -void TraceObject(std::string_view const Format, uint64_t Duration) {} +void TraceObject(const std::string_view Format, uint64_t Duration) {} -void TraceObject(std::string_view const Format) { +void TraceObject(const std::string_view Format) { if (Tracy::Enable) { TracyMessage(Format.data(), Format.size()); } @@ -212,7 +212,7 @@ void Shutdown() { #endif } -void TraceObject(std::string_view const Format, uint64_t Duration) { +void TraceObject(const std::string_view Format, uint64_t Duration) { #if FEXCORE_PROFILER_BACKEND == FEXCORE_PROFILER_BACKEND_GPUVIS GPUVis::TraceObject(Format, Duration); #elif FEXCORE_PROFILER_BACKEND == FEXCORE_PROFILER_BACKEND_TRACY @@ -220,7 +220,7 @@ void TraceObject(std::string_view const Format, uint64_t Duration) { #endif } -void TraceObject(std::string_view const Format) { +void TraceObject(const std::string_view Format) { #if FEXCORE_PROFILER_BACKEND == FEXCORE_PROFILER_BACKEND_GPUVIS GPUVis::TraceObject(Format); #elif FEXCORE_PROFILER_BACKEND == FEXCORE_PROFILER_BACKEND_TRACY diff --git a/FEXCore/include/FEXCore/Config/Config.h b/FEXCore/include/FEXCore/Config/Config.h index 91fc1006c..d388f8243 100644 --- a/FEXCore/include/FEXCore/Config/Config.h +++ b/FEXCore/include/FEXCore/Config/Config.h @@ -75,7 +75,7 @@ enum class LayerType { }; template -static inline std::optional EnumParser(const ArrayPairType& EnumPairs, std::string_view const View) { +static inline std::optional EnumParser(const ArrayPairType& EnumPairs, const std::string_view View) { uint64_t EnumMask {}; auto Results = std::from_chars(View.data(), View.data() + View.size(), EnumMask); if (Results.ec == std::errc()) { diff --git a/FEXCore/include/FEXCore/IR/IR.h b/FEXCore/include/FEXCore/IR/IR.h index 31d11fbf5..b517566ad 100644 --- a/FEXCore/include/FEXCore/IR/IR.h +++ b/FEXCore/include/FEXCore/IR/IR.h @@ -107,14 +107,12 @@ enum IndexNamedVectorConstant : uint8_t { struct SHA256Sum final { uint8_t data[32]; [[nodiscard]] - bool - operator<(const SHA256Sum& rhs) const { + bool operator<(const SHA256Sum& rhs) const { return memcmp(data, rhs.data, sizeof(data)) < 0; } [[nodiscard]] - bool - operator==(const SHA256Sum& rhs) const { + bool operator==(const SHA256Sum& rhs) const { return memcmp(data, rhs.data, sizeof(data)) == 0; } }; diff --git a/FEXCore/include/FEXCore/Utils/EnumUtils.h b/FEXCore/include/FEXCore/Utils/EnumUtils.h index 576e27ac1..26723b198 100644 --- a/FEXCore/include/FEXCore/Utils/EnumUtils.h +++ b/FEXCore/include/FEXCore/Utils/EnumUtils.h @@ -12,20 +12,17 @@ namespace FEXCore { // boilerplate. #define FEX_DECLARE_ENUM_FLAG_OPERATORS(type) \ [[nodiscard]] \ - constexpr type \ - operator|(type a, type b) noexcept { \ + constexpr type operator|(type a, type b) noexcept { \ using T = std::underlying_type_t; \ return static_cast(static_cast(a) | static_cast(b)); \ } \ [[nodiscard]] \ - constexpr type \ - operator&(type a, type b) noexcept { \ + constexpr type operator&(type a, type b) noexcept { \ using T = std::underlying_type_t; \ return static_cast(static_cast(a) & static_cast(b)); \ } \ [[nodiscard]] \ - constexpr type \ - operator^(type a, type b) noexcept { \ + constexpr type operator^(type a, type b) noexcept { \ using T = std::underlying_type_t; \ return static_cast(static_cast(a) ^ static_cast(b)); \ } \ @@ -42,8 +39,7 @@ namespace FEXCore { return a; \ } \ [[nodiscard]] \ - constexpr type \ - operator~(type key) noexcept { \ + constexpr type operator~(type key) noexcept { \ using T = std::underlying_type_t; \ return static_cast(~static_cast(key)); \ } \ diff --git a/FEXCore/include/FEXCore/Utils/File.h b/FEXCore/include/FEXCore/Utils/File.h index aeed5a87d..0d5185e47 100644 --- a/FEXCore/include/FEXCore/Utils/File.h +++ b/FEXCore/include/FEXCore/Utils/File.h @@ -82,7 +82,7 @@ public: #endif } - ssize_t Write(std::string_view const Data) { + ssize_t Write(const std::string_view Data) { return Write(Data.data(), Data.size()); } diff --git a/FEXCore/include/FEXCore/Utils/LogManager.h b/FEXCore/include/FEXCore/Utils/LogManager.h index 30597eee8..3b0f6fba0 100644 --- a/FEXCore/include/FEXCore/Utils/LogManager.h +++ b/FEXCore/include/FEXCore/Utils/LogManager.h @@ -141,10 +141,10 @@ namespace Msg { } \ } while (0); -#define ERROR_AND_DIE_FMT(...) \ - do { \ +#define ERROR_AND_DIE_FMT(...) \ + do { \ LogMan::Msg::MFmt(LogMan::ASSERT, __VA_ARGS__); \ - FEX_TRAP_EXECUTION; \ + FEX_TRAP_EXECUTION; \ } while (0) } // namespace Msg diff --git a/FEXCore/include/FEXCore/Utils/Profiler.h b/FEXCore/include/FEXCore/Utils/Profiler.h index b240ce439..68514d5b1 100644 --- a/FEXCore/include/FEXCore/Utils/Profiler.h +++ b/FEXCore/include/FEXCore/Utils/Profiler.h @@ -81,8 +81,8 @@ FEX_DEFAULT_VISIBILITY void Init(std::string_view ProgramName, std::string_view FEX_DEFAULT_VISIBILITY void PostForkAction(bool IsChild); FEX_DEFAULT_VISIBILITY bool IsActive(); FEX_DEFAULT_VISIBILITY void Shutdown(); -FEX_DEFAULT_VISIBILITY void TraceObject(std::string_view const Format); -FEX_DEFAULT_VISIBILITY void TraceObject(std::string_view const Format, uint64_t Duration); +FEX_DEFAULT_VISIBILITY void TraceObject(const std::string_view Format); +FEX_DEFAULT_VISIBILITY void TraceObject(const std::string_view Format, uint64_t Duration); #define UniqueScopeName2(name, line) name##line #define UniqueScopeName(name, line) UniqueScopeName2(name, line) @@ -97,13 +97,13 @@ FEX_DEFAULT_VISIBILITY void TraceObject(std::string_view const Format, uint64_t // A class that follows scoping rules to generate a profile duration block class ProfilerBlock final { public: - ProfilerBlock(std::string_view const Format); + ProfilerBlock(const std::string_view Format); ~ProfilerBlock(); private: uint64_t DurationBegin; - std::string_view const Format; + const std::string_view Format; }; // Declare a scoped profile block variable with a fixed name. @@ -148,9 +148,9 @@ static void PostForkAction(bool IsChild) {} [[maybe_unused]] static void Shutdown() {} [[maybe_unused]] -static void TraceObject(std::string_view const Format) {} +static void TraceObject(const std::string_view Format) {} [[maybe_unused]] -static void TraceObject(std::string_view const, uint64_t) {} +static void TraceObject(const std::string_view, uint64_t) {} #define FEXCORE_PROFILE_INSTANT(...) \ do { \ diff --git a/Source/Common/AsyncNet.h b/Source/Common/AsyncNet.h index 8b663d43d..dca6e863a 100644 --- a/Source/Common/AsyncNet.h +++ b/Source/Common/AsyncNet.h @@ -257,21 +257,21 @@ struct tcp_acceptor { .revents = 0, }, [ServerFD = FD, &Reactor = Reactor, OnAccept = std::move(OnAccept)](error ec) mutable { - if (ec != error::success) { - return post_callback::drop; - } + if (ec != error::success) { + return post_callback::drop; + } - sockaddr_storage Addr {}; - socklen_t AddrSize {}; - int NewFD; - do { - NewFD = ::accept(ServerFD, reinterpret_cast(&Addr), &AddrSize); - } while (NewFD < 0 && (errno == EINTR || errno == EAGAIN)); - if (NewFD < 0) { - return OnAccept(error::generic_errno, std::nullopt); - } + sockaddr_storage Addr {}; + socklen_t AddrSize {}; + int NewFD; + do { + NewFD = ::accept(ServerFD, reinterpret_cast(&Addr), &AddrSize); + } while (NewFD < 0 && (errno == EINTR || errno == EAGAIN)); + if (NewFD < 0) { + return OnAccept(error::generic_errno, std::nullopt); + } - return OnAccept(error::success, tcp_socket {Reactor, NewFD}); + return OnAccept(error::success, tcp_socket {Reactor, NewFD}); }); } diff --git a/Source/Tools/CommonTools/Linux/Utils/ELFContainer.h b/Source/Tools/CommonTools/Linux/Utils/ELFContainer.h index b21af4a17..fa1fb52b6 100644 --- a/Source/Tools/CommonTools/Linux/Utils/ELFContainer.h +++ b/Source/Tools/CommonTools/Linux/Utils/ELFContainer.h @@ -15,11 +15,11 @@ // Add macros which are missing in some versions of #ifndef ELF32_ST_VISIBILITY -#define ELF32_ST_VISIBILITY(o) ((o)&0x3) +#define ELF32_ST_VISIBILITY(o) ((o) & 0x3) #endif #ifndef ELF64_ST_VISIBILITY -#define ELF64_ST_VISIBILITY(o) ((o)&0x3) +#define ELF64_ST_VISIBILITY(o) ((o) & 0x3) #endif namespace ELFLoader { diff --git a/Source/Tools/FEXLoader/ELFCodeLoader.h b/Source/Tools/FEXLoader/ELFCodeLoader.h index aa1ba0cda..1ddf3445d 100644 --- a/Source/Tools/FEXLoader/ELFCodeLoader.h +++ b/Source/Tools/FEXLoader/ELFCodeLoader.h @@ -32,7 +32,7 @@ #include #define PAGE_START(x) ((x) & ~(uintptr_t)(4095)) -#define PAGE_OFFSET(x) ((x)&4095) +#define PAGE_OFFSET(x) ((x) & 4095) #define PAGE_ALIGN(x) (((x) + 4095) & ~(uintptr_t)(4095)) class ELFCodeLoader final : public FEX::CodeLoader { diff --git a/Source/Tools/FEXLoader/FEXLoader.cpp b/Source/Tools/FEXLoader/FEXLoader.cpp index 0081eeeba..ed9cd9d91 100644 --- a/Source/Tools/FEXLoader/FEXLoader.cpp +++ b/Source/Tools/FEXLoader/FEXLoader.cpp @@ -271,7 +271,7 @@ void SetupCompatInput(bool enable) { } // namespace FEX::CompatInput namespace FEX::GCS { - void CheckForGCS() { +void CheckForGCS() { #ifndef PR_GET_SHADOW_STACK_STATUS #define PR_GET_SHADOW_STACK_STATUS 74 #endif @@ -281,21 +281,21 @@ namespace FEX::GCS { #ifndef PR_SHADOW_STACK_ENABLE #define PR_SHADOW_STACK_ENABLE (1ULL << 0) #endif - uint64_t ShadowStackWord {}; - if (prctl(PR_GET_SHADOW_STACK_STATUS, &ShadowStackWord, 0, 0, 0) == -1) { - return; - } - - // Kernel supports shadow stack. - if (ShadowStackWord & PR_SHADOW_STACK_ENABLE) { - // Welp. - ERROR_AND_DIE_FMT("Shadow stack is enabled which FEX is incompatible with!"); - } - - // Disable if we've gotten this far, to ensure guest can't try. - prctl(PR_LOCK_SHADOW_STACK_STATUS, ~0ULL, 0, 0, 0); + uint64_t ShadowStackWord {}; + if (prctl(PR_GET_SHADOW_STACK_STATUS, &ShadowStackWord, 0, 0, 0) == -1) { + return; } + + // Kernel supports shadow stack. + if (ShadowStackWord & PR_SHADOW_STACK_ENABLE) { + // Welp. + ERROR_AND_DIE_FMT("Shadow stack is enabled which FEX is incompatible with!"); + } + + // Disable if we've gotten this far, to ensure guest can't try. + prctl(PR_LOCK_SHADOW_STACK_STATUS, ~0ULL, 0, 0, 0); } +} // namespace FEX::GCS /** * @brief Get an FD from an environment variable and then unset the environment variable. diff --git a/Source/Tools/FEXServer/ProcessPipe.cpp b/Source/Tools/FEXServer/ProcessPipe.cpp index b3eca20d8..b4375fedb 100644 --- a/Source/Tools/FEXServer/ProcessPipe.cpp +++ b/Source/Tools/FEXServer/ProcessPipe.cpp @@ -219,14 +219,14 @@ bool InitializeServerSocket(bool abstract) { .revents = 0, }, [Socket = std::move(Socket).value()](fasio::error ec) mutable { - if (ec != fasio::error::success) { - close(Socket.FD); - --NumClients; - return fasio::post_callback::drop; - } - HandleSocketData(Socket); - // Wait for next data - return fasio::post_callback::repeat; + if (ec != fasio::error::success) { + close(Socket.FD); + --NumClients; + return fasio::post_callback::drop; + } + HandleSocketData(Socket); + // Wait for next data + return fasio::post_callback::repeat; }); // Wait for next connection diff --git a/Source/Tools/LinuxEmulation/LinuxSyscalls/GdbServer.cpp b/Source/Tools/LinuxEmulation/LinuxSyscalls/GdbServer.cpp index fbe442811..ae0015d80 100644 --- a/Source/Tools/LinuxEmulation/LinuxSyscalls/GdbServer.cpp +++ b/Source/Tools/LinuxEmulation/LinuxSyscalls/GdbServer.cpp @@ -99,28 +99,28 @@ GdbServer::GdbServer(FEXCore::Context::Context* ctx, FEX::HLE::SignalDelegator* SignalDelegation->RegisterHostSignalHandler( Signal, [this](FEXCore::Core::InternalThreadState* Thread, int Signal, void* info, void* ucontext) { - if (PassSignals[Signal]) { - // Pass signal to the guest - return false; - } + if (PassSignals[Signal]) { + // Pass signal to the guest + return false; + } - auto ThreadObject = FEX::HLE::ThreadManager::GetStateObjectFromFEXCoreThread(Thread); - ThreadObject->GdbInfo = {}; - ThreadObject->GdbInfo->Signal = Signal; + auto ThreadObject = FEX::HLE::ThreadManager::GetStateObjectFromFEXCoreThread(Thread); + ThreadObject->GdbInfo = {}; + ThreadObject->GdbInfo->Signal = Signal; - ThreadObject->GdbInfo->SignalPC = ArchHelpers::Context::GetPc(ucontext); - this->SignalDelegation->SpillSRA(Thread, ucontext, Thread->CurrentFrame->InSyscallInfo); + ThreadObject->GdbInfo->SignalPC = ArchHelpers::Context::GetPc(ucontext); + this->SignalDelegation->SpillSRA(Thread, ucontext, Thread->CurrentFrame->InSyscallInfo); - memcpy(ThreadObject->GdbInfo->GPRs, ArchHelpers::Context::GetArmGPRs(ucontext), sizeof(ThreadObject->GdbInfo->GPRs)); - ThreadObject->GdbInfo->PState = ArchHelpers::Context::GetArmPState(ucontext); + memcpy(ThreadObject->GdbInfo->GPRs, ArchHelpers::Context::GetArmGPRs(ucontext), sizeof(ThreadObject->GdbInfo->GPRs)); + ThreadObject->GdbInfo->PState = ArchHelpers::Context::GetArmPState(ucontext); - // Let GDB know that we have a signal - this->Break(Thread, Signal); + // Let GDB know that we have a signal + this->Break(Thread, Signal); - WaitForThreadWakeup(); - ThreadObject->GdbInfo.reset(); + WaitForThreadWakeup(); + ThreadObject->GdbInfo.reset(); - return true; + return true; }, true); } diff --git a/Source/Tools/LinuxEmulation/LinuxSyscalls/LinuxAllocator.cpp b/Source/Tools/LinuxEmulation/LinuxSyscalls/LinuxAllocator.cpp index 5d2604f4a..d99ad7215 100644 --- a/Source/Tools/LinuxEmulation/LinuxSyscalls/LinuxAllocator.cpp +++ b/Source/Tools/LinuxEmulation/LinuxSyscalls/LinuxAllocator.cpp @@ -176,7 +176,7 @@ void* MemAllocator32Bit::Mmap(void* addr, size_t length, int prot, int flags, in auto AllocateNoHint = [&]() -> void* { bool Wrapped = false; uint64_t BottomPage = Map32Bit && (LastScanLocation >= LastKeyLocation32Bit) ? LastKeyLocation32Bit : LastScanLocation; -restart : { +restart: { // Linear range scan uint64_t LowerPage = (this->*FindPageRangePtr)(BottomPage, PagesLength); if (LowerPage == 0) { @@ -452,7 +452,7 @@ uint64_t MemAllocator32Bit::Shmat(int shmid, const void* shmaddr, int shmflg, ui bool Wrapped = false; uint64_t BottomPage = LastScanLocation; -restart : { +restart: { // Linear range scan uint64_t LowerPage = (this->*FindPageRangePtr)(BottomPage, PagesLength); if (LowerPage == 0) { diff --git a/Source/Tools/LinuxEmulation/LinuxSyscalls/Seccomp/Dumper.cpp b/Source/Tools/LinuxEmulation/LinuxSyscalls/Seccomp/Dumper.cpp index bf2a3764c..4b8459833 100644 --- a/Source/Tools/LinuxEmulation/LinuxSyscalls/Seccomp/Dumper.cpp +++ b/Source/Tools/LinuxEmulation/LinuxSyscalls/Seccomp/Dumper.cpp @@ -14,7 +14,7 @@ $end_info$ namespace FEX::HLE { void SeccompEmulator::DumpProgram(const sock_fprog* prog) { auto Parse_Class_LD = [](uint32_t BPFIP, const sock_filter* Inst) { - auto DestName = [](sock_filter const* Inst) { + auto DestName = [](const sock_filter* Inst) { if (BPF_CLASS(Inst->code) == BPF_LD) { return "A"; } else { @@ -22,7 +22,7 @@ void SeccompEmulator::DumpProgram(const sock_fprog* prog) { } }; - auto AccessSize = [](sock_filter const* Inst) { + auto AccessSize = [](const sock_filter* Inst) { switch (BPF_SIZE(Inst->code)) { case BPF_W: return 32; case BPF_H: return 16; @@ -32,7 +32,7 @@ void SeccompEmulator::DumpProgram(const sock_fprog* prog) { return 0; }; - auto ModeType = [](sock_filter const* Inst) { + auto ModeType = [](const sock_filter* Inst) { switch (BPF_MODE(Inst->code)) { case BPF_IMM: return "IMM"; case BPF_ABS: return "ABS"; @@ -44,7 +44,7 @@ void SeccompEmulator::DumpProgram(const sock_fprog* prog) { return "Unknown"; }; - auto LoadName = [](sock_filter const* Inst) { + auto LoadName = [](const sock_filter* Inst) { using namespace std::string_view_literals; switch (BPF_MODE(Inst->code)) { case BPF_IMM: return fextl::fmt::format("#{}", Inst->k); @@ -61,7 +61,7 @@ void SeccompEmulator::DumpProgram(const sock_fprog* prog) { }; auto Parse_Class_ST = [](uint32_t BPFIP, const sock_filter* Inst) { - auto DestName = [](sock_filter const* Inst) { + auto DestName = [](const sock_filter* Inst) { if (BPF_CLASS(Inst->code) == BPF_ST) { return "A"; } else { @@ -73,7 +73,7 @@ void SeccompEmulator::DumpProgram(const sock_fprog* prog) { }; auto Parse_Class_ALU = [](uint32_t BPFIP, const sock_filter* Inst) { - auto GetOp = [](sock_filter const* Inst) { + auto GetOp = [](const sock_filter* Inst) { const auto Op = BPF_OP(Inst->code); switch (Op) { @@ -92,7 +92,7 @@ void SeccompEmulator::DumpProgram(const sock_fprog* prog) { } }; - auto GetSrc = [](sock_filter const* Inst) { + auto GetSrc = [](const sock_filter* Inst) { switch (BPF_SRC(Inst->code)) { case BPF_K: return fextl::fmt::format("0x{:x}", Inst->k); case BPF_X: return fextl::fmt::format(""); @@ -104,7 +104,7 @@ void SeccompEmulator::DumpProgram(const sock_fprog* prog) { }; auto Parse_Class_JMP = [](uint32_t BPFIP, const sock_filter* Inst) { - auto GetOp = [](sock_filter const* Inst) { + auto GetOp = [](const sock_filter* Inst) { switch (BPF_OP(Inst->code)) { case BPF_JA: return "a"; case BPF_JEQ: return "eq"; @@ -115,7 +115,7 @@ void SeccompEmulator::DumpProgram(const sock_fprog* prog) { return "Unknown"; }; - auto GetSrc = [](sock_filter const* Inst) { + auto GetSrc = [](const sock_filter* Inst) { switch (BPF_SRC(Inst->code)) { case BPF_K: return fextl::fmt::format("0x{:x}", Inst->k); case BPF_X: return fextl::fmt::format(""); @@ -128,7 +128,7 @@ void SeccompEmulator::DumpProgram(const sock_fprog* prog) { }; auto Parse_Class_RET = [](uint32_t BPFIP, const sock_filter* Inst) { - auto GetRetValue = [](sock_filter const* Inst) { + auto GetRetValue = [](const sock_filter* Inst) { switch (BPF_RVAL(Inst->code)) { case BPF_K: { uint32_t RetData = Inst->k & SECCOMP_RET_DATA; diff --git a/Source/Tools/LinuxEmulation/LinuxSyscalls/SignalDelegator.h b/Source/Tools/LinuxEmulation/LinuxSyscalls/SignalDelegator.h index 5fefa13c6..5fbffeed2 100644 --- a/Source/Tools/LinuxEmulation/LinuxSyscalls/SignalDelegator.h +++ b/Source/Tools/LinuxEmulation/LinuxSyscalls/SignalDelegator.h @@ -159,7 +159,7 @@ private: } FEX_CONFIG_OPT(Is64BitMode, IS64BIT_MODE); - fextl::string const ApplicationName; + const fextl::string ApplicationName; FEX_CONFIG_OPT(ParanoidTSO, PARANOIDTSO); FEX_CONFIG_OPT(HalfBarrierTSOEnabled, HALFBARRIERTSOENABLED); diff --git a/Source/Tools/LinuxEmulation/LinuxSyscalls/SyscallsVMATracking.h b/Source/Tools/LinuxEmulation/LinuxSyscalls/SyscallsVMATracking.h index d76cf9431..5c0f0e693 100644 --- a/Source/Tools/LinuxEmulation/LinuxSyscalls/SyscallsVMATracking.h +++ b/Source/Tools/LinuxEmulation/LinuxSyscalls/SyscallsVMATracking.h @@ -17,7 +17,7 @@ namespace FEX::HLE::VMATracking { namespace SpecialDev { static constexpr uint64_t Anon = 0x1'0000'0000; // Anonymous shared mapping, id is incrementing allocation number static constexpr uint64_t SHM = 0x2'0000'0000; // sys-v shm, id is shmid -}; // namespace SpecialDev +}; // namespace SpecialDev // Memory Resource ID // An id that can be used to identify when shared mappings actually have the same backing storage diff --git a/Source/Tools/TestHarnessRunner/TestHarnessRunner.cpp b/Source/Tools/TestHarnessRunner/TestHarnessRunner.cpp index 5156324cd..9c858d37c 100644 --- a/Source/Tools/TestHarnessRunner/TestHarnessRunner.cpp +++ b/Source/Tools/TestHarnessRunner/TestHarnessRunner.cpp @@ -121,14 +121,14 @@ void RegisterLongJumpHandler(FEX::HLE::SignalDelegator* Handler) { Handler->RegisterFrontendHostSignalHandler( SIGSEGV, [](FEXCore::Core::InternalThreadState* Thread, int Signal, void* info, void* ucontext) { - constexpr uint8_t HLT = 0xF4; - if (reinterpret_cast(Thread->CurrentFrame->State.rip)[0] != HLT) { - DidFault = true; - return false; - } + constexpr uint8_t HLT = 0xF4; + if (reinterpret_cast(Thread->CurrentFrame->State.rip)[0] != HLT) { + DidFault = true; + return false; + } - longjmp(LongJumpHandler::LongJump, 1); - return false; + longjmp(LongJumpHandler::LongJump, 1); + return false; }, true); } diff --git a/Source/Windows/Common/CRT/String.cpp b/Source/Windows/Common/CRT/String.cpp index dab3cb860..83c9a749c 100644 --- a/Source/Windows/Common/CRT/String.cpp +++ b/Source/Windows/Common/CRT/String.cpp @@ -171,7 +171,7 @@ size_t wcrtomb(char* __restrict__ _Dest, wchar_t _Source, mbstate_t* __restrict_ UNIMPLEMENTED(); } -DLLEXPORT_FUNC(errno_t, wcrtomb_s, (size_t * _Retval, char* _Dst, size_t _SizeInBytes, wchar_t _Ch, mbstate_t* _State)) { +DLLEXPORT_FUNC(errno_t, wcrtomb_s, (size_t* _Retval, char* _Dst, size_t _SizeInBytes, wchar_t _Ch, mbstate_t* _State)) { UNIMPLEMENTED(); } diff --git a/Source/Windows/include/winternl.h b/Source/Windows/include/winternl.h index 6714fa44a..ac3683b3c 100644 --- a/Source/Windows/include/winternl.h +++ b/Source/Windows/include/winternl.h @@ -178,7 +178,7 @@ typedef struct __PEB { /* win32/win64 */ #ifdef _WIN64 ULONG GdiHandleBuffer[60]; /* /140 */ #else - ULONG GdiHandleBuffer[34]; /* 0c4/ */ + ULONG GdiHandleBuffer[34]; /* 0c4/ */ #endif PVOID PostProcessInitRoutine; /* 14c/230 */ PRTL_BITMAP TlsExpansionBitmap; /* 150/238 */ @@ -259,7 +259,7 @@ typedef struct __TEB { /* win32/win64 */ #ifdef _WIN64 PVOID SystemReserved1[30]; /* /0190 */ #else - PVOID SystemReserved1[26]; /* 10c/ used for krnl386 private data in Wine */ + PVOID SystemReserved1[26]; /* 10c/ used for krnl386 private data in Wine */ #endif char PlaceholderCompatibilityMode; /* 174/0280 */ BOOLEAN PlaceholderHydrationAlwaysExplicit; /* 175/0281 */ @@ -309,7 +309,7 @@ typedef struct __TEB { /* win32/win64 */ #ifdef _WIN64 PVOID Instrumentation[11]; /* /16b8 */ #else - PVOID Instrumentation[9]; /* f2c/ */ + PVOID Instrumentation[9]; /* f2c/ */ #endif GUID ActivityId; /* f50/1710 */ PVOID SubProcessTag; /* f60/1720 */ diff --git a/ThunkLibs/include/common/PackedArguments.h b/ThunkLibs/include/common/PackedArguments.h index 4a9efcbf5..447bffe8c 100644 --- a/ThunkLibs/include/common/PackedArguments.h +++ b/ThunkLibs/include/common/PackedArguments.h @@ -199,8 +199,8 @@ struct __attribute__((packed)) PackedArguments -struct __attribute__((packed)) -PackedArguments { +struct __attribute__(( + packed)) PackedArguments { A0 a0; A1 a1; A2 a2; @@ -230,8 +230,8 @@ PackedArguments -struct __attribute__((packed)) -PackedArguments { +struct __attribute__(( + packed)) PackedArguments { A0 a0; A1 a1; A2 a2; diff --git a/ThunkLibs/libwayland-client/Host.cpp b/ThunkLibs/libwayland-client/Host.cpp index 37aac4587..41bca8a52 100644 --- a/ThunkLibs/libwayland-client/Host.cpp +++ b/ThunkLibs/libwayland-client/Host.cpp @@ -479,13 +479,13 @@ void fexfn_impl_libwayland_client_fex_wl_exchange_interface_pointer(guest_layout // NOTE: These arrays are complements to global symbols in the guest, so we // never explicitly free this memory - guest_interface.data.methods.data = (uintptr_t) new guest_layout[host_interface->method_count]; + guest_interface.data.methods.data = (uintptr_t)new guest_layout[host_interface->method_count]; for (int i = 0; i < host_interface->method_count; ++i) { guest_interface.data.methods.get_pointer()[i] = to_guest(to_host_layout(host_interface->methods[i])); guest_interface.data.methods.get_pointer()[i].data.types = to_guest(to_host_layout(host_interface->methods[i].types)); } - guest_interface.data.events.data = (uintptr_t) new guest_layout[host_interface->event_count]; + guest_interface.data.events.data = (uintptr_t)new guest_layout[host_interface->event_count]; for (int i = 0; i < host_interface->event_count; ++i) { guest_interface.data.events.get_pointer()[i] = to_guest(to_host_layout(host_interface->events[i])); guest_interface.data.events.get_pointer()[i].data.types = to_guest(to_host_layout(host_interface->events[i].types)); diff --git a/unittests/FEXLinuxTests/tests/syscalls/syscalls_efault.cpp b/unittests/FEXLinuxTests/tests/syscalls/syscalls_efault.cpp index 1c61ed0cc..9e598496b 100644 --- a/unittests/FEXLinuxTests/tests/syscalls/syscalls_efault.cpp +++ b/unittests/FEXLinuxTests/tests/syscalls/syscalls_efault.cpp @@ -34,7 +34,9 @@ TEST_CASE("ppoll") { SECTION("invalid timespec") { struct pollfd valid_fds { - .fd = STDOUT_FILENO, .events = 0, .revents = 0, + .fd = STDOUT_FILENO, + .events = 0, + .revents = 0, }; auto ret = ::syscall(SYS_ppoll, &valid_fds, 1, invalid_timespec, nullptr, sizeof(uint64_t)); REQUIRE(ret == -1); @@ -43,7 +45,9 @@ TEST_CASE("ppoll") { SECTION("invalid sigset") { struct pollfd valid_fds { - .fd = STDOUT_FILENO, .events = 0, .revents = 0, + .fd = STDOUT_FILENO, + .events = 0, + .revents = 0, }; struct timespec valid_ts {}; @@ -54,7 +58,9 @@ TEST_CASE("ppoll") { SECTION("valid configuration") { struct pollfd valid_fds { - .fd = STDOUT_FILENO, .events = 0, .revents = 0, + .fd = STDOUT_FILENO, + .events = 0, + .revents = 0, }; struct timespec valid_ts {}; @@ -66,7 +72,9 @@ TEST_CASE("ppoll") { SECTION("invalid timespec write-back") { struct pollfd valid_fds { - .fd = STDOUT_FILENO, .events = 0, .revents = 0, + .fd = STDOUT_FILENO, + .events = 0, + .revents = 0, }; // Kernel will read timespec, but it then can't write the result back. @@ -112,7 +120,9 @@ TEST_CASE("ppoll_64") { SECTION("invalid timespec") { struct pollfd valid_fds { - .fd = STDOUT_FILENO, .events = 0, .revents = 0, + .fd = STDOUT_FILENO, + .events = 0, + .revents = 0, }; auto ret = ::syscall(SYS_ppoll_time64, &valid_fds, 1, invalid_timespec, nullptr, sizeof(uint64_t)); REQUIRE(ret == -1); @@ -121,7 +131,9 @@ TEST_CASE("ppoll_64") { SECTION("invalid sigset") { struct pollfd valid_fds { - .fd = STDOUT_FILENO, .events = 0, .revents = 0, + .fd = STDOUT_FILENO, + .events = 0, + .revents = 0, }; timespec64 valid_ts {}; @@ -132,7 +144,9 @@ TEST_CASE("ppoll_64") { SECTION("valid configuration") { struct pollfd valid_fds { - .fd = STDOUT_FILENO, .events = 0, .revents = 0, + .fd = STDOUT_FILENO, + .events = 0, + .revents = 0, }; timespec64 valid_ts {}; @@ -144,7 +158,9 @@ TEST_CASE("ppoll_64") { SECTION("invalid timespec write-back") { struct pollfd valid_fds { - .fd = STDOUT_FILENO, .events = 0, .revents = 0, + .fd = STDOUT_FILENO, + .events = 0, + .revents = 0, }; // Kernel will read timespec, but it then can't write the result back. diff --git a/unittests/ThunkLibs/generator.cpp b/unittests/ThunkLibs/generator.cpp index 1f6b968c8..c5644a2c8 100644 --- a/unittests/ThunkLibs/generator.cpp +++ b/unittests/ThunkLibs/generator.cpp @@ -434,12 +434,10 @@ TEST_CASE_METHOD(Fixture, "VersionedLibrary") { #if CLANG_VERSION_MAJOR >= 17 CHECK_THAT(output, matches(callExpr(callee(functionDecl(hasName("dlopen"))), hasArgument(0, stringLiteral().bind("libname")))) - .check_binding( - "libname", +[](const clang::StringLiteral* lit) { return lit->getString().ends_with(".so.123"); })); + .check_binding("libname", +[](const clang::StringLiteral* lit) { return lit->getString().ends_with(".so.123"); })); #else CHECK_THAT(output, matches(callExpr(callee(functionDecl(hasName("dlopen"))), hasArgument(0, stringLiteral().bind("libname")))) - .check_binding( - "libname", +[](const clang::StringLiteral* lit) { return lit->getString().endswith(".so.123"); })); + .check_binding("libname", +[](const clang::StringLiteral* lit) { return lit->getString().endswith(".so.123"); })); #endif } @@ -577,8 +575,7 @@ TEST_CASE_METHOD(Fixture, "LayoutWrappers") { has(fieldDecl(hasName("data"), hasType(hasCanonicalType(asString("struct A"))))))); const auto layout_undefined = [](const char* type) { return matches(classTemplateSpecializationDecl(hasName(type), hasAnyTemplateArgument(refersToType(asString("struct A")))).bind("layout")) - .check_binding( - "layout", +[](const clang::ClassTemplateSpecializationDecl* decl) { return !decl->isCompleteDefinition(); }); + .check_binding("layout", +[](const clang::ClassTemplateSpecializationDecl* decl) { return !decl->isCompleteDefinition(); }); }; const auto guest_converter_defined = matches(functionDecl( hasName("to_guest"),