summaryrefslogtreecommitdiff
path: root/indra/llcommon
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llcommon')
-rw-r--r--indra/llcommon/llapr.h2
-rw-r--r--indra/llcommon/llfixedbuffer.cpp2
-rw-r--r--indra/llcommon/llhash.h4
-rw-r--r--indra/llcommon/llpreprocessor.h5
-rw-r--r--indra/llcommon/llprocessor.cpp124
-rw-r--r--indra/llcommon/llsdutil.cpp2
-rw-r--r--indra/llcommon/llstring.h10
-rw-r--r--indra/llcommon/llsys.cpp68
-rw-r--r--indra/llcommon/llthread.cpp4
-rw-r--r--indra/llcommon/lltimer.cpp8
-rw-r--r--indra/llcommon/llworkerthread.cpp2
-rw-r--r--indra/llcommon/stdtypes.h22
-rw-r--r--indra/llcommon/timing.h2
13 files changed, 214 insertions, 41 deletions
diff --git a/indra/llcommon/llapr.h b/indra/llcommon/llapr.h
index 6e8912c461..1e2d86f814 100644
--- a/indra/llcommon/llapr.h
+++ b/indra/llcommon/llapr.h
@@ -11,7 +11,7 @@
#ifndef LL_LLAPR_H
#define LL_LLAPR_H
-#if LL_LINUX
+#if LL_LINUX || LL_SOLARIS
#include <sys/param.h> // Need PATH_MAX in APR headers...
#endif
diff --git a/indra/llcommon/llfixedbuffer.cpp b/indra/llcommon/llfixedbuffer.cpp
index ca7bf1ce48..113c8cecb1 100644
--- a/indra/llcommon/llfixedbuffer.cpp
+++ b/indra/llcommon/llfixedbuffer.cpp
@@ -62,7 +62,7 @@ void LLFixedBuffer::setMaxLines(S32 max_lines)
void LLFixedBuffer::removeExtraLines()
{
- while ((S32)mLines.size() > llmax(0, (S32)(mMaxLines - 1)))
+ while ((S32)mLines.size() > llmax((S32)0, (S32)(mMaxLines - 1)))
{
mLines.pop_front();
mAddTimes.pop_front();
diff --git a/indra/llcommon/llhash.h b/indra/llcommon/llhash.h
index fbf059bbcd..d03c70b04b 100644
--- a/indra/llcommon/llhash.h
+++ b/indra/llcommon/llhash.h
@@ -22,6 +22,8 @@
# else
# include <hashtable.h>
# endif
+#elif LL_SOLARIS
+#include <ext/hashtable.h>
#else
#error Please define your platform.
#endif
@@ -33,7 +35,7 @@ template<class T> inline size_t llhash(T value)
#elif ( (defined _STLPORT_VERSION) || ((LL_LINUX) && (__GNUC__ <= 2)) )
std::hash<T> H;
return H(value);
-#elif LL_DARWIN || LL_LINUX
+#elif LL_DARWIN || LL_LINUX || LL_SOLARIS
__gnu_cxx::hash<T> H;
return H(value);
#else
diff --git a/indra/llcommon/llpreprocessor.h b/indra/llcommon/llpreprocessor.h
index 4389fd3e30..6f38058439 100644
--- a/indra/llcommon/llpreprocessor.h
+++ b/indra/llcommon/llpreprocessor.h
@@ -42,6 +42,11 @@
#ifndef LL_LIBXUL_ENABLED
#define LL_LIBXUL_ENABLED 1
#endif // def LL_LIBXUL_ENABLED
+#elif LL_SOLARIS
+ #define LL_QUICKTIME_ENABLED 0
+ #ifndef LL_LIBXUL_ENABLED
+ #define LL_LIBXUL_ENABLED 0
+ #endif // def LL_LIBXUL_ENABLED
#endif
#if LL_LIBXUL_ENABLED && !defined(MOZILLA_INTERNAL_API)
diff --git a/indra/llcommon/llprocessor.cpp b/indra/llcommon/llprocessor.cpp
index 3ff41a0104..e7cfe564f8 100644
--- a/indra/llcommon/llprocessor.cpp
+++ b/indra/llcommon/llprocessor.cpp
@@ -38,7 +38,7 @@
# include <windows.h>
#endif
-#if !LL_DARWIN
+#if !LL_DARWIN && !LL_SOLARIS
#ifdef PROCESSOR_FREQUENCY_MEASURE_AVAILABLE
// We need the QueryPerformanceCounter and Sleep functions
@@ -1632,6 +1632,125 @@ const ProcessorInfo *CProcessor::GetCPUInfo()
return (&CPUInfo);
}
+#elif LL_SOLARIS
+#include <kstat.h>
+
+// ======================
+// Class constructor:
+/////////////////////////
+CProcessor::CProcessor()
+{
+ uqwFrequency = 0;
+ strCPUName[0] = 0;
+ memset(&CPUInfo, 0, sizeof(CPUInfo));
+}
+
+// unsigned __int64 CProcessor::GetCPUFrequency(unsigned int uiMeasureMSecs)
+// =========================================================================
+// Function to query the current CPU frequency
+////////////////////////////////////////////////////////////////////////////
+F64 CProcessor::GetCPUFrequency(unsigned int /*uiMeasureMSecs*/)
+{
+ if(uqwFrequency == 0){
+ GetCPUInfo();
+ }
+
+ return uqwFrequency;
+}
+
+// const ProcessorInfo *CProcessor::GetCPUInfo()
+// =============================================
+// Calls all the other detection function to create an detailed
+// processor information
+///////////////////////////////////////////////////////////////
+const ProcessorInfo *CProcessor::GetCPUInfo()
+{
+ // In Solaris the CPU info is in the kstats
+ // try "psrinfo" or "kstat cpu_info" to see all
+ // that's available
+ int ncpus=0, i;
+ kstat_ctl_t *kc;
+ kstat_t *ks;
+ kstat_named_t *ksinfo, *ksi;
+ kstat_t *CPU_stats_list;
+
+ kc = kstat_open();
+
+ if((int)kc == -1){
+ llwarns << "kstat_open(0 failed!" << llendl;
+ return (&CPUInfo);
+ }
+
+ for (ks = kc->kc_chain; ks != NULL; ks = ks->ks_next) {
+ if (strncmp(ks->ks_module, "cpu_info", 8) == 0 &&
+ strncmp(ks->ks_name, "cpu_info", 8) == 0)
+ ncpus++;
+ }
+
+ if(ncpus < 1){
+ llwarns << "No cpus found in kstats!" << llendl;
+ return (&CPUInfo);
+ }
+
+ for (ks = kc->kc_chain; ks; ks = ks->ks_next) {
+ if (strncmp(ks->ks_module, "cpu_info", 8) == 0
+ && strncmp(ks->ks_name, "cpu_info", 8) == 0
+ && kstat_read(kc, ks, NULL) != -1){
+ CPU_stats_list = ks; // only looking at the first CPU
+
+ break;
+ }
+ }
+
+ if(ncpus > 1)
+ snprintf(strCPUName, sizeof(strCPUName), "%d x ", ncpus);
+
+ kstat_read(kc, CPU_stats_list, NULL);
+ ksinfo = (kstat_named_t *)CPU_stats_list->ks_data;
+ for(i=0; i < (int)(CPU_stats_list->ks_ndata); ++i){ // Walk the kstats for this cpu gathering what we need
+ ksi = ksinfo++;
+ if(!strcmp(ksi->name, "brand")){
+ strncat(strCPUName, (char *)KSTAT_NAMED_STR_PTR(ksi),
+ sizeof(strCPUName)-strlen(strCPUName)-1);
+ strncat(CPUInfo.strFamily, (char *)KSTAT_NAMED_STR_PTR(ksi),
+ sizeof(CPUInfo.strFamily)-strlen(CPUInfo.strFamily)-1);
+ strncpy(CPUInfo.strBrandID, strCPUName,sizeof(CPUInfo.strBrandID)-1);
+ CPUInfo.strBrandID[sizeof(CPUInfo.strBrandID)-1]='\0';
+ // DEBUG llinfos << "CPU brand: " << strCPUName << llendl;
+ continue;
+ }
+
+ if(!strcmp(ksi->name, "clock_MHz")){
+#if defined(__sparc)
+ llinfos << "Raw kstat clock rate is: " << ksi->value.l << llendl;
+ uqwFrequency = (F64)(ksi->value.l * 1000000);
+#else
+ uqwFrequency = (F64)(ksi->value.i64 * 1000000);
+#endif
+ //DEBUG llinfos << "CPU frequency: " << uqwFrequency << llendl;
+ continue;
+ }
+
+#if defined(__i386)
+ if(!strcmp(ksi->name, "vendor_id")){
+ strncpy(CPUInfo.strVendor, (char *)KSTAT_NAMED_STR_PTR(ksi), sizeof(CPUInfo.strVendor)-1);
+ // DEBUG llinfos << "CPU vendor: " << CPUInfo.strVendor << llendl;
+ continue;
+ }
+#endif
+ }
+
+ kstat_close(kc);
+
+#if defined(__sparc) // SPARC does not define a vendor string in kstat
+ strncpy(CPUInfo.strVendor, "Sun Microsystems, Inc.", sizeof(CPUInfo.strVendor)-1);
+#endif
+
+ // DEBUG llinfo << "The system has " << ncpus << " CPUs with a clock rate of " << uqwFrequency << "MHz." << llendl;
+
+ return (&CPUInfo);
+}
+
#else
// LL_DARWIN
@@ -2006,6 +2125,7 @@ bool CProcessor::CPUInfoToText(char *strBuffer, unsigned int uiMaxLen)
{
COPYADD("Processor Serial: Disabled\n");
}
+#if !LL_SOLARIS // NOTE: Why bother printing all this when it's irrelavent
COPYADD("\n\n// CPU Configuration\n////////////////////\n");
FORMATADD("L1 instruction cache: %s\n", CPUInfo._L1.Instruction.strCache);
@@ -2062,7 +2182,7 @@ bool CProcessor::CPUInfoToText(char *strBuffer, unsigned int uiMaxLen)
BOOLADD("VME Virtual 8086 Mode Enhancements: ", CPUInfo._Ext.VME_Virtual8086ModeEnhancements);
BOOLADD("3DNow! Instructions: ", CPUInfo._Ext._3DNOW_InstructionExtensions);
BOOLADD("Enhanced 3DNow! Instructions: ", CPUInfo._Ext._E3DNOW_InstructionExtensions);
-
+#endif
// Yippie!!!
return true;
}
diff --git a/indra/llcommon/llsdutil.cpp b/indra/llcommon/llsdutil.cpp
index e6d9396f7d..2b94e19fd4 100644
--- a/indra/llcommon/llsdutil.cpp
+++ b/indra/llcommon/llsdutil.cpp
@@ -15,7 +15,7 @@
#if LL_WINDOWS
# define WIN32_LEAN_AND_MEAN
# include <winsock2.h> // for htonl
-#elif LL_LINUX
+#elif LL_LINUX || LL_SOLARIS
# include <netinet/in.h>
#elif LL_DARWIN
# include <arpa/inet.h>
diff --git a/indra/llcommon/llstring.h b/indra/llcommon/llstring.h
index c958e08415..3005155b19 100644
--- a/indra/llcommon/llstring.h
+++ b/indra/llcommon/llstring.h
@@ -20,7 +20,7 @@
#include <errno.h>
#include <math.h>
#include <stdarg.h> /* for vsnprintf */
-#if LL_LINUX
+#if LL_LINUX || LL_SOLARIS
#include <wctype.h>
#include <wchar.h>
#endif
@@ -34,7 +34,7 @@ class LLUUID;
class LLColor4;
class LLColor4U;
-#if (LL_DARWIN || (LL_LINUX && __GNUC__ > 2))
+#if (LL_DARWIN || LL_SOLARIS || (LL_LINUX && __GNUC__ > 2))
// Template specialization of char_traits for U16s. Only necessary on Mac for now (exists on Windows, unused/broken on Linux/gcc2.95)
namespace std
{
@@ -185,7 +185,7 @@ public:
LLStringBase(const T* s, size_type n);
LLStringBase(const T* s, size_type pos, size_type n );
-#if LL_LINUX
+#if LL_LINUX || LL_SOLARIS
void clear() { assign(null); }
LLStringBase<T>& assign(const T* s);
@@ -680,7 +680,7 @@ LLStringBase<T>::LLStringBase(const T* s, size_type pos, size_type n ) : std::ba
}
}
-#if LL_LINUX
+#if LL_LINUX || LL_SOLARIS
template<class T>
LLStringBase<T>& LLStringBase<T>::assign(const T* s)
{
@@ -1075,7 +1075,7 @@ BOOL LLStringBase<T>::read(std::basic_string<T>& string, const char* filename)
template<class T>
BOOL LLStringBase<T>::write(std::basic_string<T>& string, const char* filename)
{
-#ifdef LL_LINUX
+#if LL_LINUX || LL_SOLARIS
printf("STUBBED: LLStringBase<T>::write at %s:%d\n", __FILE__, __LINE__);
#else
llofstream ofs(filename, llofstream::binary);
diff --git a/indra/llcommon/llsys.cpp b/indra/llcommon/llsys.cpp
index 3398f475aa..87d31987ce 100644
--- a/indra/llcommon/llsys.cpp
+++ b/indra/llcommon/llsys.cpp
@@ -166,7 +166,7 @@ LLOSInfo::LLOSInfo() :
}
#else
struct utsname un;
- if(0==uname(&un))
+ if(uname(&un) != -1)
{
mOSString.append(un.sysname);
mOSString.append(" ");
@@ -239,10 +239,9 @@ U32 LLOSInfo::getProcessVirtualSizeKB()
FILE* status_filep = LLFile::fopen("/proc/self/status", "r"); /* Flawfinder: ignore */
S32 numRead = 0;
char buff[STATUS_SIZE]; /* Flawfinder: ignore */
- bzero(buff, STATUS_SIZE);
- rewind(status_filep);
- fread(buff, 1, STATUS_SIZE-2, status_filep);
+ size_t nbytes = fread(buff, 1, STATUS_SIZE-1, status_filep);
+ buff[nbytes] = '\0';
// All these guys return numbers in KB
char *memp = strstr(buff, "VmSize:");
@@ -251,6 +250,24 @@ U32 LLOSInfo::getProcessVirtualSizeKB()
numRead += sscanf(memp, "%*s %u", &virtual_size);
}
fclose(status_filep);
+#elif LL_SOLARIS
+ char proc_ps[LL_MAX_PATH];
+ sprintf(proc_ps, "/proc/%d/psinfo", (int)getpid());
+ int proc_fd = -1;
+ if((proc_fd = open(proc_ps, O_RDONLY)) == -1){
+ llwarns << "unable to open " << proc_ps << llendl;
+ return 0;
+ }
+ psinfo_t proc_psinfo;
+ if(read(proc_fd, &proc_psinfo, sizeof(psinfo_t)) != sizeof(psinfo_t)){
+ llwarns << "Unable to read " << proc_ps << llendl;
+ close(proc_fd);
+ return 0;
+ }
+
+ close(proc_fd);
+
+ virtual_size = proc_psinfo.pr_size;
#endif
return virtual_size;
}
@@ -267,10 +284,9 @@ U32 LLOSInfo::getProcessResidentSizeKB()
{
S32 numRead = 0;
char buff[STATUS_SIZE]; /* Flawfinder: ignore */
- bzero(buff, STATUS_SIZE);
- rewind(status_filep);
- fread(buff, 1, STATUS_SIZE-2, status_filep);
+ size_t nbytes = fread(buff, 1, STATUS_SIZE-1, status_filep);
+ buff[nbytes] = '\0';
// All these guys return numbers in KB
char *memp = strstr(buff, "VmRSS:");
@@ -280,6 +296,24 @@ U32 LLOSInfo::getProcessResidentSizeKB()
}
fclose(status_filep);
}
+#elif LL_SOLARIS
+ char proc_ps[LL_MAX_PATH];
+ sprintf(proc_ps, "/proc/%d/psinfo", (int)getpid());
+ int proc_fd = -1;
+ if((proc_fd = open(proc_ps, O_RDONLY)) == -1){
+ llwarns << "unable to open " << proc_ps << llendl;
+ return 0;
+ }
+ psinfo_t proc_psinfo;
+ if(read(proc_fd, &proc_psinfo, sizeof(psinfo_t)) != sizeof(psinfo_t)){
+ llwarns << "Unable to read " << proc_ps << llendl;
+ close(proc_fd);
+ return 0;
+ }
+
+ close(proc_fd);
+
+ resident_size = proc_psinfo.pr_rssize;
#endif
return resident_size;
}
@@ -318,7 +352,7 @@ S32 LLCPUInfo::getMhz() const
std::string LLCPUInfo::getCPUString() const
{
-#if LL_WINDOWS || LL_DARWIN
+#if LL_WINDOWS || LL_DARWIN || LL_SOLARIS
std::ostringstream out;
CProcessor proc;
@@ -341,7 +375,7 @@ std::string LLCPUInfo::getCPUString() const
void LLCPUInfo::stream(std::ostream& s) const
{
-#if LL_WINDOWS || LL_DARWIN
+#if LL_WINDOWS || LL_DARWIN || LL_SOLARIS
// gather machine information.
char proc_buf[CPUINFO_BUFFER_SIZE]; /* Flawfinder: ignore */
CProcessor proc;
@@ -404,7 +438,8 @@ U32 LLMemoryInfo::getPhysicalMemory() const
#elif LL_LINUX
return getpagesize() * get_phys_pages();
-
+#elif LL_SOLARIS
+ return getpagesize() * sysconf(_SC_PHYS_PAGES);
#else
return 0;
@@ -438,7 +473,12 @@ void LLMemoryInfo::stream(std::ostream& s) const
{
s << "Unable to collect memory information";
}
-
+#elif LL_SOLARIS
+ U64 phys = 0;
+
+ phys = (U64)(sysconf(_SC_PHYS_PAGES)) * (U64)(sysconf(_SC_PAGESIZE)/1024);
+
+ s << "Total Physical Kb: " << phys << std::endl;
#else
// *NOTE: This works on linux. What will it do on other systems?
FILE* meminfo = LLFile::fopen(MEMINFO_FILE,"r"); /* Flawfinder: ignore */
@@ -496,7 +536,11 @@ BOOL gunzip_file(const char *srcfile, const char *dstfile)
do
{
bytes = gzread(src, buffer, UNCOMPRESS_BUFFER_SIZE);
- fwrite(buffer, sizeof(U8), bytes, dst);
+ size_t nwrit = fwrite(buffer, sizeof(U8), bytes, dst);
+ if (nwrit < (size_t) bytes)
+ {
+ llerrs << "Short write on " << tmpfile << llendl;
+ }
} while(gzeof(src) == 0);
fclose(dst);
dst = NULL;
diff --git a/indra/llcommon/llthread.cpp b/indra/llcommon/llthread.cpp
index a92d553148..b7be8d6a3b 100644
--- a/indra/llcommon/llthread.cpp
+++ b/indra/llcommon/llthread.cpp
@@ -12,7 +12,7 @@
#include "lltimer.h"
-#if LL_LINUX
+#if LL_LINUX || LL_SOLARIS
#include <sched.h>
#endif
@@ -206,7 +206,7 @@ void LLThread::setQuitting()
// static
void LLThread::yield()
{
-#if LL_LINUX
+#if LL_LINUX || LL_SOLARIS
sched_yield(); // annoyingly, apr_thread_yield is a noop on linux...
#else
apr_thread_yield();
diff --git a/indra/llcommon/lltimer.cpp b/indra/llcommon/lltimer.cpp
index a8118258f9..993574b528 100644
--- a/indra/llcommon/lltimer.cpp
+++ b/indra/llcommon/lltimer.cpp
@@ -17,7 +17,7 @@
# include <winsock2.h>
# include <windows.h>
# include <time.h>
-#elif LL_LINUX
+#elif LL_LINUX || LL_SOLARIS
# include <time.h>
# include <sys/time.h>
# include <sched.h>
@@ -70,7 +70,7 @@ void llyield()
{
SleepEx(0, TRUE); // Relinquishes time slice to any thread of equal priority, can be woken up by extended IO functions
}
-#elif LL_LINUX
+#elif LL_LINUX || LL_SOLARIS
void ms_sleep(long ms)
{
struct timespec t;
@@ -130,7 +130,7 @@ F64 calc_clock_frequency(U32 uiMeasureMSecs)
#endif // LL_WINDOWS
-#if LL_LINUX || LL_DARWIN
+#if LL_LINUX || LL_DARWIN || LL_SOLARIS
// Both Linux and Mac use gettimeofday for accurate time
F64 calc_clock_frequency(unsigned int uiMeasureMSecs)
{
@@ -149,7 +149,7 @@ U64 get_clock_count()
void update_clock_frequencies()
{
- gClockFrequency = calc_clock_frequency(50);
+ gClockFrequency = calc_clock_frequency(50U);
gClockFrequencyInv = 1.0/gClockFrequency;
gClocksToMicroseconds = gClockFrequencyInv * SEC_TO_MICROSEC;
}
diff --git a/indra/llcommon/llworkerthread.cpp b/indra/llcommon/llworkerthread.cpp
index 31f5c1cfcd..5c304077fb 100644
--- a/indra/llcommon/llworkerthread.cpp
+++ b/indra/llcommon/llworkerthread.cpp
@@ -84,6 +84,8 @@ S32 LLWorkerThread::update(U32 max_time_ms)
}
delete *iter;
}
+ // delete and aborted entries mean there's still work to do
+ res += delete_list.size() + abort_list.size();
return res;
}
diff --git a/indra/llcommon/stdtypes.h b/indra/llcommon/stdtypes.h
index b898475683..ccb843061d 100644
--- a/indra/llcommon/stdtypes.h
+++ b/indra/llcommon/stdtypes.h
@@ -11,18 +11,18 @@
#include <limits.h>
#include <float.h>
-typedef signed char S8;
+typedef signed char S8;
typedef unsigned char U8;
typedef signed short S16;
typedef unsigned short U16;
-typedef signed int S32;
+typedef signed int S32;
typedef unsigned int U32;
#if LL_WINDOWS
// Windows wchar_t is 16-bit
-typedef U32 llwchar;
+typedef U32 llwchar;
#else
-typedef wchar_t llwchar;
+typedef wchar_t llwchar;
#endif
#if LL_WINDOWS
@@ -33,20 +33,20 @@ typedef unsigned __int64 U64;
#define U64L(a) (a)
#else
typedef long long int S64;
-typedef long long unsigned int U64;
-#if LL_DARWIN || LL_LINUX
-#define S64L(a) (a##LL)
-#define U64L(a) (a##ULL)
+typedef long long unsigned int U64;
+#if LL_DARWIN || LL_LINUX || LL_SOLARIS
+#define S64L(a) (a##LL)
+#define U64L(a) (a##ULL)
#endif
#endif
-typedef float F32;
-typedef double F64;
+typedef float F32;
+typedef double F64;
typedef S32 BOOL;
typedef U8 KEY;
typedef U32 MASK;
-typedef U32 TPACKETID;
+typedef U32 TPACKETID;
// Use #define instead of consts to avoid conversion headaches
#define S8_MAX (SCHAR_MAX)
diff --git a/indra/llcommon/timing.h b/indra/llcommon/timing.h
index f09fb0f92b..8952bc3b52 100644
--- a/indra/llcommon/timing.h
+++ b/indra/llcommon/timing.h
@@ -11,7 +11,7 @@
#include <time.h>
-#if LL_LINUX || LL_DARWIN
+#if LL_LINUX || LL_DARWIN || LL_SOLARIS
# include <sys/time.h>
#endif