2
0
mirror of https://github.com/rehlds/rehlds.git synced 2025-02-05 18:20:45 +03:00

Fixed crash hlds, when building with GCC 6.X and later

Fix gcc compile
This commit is contained in:
s1lent 2017-07-24 01:09:08 +07:00
parent 2cf2fc6b63
commit b0660861cb
No known key found for this signature in database
GPG Key ID: 0FE401DC73916B5C
10 changed files with 101 additions and 26 deletions

View File

@ -155,7 +155,7 @@
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>HOOK_HLTV;HLTV;WIN32;NDEBUG;_WINDOWS;_USRDLL;DEMOPLAYER_MODULE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitiHOOons)</PreprocessorDefinitions>
<PreprocessorDefinitions>HLTV;WIN32;NDEBUG;_WINDOWS;_USRDLL;DEMOPLAYER_MODULE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitiHOOons)</PreprocessorDefinitions>
<PrecompiledHeaderFile>precompiled.h</PrecompiledHeaderFile>
<AdditionalIncludeDirectories>$(ProjectDir)\..\src;$(ProjectDir)\..\..\;$(ProjectDir)\..\..\..\;$(ProjectDir)\..\..\..\common;$(ProjectDir)\..\..\..\engine;$(ProjectDir)\..\..\..\public;$(ProjectDir)\..\..\..\public\rehlds;$(ProjectDir)\..\..\..\pm_shared;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>

View File

@ -35,7 +35,7 @@
#include "vmodes.h"
#include "cdll_int.h"
#include "IDemoPlayer.h"
#include "IEngineWrapper.h"
#include "IEngineWrapperEx.h"
#include "BaseSystemModule.h"
#include "ObjectDictionary.h"

View File

@ -0,0 +1,77 @@
/*
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#pragma once
#include "event_args.h"
#include "vmodes.h"
#include "cdll_int.h"
class IBaseSystem;
class ISystemModule;
// TODO: common/IEngineWrapper.h
class IEngineWrapperEx {
public:
virtual ~IEngineWrapperEx() {}
virtual bool Init(IBaseSystem *system, int serial, char *name) = 0;
virtual void RunFrame(double time) = 0;
virtual void ReceiveSignal(ISystemModule *module, unsigned int signal, void *data) = 0;
virtual void ExecuteCommand(int commandID, char *commandLine) = 0;
virtual void RegisterListener(ISystemModule *module) = 0;
virtual void RemoveListener(ISystemModule *module) = 0;
virtual IBaseSystem *GetSystem() = 0;
virtual int GetSerial() = 0;
virtual char *GetStatusLine() = 0;
virtual char *GetType() = 0;
virtual char *GetName() = 0;
virtual int GetState() = 0;
virtual int GetVersion() = 0;
virtual void ShutDown() = 0;
virtual bool GetViewOrigin(float *origin) = 0;
virtual bool GetViewAngles(float *angles) = 0;
virtual int GetTraceEntity() = 0;
virtual float GetCvarFloat(char *szName) = 0;
virtual char *GetCvarString(char *szName) = 0;
virtual void SetCvar(char *szName, char *szValue) = 0;
virtual void Cbuf_AddText(char *text) = 0;
virtual void DemoUpdateClientData(client_data_t *cdat) = 0;
virtual void CL_QueueEvent(int flags, int index, float delay, event_args_t *pargs) = 0;
virtual void HudWeaponAnim(int iAnim, int body) = 0;
virtual void CL_DemoPlaySound(int channel, char *sample, float attenuation, float volume, int flags, int pitch) = 0;
virtual void ClientDLL_ReadDemoBuffer(int size, unsigned char *buffer) = 0;
};
using IEngineWrapper = IEngineWrapperEx;
#define ENGINEWRAPPER_INTERFACE_VERSION "enginewrapper001"

View File

@ -166,7 +166,7 @@ void setupToolchain(NativeBinarySpec b) {
if (useGcc) {
// Produce code optimized for the most common IA32/AMD64/EM64T processors.
// As new processors are deployed in the marketplace, the behavior of this option will change.
cfg.compilerOptions.args '-mtune=generic', '-Wno-write-strings'
cfg.compilerOptions.args '-mtune=generic', '-Wno-write-strings', '-msse3'
} else {
cfg.compilerOptions.args '-Qoption,cpp,--treat_func_as_string_literal_cpp', '-fno-rtti'
}

View File

@ -35,28 +35,10 @@
class IBaseSystem;
class ISystemModule;
class IEngineWrapper {
class IEngineWrapper: virtual public ISystemModule {
public:
virtual ~IEngineWrapper() {}
virtual bool Init(IBaseSystem *system, int serial, char *name) = 0;
virtual void RunFrame(double time) = 0;
virtual void ReceiveSignal(ISystemModule *module, unsigned int signal, void *data) = 0;
virtual void ExecuteCommand(int commandID, char *commandLine) = 0;
virtual void RegisterListener(ISystemModule *module) = 0;
virtual void RemoveListener(ISystemModule *module) = 0;
virtual IBaseSystem *GetSystem() = 0;
virtual int GetSerial() = 0;
virtual char *GetStatusLine() = 0;
virtual char *GetType() = 0;
virtual char *GetName() = 0;
virtual int GetState() = 0;
virtual int GetVersion() = 0;
virtual void ShutDown() = 0;
virtual bool GetViewOrigin(float *origin) = 0;
virtual bool GetViewAngles(float *angles) = 0;
virtual int GetTraceEntity() = 0;

View File

@ -81,6 +81,7 @@ inline void xmm2vec(vec_t *v, const __m128 m)
_mm_store_ss(v + 2, _mm_shuffle_ps(m, m, 0x02));
}
FUNC_TARGET("sse4.1")
inline __m128 dotProduct3D(__m128 v1, __m128 v2)
{
if (cpuinfo.sse4_1)

View File

@ -115,10 +115,12 @@ uint32 crc32c_t_nosse(uint32 iCRC, const uint8 *buf, int len) {
return crc;
}
FUNC_TARGET("sse4.2")
uint32 crc32c_t8_sse(uint32 iCRC, uint8 u8) {
return _mm_crc32_u8(iCRC, u8);
}
FUNC_TARGET("sse4.2")
uint32 crc32c_t_sse(uint32 iCRC, const uint8 *buf, unsigned int len) {
uint32 crc32cval = iCRC;
unsigned int i = 0;

View File

@ -111,6 +111,7 @@
#define ALIGN16 __declspec(align(16))
#define NORETURN __declspec(noreturn)
#define FORCE_STACK_ALIGN
#define FUNC_TARGET(x)
#define __builtin_bswap16 _byteswap_ushort
#define __builtin_bswap32 _byteswap_ulong
@ -160,9 +161,13 @@
#define FORCE_STACK_ALIGN __attribute__((force_align_arg_pointer))
#if defined __INTEL_COMPILER
#define FUNC_TARGET(x)
#define __builtin_bswap16 _bswap16
#define __builtin_bswap32 _bswap
#define __builtin_bswap64 _bswap64
#else
#define FUNC_TARGET(x) __attribute__((target(x)))
#endif // __INTEL_COMPILER
//inline bool SOCKET_FIONBIO(SOCKET s, int m) { return (ioctl(s, FIONBIO, (int*)&m) == 0); }

View File

@ -171,8 +171,8 @@ size_t Q_strlcat(char (&dest)[N], const char *src)
if (srclen > size)
srclen = size;
Q_memcpy(dst + dstlen, src, srclen);
dst[dstlen + srclen] = '\0';
Q_memcpy(dest + dstlen, src, srclen);
dest[dstlen + srclen] = '\0';
return dstlen + srclen;
}

View File

@ -16,7 +16,11 @@ rootProject.ext.createGccConfig = { boolean release, BinaryKind binKind ->
//intelExtensions: false,
//asmBlocks: true,
positionIndependentCode: false
positionIndependentCode: false,
extraDefines: [
'_GLIBCXX_USE_CXX11_ABI': 0,
]
),
linkerOptions: new GccToolchainConfig.LinkerOptions(
@ -41,7 +45,11 @@ rootProject.ext.createGccConfig = { boolean release, BinaryKind binKind ->
noBuiltIn: true,
//intelExtensions: false,
//asmBlocks: true
//asmBlocks: true,
extraDefines: [
'_GLIBCXX_USE_CXX11_ABI': 0,
]
),
linkerOptions: new GccToolchainConfig.LinkerOptions(