summaryrefslogtreecommitdiff
path: root/indra/llcommon
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llcommon')
-rw-r--r--indra/llcommon/CMakeLists.txt11
-rw-r--r--indra/llcommon/StackWalker.cpp8
-rw-r--r--indra/llcommon/llfasttimer.h8
-rw-r--r--indra/llcommon/llprocessor.cpp63
-rw-r--r--indra/llcommon/llstring.cpp2
-rw-r--r--indra/llcommon/llstring.h4
6 files changed, 94 insertions, 2 deletions
diff --git a/indra/llcommon/CMakeLists.txt b/indra/llcommon/CMakeLists.txt
index 04d14ff321..07d2c4afeb 100644
--- a/indra/llcommon/CMakeLists.txt
+++ b/indra/llcommon/CMakeLists.txt
@@ -11,6 +11,9 @@ include(LLSharedLibs)
include(ZLIBNG)
include(Tracy)
+if ($ENV{MSYSTEM_CARCH} MATCHES aarch64)
+ include(cpuinfo)
+endif ()
set(llcommon_SOURCE_FILES
apply.cpp
@@ -282,10 +285,14 @@ target_link_libraries(
ll::tracy
)
+if ($ENV{MSYSTEM_CARCH} MATCHES aarch64)
+ target_link_libraries(llcommon ll::cpuinfo)
+endif ()
+
target_include_directories(llcommon INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
target_include_directories(llcommon PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
-if (CMAKE_OSX_ARCHITECTURES MATCHES arm64 OR CMAKE_SYSTEM_PROCESSOR MATCHES aarch64 OR ($ENV{MSYSTEM_CARCH} MATCHES aarch64))
+if (CMAKE_OSX_ARCHITECTURES MATCHES arm64 OR CMAKE_SYSTEM_PROCESSOR MATCHES aarch64)
if (${PREBUILD_TRACKING_DIR}/sentinel_installed IS_NEWER_THAN ${PREBUILD_TRACKING_DIR}/sse2neon_installed OR NOT ${sse2neon_installed} EQUAL 0)
file(MAKE_DIRECTORY ${LIBS_PREBUILT_DIR}/include/sse2neon)
if (NOT EXISTS ${LIBS_PREBUILT_DIR}/include/sse2neon/sse2neon.h)
@@ -297,6 +304,8 @@ if (CMAKE_OSX_ARCHITECTURES MATCHES arm64 OR CMAKE_SYSTEM_PROCESSOR MATCHES aarc
file(WRITE ${PREBUILD_TRACKING_DIR}/sse2neon_installed "0")
endif ()
target_include_directories(llcommon PUBLIC ${LIBS_PREBUILT_DIR}/include/sse2neon)
+elseif ($ENV{MSYSTEM_CARCH} MATCHES aarch64)
+ target_include_directories(llcommon PUBLIC ${prefix_result}/../include/sse2neon)
endif ()
if (${LINUX_DISTRO} MATCHES debian OR (${LINUX_DISTRO} MATCHES ubuntu) OR (${LINUX_DISTRO} MATCHES opensuse-tumbleweed))
diff --git a/indra/llcommon/StackWalker.cpp b/indra/llcommon/StackWalker.cpp
index e9ae1723fb..027df80df5 100644
--- a/indra/llcommon/StackWalker.cpp
+++ b/indra/llcommon/StackWalker.cpp
@@ -1100,6 +1100,14 @@ bool StackWalker::ShowCallstack(bool verbose, HANDLE hThread, const CONTEXT *con
s.AddrBStore.Mode = AddrModeFlat;
s.AddrStack.Offset = c.IntSp;
s.AddrStack.Mode = AddrModeFlat;
+#elif _M_ARM64
+ imageType = IMAGE_FILE_MACHINE_ARM64;
+ s.AddrPC.Offset = c.Pc;
+ s.AddrPC.Mode = AddrModeFlat;
+ s.AddrFrame.Offset = c.Fp;
+ s.AddrFrame.Mode = AddrModeFlat;
+ s.AddrStack.Offset = c.Sp;
+ s.AddrStack.Mode = AddrModeFlat;
#else
#error "Platform not supported!"
#endif
diff --git a/indra/llcommon/llfasttimer.h b/indra/llcommon/llfasttimer.h
index a69a03e419..8499655bfa 100644
--- a/indra/llcommon/llfasttimer.h
+++ b/indra/llcommon/llfasttimer.h
@@ -99,7 +99,11 @@ public:
#if LL_FASTTIMER_USE_RDTSC
static U32 getCPUClockCount32()
{
+#if _M_ARM64
+ unsigned __int64 val = _ReadStatusReg(ARM64_PMCCNTR_EL0);
+#else
unsigned __int64 val = __rdtsc();
+#endif
val = val >> 8;
return static_cast<U32>(val);
}
@@ -107,7 +111,11 @@ public:
// return full timer value, *not* shifted by 8 bits
static U64 getCPUClockCount64()
{
+#if _M_ARM64
+ return static_cast<U64>( _ReadStatusReg(ARM64_PMCCNTR_EL0) );
+#else
return static_cast<U64>( __rdtsc() );
+#endif
}
#else
diff --git a/indra/llcommon/llprocessor.cpp b/indra/llcommon/llprocessor.cpp
index 9b3cdf4df5..434501af77 100644
--- a/indra/llcommon/llprocessor.cpp
+++ b/indra/llcommon/llprocessor.cpp
@@ -40,6 +40,9 @@
# include <intrin.h>
# undef _interlockedbittestandset
# undef _interlockedbittestandreset
+#if _M_ARM64
+# include <cpuinfo.h>
+#endif
#endif
#include "llsd.h"
@@ -439,13 +442,21 @@ static F64 calculate_cpu_frequency(U32 measure_msecs)
//// completed now (serialization)
//__asm cpuid
int cpu_info[4] = {-1};
+#if _M_ARM64
+ std::fill(cpu_info, cpu_info + 4, 0);
+#else
__cpuid(cpu_info, 0);
+#endif
// We ask the high-res timer for the start time
QueryPerformanceCounter((LARGE_INTEGER *) &starttime);
// Then we get the current cpu clock and store it
+#if _M_ARM64
+ start = _ReadStatusReg(ARM64_PMCCNTR_EL0);
+#else
start = __rdtsc();
+#endif
// Now we wart for some msecs
_Delay(measure_msecs);
@@ -455,7 +466,11 @@ static F64 calculate_cpu_frequency(U32 measure_msecs)
QueryPerformanceCounter((LARGE_INTEGER *) &endtime);
// And also for the end cpu clock
+#if _M_ARM64
+ end = _ReadStatusReg(ARM64_PMCCNTR_EL0);
+#else
end = __rdtsc();
+#endif
// Now we can restore the default process and thread priorities
SetProcessAffinityMask(hProcess, dwProcessMask);
@@ -495,17 +510,60 @@ private:
// the other three array elements. The CPU identification string is
// not in linear order. The code below arranges the information
// in a human readable form.
+#if _M_ARM64
+ cpuinfo_initialize();
+#else
int cpu_info[4] = {-1};
__cpuid(cpu_info, 0);
unsigned int ids = (unsigned int)cpu_info[0];
setConfig(eMaxID, (S32)ids);
+#endif
char cpu_vendor[0x20];
memset(cpu_vendor, 0, sizeof(cpu_vendor));
+#if _M_ARM64
+ switch (cpuinfo_get_current_core()->vendor)
+ {
+ case cpuinfo_vendor_unknown:
+ setInfo(eVendor, "Unknown");
+ break;
+ case cpuinfo_vendor_arm:
+ setInfo(eVendor, "ARM");
+ break;
+ case cpuinfo_vendor_qualcomm:
+ setInfo(eVendor, "Qualcomm");
+ break;
+ case cpuinfo_vendor_apple:
+ setInfo(eVendor, "Apple");
+ break;
+ case cpuinfo_vendor_samsung:
+ setInfo(eVendor, "Samsung");
+ break;
+ case cpuinfo_vendor_nvidia:
+ setInfo(eVendor, "Nvidia");
+ break;
+ case cpuinfo_vendor_cavium:
+ setInfo(eVendor, "Cavium");
+ break;
+ case cpuinfo_vendor_broadcom:
+ setInfo(eVendor, "Broadcom");
+ break;
+ case cpuinfo_vendor_apm:
+ setInfo(eVendor, "APM");
+ break;
+ case cpuinfo_vendor_huawei:
+ setInfo(eVendor, "Huawei");
+ break;
+ default:
+ setInfo(eVendor, "Unknown");
+ break;
+ }
+#else
*((int*)cpu_vendor) = cpu_info[1];
*((int*)(cpu_vendor+4)) = cpu_info[3];
*((int*)(cpu_vendor+8)) = cpu_info[2];
setInfo(eVendor, cpu_vendor);
+#endif
std::string cmp_vendor(cpu_vendor);
bool is_amd = false;
if (cmp_vendor == "AuthenticAMD")
@@ -513,6 +571,10 @@ private:
is_amd = true;
}
+#if _M_ARM64
+ setInfo(eModel, cpuinfo_get_package(0)->name);
+ setInfo(eType, cpuinfo_get_uarch(0)->uarch);
+#else
// Get the information associated with each valid Id
for(unsigned int i=0; i<=ids; ++i)
{
@@ -623,6 +685,7 @@ private:
setConfig(eCacheSizeK, (cpu_info[2] >> 16) & 0xffff);
}
}
+#endif
}
};
diff --git a/indra/llcommon/llstring.cpp b/indra/llcommon/llstring.cpp
index 07adf71d18..bb6d091a97 100644
--- a/indra/llcommon/llstring.cpp
+++ b/indra/llcommon/llstring.cpp
@@ -260,7 +260,7 @@ S32 utf16str_wstring_length(const llutf16string &utf16str, const S32 utf16_len)
{
S32 surrogate_pairs = 0;
// ... craziness to make gcc happy (llutf16string.c_str() is tweaked on linux):
- const U16 *const utf16_chars = &(*(utf16str.begin()));
+ const auto *const utf16_chars = &(*(utf16str.begin()));
S32 i = 0;
while (i < utf16_len)
{
diff --git a/indra/llcommon/llstring.h b/indra/llcommon/llstring.h
index 7a8edc176d..2e579a4d2d 100644
--- a/indra/llcommon/llstring.h
+++ b/indra/llcommon/llstring.h
@@ -635,7 +635,11 @@ LL_COMMON_API std::string rawstr_to_utf8(const std::string& raw);
//
// This typedef may or may not be identical to std::wstring, depending on
// LL_WCHAR_T_NATIVE.
+#if __FreeBSD__
+typedef std::basic_string<char16_t> llutf16string;
+#else
typedef std::basic_string<U16> llutf16string;
+#endif
// Considering wchar_t, llwchar and U16, there are three relevant cases:
#if LLWCHAR_IS_WCHAR_T // every which way but Windows