summaryrefslogtreecommitdiff
path: root/indra/llcommon
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llcommon')
-rw-r--r--indra/llcommon/CMakeLists.txt24
-rw-r--r--indra/llcommon/hbxxh.cpp4
-rw-r--r--indra/llcommon/llfasttimer.cpp2
-rw-r--r--indra/llcommon/llfasttimer.h4
-rw-r--r--indra/llcommon/llmemory.h8
-rw-r--r--indra/llcommon/llpreprocessor.h6
-rw-r--r--indra/llcommon/llprocess.h2
-rw-r--r--indra/llcommon/llprocessor.cpp101
-rw-r--r--indra/llcommon/llsdutil.cpp2
-rw-r--r--indra/llcommon/llsys.cpp23
-rw-r--r--indra/llcommon/llsys.h2
-rw-r--r--indra/llcommon/llthreadsafequeue.h4
-rw-r--r--indra/llcommon/lltimer.cpp6
-rw-r--r--indra/llcommon/lluuid.cpp4
-rw-r--r--indra/llcommon/stdtypes.h7
15 files changed, 180 insertions, 19 deletions
diff --git a/indra/llcommon/CMakeLists.txt b/indra/llcommon/CMakeLists.txt
index fa9c6eaa79..45b1bcb932 100644
--- a/indra/llcommon/CMakeLists.txt
+++ b/indra/llcommon/CMakeLists.txt
@@ -9,7 +9,9 @@ include(Linking)
include(Boost)
include(LLSharedLibs)
include(JsonCpp)
+if (USE_AUTOBUILD_3P OR USE_CONAN)
include(Copy3rdPartyLibs)
+endif ()
include(ZLIBNG)
include(URIPARSER)
include(Tracy)
@@ -158,6 +160,7 @@ set(llcommon_HEADER_FILES
lleventdispatcher.h
lleventfilter.h
llevents.h
+ lleventtimer.h
lleventemitter.h
llexception.h
llfasttimer.h
@@ -182,12 +185,14 @@ set(llcommon_HEADER_FILES
llliveappconfig.h
lllivefile.h
llmainthreadtask.h
+ llmake.h
llmd5.h
llmemory.h
llmemorystream.h
llmetrics.h
llmetricperformancetester.h
llmortician.h
+ llmutex.h
llnametable.h
llpointer.h
llprofiler.h
@@ -244,7 +249,9 @@ set(llcommon_HEADER_FILES
llwin32headerslean.h
llworkerthread.h
hbxxh.h
+ is_approx_equal_fraction.h
lockstatic.h
+ mutex.h
stdtypes.h
stringize.h
threadpool.h
@@ -281,7 +288,24 @@ target_link_libraries(
target_include_directories(llcommon INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
target_include_directories(llcommon PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
+if (USE_AUTOBUILD_3P OR USE_CONAN)
add_dependencies(llcommon stage_third_party_libs)
+else ()
+ target_compile_options(${PROJECT_NAME} PUBLIC -Wno-deprecated-declarations)
+ if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
+ set_source_files_properties(
+ llapp.cpp
+ llsdutil.cpp
+ PROPERTIES COMPILE_FLAGS -Wno-stringop-truncation)
+ set_source_files_properties(llevent.cpp PROPERTIES
+ COMPILE_FLAGS -Wno-nonnull)
+ elseif (LINUX AND CMAKE_CXX_COMPILER_ID MATCHES "Clang")
+ set_source_files_properties(llsys.cpp PROPERTIES
+ COMPILE_FLAGS -Wno-unused-but-set-variable)
+ endif()
+endif ()
+
+include(LibraryInstall)
if (LL_TESTS)
include(LLAddBuildTest)
diff --git a/indra/llcommon/hbxxh.cpp b/indra/llcommon/hbxxh.cpp
index 388269d6c8..84d215d468 100644
--- a/indra/llcommon/hbxxh.cpp
+++ b/indra/llcommon/hbxxh.cpp
@@ -34,7 +34,11 @@
// in your build, in which case the latter would be used instead. For ARM64
// builds, this would also automatically enable NEON vectorization.
#define XXH_INLINE_ALL
+#if LL_USESYSTEMLIBS
+#include <xxhash.h>
+#else
#include "xxhash/xxhash.h"
+#endif
#include "hbxxh.h"
diff --git a/indra/llcommon/llfasttimer.cpp b/indra/llcommon/llfasttimer.cpp
index 2612d0f07c..b30bb110c9 100644
--- a/indra/llcommon/llfasttimer.cpp
+++ b/indra/llcommon/llfasttimer.cpp
@@ -43,7 +43,7 @@
#if LL_WINDOWS
#include "lltimer.h"
-#elif LL_LINUX
+#elif LL_LINUX || LL_FREEBSD
#include <sys/time.h>
#include <sched.h>
#include "lltimer.h"
diff --git a/indra/llcommon/llfasttimer.h b/indra/llcommon/llfasttimer.h
index 9bd93d7240..9a5789d719 100644
--- a/indra/llcommon/llfasttimer.h
+++ b/indra/llcommon/llfasttimer.h
@@ -128,7 +128,7 @@ public:
#endif
-#if (LL_LINUX) && !(defined(__i386__) || defined(__amd64__))
+#if (LL_LINUX || LL_DARWIN) && !(defined(__i386__) || defined(__amd64__))
//
// Linux implementation of CPU clock - non-x86.
// This is accurate but SLOW! Only use out of desperation.
@@ -159,7 +159,7 @@ public:
#endif // (LL_LINUX) && !(defined(__i386__) || defined(__amd64__))
-#if (LL_LINUX || LL_DARWIN) && (defined(__i386__) || defined(__amd64__))
+#if (LL_LINUX || LL_DARWIN || LL_FREEBSD) && (defined(__i386__) || defined(__amd64__))
//
// Mac+Linux FAST x86 implementation of CPU clock
static U32 getCPUClockCount32()
diff --git a/indra/llcommon/llmemory.h b/indra/llcommon/llmemory.h
index ac6c969d70..dd9867c9b3 100644
--- a/indra/llcommon/llmemory.h
+++ b/indra/llcommon/llmemory.h
@@ -52,7 +52,7 @@ class LLMutex ;
#define LL_DEFAULT_HEAP_ALIGN 8
#elif LL_DARWIN
#define LL_DEFAULT_HEAP_ALIGN 16
-#elif LL_LINUX
+#elif LL_LINUX || LL_FREEBSD
#define LL_DEFAULT_HEAP_ALIGN 8
#endif
@@ -71,7 +71,11 @@ LL_COMMON_API void ll_assert_aligned_func(uintptr_t ptr,U32 alignment);
#define ll_assert_aligned(ptr,alignment)
#endif
+#if defined(__i386__) || defined(__x86_64__)
#include <xmmintrin.h>
+#else
+#include <sse2neon.h>
+#endif
template <typename T> T* LL_NEXT_ALIGNED_ADDRESS(T* address)
{
@@ -85,7 +89,7 @@ template <typename T> T* LL_NEXT_ALIGNED_ADDRESS_64(T* address)
(uintptr_t(address) + 0x3F) & ~0x3F);
}
-#if LL_LINUX || LL_DARWIN
+#if LL_LINUX || LL_DARWIN || LL_FREEBSD
#define LL_ALIGN_PREFIX(x)
#define LL_ALIGN_POSTFIX(x) __attribute__((aligned(x)))
diff --git a/indra/llcommon/llpreprocessor.h b/indra/llcommon/llpreprocessor.h
index dc586b0008..3c05fd32da 100644
--- a/indra/llcommon/llpreprocessor.h
+++ b/indra/llcommon/llpreprocessor.h
@@ -32,9 +32,11 @@
#ifdef LL_LINUX
#define __ENABLE_WSTRING
#include <endian.h>
+#elif defined(LL_FREEBSD)
+#include <sys/endian.h>
#endif // LL_LINUX
-#if (defined(LL_WINDOWS) || (defined(LL_LINUX) && (__BYTE_ORDER == __LITTLE_ENDIAN)) || (defined(LL_DARWIN) && defined(__LITTLE_ENDIAN__)))
+#if (defined(LL_WINDOWS) || (defined(LL_LINUX) && (__BYTE_ORDER == __LITTLE_ENDIAN)) || (defined(LL_DARWIN) && defined(__LITTLE_ENDIAN__)) || (defined(LL_FREEBSD) && (_BYTE_ORDER == _LITTLE_ENDIAN)))
#define LL_LITTLE_ENDIAN 1
#else
#define LL_BIG_ENDIAN 1
@@ -80,7 +82,7 @@
#endif
// Deal with minor differences on Unixy OSes.
-#if LL_DARWIN || LL_LINUX
+#if LL_DARWIN || LL_LINUX || LL_FREEBSD
// Different name, same functionality.
#define stricmp strcasecmp
#define strnicmp strncasecmp
diff --git a/indra/llcommon/llprocess.h b/indra/llcommon/llprocess.h
index e3386ad88e..9555df9bba 100644
--- a/indra/llcommon/llprocess.h
+++ b/indra/llcommon/llprocess.h
@@ -40,7 +40,7 @@
#if LL_WINDOWS
#include "llwin32headerslean.h" // for HANDLE
-#elif LL_LINUX
+#elif LL_LINUX || LL_FREEBSD
#if defined(Status)
#undef Status
#endif
diff --git a/indra/llcommon/llprocessor.cpp b/indra/llcommon/llprocessor.cpp
index 28f8bc2b93..cf97e7d7da 100644
--- a/indra/llcommon/llprocessor.cpp
+++ b/indra/llcommon/llprocessor.cpp
@@ -742,12 +742,14 @@ private:
: "0" (level))
#endif
+#if __i386__ || __x86_64__
unsigned int eax, ebx, ecx, edx;
__cpuid(0x1, eax, ebx, ecx, edx);
if(feature_infos[0] != (S32)edx)
{
LL_WARNS() << "machdep.cpu.feature_bits doesn't match expected cpuid result!" << LL_ENDL;
}
+#endif // __i386__ || __x86_64__
#endif // LL_RELEASE_FOR_DOWNLOAD
@@ -792,6 +794,100 @@ private:
}
};
+#elif LL_FREEBSD
+
+#include <sys/sysctl.h>
+class LLProcessorInfoFreeBSDImpl : public LLProcessorInfoImpl
+{
+public:
+ LLProcessorInfoFreeBSDImpl()
+ {
+ size_t len = 0;
+ using std::string;
+
+ char cpu_brand_string[0x40];
+ len = sizeof cpu_brand_string;
+ memset(cpu_brand_string, '\0', len);
+ sysctlbyname("hw.model", (void *)cpu_brand_string, &len,
+ NULL, 0);
+ cpu_brand_string[0x3f] = '\0';
+ setInfo(eBrandName, cpu_brand_string);
+
+ uint64_t cpu_frequency = 0;
+ len = sizeof cpu_frequency;
+ sysctlbyname("hw.clockrate", (void *)&cpu_frequency, &len,
+ NULL, 0);
+ setInfo(eFrequency, (F64)cpu_frequency);
+
+ auto dmesgboot = LLFile::fopen("/var/run/dmesg.boot", "rb");
+ std::ostringstream s;
+ if (dmesgboot) {
+ char line[MAX_STRING];
+ memset(line, 0, MAX_STRING);
+ while (fgets(line, MAX_STRING, dmesgboot)) {
+ line[strlen(line) - 1] = ' ';
+ s << line;
+ s << std::endl;
+ }
+ fclose(dmesgboot);
+ s << std::endl;
+ }
+
+ auto dmesgboot_str = s.str();
+ int decimal;
+
+ auto idx1 = dmesgboot_str.find_first_of("\"") + 1;
+ auto idx2 = (idx1 != string::npos)
+ ? dmesgboot_str.find_first_of("\"", idx1)
+ : string::npos;
+ auto vendor = dmesgboot_str.substr(idx1, idx2 - idx1);
+ if (vendor.length() > 0) setInfo(eVendor, vendor.c_str());
+
+ idx1 = dmesgboot_str.find_first_of("=", idx2);
+ idx1 = dmesgboot_str.find_first_of("=", idx1 + 1) + 3;
+ idx2 = dmesgboot_str.find_first_of(" ", idx1);
+ auto family = dmesgboot_str.substr(idx1, idx2 - idx1);
+ std::istringstream(family) >> std::hex >> decimal;
+ setInfo(eFamily, decimal);
+ setInfo(eFamilyName, compute_CPUFamilyName(vendor.c_str(),
+ decimal, 0));
+
+ idx1 = dmesgboot_str.find_first_of("=", idx2) + 3;
+ idx2 = dmesgboot_str.find_first_of(" ", idx1);
+ auto model = dmesgboot_str.substr(idx1, idx2 - idx1);
+ std::istringstream(model) >> std::hex >> decimal;
+ setInfo(eModel, decimal);
+
+ idx1 = dmesgboot_str.find_first_of("=", idx2) + 1;
+ idx2 = dmesgboot_str.find_first_of("\n", idx1);
+ auto stepping = dmesgboot_str.substr(idx1, idx2 - idx1);
+ setInfo(eStepping, std::stoi(stepping));
+
+ if (dmesgboot_str.find(",SSE,") != string::npos)
+ setExtension(cpu_feature_names[eSSE_Ext]);
+
+ if (dmesgboot_str.find(",SSE2,") != string::npos)
+ setExtension(cpu_feature_names[eSSE2_Ext]);
+
+ if (dmesgboot_str.find("<SSE3,") != string::npos)
+ setExtension(cpu_feature_names[eSSE3_Features]);
+
+ if (dmesgboot_str.find(",SSSE3,") != string::npos)
+ setExtension(cpu_feature_names[eSSE3S_Features]);
+
+ if (dmesgboot_str.find(",SSE4.1,") != string::npos)
+ setExtension(cpu_feature_names[eSSE4_1_Features]);
+
+ if (dmesgboot_str.find(",SSE4.2,") != string::npos)
+ setExtension(cpu_feature_names[eSSE4_2_Features]);
+
+ if (dmesgboot_str.find(",SSE4A,") != string::npos)
+ setExtension(cpu_feature_names[eSSE4a_Features]);
+ }
+
+ virtual ~LLProcessorInfoFreeBSDImpl() {}
+};
+
#elif LL_LINUX
const char CPUINFO_FILE[] = "/proc/cpuinfo";
@@ -867,7 +963,7 @@ private:
LLPI_SET_INFO_INT(eModel, "model");
- S32 family;
+ S32 family = 0;
if (!cpuinfo["cpu family"].empty()
&& LLStringUtil::convertToS32(cpuinfo["cpu family"], family))
{
@@ -972,6 +1068,9 @@ LLProcessorInfo::LLProcessorInfo() : mImpl(NULL)
#elif LL_DARWIN
static LLProcessorInfoDarwinImpl the_impl;
mImpl = &the_impl;
+#elif LL_FREEBSD
+ static LLProcessorInfoFreeBSDImpl the_impl;
+ mImpl = &the_impl;
#else
static LLProcessorInfoLinuxImpl the_impl;
mImpl = &the_impl;
diff --git a/indra/llcommon/llsdutil.cpp b/indra/llcommon/llsdutil.cpp
index f70bee9903..512f630cdc 100644
--- a/indra/llcommon/llsdutil.cpp
+++ b/indra/llcommon/llsdutil.cpp
@@ -36,7 +36,7 @@
# include <winsock2.h> // for htonl
#elif LL_LINUX
# include <netinet/in.h>
-#elif LL_DARWIN
+#elif LL_DARWIN || LL_FREEBSD
# include <arpa/inet.h>
#endif
diff --git a/indra/llcommon/llsys.cpp b/indra/llcommon/llsys.cpp
index 938685bae6..1e0a9e815f 100644
--- a/indra/llcommon/llsys.cpp
+++ b/indra/llcommon/llsys.cpp
@@ -82,8 +82,13 @@ using namespace llsd;
# include <sys/sysinfo.h>
# include <stdexcept>
const char MEMINFO_FILE[] = "/proc/meminfo";
+#ifdef __GNU__
# include <gnu/libc-version.h>
#endif
+#elif LL_FREEBSD
+# include <sys/sysctl.h>
+# include <sys/utsname.h>
+#endif
LLCPUInfo gSysCPU;
@@ -350,6 +355,7 @@ LLOSInfo::LLOSInfo() :
boost::regex os_version_parse(OS_VERSION_MATCH_EXPRESSION);
boost::smatch matched;
+#ifdef __GNU__
std::string glibc_version(gnu_get_libc_version());
if ( ll_regex_match(glibc_version, matched, os_version_parse) )
{
@@ -408,6 +414,7 @@ LLOSInfo::LLOSInfo() :
{
LL_WARNS("AppInit") << "glibc version '" << glibc_version << "' cannot be parsed to three numbers; using all zeros" << LL_ENDL;
}
+#endif // __GNU__
#else
@@ -435,6 +442,14 @@ LLOSInfo::LLOSInfo() :
if (simple.length() > 0)
mOSStringSimple = simple;
}
+ else if (ostype == "FreeBSD")
+ {
+ // Only care about major and minor FreeBSD versions, truncate at first '-'
+ std::string simple = mOSStringSimple.substr(0,
+ mOSStringSimple.find_first_of("-", 0));
+ if (simple.length() > 0)
+ mOSStringSimple = simple;
+ }
}
else
{
@@ -771,13 +786,17 @@ static U32Kilobytes LLMemoryAdjustKBResult(U32Kilobytes inKB)
}
#endif
-#if LL_DARWIN
+#if LL_DARWIN || LL_FREEBSD
// static
U32Kilobytes LLMemoryInfo::getHardwareMemSize()
{
// This might work on Linux as well. Someone check...
uint64_t phys = 0;
+#if LL_DARWIN
int mib[2] = { CTL_HW, HW_MEMSIZE };
+#else
+ int mib[2] = { CTL_HW, HW_PHYSMEM };
+#endif
size_t len = sizeof(phys);
sysctl(mib, 2, &phys, &len, NULL, 0);
@@ -791,7 +810,7 @@ U32Kilobytes LLMemoryInfo::getPhysicalMemoryKB() const
#if LL_WINDOWS
return LLMemoryAdjustKBResult(U32Kilobytes(mStatsMap["Total Physical KB"].asInteger()));
-#elif LL_DARWIN
+#elif LL_DARWIN || LL_FREEBSD
return getHardwareMemSize();
#elif LL_LINUX
diff --git a/indra/llcommon/llsys.h b/indra/llcommon/llsys.h
index 08d4abffa2..d37e0d42df 100644
--- a/indra/llcommon/llsys.h
+++ b/indra/llcommon/llsys.h
@@ -130,7 +130,7 @@ public:
void stream(std::ostream& s) const; ///< output text info to s
U32Kilobytes getPhysicalMemoryKB() const;
-#if LL_DARWIN
+#if LL_DARWIN || LL_FREEBSD
static U32Kilobytes getHardwareMemSize(); // Because some Mac linkers won't let us reference extern gSysMemory from a different lib.
#endif
diff --git a/indra/llcommon/llthreadsafequeue.h b/indra/llcommon/llthreadsafequeue.h
index f396a71e6f..3ffba7b377 100644
--- a/indra/llcommon/llthreadsafequeue.h
+++ b/indra/llcommon/llthreadsafequeue.h
@@ -452,7 +452,11 @@ ElementT LLThreadSafeQueue<ElementT, QueueT>::pop(void)
// so we can finish draining the queue.
pop_result popped = pop_(lock1, value);
if (popped == POPPED)
+#if LL_LINUX
+ return value;
+#else
return std::move(value);
+#endif
// Once the queue is DONE, there will never be any more coming.
if (popped == DONE)
diff --git a/indra/llcommon/lltimer.cpp b/indra/llcommon/lltimer.cpp
index 1a99ac2886..e96927e9c1 100644
--- a/indra/llcommon/lltimer.cpp
+++ b/indra/llcommon/lltimer.cpp
@@ -35,7 +35,7 @@
#if LL_WINDOWS
# include "llwin32headerslean.h"
-#elif LL_LINUX || LL_DARWIN
+#elif LL_LINUX || LL_DARWIN || LL_FREEBSD
# include <errno.h>
# include <sys/time.h>
#else
@@ -115,7 +115,7 @@ void ms_sleep(U32 ms)
#endif
-#elif LL_LINUX || LL_DARWIN
+#elif LL_LINUX || LL_DARWIN || LL_FREEBSD
static void _sleep_loop(struct timespec& thiswait)
{
struct timespec nextwait;
@@ -233,7 +233,7 @@ F64 calc_clock_frequency()
#endif // LL_WINDOWS
-#if LL_LINUX || LL_DARWIN
+#if LL_LINUX || LL_DARWIN || LL_FREEBSD
// Both Linux and Mac use gettimeofday for accurate time
F64 calc_clock_frequency()
{
diff --git a/indra/llcommon/lluuid.cpp b/indra/llcommon/lluuid.cpp
index 200add404f..ae67188242 100644
--- a/indra/llcommon/lluuid.cpp
+++ b/indra/llcommon/lluuid.cpp
@@ -522,7 +522,7 @@ S32 LLUUID::getNodeID(unsigned char* node_id)
#include <net/if.h>
#include <net/if_types.h>
#include <net/if_dl.h>
-#include <net/route.h>
+//#include <net/route.h>
#include <ifaddrs.h>
// static
@@ -606,7 +606,7 @@ S32 LLUUID::getNodeID(unsigned char* node_id)
#define HAVE_NETINET_IN_H
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
-#if !LL_DARWIN
+#if !LL_DARWIN && !LL_FREEBSD
#include <linux/sockios.h>
#endif
#endif
diff --git a/indra/llcommon/stdtypes.h b/indra/llcommon/stdtypes.h
index 0b43d7ad4b..463e1e832b 100644
--- a/indra/llcommon/stdtypes.h
+++ b/indra/llcommon/stdtypes.h
@@ -29,6 +29,7 @@
#include <cassert>
#include <cfloat>
#include <climits>
+#include <cstddef>
#include <limits>
#include <type_traits>
@@ -71,7 +72,7 @@ typedef unsigned __int64 U64;
#else
typedef long long int S64;
typedef long long unsigned int U64;
-#if LL_DARWIN || LL_LINUX
+#if LL_DARWIN || LL_LINUX || LL_FREEBSD
#define S64L(a) (a##LL)
#define U64L(a) (a##ULL)
#endif
@@ -113,6 +114,10 @@ typedef U32 TPACKETID;
#define FALSE (0)
#endif
+#if LL_FREEBSD
+#undef NULL
+#endif
+
#ifndef NULL
#define NULL (0)
#endif