arch: added support for aarch64

This commit is contained in:
dmitry 2021-09-11 02:03:49 +03:00
commit 1ecc0827c9
No known key found for this signature in database
GPG key ID: 8297CE728B7A7E37
7 changed files with 83 additions and 48 deletions

@ -1 +1 @@
Subproject commit e9c1c7c9cb290149a260c9e9c56997051be34570
Subproject commit 0252d7bd8561047a70ebd6cec421af7d9e1cc9c7

View file

@ -635,7 +635,7 @@ public:
};
// for android
#if defined (CR_ANDROID) && defined(CR_ARCH_ARM)
#if defined (CR_ARCH_ARM)
extern "C" void player (entvars_t *);
#endif
@ -680,7 +680,7 @@ public:
public:
void callPlayerFunction (edict_t *ent) {
#if defined (CR_ANDROID) && defined (CR_ARCH_ARM)
#if defined (CR_ARCH_ARM)
player (&ent->v);
#else
reinterpret_cast <EntityFunction> (lookup (Game::instance ().lib ().handle (), "player")) (&ent->v);

View file

@ -23,7 +23,8 @@ project (
'optimization=3',
'default_library=static',
'cpp_eh=none',
'b_vscrt=static_from_buildtype'
'b_vscrt=static_from_buildtype',
'b_lto=true'
],
meson_version: '>=0.56.0')
@ -33,6 +34,7 @@ find_program ('hostname', required: true)
cpp = meson.get_compiler ('cpp')
sys = host_machine.system ()
target = build_machine.cpu_family ()
version = meson.project_version ()
count = run_command ('git', 'rev-list', '--count', 'HEAD').stdout ().strip ()
@ -48,6 +50,7 @@ clang = cpp_id == 'clang'
win32 = sys == 'windows'
linux = sys == 'linux'
mac = sys == 'darwin'
aarch64 = target == 'aarch64'
ldflags = []
ccflags = []
@ -76,12 +79,15 @@ ccflags += '-DVERSION_GENERATED'
if clang or gcc
ccflags += [
'-m32',
'-fno-threadsafe-statics',
'-fno-exceptions',
'-fno-rtti'
]
if not aarch64
ccflags += '-m32'
endif
if not mac
ccflags += [
'-pedantic',
@ -90,31 +96,35 @@ if clang or gcc
if optmize
if (clang or gcc) and not mac
if not aarch64
ccflags += [
'-flto',
'-fdata-sections',
'-ffunction-sections'
]
endif
if gcc
ccflags += '-fgraphite-identity'
ldflags += '-flto-partition=none'
endif
if not aarch64
ldflags += [
'-flto',
'-Wl,--version-script=../ldscript.lds',
'-Wl,--gc-sections'
]
endif
endif
endif
if linux
ldflags += [
'-m32',
'-lm',
'-ldl'
]
if not aarch64
ldflags += '-m32'
endif
endif
endif
@ -138,8 +148,6 @@ if linux or mac or (win32 and (gcc or clang))
else
ccflags += [
'-mtune=generic',
'-msse2',
'-mfpmath=sse',
'-fno-builtin',
'-funroll-loops',
'-fomit-frame-pointer',
@ -148,6 +156,13 @@ if linux or mac or (win32 and (gcc or clang))
'-fvisibility-inlines-hidden'
]
if not aarch64
ccflags += [
'-msse2',
'-mfpmath=sse',
]
endif
if clang and not mac
lld = find_program ('lld', required: false)

View file

@ -8,7 +8,7 @@
#include <yapb.h>
// until hook code will be compatible with ARM, it's here
#if defined (CR_ANDROID) && defined(CR_ARCH_ARM)
#if defined(CR_ARCH_ARM)
CR_EXPORT int Server_GetBlendingInterface (int version, struct sv_blending_interface_s **ppinterface, struct engine_studio_api_s *pstudio, float *rotationmatrix, float *bonetransform) {
// this function synchronizes the studio model animation blending interface (i.e, what parts

View file

@ -254,6 +254,32 @@ void Game::testHull (const Vector &start, const Vector &end, int ignoreFlags, in
engfuncs.pfnTraceHull (start, end, !!(ignoreFlags & TraceIgnore::Monsters), hullNumber, ignoreEntity, ptr);
}
// helper class for reading wave header
class WaveEndianessHelper : public DenyCopying {
private:
#if defined (CR_ARCH_CPU_BIG_ENDIAN)
bool little { false };
#else
bool little { true };
#endif
public:
uint16_t read16 (uint16_t value) {
return little ? value : static_cast <uint16_t> ((value >> 8) | (value << 8));
}
uint32_t read32 (uint32_t value) {
return little ? value : (((value & 0x000000ff) << 24) | ((value & 0x0000ff00) << 8) | ((value & 0x00ff0000) >> 8) | ((value & 0xff000000) >> 24));
}
bool isWave (char *format) {
if (little && memcmp (format, "WAVE", 4) == 0) {
return true;
}
return *reinterpret_cast <uint32_t *> (format) == 0x57415645;
}
};
float Game::getWaveLen (const char *fileName) {
auto filePath = strings.format ("%s/%s/%s.wav", getRunningModName (), cv_chatter_path.str (), fileName);
@ -264,47 +290,41 @@ float Game::getWaveLen (const char *fileName) {
return 0.0f;
}
// check if we have engine function for this
if (!is (GameFlags::Xash3D) && plat.checkPointer (engfuncs.pfnGetApproxWavePlayLen)) {
fp.close ();
return engfuncs.pfnGetApproxWavePlayLen (filePath) / 1000.0f;
}
// else fuck with manual search
struct WavHeader {
char riffChunkId[4];
unsigned long packageSize;
char chunkID[4];
char formatChunkId[4];
unsigned long formatChunkLength;
uint16 dummy;
uint16 channels;
unsigned long sampleRate;
unsigned long bytesPerSecond;
uint16 bytesPerSample;
uint16 bitsPerSample;
char riff[4];
uint32_t chunkSize;
char wave[4];
char fmt[4];
uint32_t subchunk1Size;
uint16_t audioFormat;
uint16_t numChannels;
uint32_t sampleRate;
uint32_t byteRate;
uint16_t blockAlign;
uint16_t bitsPerSample;
char dataChunkId[4];
unsigned long dataChunkLength;
} waveHdr {};
uint32_t dataChunkLength;
} header {};
plat.bzero (&waveHdr, sizeof (waveHdr));
WaveEndianessHelper weh;
if (fp.read (&waveHdr, sizeof (WavHeader)) == 0) {
if (fp.read (&header, sizeof (WavHeader)) == 0) {
logger.error ("Wave File %s - has wrong or unsupported format", filePath);
return 0.0f;
}
fp.close ();
if (strncmp (waveHdr.chunkID, "WAVE", 4) != 0) {
if (!weh.isWave (header.wave)) {
logger.error ("Wave File %s - has wrong wave chunk id", filePath);
return 0.0f;
}
if (waveHdr.dataChunkLength == 0) {
if (weh.read32 (header.dataChunkLength) == 0) {
logger.error ("Wave File %s - has zero length!", filePath);
return 0.0f;
}
return static_cast <float> (waveHdr.dataChunkLength) / static_cast <float> (waveHdr.bytesPerSecond);
return 1.0f * weh.read32 (header.dataChunkLength) / (weh.read16 (header.bitsPerSample) / 8) / weh.read16 (header.numChannels) / weh.read32 (header.sampleRate);
}
bool Game::isDedicated () {

View file

@ -943,7 +943,7 @@ CR_EXPORT void Meta_Init () {
# elif defined(CR_CXX_CLANG) || defined(CR_CXX_GCC) || defined(CR_ARCH_X64)
# define DLL_GIVEFNPTRSTODLL CR_EXPORT void CR_STDCALL
# endif
#elif defined(CR_LINUX) || defined (CR_OSX) || defined (CR_ANDROID)
#else
# define DLL_GIVEFNPTRSTODLL CR_EXPORT void
#endif

View file

@ -559,7 +559,7 @@ void BotManager::serverFill (int selection, int personality, int difficulty, int
void BotManager::kickEveryone (bool instant, bool zeroQuota) {
// this function drops all bot clients from server (this function removes only yapb's)
if (cv_quota.bool_ ()) {
if (cv_quota.bool_ () && getBotCount () > 0) {
ctrl.msg ("Bots are removed from server.");
}