aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llcommon
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:45:04 -0500
committerJacek Antonelli2008-08-15 23:45:04 -0500
commit117e22047c5752352342d64e3fb7ce00a4eb8113 (patch)
treee32de2cfba0dda8705ae528fcd1fbe23ba075685 /linden/indra/llcommon
parentSecond Life viewer sources 1.18.0.6 (diff)
downloadmeta-impy-117e22047c5752352342d64e3fb7ce00a4eb8113.zip
meta-impy-117e22047c5752352342d64e3fb7ce00a4eb8113.tar.gz
meta-impy-117e22047c5752352342d64e3fb7ce00a4eb8113.tar.bz2
meta-impy-117e22047c5752352342d64e3fb7ce00a4eb8113.tar.xz
Second Life viewer sources 1.18.1.2
Diffstat (limited to '')
-rw-r--r--linden/indra/llcommon/indra_constants.h10
-rw-r--r--linden/indra/llcommon/llapr.h2
-rw-r--r--linden/indra/llcommon/llcommon.vcproj3
-rw-r--r--linden/indra/llcommon/lldate.cpp48
-rw-r--r--linden/indra/llcommon/lldate.h6
-rw-r--r--linden/indra/llcommon/llfasttimer.cpp8
-rw-r--r--linden/indra/llcommon/llfixedbuffer.cpp2
-rw-r--r--linden/indra/llcommon/llhash.h4
-rw-r--r--linden/indra/llcommon/llmemory.cpp5
-rw-r--r--linden/indra/llcommon/llmemtype.h2
-rw-r--r--linden/indra/llcommon/llpagemem.h393
-rw-r--r--linden/indra/llcommon/llpreprocessor.h27
-rw-r--r--linden/indra/llcommon/llprocessor.cpp184
-rw-r--r--linden/indra/llcommon/llprocessor.h15
-rw-r--r--linden/indra/llcommon/llsdserialize_xml.cpp6
-rw-r--r--linden/indra/llcommon/llsdutil.cpp2
-rw-r--r--linden/indra/llcommon/llskiplist.h12
-rw-r--r--linden/indra/llcommon/llstring.h10
-rw-r--r--linden/indra/llcommon/llsys.cpp204
-rw-r--r--linden/indra/llcommon/llsys.h13
-rw-r--r--linden/indra/llcommon/llthread.cpp4
-rw-r--r--linden/indra/llcommon/lltimer.cpp14
-rw-r--r--linden/indra/llcommon/lltimer.h2
-rw-r--r--linden/indra/llcommon/lluri.cpp35
-rw-r--r--linden/indra/llcommon/lluri.h97
-rw-r--r--linden/indra/llcommon/llversion.h4
-rw-r--r--linden/indra/llcommon/llworkerthread.cpp2
-rw-r--r--linden/indra/llcommon/stdtypes.h22
-rw-r--r--linden/indra/llcommon/timing.h2
29 files changed, 560 insertions, 578 deletions
diff --git a/linden/indra/llcommon/indra_constants.h b/linden/indra/llcommon/indra_constants.h
index 9024b12..21635b5 100644
--- a/linden/indra/llcommon/indra_constants.h
+++ b/linden/indra/llcommon/indra_constants.h
@@ -130,10 +130,12 @@ const char CLOUD_LAYER_CODE = '8';
130 130
131// keys 131// keys
132// Bit masks for various keyboard modifier keys. 132// Bit masks for various keyboard modifier keys.
133const MASK MASK_NONE = 0x0000; 133const MASK MASK_NONE = 0x0000;
134const MASK MASK_CONTROL = 0x0001; 134const MASK MASK_CONTROL = 0x0001; // Mapped to cmd on Macs
135const MASK MASK_ALT = 0x0002; 135const MASK MASK_ALT = 0x0002;
136const MASK MASK_SHIFT = 0x0004; 136const MASK MASK_SHIFT = 0x0004;
137const MASK MASK_NORMALKEYS = 0x0007; // A real mask - only get the bits for normal modifier keys
138const MASK MASK_MAC_CONTROL = 0x0008; // Un-mapped Ctrl key on Macs, not used on Windows
137 139
138// Special keys go into >128 140// Special keys go into >128
139const KEY KEY_SPECIAL = 0x80; // special keys start here 141const KEY KEY_SPECIAL = 0x80; // special keys start here
diff --git a/linden/indra/llcommon/llapr.h b/linden/indra/llcommon/llapr.h
index e7b12d5..6edfc18 100644
--- a/linden/indra/llcommon/llapr.h
+++ b/linden/indra/llcommon/llapr.h
@@ -31,7 +31,7 @@
31#ifndef LL_LLAPR_H 31#ifndef LL_LLAPR_H
32#define LL_LLAPR_H 32#define LL_LLAPR_H
33 33
34#if LL_LINUX 34#if LL_LINUX || LL_SOLARIS
35#include <sys/param.h> // Need PATH_MAX in APR headers... 35#include <sys/param.h> // Need PATH_MAX in APR headers...
36#endif 36#endif
37 37
diff --git a/linden/indra/llcommon/llcommon.vcproj b/linden/indra/llcommon/llcommon.vcproj
index 399dae3..5557f94 100644
--- a/linden/indra/llcommon/llcommon.vcproj
+++ b/linden/indra/llcommon/llcommon.vcproj
@@ -445,9 +445,6 @@
445 RelativePath=".\llnametable.h"> 445 RelativePath=".\llnametable.h">
446 </File> 446 </File>
447 <File 447 <File
448 RelativePath=".\llpagemem.h">
449 </File>
450 <File
451 RelativePath=".\llpreprocessor.h"> 448 RelativePath=".\llpreprocessor.h">
452 </File> 449 </File>
453 <File 450 <File
diff --git a/linden/indra/llcommon/lldate.cpp b/linden/indra/llcommon/lldate.cpp
index ccc314d..47e5370 100644
--- a/linden/indra/llcommon/lldate.cpp
+++ b/linden/indra/llcommon/lldate.cpp
@@ -72,6 +72,54 @@ std::string LLDate::asString() const
72 return stream.str(); 72 return stream.str();
73} 73}
74 74
75//@ brief Converts time in seconds since EPOCH
76// to RFC 1123 compliant date format
77// E.g. 1184797044.037586 == Wednesday, 18 Jul 2007 22:17:24 GMT
78// in RFC 1123. HTTP dates are always in GMT and RFC 1123
79// is one of the standards used and the prefered format
80std::string LLDate::asRFC1123() const
81{
82 std::ostringstream stream;
83 toHTTPDateStream(stream);
84 return stream.str();
85}
86
87void LLDate::toHTTPDateStream(std::ostream& s) const
88{
89 // http://apr.apache.org/docs/apr/0.9/group__apr__time.html
90 apr_time_t time = (apr_time_t)(mSecondsSinceEpoch * LL_APR_USEC_PER_SEC);
91
92 apr_time_exp_t exp_time ; //Apache time module
93
94 if (apr_time_exp_gmt(&exp_time, time) != APR_SUCCESS)
95 {
96 // Return Epoch UTC date
97 s << "Thursday, 01 Jan 1970 00:00:00 GMT" ;
98 return;
99 }
100
101 s << std::dec << std::setfill('0');
102#if( LL_WINDOWS || __GNUC__ > 2)
103 s << std::right ;
104#else
105 s.setf(ios::right);
106#endif
107 std::string day = weekdays[exp_time.tm_wday];
108 std::string month = months[exp_time.tm_mon];
109
110 s << std::setw(day.length()) << (day)
111 << ", " << std::setw(2) << (exp_time.tm_mday)
112 << ' ' << std::setw(month.length()) << (month)
113 << ' ' << std::setw(4) << (exp_time.tm_year + 1900)
114 << ' ' << std::setw(2) << (exp_time.tm_hour)
115 << ':' << std::setw(2) << (exp_time.tm_min)
116 << ':' << std::setw(2) << (exp_time.tm_sec)
117 << " GMT";
118
119 // RFC 1123 date does not use microseconds
120 llinfos << "Date in RFC 1123 format is " << s << llendl;
121}
122
75void LLDate::toStream(std::ostream& s) const 123void LLDate::toStream(std::ostream& s) const
76{ 124{
77 apr_time_t time = (apr_time_t)(mSecondsSinceEpoch * LL_APR_USEC_PER_SEC); 125 apr_time_t time = (apr_time_t)(mSecondsSinceEpoch * LL_APR_USEC_PER_SEC);
diff --git a/linden/indra/llcommon/lldate.h b/linden/indra/llcommon/lldate.h
index f8bd625..5d90a54 100644
--- a/linden/indra/llcommon/lldate.h
+++ b/linden/indra/llcommon/lldate.h
@@ -77,7 +77,9 @@ public:
77 * @return A string representation of the date. 77 * @return A string representation of the date.
78 */ 78 */
79 std::string asString() const; 79 std::string asString() const;
80 std::string asRFC1123() const;
80 void toStream(std::ostream&) const; 81 void toStream(std::ostream&) const;
82 void toHTTPDateStream(std::ostream&) const;
81 /** 83 /**
82 * @brief Set the date from an ISO-8601 string. 84 * @brief Set the date from an ISO-8601 string.
83 * 85 *
@@ -119,4 +121,8 @@ std::ostream& operator<<(std::ostream& s, const LLDate& date);
119std::istream& operator>>(std::istream& s, LLDate& date); 121std::istream& operator>>(std::istream& s, LLDate& date);
120 122
121 123
124const static std::string weekdays[] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
125
126const static std::string months[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
127
122#endif // LL_LLDATE_H 128#endif // LL_LLDATE_H
diff --git a/linden/indra/llcommon/llfasttimer.cpp b/linden/indra/llcommon/llfasttimer.cpp
index 2b1d58f..6c0f9ac 100644
--- a/linden/indra/llcommon/llfasttimer.cpp
+++ b/linden/indra/llcommon/llfasttimer.cpp
@@ -33,7 +33,7 @@
33#if LL_WINDOWS 33#if LL_WINDOWS
34#include <time.h> 34#include <time.h>
35 35
36#elif LL_LINUX 36#elif LL_LINUX || LL_SOLARIS
37#include <time.h> 37#include <time.h>
38#include <sys/time.h> 38#include <sys/time.h>
39#include <sched.h> 39#include <sched.h>
@@ -91,7 +91,7 @@ U64 get_cpu_clock_count()
91#endif // LL_WINDOWS 91#endif // LL_WINDOWS
92 92
93 93
94#if LL_LINUX 94#if (LL_LINUX || LL_SOLARIS) && (defined(__i386__) || defined(__amd64__))
95U64 get_cpu_clock_count() 95U64 get_cpu_clock_count()
96{ 96{
97 U64 x; 97 U64 x;
@@ -100,7 +100,7 @@ U64 get_cpu_clock_count()
100} 100}
101#endif 101#endif
102 102
103#if LL_DARWIN 103#if LL_DARWIN || (LL_SOLARIS && defined(__sparc__))
104// 104//
105// Mac implementation of CPU clock 105// Mac implementation of CPU clock
106// 106//
@@ -115,7 +115,7 @@ U64 get_cpu_clock_count()
115////////////////////////////////////////////////////////////////////////////// 115//////////////////////////////////////////////////////////////////////////////
116 116
117//static 117//static
118#if LL_LINUX || LL_DARWIN 118#if LL_LINUX || LL_DARWIN || LL_SOLARIS
119// Both Linux and Mac use gettimeofday for accurate time 119// Both Linux and Mac use gettimeofday for accurate time
120U64 LLFastTimer::countsPerSecond() 120U64 LLFastTimer::countsPerSecond()
121{ 121{
diff --git a/linden/indra/llcommon/llfixedbuffer.cpp b/linden/indra/llcommon/llfixedbuffer.cpp
index 397fcfd..6defd92 100644
--- a/linden/indra/llcommon/llfixedbuffer.cpp
+++ b/linden/indra/llcommon/llfixedbuffer.cpp
@@ -82,7 +82,7 @@ void LLFixedBuffer::setMaxLines(S32 max_lines)
82 82
83void LLFixedBuffer::removeExtraLines() 83void LLFixedBuffer::removeExtraLines()
84{ 84{
85 while ((S32)mLines.size() > llmax(0, (S32)(mMaxLines - 1))) 85 while ((S32)mLines.size() > llmax((S32)0, (S32)(mMaxLines - 1)))
86 { 86 {
87 mLines.pop_front(); 87 mLines.pop_front();
88 mAddTimes.pop_front(); 88 mAddTimes.pop_front();
diff --git a/linden/indra/llcommon/llhash.h b/linden/indra/llcommon/llhash.h
index c3c4ec9..793783f 100644
--- a/linden/indra/llcommon/llhash.h
+++ b/linden/indra/llcommon/llhash.h
@@ -42,6 +42,8 @@
42# else 42# else
43# include <hashtable.h> 43# include <hashtable.h>
44# endif 44# endif
45#elif LL_SOLARIS
46#include <ext/hashtable.h>
45#else 47#else
46#error Please define your platform. 48#error Please define your platform.
47#endif 49#endif
@@ -53,7 +55,7 @@ template<class T> inline size_t llhash(T value)
53#elif ( (defined _STLPORT_VERSION) || ((LL_LINUX) && (__GNUC__ <= 2)) ) 55#elif ( (defined _STLPORT_VERSION) || ((LL_LINUX) && (__GNUC__ <= 2)) )
54 std::hash<T> H; 56 std::hash<T> H;
55 return H(value); 57 return H(value);
56#elif LL_DARWIN || LL_LINUX 58#elif LL_DARWIN || LL_LINUX || LL_SOLARIS
57 __gnu_cxx::hash<T> H; 59 __gnu_cxx::hash<T> H;
58 return H(value); 60 return H(value);
59#else 61#else
diff --git a/linden/indra/llcommon/llmemory.cpp b/linden/indra/llcommon/llmemory.cpp
index 284c8e7..65f3409 100644
--- a/linden/indra/llcommon/llmemory.cpp
+++ b/linden/indra/llcommon/llmemory.cpp
@@ -69,6 +69,7 @@ S32 LLMemType::sCurType = LLMemType::MTYPE_INIT;
69S32 LLMemType::sType[LLMemType::MTYPE_MAX_DEPTH]; 69S32 LLMemType::sType[LLMemType::MTYPE_MAX_DEPTH];
70S32 LLMemType::sMemCount[LLMemType::MTYPE_NUM_TYPES] = { 0 }; 70S32 LLMemType::sMemCount[LLMemType::MTYPE_NUM_TYPES] = { 0 };
71S32 LLMemType::sMaxMemCount[LLMemType::MTYPE_NUM_TYPES] = { 0 }; 71S32 LLMemType::sMaxMemCount[LLMemType::MTYPE_NUM_TYPES] = { 0 };
72S32 LLMemType::sNewCount[LLMemType::MTYPE_NUM_TYPES] = { 0 };
72S32 LLMemType::sOverheadMem = 0; 73S32 LLMemType::sOverheadMem = 0;
73 74
74const char* LLMemType::sTypeDesc[LLMemType::MTYPE_NUM_TYPES] = 75const char* LLMemType::sTypeDesc[LLMemType::MTYPE_NUM_TYPES] =
@@ -133,7 +134,7 @@ void LLMemType::printMem()
133 { 134 {
134 if (sMemCount[i]) 135 if (sMemCount[i])
135 { 136 {
136 llinfos << llformat("MEM: % 20s %03d MB (%03d MB)",sTypeDesc[i],sMemCount[i]>>20,sMaxMemCount[i]>>20) << llendl; 137 llinfos << llformat("MEM: % 20s %03d MB (%03d MB) in %06d News",sTypeDesc[i],sMemCount[i]>>20,sMaxMemCount[i]>>20, sNewCount[i]) << llendl;
137 } 138 }
138 misc_mem -= sMemCount[i]; 139 misc_mem -= sMemCount[i];
139 } 140 }
@@ -180,6 +181,7 @@ void* ll_allocate (size_t size)
180 { 181 {
181 LLMemType::sMaxMemCount[LLMemType::sCurType] = LLMemType::sMemCount[LLMemType::sCurType]; 182 LLMemType::sMaxMemCount[LLMemType::sCurType] = LLMemType::sMemCount[LLMemType::sCurType];
182 } 183 }
184 LLMemType::sNewCount[LLMemType::sCurType]++;
183#endif 185#endif
184 return (void*)p; 186 return (void*)p;
185} 187}
@@ -205,6 +207,7 @@ void ll_release (void *pin)
205#if MEM_TRACK_TYPE 207#if MEM_TRACK_TYPE
206 LLMemType::sMemCount[type] -= size; 208 LLMemType::sMemCount[type] -= size;
207 LLMemType::sOverheadMem -= 4; 209 LLMemType::sOverheadMem -= 4;
210 LLMemType::sNewCount[type]--;
208#endif 211#endif
209 LLMemType::sTotalMem -= size; 212 LLMemType::sTotalMem -= size;
210 free(p); 213 free(p);
diff --git a/linden/indra/llcommon/llmemtype.h b/linden/indra/llcommon/llmemtype.h
index 501b5f5..9bab72e 100644
--- a/linden/indra/llcommon/llmemtype.h
+++ b/linden/indra/llcommon/llmemtype.h
@@ -41,6 +41,7 @@ extern void ll_release (void *p);
41#define MEM_TRACK_TYPE (1 && MEM_TRACK_MEM) 41#define MEM_TRACK_TYPE (1 && MEM_TRACK_MEM)
42 42
43#if MEM_TRACK_TYPE 43#if MEM_TRACK_TYPE
44#define MEM_DUMP_DATA 1
44#define MEM_TYPE_NEW(T) \ 45#define MEM_TYPE_NEW(T) \
45static void* operator new(size_t s) { LLMemType mt(T); return ll_allocate(s); } \ 46static void* operator new(size_t s) { LLMemType mt(T); return ll_allocate(s); } \
46static void operator delete(void* p) { ll_release(p); } 47static void operator delete(void* p) { ll_release(p); }
@@ -143,6 +144,7 @@ public:
143 static S32 sType[MTYPE_MAX_DEPTH]; 144 static S32 sType[MTYPE_MAX_DEPTH];
144 static S32 sMemCount[MTYPE_NUM_TYPES]; 145 static S32 sMemCount[MTYPE_NUM_TYPES];
145 static S32 sMaxMemCount[MTYPE_NUM_TYPES]; 146 static S32 sMaxMemCount[MTYPE_NUM_TYPES];
147 static S32 sNewCount[MTYPE_NUM_TYPES];
146 static S32 sOverheadMem; 148 static S32 sOverheadMem;
147 static const char* sTypeDesc[MTYPE_NUM_TYPES]; 149 static const char* sTypeDesc[MTYPE_NUM_TYPES];
148#endif 150#endif
diff --git a/linden/indra/llcommon/llpagemem.h b/linden/indra/llcommon/llpagemem.h
deleted file mode 100644
index f3d6061..0000000
--- a/linden/indra/llcommon/llpagemem.h
+++ /dev/null
@@ -1,393 +0,0 @@
1/**
2 * @file llpagemem.h
3 *
4 * Copyright (c) 2002-2007, Linden Research, Inc.
5 *
6 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement
10 * ("Other License"), formally executed by you and Linden Lab. Terms of
11 * the GPL can be found in doc/GPL-license.txt in this distribution, or
12 * online at http://secondlife.com/developers/opensource/gplv2
13 *
14 * There are special exceptions to the terms and conditions of the GPL as
15 * it is applied to this Source Code. View the full text of the exception
16 * in the file doc/FLOSS-exception.txt in this software distribution, or
17 * online at http://secondlife.com/developers/opensource/flossexception
18 *
19 * By copying, modifying or distributing this software, you acknowledge
20 * that you have read and understood your obligations described above,
21 * and agree to abide by those obligations.
22 *
23 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
24 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
25 * COMPLETENESS OR PERFORMANCE.
26 */
27#ifndef LL_LLPAGEMEM_H
28#define LL_LLPAGEMEM_H
29
30#if !LL_DARWIN
31#include "malloc.h"
32#endif
33
34#include "llrand.h"
35
36
37#ifndef __GNUC__
38template <class Object, U32 mPageSize=1024>
39class LLPageMemory
40{
41private:
42
43 union XObject
44 {
45 XObject *mNextFreeObject;
46 U8 mObject[sizeof(Object)];
47 };
48
49 template <U32 mPageSize> struct Page
50 {
51 XObject *mFirstFreeObject;
52 U32 mObjectCount;
53 U8 mObjects[mPageSize-8];
54
55 void init(U32 mObjPerPage)
56 {
57 XObject *o = (XObject*)&mObjects;
58 mObjectCount = 0;
59 mFirstFreeObject = o;
60
61 for (U32 i = 0; i < mObjPerPage-1; i++)
62 {
63 o->mNextFreeObject = o+1;
64 o++;
65 }
66 o->mNextFreeObject = NULL;
67 };
68
69 Object* alloc()
70 {
71 if (mFirstFreeObject)
72 {
73 XObject *ret = mFirstFreeObject;
74 mFirstFreeObject = mFirstFreeObject->mNextFreeObject;
75 ret->mNextFreeObject = NULL;
76 mObjectCount++;
77 return (Object*)&ret->mObject;
78 };
79 return NULL;
80 }
81 };
82
83 U32 mObjPerPage;
84 U32 mMaxPages;
85 U32 mObjectCount;
86
87 Page<mPageSize>* mPageMemory;
88 Page<mPageSize>* mFirstPage;
89
90public:
91 U32 precise, anywhere, fail;
92
93 void init()
94 {
95 Page<mPageSize> *p = mFirstPage;
96 for (U32 i = 0; i < mMaxPages; i++)
97 {
98 p[i].init(mObjPerPage);
99 }
100
101 precise = 0;
102 anywhere = 0;
103 fail = 0;
104 };
105
106public:
107
108 Page<mPageSize>* pageof(Object *object)
109 {
110 return (Page<mPageSize>*) ((((U32)object - 8) / mPageSize) * mPageSize );
111 }
112
113 LLPageMemory(U32 maxObjects)
114 {
115 mObjPerPage = (mPageSize-8) / sizeof(Object);
116 mMaxPages = (maxObjects / mObjPerPage) + 1;
117 mObjectCount= 0;
118
119 //printf("%d objects per page, %d pages total, %d/%d objects\n",
120 // mObjPerPage, mMaxPages, mMaxPages * mObjPerPage,maxObjects);
121
122 mPageMemory = (Page<mPageSize>*)calloc(mPageSize,mMaxPages+1);
123 mFirstPage = mPageMemory;
124 U32 fix = ((U32)mPageMemory % mPageSize);
125 if (fix) mFirstPage = (Page<mPageSize>*)((U32)mPageMemory+mPageSize-fix);
126
127 //printf("fix = %d\n",fix);
128
129 init();
130 };
131
132 LLPageMemory(void *pageMem, U32 bytes)
133 {
134 }
135
136 ~LLPageMemory()
137 {
138 if (mPageMemory)
139 {
140 free(mPageMemory);
141 }
142 }
143
144 Object* alloc(Object *after=NULL)
145 {
146 Page<mPageSize> * p = mFirstPage;
147 Object * o = NULL;
148 U32 i = mMaxPages;
149
150 if (after)
151 {
152 o = pageof(after)->alloc();
153 if (o)
154 {
155 precise++;
156 return o;
157 }
158 return NULL;
159 }
160
161 F32 frac = 1.0f / (F32)mMaxPages;
162 F32 thresh = 0.0f;
163 for (i = 0; i < mMaxPages; i++)
164 {
165 if (thresh > ((F32)p[i].mObjectCount / (F32)mObjPerPage))
166 {
167 o = p[i].alloc();
168 if (o)
169 {
170 //printf("allocating page %x obj %x\n",p, o);
171 anywhere++;
172 return o;
173 }
174 }
175 thresh += frac;
176 }
177
178 fail++;
179 return NULL;
180 };
181
182 void free(Object *o)
183 {
184 if (!o) return;
185
186 Page<mPageSize> *page = pageof(o);
187 XObject *obj = (XObject*)o;
188
189 //printf("freeing %x\n",obj);
190
191 obj->mNextFreeObject = page->mFirstFreeObject;
192 page->mFirstFreeObject = obj;
193 page->mObjectCount--;
194
195 //printf("freeing page %x %d\n",page, page->mObjectCount);
196 };
197
198 U32 indexof(Object *object)
199 {
200 if (!object) return -1;
201
202 return ((((U32)object-8) % mPageSize) / sizeof(Object)) +
203 ((pageof(object) - mFirstPage) * mObjPerPage);
204 }
205
206
207 void dump()
208 {
209
210 for (U32 i=0;i < mMaxPages;i++)
211 {
212 //printf("page %d %d/%d objects\n",i,mFirstPage[i].mObjectCount,mObjPerPage);
213 }
214 //printf("precise = %d anywhere %d ratio = %f\n",precise,anywhere,(F32)precise/(F32)(anywhere+precise));
215 //printf("fail = %d\n",fail);
216
217 }
218
219 static void test()
220 {
221 struct Foo
222 {
223 U32 ord;
224 U32 foo[8];
225 };
226
227 const U32 count = 100;
228 U32 i,c;
229 U32 mix = 50;
230
231 LLPageMemory<Foo> mem(count);
232 LLRand rand(LLUUID::getRandomSeed());
233
234 Foo *obj[count];
235
236 for (i=0;i<count;i++) obj[i] = 0;
237
238 U32 x= 0;
239 for (U32 run=0; run < 10000 ;run++)
240 {
241 U32 m =rand.llrand(count);
242 for (c=0;c < m;c++)
243 {
244 U32 j = rand.llrand(count);
245 if (obj[j])
246 {
247 mem.free(obj[j]);
248 obj[j] = 0;
249 }
250 }
251
252 m =rand.llrand(count);
253 for (c=0;c<m;c++)
254 {
255 U32 i = rand.llrand(count);
256 while (obj[i] && i < count) i++;
257
258 if (!obj[i])
259 {
260 if (i > 0) obj[i] = mem.alloc(obj[i-1]);
261 else obj[i] = mem.alloc();
262 if (obj[i]) obj[i]->ord = x++;
263 }
264 }
265 }
266
267 for (i = 0; i< count; i++)
268 {
269 //printf("obj[%2d] = %08x %02d %4d\n",i,obj[i],mem.indexof(obj[i]),(obj[i] ? obj[i]->ord : -1));
270 }
271
272 mem.dump();
273 }
274};
275
276
277template <class Object>
278class LLObjectPool
279{
280private:
281
282 class XObject
283 {
284 public:
285 Object mObject;
286 U32 mNextFreeObject;
287
288 XObject() { mObject = NULL; mNextFreeObject = 0; }
289 };
290
291 U32 mNumObjects;
292 U32 mMaxObjects;
293 XObject* mObjects;
294 U32 mFirstFreeObject;
295
296 U32 indexof(XObject *xobj) { return (xobj - mObjects); }
297
298public:
299 LLObjectPool(U32 maxObjects)
300 {
301 mMaxObjects = maxObjects;
302 mFirstFreeObject = 0;
303
304 mObjects = new XObject[mMaxObjects];
305
306 //printf("objectpool allocated %d bytes\n",sizeof(XObject) * mMaxObjects);
307
308 for (U32 i=0;i<mMaxObjects;i++) mObjects[i].mNextFreeObject = i+1;
309 };
310
311 ~LLObjectPool()
312 {
313 delete [] mObjects;
314 mObjects = NULL;
315 }
316
317 Object* alloc(Object *after=NULL)
318 {
319 XObject *obj = &mObjects[mFirstFreeObject];
320 mFirstFreeObject = obj->mNextFreeObject;
321 if (mFirstFreeObject >= mMaxObjects)
322 {
323 llerrs << "Attempted to allocate too many objects out of pool\n" << llendl;
324 llassert(0);
325 }
326 return &obj->mObject;
327 };
328
329 void free(Object *obj)
330 {
331 if (!obj) return;
332 XObject *xobj = (XObject*)obj;
333 xobj->mNextFreeObject = mFirstFreeObject;
334 mFirstFreeObject = indexof(xobj);
335 };
336
337 static void test()
338 {
339 struct Foo
340 {
341 U32 ord;
342 U32 foo[8];
343 };
344
345 const U32 count = 100;
346 U32 i,c;
347 U32 mix = 50;
348
349 LLPageMemory<Foo> mem(count);
350 LLRand rand(LLUUID::getRandomSeed());
351
352 Foo *obj[count];
353
354 for (i=0;i<count;i++) obj[i] = 0;
355
356 U32 x= 0;
357 for (U32 run=0; run < 10000 ;run++)
358 {
359 U32 m =rand.llrand(count);
360 for (c=0;c < m;c++)
361 {
362 U32 j = rand.llrand(count);
363 if (obj[j])
364 {
365 mem.free(obj[j]);
366 obj[j] = 0;
367 }
368 }
369
370 m =rand.llrand(count);
371 for (c=0;c<m;c++)
372 {
373 U32 i = rand.llrand(count);
374 while (obj[i] && i < count) i++;
375
376 if (!obj[i])
377 {
378 if (i > 0) obj[i] = mem.alloc(obj[i-1]);
379 else obj[i] = mem.alloc();
380 if (obj[i]) obj[i]->ord = x++;
381 }
382 }
383 }
384
385 for (i = 0; i< count; i++)
386 {
387 //printf("obj[%2d] = %08x %02d %4d\n",i,obj[i],mem.indexof(obj[i]),(obj[i] ? obj[i]->ord : -1));
388 }
389 }
390};
391#endif // !defined __GNUC__
392
393#endif
diff --git a/linden/indra/llcommon/llpreprocessor.h b/linden/indra/llcommon/llpreprocessor.h
index 495b9e8..f19d5a0 100644
--- a/linden/indra/llcommon/llpreprocessor.h
+++ b/linden/indra/llcommon/llpreprocessor.h
@@ -62,6 +62,11 @@
62 #ifndef LL_LIBXUL_ENABLED 62 #ifndef LL_LIBXUL_ENABLED
63 #define LL_LIBXUL_ENABLED 1 63 #define LL_LIBXUL_ENABLED 1
64 #endif // def LL_LIBXUL_ENABLED 64 #endif // def LL_LIBXUL_ENABLED
65#elif LL_SOLARIS
66 #define LL_QUICKTIME_ENABLED 0
67 #ifndef LL_LIBXUL_ENABLED
68 #define LL_LIBXUL_ENABLED 0
69 #endif // def LL_LIBXUL_ENABLED
65#endif 70#endif
66 71
67#if LL_LIBXUL_ENABLED && !defined(MOZILLA_INTERNAL_API) 72#if LL_LIBXUL_ENABLED && !defined(MOZILLA_INTERNAL_API)
@@ -71,12 +76,22 @@
71 #define MOZILLA_INTERNAL_API 1 76 #define MOZILLA_INTERNAL_API 1
72#endif 77#endif
73 78
74// Deal with minor differences on Unixy OSes. 79// Figure out differences between compilers
75#if LL_DARWIN || LL_LINUX 80#if defined(__GNUC__)
76 #define GCC_VERSION (__GNUC__ * 10000 \ 81 #define GCC_VERSION (__GNUC__ * 10000 \
77 + __GNUC_MINOR__ * 100 \ 82 + __GNUC_MINOR__ * 100 \
78 + __GNUC_PATCHLEVEL__) 83 + __GNUC_PATCHLEVEL__)
84 #ifndef LL_GNUC
85 #define LL_GNUC 1
86 #endif
87#elif defined(__MSVC_VER__) || defined(_MSC_VER)
88 #ifndef LL_MSVC
89 #define LL_MSVC 1
90 #endif
91#endif
79 92
93// Deal with minor differences on Unixy OSes.
94#if LL_DARWIN || LL_LINUX
80 // Different name, same functionality. 95 // Different name, same functionality.
81 #define stricmp strcasecmp 96 #define stricmp strcasecmp
82 #define strnicmp strncasecmp 97 #define strnicmp strncasecmp
@@ -89,9 +104,9 @@
89#endif 104#endif
90 105
91// Deal with the differeneces on Windows 106// Deal with the differeneces on Windows
92#if LL_WINDOWS 107#if LL_MSVC
93#define snprintf safe_snprintf /* Flawfinder: ignore */ 108#define snprintf safe_snprintf /* Flawfinder: ignore */
94#endif // LL_WINDOWS 109#endif // LL_MSVC
95 110
96// Static linking with apr on windows needs to be declared. 111// Static linking with apr on windows needs to be declared.
97#ifdef LL_WINDOWS 112#ifdef LL_WINDOWS
@@ -110,7 +125,7 @@
110 125
111 126
112// Deal with VC6 problems 127// Deal with VC6 problems
113#if defined(LL_WINDOWS) 128#if LL_MSVC
114#pragma warning( 3 : 4701 ) // "local variable used without being initialized" Treat this as level 3, not level 4. 129#pragma warning( 3 : 4701 ) // "local variable used without being initialized" Treat this as level 3, not level 4.
115#pragma warning( 3 : 4702 ) // "unreachable code" Treat this as level 3, not level 4. 130#pragma warning( 3 : 4702 ) // "unreachable code" Treat this as level 3, not level 4.
116#pragma warning( 3 : 4189 ) // "local variable initialized but not referenced" Treat this as level 3, not level 4. 131#pragma warning( 3 : 4189 ) // "local variable initialized but not referenced" Treat this as level 3, not level 4.
@@ -121,6 +136,6 @@
121#pragma warning( disable : 4503 ) // 'decorated name length exceeded, name was truncated'. Does not seem to affect compilation. 136#pragma warning( disable : 4503 ) // 'decorated name length exceeded, name was truncated'. Does not seem to affect compilation.
122#pragma warning( disable : 4800 ) // 'BOOL' : forcing value to bool 'true' or 'false' (performance warning) 137#pragma warning( disable : 4800 ) // 'BOOL' : forcing value to bool 'true' or 'false' (performance warning)
123#pragma warning( disable : 4996 ) // warning: deprecated 138#pragma warning( disable : 4996 ) // warning: deprecated
124#endif // LL_WINDOWS 139#endif // LL_MSVC
125 140
126#endif // not LL_LINDEN_PREPROCESSOR_H 141#endif // not LL_LINDEN_PREPROCESSOR_H
diff --git a/linden/indra/llcommon/llprocessor.cpp b/linden/indra/llcommon/llprocessor.cpp
index bd21351..4d00ab5 100644
--- a/linden/indra/llcommon/llprocessor.cpp
+++ b/linden/indra/llcommon/llprocessor.cpp
@@ -58,7 +58,7 @@
58# include <windows.h> 58# include <windows.h>
59#endif 59#endif
60 60
61#if !LL_DARWIN 61#if !LL_DARWIN && !LL_SOLARIS
62 62
63#ifdef PROCESSOR_FREQUENCY_MEASURE_AVAILABLE 63#ifdef PROCESSOR_FREQUENCY_MEASURE_AVAILABLE
64// We need the QueryPerformanceCounter and Sleep functions 64// We need the QueryPerformanceCounter and Sleep functions
@@ -255,24 +255,24 @@ bool CProcessor::AnalyzeIntelProcessor()
255 /* 0x03 */ "0.13 micron Intel Celeron", 255 /* 0x03 */ "0.13 micron Intel Celeron",
256 /* 0x04 */ "0.13 micron Intel Pentium III", 256 /* 0x04 */ "0.13 micron Intel Pentium III",
257 /* 0x05 */ "", 257 /* 0x05 */ "",
258 /* 0x06 */ "0.13 micron Intel Pentium III mobile", 258 /* 0x06 */ "0.13 micron Intel Pentium III Mobile",
259 /* 0x07 */ "0.13 micron Intel Celeron mobile", 259 /* 0x07 */ "0.13 micron Intel Celeron Mobile",
260 /* 0x08 */ "0.18 micron Intel Pentium 4", 260 /* 0x08 */ "0.18 micron Intel Pentium 4",
261 /* 0x09 */ "0.13 micron Intel Pentium 4", 261 /* 0x09 */ "0.13 micron Intel Pentium 4",
262 /* 0x0A */ "0.13 micron Intel Pentium 4", 262 /* 0x0A */ "0.13 micron Intel Celeron",
263 /* 0x0B */ "0.13 micron Intel Pentium 4 Xeon", 263 /* 0x0B */ "0.13 micron Intel Pentium 4 Xeon",
264 /* 0x0C */ "", 264 /* 0x0C */ "Intel Xeon MP",
265 /* 0x0D */ "", 265 /* 0x0D */ "",
266 /* 0x0E */ "0.18 micron Intel Pentium 4 Xeon", 266 /* 0x0E */ "0.18 micron Intel Pentium 4 Xeon",
267 /* 0x0F */ "", 267 /* 0x0F */ "Mobile Intel Celeron",
268 /* 0x10 */ "", 268 /* 0x10 */ "",
269 /* 0x11 */ "", 269 /* 0x11 */ "Mobile Genuine Intel",
270 /* 0x12 */ "Intel Celeron M", 270 /* 0x12 */ "Intel Celeron M",
271 /* 0x13 */ "mobile Intel Celeron", 271 /* 0x13 */ "Mobile Intel Celeron",
272 /* 0x14 */ "Intel Celeron", 272 /* 0x14 */ "Intel Celeron",
273 /* 0x15 */ "mobile Intel", 273 /* 0x15 */ "Mobile Genuine Intel",
274 /* 0x16 */ "Intel Pentium M", 274 /* 0x16 */ "Intel Pentium M",
275 /* 0x17 */ "mobile Intel Celeron", 275 /* 0x17 */ "Mobile Intel Celeron",
276 }; 276 };
277 277
278 // Only override the brand if we have it in the lookup table. We should 278 // Only override the brand if we have it in the lookup table. We should
@@ -300,7 +300,7 @@ bool CProcessor::AnalyzeIntelProcessor()
300 strcpy(CPUInfo.strFamily, "Intel Pentium"); /* Flawfinder: ignore */ 300 strcpy(CPUInfo.strFamily, "Intel Pentium"); /* Flawfinder: ignore */
301 break; 301 break;
302 case 6: // Family = 6: Pentium Pro (80686) processor family 302 case 6: // Family = 6: Pentium Pro (80686) processor family
303 strcpy(CPUInfo.strFamily, "Intel Pentium Pro"); /* Flawfinder: ignore */ 303 strcpy(CPUInfo.strFamily, "Intel Pentium Pro/2/3, Core"); /* Flawfinder: ignore */
304 break; 304 break;
305 case 15: // Family = 15: Extended family specific 305 case 15: // Family = 15: Extended family specific
306 // Masking the extended family 306 // Masking the extended family
@@ -447,17 +447,21 @@ bool CProcessor::AnalyzeIntelProcessor()
447 case 1: // Model = 8, Brand id = 1: Celeron (on-die L2 cache) processor model 447 case 1: // Model = 8, Brand id = 1: Celeron (on-die L2 cache) processor model
448 strncat(strCPUName, "Intel Celeron (0.18 micron process) with internal L2 cache", sizeof(strCPUName)-(strlen(strCPUName)-1)); /*Flawfinder: ignore*/ 448 strncat(strCPUName, "Intel Celeron (0.18 micron process) with internal L2 cache", sizeof(strCPUName)-(strlen(strCPUName)-1)); /*Flawfinder: ignore*/
449 break; 449 break;
450 case 2: // Model = 8, Brand id = 2: Pentium III (on-die L2 cache) processor model (my current cpu :-)) 450 case 2: // Model = 8, Brand id = 2: Pentium III (on-die L2 cache) processor model (my current cpu :-))
451 strncat(strCPUName, "Intel Pentium III (0.18 micron process) with internal L2 cache", sizeof(strCPUName)-(strlen(strCPUName)-1)); /*Flawfinder: ignore*/ 451 strncat(strCPUName, "Intel Pentium III (0.18 micron process) with internal L2 cache", sizeof(strCPUName)-(strlen(strCPUName)-1)); /*Flawfinder: ignore*/
452 break; 452 break;
453 case 3: // Model = 8, Brand id = 3: Pentium III Xeon (on-die L2 cache) processor model 453 case 3: // Model = 8, Brand id = 3: Pentium III Xeon (on-die L2 cache) processor model
454 strncat(strCPUName, "Intel Pentium III Xeon (0.18 micron process) with internal L2 cache", sizeof(strCPUName)-(strlen(strCPUName)-1)); /*Flawfinder: ignore*/ 454 strncat(strCPUName, "Intel Pentium III Xeon (0.18 micron process) with internal L2 cache", sizeof(strCPUName)-(strlen(strCPUName)-1)); /*Flawfinder: ignore*/
455 break; 455 break;
456 default: // ... 456 default: // ...
457 strncat(strCPUName, "Intel Pentium III core (unknown model, 0.18 micron process) with internal L2 cache", sizeof(strCPUName)-(strlen(strCPUName)-1)); /*Flawfinder: ignore*/ 457 strncat(strCPUName, "Intel Pentium III core (unknown model, 0.18 micron process) with internal L2 cache", sizeof(strCPUName)-(strlen(strCPUName)-1)); /*Flawfinder: ignore*/
458 break; 458 break;
459 } 459 }
460 break; 460 break;
461 case 9: // Model = 9: Intel Pentium M processor, Intel Celeron M processor, model 9
462 strcpy(CPUInfo.strModel, "Intel Pentium M Series Processor"); /*Flawfinder: ignore*/
463 strncat(strCPUName, "Intel Pentium M Series Processor", sizeof(strCPUName)-(strlen(strCPUName)-1)); /*Flawfinder: ignore*/
464 break;
461 case 0xA: // Model = 0xA: Pentium III/Xeon/Celeron (1 or 2 MB on-die L2 cache) processor model 465 case 0xA: // Model = 0xA: Pentium III/Xeon/Celeron (1 or 2 MB on-die L2 cache) processor model
462 strcpy(CPUInfo.strModel, "Intel Pentium III/Celeron/Pentium III Xeon - internal L2 cache, 0.18 micron"); /*Flawfinder: ignore*/ 466 strcpy(CPUInfo.strModel, "Intel Pentium III/Celeron/Pentium III Xeon - internal L2 cache, 0.18 micron"); /*Flawfinder: ignore*/
463 // Exact detection: 467 // Exact detection:
@@ -466,11 +470,11 @@ bool CProcessor::AnalyzeIntelProcessor()
466 case 1: // Model = 0xA, Brand id = 1: Celeron (1 or 2 MB on-die L2 cache (does it exist??)) processor model 470 case 1: // Model = 0xA, Brand id = 1: Celeron (1 or 2 MB on-die L2 cache (does it exist??)) processor model
467 strncat(strCPUName, "Intel Celeron (0.18 micron process) with internal L2 cache", sizeof(strCPUName)-(strlen(strCPUName)-1)); /*Flawfinder: ignore*/ 471 strncat(strCPUName, "Intel Celeron (0.18 micron process) with internal L2 cache", sizeof(strCPUName)-(strlen(strCPUName)-1)); /*Flawfinder: ignore*/
468 break; 472 break;
469 case 2: // Model = 0xA, Brand id = 2: Pentium III (1 or 2 MB on-die L2 cache (never seen...)) processor model 473 case 2: // Model = 0xA, Brand id = 2: Pentium III (1 or 2 MB on-die L2 cache (never seen...)) processor model
470 strncat(strCPUName, "Intel Pentium III (0.18 micron process) with internal L2 cache", sizeof(strCPUName)-(strlen(strCPUName)-1)); /*Flawfinder: ignore*/ 474 strncat(strCPUName, "Intel Pentium III (0.18 micron process) with internal L2 cache", sizeof(strCPUName)-(strlen(strCPUName)-1)); /*Flawfinder: ignore*/
471 break; 475 break;
472 case 3: // Model = 0xA, Brand id = 3: Pentium III Xeon (1 or 2 MB on-die L2 cache) processor model 476 case 3: // Model = 0xA, Brand id = 3: Pentium III Xeon (1 or 2 MB on-die L2 cache) processor model
473 strncat(strCPUName, "Intel Pentium III Xeon (0.18 micron process) with internal L2 cache", sizeof(strCPUName)-(strlen(strCPUName)-1)); /*Flawfinder: ignore*/ 477 strncat(strCPUName, "Intel Pentium III Xeon (0.18 micron process) with internal L2 cache", sizeof(strCPUName)-(strlen(strCPUName)-1)); /*Flawfinder: ignore*/
474 break; 478 break;
475 default: // Getting bored of this............ 479 default: // Getting bored of this............
476 strncat(strCPUName, "Intel Pentium III core (unknown model, 0.18 micron process) with internal L2 cache", sizeof(strCPUName)-(strlen(strCPUName)-1)); /*Flawfinder: ignore*/ 480 strncat(strCPUName, "Intel Pentium III core (unknown model, 0.18 micron process) with internal L2 cache", sizeof(strCPUName)-(strlen(strCPUName)-1)); /*Flawfinder: ignore*/
@@ -485,20 +489,32 @@ bool CProcessor::AnalyzeIntelProcessor()
485 case 3: // Model = 0xB, Brand id = 3: Celeron (Tualatin core) processor model 489 case 3: // Model = 0xB, Brand id = 3: Celeron (Tualatin core) processor model
486 strncat(strCPUName, "Intel Celeron (Tualatin core, 0.13 micron process) with internal L2 cache", sizeof(strCPUName)-(strlen(strCPUName)-1)); /*Flawfinder: ignore*/ 490 strncat(strCPUName, "Intel Celeron (Tualatin core, 0.13 micron process) with internal L2 cache", sizeof(strCPUName)-(strlen(strCPUName)-1)); /*Flawfinder: ignore*/
487 break; 491 break;
488 case 4: // Model = 0xB, Brand id = 4: Pentium III (Tualatin core) processor model 492 case 4: // Model = 0xB, Brand id = 4: Pentium III (Tualatin core) processor model
489 strncat(strCPUName, "Intel Pentium III (Tualatin core, 0.13 micron process) with internal L2 cache", sizeof(strCPUName)-(strlen(strCPUName)-1)); /*Flawfinder: ignore*/ 493 strncat(strCPUName, "Intel Pentium III (Tualatin core, 0.13 micron process) with internal L2 cache", sizeof(strCPUName)-(strlen(strCPUName)-1)); /*Flawfinder: ignore*/
490 break; 494 break;
491 case 7: // Model = 0xB, Brand id = 7: Celeron mobile (Tualatin core) processor model 495 case 7: // Model = 0xB, Brand id = 7: Celeron mobile (Tualatin core) processor model
492 strncat(strCPUName, "Intel Celeron mobile (Tualatin core, 0.13 micron process) with internal L2 cache", sizeof(strCPUName)-(strlen(strCPUName)-1)); /*Flawfinder: ignore*/ 496 strncat(strCPUName, "Intel Celeron mobile (Tualatin core, 0.13 micron process) with internal L2 cache", sizeof(strCPUName)-(strlen(strCPUName)-1)); /*Flawfinder: ignore*/
493 break; 497 break;
494 default: // *bored* 498 default: // *bored*
495 strncat(strCPUName, "Intel Pentium III Tualatin core (unknown model, 0.13 micron process) with internal L2 cache", sizeof(strCPUName)-(strlen(strCPUName)-1)); /*Flawfinder: ignore*/ 499 strncat(strCPUName, "Intel Pentium III Tualatin core (unknown model, 0.13 micron process) with internal L2 cache", sizeof(strCPUName)-(strlen(strCPUName)-1)); /*Flawfinder: ignore*/
496 break; 500 break;
497 } 501 }
498 break; 502 break;
503 case 0xD: // Model = 0xD: Intel Pentium M processor, Intel Celeron M processor, model D
504 strcpy(CPUInfo.strModel, "Intel Pentium M Series Processor"); /*Flawfinder: ignore*/
505 strncat(strCPUName, "Intel Pentium M Series Processor", sizeof(strCPUName)-(strlen(strCPUName)-1)); /*Flawfinder: ignore*/
506 break;
507 case 0xE: // Model = 0xE: Intel Core Duo processor, Intel Core Solo processor, model E
508 strcpy(CPUInfo.strModel, "Intel Core Series Processor"); /*Flawfinder: ignore*/
509 strncat(strCPUName, "Intel Core Series Processor", sizeof(strCPUName)-(strlen(strCPUName)-1)); /*Flawfinder: ignore*/
510 break;
511 case 0xF: // Model = 0xF: Intel Core 2 Duo processor, model F
512 strcpy(CPUInfo.strModel, "Intel Core 2 Series Processor"); /*Flawfinder: ignore*/
513 strncat(strCPUName, "Intel Core 2 Series Processor", sizeof(strCPUName)-(strlen(strCPUName)-1)); /*Flawfinder: ignore*/
514 break;
499 default: // *more bored* 515 default: // *more bored*
500 strcpy(CPUInfo.strModel, "Unknown Intel Pentium Pro"); /*Flawfinder: ignore*/ 516 strcpy(CPUInfo.strModel, "Unknown Intel Pentium Pro/2/3, Core"); /*Flawfinder: ignore*/
501 strncat(strCPUName, "Intel Pentium Pro (Unknown model)", sizeof(strCPUName)-(strlen(strCPUName)-1)); /*Flawfinder: ignore*/ 517 strncat(strCPUName, "Intel Pentium Pro/2/3, Core (Unknown model)", sizeof(strCPUName)-(strlen(strCPUName)-1)); /*Flawfinder: ignore*/
502 break; 518 break;
503 } 519 }
504 break; 520 break;
@@ -1538,6 +1554,7 @@ void CProcessor::GetStandardProcessorExtensions()
1538 CPUInfo._Ext.FXSR_FastStreamingSIMD_ExtensionsSaveRestore = CheckBit(edxreg, 24); 1554 CPUInfo._Ext.FXSR_FastStreamingSIMD_ExtensionsSaveRestore = CheckBit(edxreg, 24);
1539 CPUInfo._Ext.SSE_StreamingSIMD_Extensions = CheckBit(edxreg, 25); 1555 CPUInfo._Ext.SSE_StreamingSIMD_Extensions = CheckBit(edxreg, 25);
1540 CPUInfo._Ext.SSE2_StreamingSIMD2_Extensions = CheckBit(edxreg, 26); 1556 CPUInfo._Ext.SSE2_StreamingSIMD2_Extensions = CheckBit(edxreg, 26);
1557 CPUInfo._Ext.Altivec_Extensions = false;
1541 CPUInfo._Ext.SS_SelfSnoop = CheckBit(edxreg, 27); 1558 CPUInfo._Ext.SS_SelfSnoop = CheckBit(edxreg, 27);
1542 CPUInfo._Ext.HT_HyperThreading = CheckBit(edxreg, 28); 1559 CPUInfo._Ext.HT_HyperThreading = CheckBit(edxreg, 28);
1543 CPUInfo._Ext.HT_HyterThreadingSiblings = (ebxreg >> 16) & 0xFF; 1560 CPUInfo._Ext.HT_HyterThreadingSiblings = (ebxreg >> 16) & 0xFF;
@@ -1643,6 +1660,125 @@ const ProcessorInfo *CProcessor::GetCPUInfo()
1643 return (&CPUInfo); 1660 return (&CPUInfo);
1644} 1661}
1645 1662
1663#elif LL_SOLARIS
1664#include <kstat.h>
1665
1666// ======================
1667// Class constructor:
1668/////////////////////////
1669CProcessor::CProcessor()
1670{
1671 uqwFrequency = 0;
1672 strCPUName[0] = 0;
1673 memset(&CPUInfo, 0, sizeof(CPUInfo));
1674}
1675
1676// unsigned __int64 CProcessor::GetCPUFrequency(unsigned int uiMeasureMSecs)
1677// =========================================================================
1678// Function to query the current CPU frequency
1679////////////////////////////////////////////////////////////////////////////
1680F64 CProcessor::GetCPUFrequency(unsigned int /*uiMeasureMSecs*/)
1681{
1682 if(uqwFrequency == 0){
1683 GetCPUInfo();
1684 }
1685
1686 return uqwFrequency;
1687}
1688
1689// const ProcessorInfo *CProcessor::GetCPUInfo()
1690// =============================================
1691// Calls all the other detection function to create an detailed
1692// processor information
1693///////////////////////////////////////////////////////////////
1694const ProcessorInfo *CProcessor::GetCPUInfo()
1695{
1696 // In Solaris the CPU info is in the kstats
1697 // try "psrinfo" or "kstat cpu_info" to see all
1698 // that's available
1699 int ncpus=0, i;
1700 kstat_ctl_t *kc;
1701 kstat_t *ks;
1702 kstat_named_t *ksinfo, *ksi;
1703 kstat_t *CPU_stats_list;
1704
1705 kc = kstat_open();
1706
1707 if((int)kc == -1){
1708 llwarns << "kstat_open(0 failed!" << llendl;
1709 return (&CPUInfo);
1710 }
1711
1712 for (ks = kc->kc_chain; ks != NULL; ks = ks->ks_next) {
1713 if (strncmp(ks->ks_module, "cpu_info", 8) == 0 &&
1714 strncmp(ks->ks_name, "cpu_info", 8) == 0)
1715 ncpus++;
1716 }
1717
1718 if(ncpus < 1){
1719 llwarns << "No cpus found in kstats!" << llendl;
1720 return (&CPUInfo);
1721 }
1722
1723 for (ks = kc->kc_chain; ks; ks = ks->ks_next) {
1724 if (strncmp(ks->ks_module, "cpu_info", 8) == 0
1725 && strncmp(ks->ks_name, "cpu_info", 8) == 0
1726 && kstat_read(kc, ks, NULL) != -1){
1727 CPU_stats_list = ks; // only looking at the first CPU
1728
1729 break;
1730 }
1731 }
1732
1733 if(ncpus > 1)
1734 snprintf(strCPUName, sizeof(strCPUName), "%d x ", ncpus);
1735
1736 kstat_read(kc, CPU_stats_list, NULL);
1737 ksinfo = (kstat_named_t *)CPU_stats_list->ks_data;
1738 for(i=0; i < (int)(CPU_stats_list->ks_ndata); ++i){ // Walk the kstats for this cpu gathering what we need
1739 ksi = ksinfo++;
1740 if(!strcmp(ksi->name, "brand")){
1741 strncat(strCPUName, (char *)KSTAT_NAMED_STR_PTR(ksi),
1742 sizeof(strCPUName)-strlen(strCPUName)-1);
1743 strncat(CPUInfo.strFamily, (char *)KSTAT_NAMED_STR_PTR(ksi),
1744 sizeof(CPUInfo.strFamily)-strlen(CPUInfo.strFamily)-1);
1745 strncpy(CPUInfo.strBrandID, strCPUName,sizeof(CPUInfo.strBrandID)-1);
1746 CPUInfo.strBrandID[sizeof(CPUInfo.strBrandID)-1]='\0';
1747 // DEBUG llinfos << "CPU brand: " << strCPUName << llendl;
1748 continue;
1749 }
1750
1751 if(!strcmp(ksi->name, "clock_MHz")){
1752#if defined(__sparc)
1753 llinfos << "Raw kstat clock rate is: " << ksi->value.l << llendl;
1754 uqwFrequency = (F64)(ksi->value.l * 1000000);
1755#else
1756 uqwFrequency = (F64)(ksi->value.i64 * 1000000);
1757#endif
1758 //DEBUG llinfos << "CPU frequency: " << uqwFrequency << llendl;
1759 continue;
1760 }
1761
1762#if defined(__i386)
1763 if(!strcmp(ksi->name, "vendor_id")){
1764 strncpy(CPUInfo.strVendor, (char *)KSTAT_NAMED_STR_PTR(ksi), sizeof(CPUInfo.strVendor)-1);
1765 // DEBUG llinfos << "CPU vendor: " << CPUInfo.strVendor << llendl;
1766 continue;
1767 }
1768#endif
1769 }
1770
1771 kstat_close(kc);
1772
1773#if defined(__sparc) // SPARC does not define a vendor string in kstat
1774 strncpy(CPUInfo.strVendor, "Sun Microsystems, Inc.", sizeof(CPUInfo.strVendor)-1);
1775#endif
1776
1777 // DEBUG llinfo << "The system has " << ncpus << " CPUs with a clock rate of " << uqwFrequency << "MHz." << llendl;
1778
1779 return (&CPUInfo);
1780}
1781
1646#else 1782#else
1647// LL_DARWIN 1783// LL_DARWIN
1648 1784
@@ -1891,11 +2027,12 @@ const ProcessorInfo *CProcessor::GetCPUInfo()
1891 break; 2027 break;
1892 } 2028 }
1893 2029
1894 // It's kinda like MMX or SSE...
1895 CPUInfo._Ext.EMMX_MultimediaExtensions = 2030 CPUInfo._Ext.EMMX_MultimediaExtensions =
1896 CPUInfo._Ext.MMX_MultimediaExtensions = 2031 CPUInfo._Ext.MMX_MultimediaExtensions =
1897 CPUInfo._Ext.SSE_StreamingSIMD_Extensions = 2032 CPUInfo._Ext.SSE_StreamingSIMD_Extensions =
1898 CPUInfo._Ext.SSE2_StreamingSIMD2_Extensions = hasFeature("hw.optional.altivec"); 2033 CPUInfo._Ext.SSE2_StreamingSIMD2_Extensions = false;
2034
2035 CPUInfo._Ext.Altivec_Extensions = hasFeature("hw.optional.altivec");
1899 2036
1900#endif 2037#endif
1901 2038
@@ -1912,6 +2049,7 @@ const ProcessorInfo *CProcessor::GetCPUInfo()
1912 CPUInfo._Ext.MMX_MultimediaExtensions = hasFeature("hw.optional.mmx"); 2049 CPUInfo._Ext.MMX_MultimediaExtensions = hasFeature("hw.optional.mmx");
1913 CPUInfo._Ext.SSE_StreamingSIMD_Extensions = hasFeature("hw.optional.sse"); 2050 CPUInfo._Ext.SSE_StreamingSIMD_Extensions = hasFeature("hw.optional.sse");
1914 CPUInfo._Ext.SSE2_StreamingSIMD2_Extensions = hasFeature("hw.optional.sse2"); 2051 CPUInfo._Ext.SSE2_StreamingSIMD2_Extensions = hasFeature("hw.optional.sse2");
2052 CPUInfo._Ext.Altivec_Extensions = false;
1915 CPUInfo._Ext.AA64_AMD64BitArchitecture = hasFeature("hw.optional.x86_64"); 2053 CPUInfo._Ext.AA64_AMD64BitArchitecture = hasFeature("hw.optional.x86_64");
1916 2054
1917#endif 2055#endif
@@ -2015,6 +2153,7 @@ bool CProcessor::CPUInfoToText(char *strBuffer, unsigned int uiMaxLen)
2015 { 2153 {
2016 COPYADD("Processor Serial: Disabled\n"); 2154 COPYADD("Processor Serial: Disabled\n");
2017 } 2155 }
2156#if !LL_SOLARIS // NOTE: Why bother printing all this when it's irrelavent
2018 2157
2019 COPYADD("\n\n// CPU Configuration\n////////////////////\n"); 2158 COPYADD("\n\n// CPU Configuration\n////////////////////\n");
2020 FORMATADD("L1 instruction cache: %s\n", CPUInfo._L1.Instruction.strCache); 2159 FORMATADD("L1 instruction cache: %s\n", CPUInfo._L1.Instruction.strCache);
@@ -2065,12 +2204,13 @@ bool CProcessor::CPUInfoToText(char *strBuffer, unsigned int uiMaxLen)
2065 BOOLADD("SS Self Snoop: ", CPUInfo._Ext.SS_SelfSnoop); 2204 BOOLADD("SS Self Snoop: ", CPUInfo._Ext.SS_SelfSnoop);
2066 BOOLADD("SSE Streaming SIMD Extensions: ", CPUInfo._Ext.SSE_StreamingSIMD_Extensions); 2205 BOOLADD("SSE Streaming SIMD Extensions: ", CPUInfo._Ext.SSE_StreamingSIMD_Extensions);
2067 BOOLADD("SSE2 Streaming SIMD 2 Extensions: ", CPUInfo._Ext.SSE2_StreamingSIMD2_Extensions); 2206 BOOLADD("SSE2 Streaming SIMD 2 Extensions: ", CPUInfo._Ext.SSE2_StreamingSIMD2_Extensions);
2207 BOOLADD("ALTVEC Altivec Extensions: ", CPUInfo._Ext.Altivec_Extensions);
2068 BOOLADD("TM Thermal Monitor: ", CPUInfo._Ext.TM_ThermalMonitor); 2208 BOOLADD("TM Thermal Monitor: ", CPUInfo._Ext.TM_ThermalMonitor);
2069 BOOLADD("TSC Time Stamp Counter: ", CPUInfo._Ext.TSC_TimeStampCounter); 2209 BOOLADD("TSC Time Stamp Counter: ", CPUInfo._Ext.TSC_TimeStampCounter);
2070 BOOLADD("VME Virtual 8086 Mode Enhancements: ", CPUInfo._Ext.VME_Virtual8086ModeEnhancements); 2210 BOOLADD("VME Virtual 8086 Mode Enhancements: ", CPUInfo._Ext.VME_Virtual8086ModeEnhancements);
2071 BOOLADD("3DNow! Instructions: ", CPUInfo._Ext._3DNOW_InstructionExtensions); 2211 BOOLADD("3DNow! Instructions: ", CPUInfo._Ext._3DNOW_InstructionExtensions);
2072 BOOLADD("Enhanced 3DNow! Instructions: ", CPUInfo._Ext._E3DNOW_InstructionExtensions); 2212 BOOLADD("Enhanced 3DNow! Instructions: ", CPUInfo._Ext._E3DNOW_InstructionExtensions);
2073 2213#endif
2074 // Yippie!!! 2214 // Yippie!!!
2075 return true; 2215 return true;
2076} 2216}
diff --git a/linden/indra/llcommon/llprocessor.h b/linden/indra/llcommon/llprocessor.h
index fd9a5da..79dd1e8 100644
--- a/linden/indra/llcommon/llprocessor.h
+++ b/linden/indra/llcommon/llprocessor.h
@@ -40,6 +40,20 @@
40#define PROCESSOR_FREQUENCY_MEASURE_AVAILABLE 40#define PROCESSOR_FREQUENCY_MEASURE_AVAILABLE
41#endif 41#endif
42 42
43#if LL_MSVC && _M_X64
44# define LL_X86_64 1
45# define LL_X86 1
46#elif LL_MSVC && _M_IX86
47# define LL_X86 1
48#elif LL_GNUC && ( defined(__amd64__) || defined(__x86_64__) )
49# define LL_X86_64 1
50# define LL_X86 1
51#elif LL_GNUC && ( defined(__i386__) )
52# define LL_X86 1
53#elif LL_GNUC && ( defined(__powerpc__) || defined(__ppc__) )
54# define LL_PPC 1
55#endif
56
43 57
44typedef struct ProcessorExtensions 58typedef struct ProcessorExtensions
45{ 59{
@@ -71,6 +85,7 @@ typedef struct ProcessorExtensions
71 bool FXSR_FastStreamingSIMD_ExtensionsSaveRestore; 85 bool FXSR_FastStreamingSIMD_ExtensionsSaveRestore;
72 bool SSE_StreamingSIMD_Extensions; 86 bool SSE_StreamingSIMD_Extensions;
73 bool SSE2_StreamingSIMD2_Extensions; 87 bool SSE2_StreamingSIMD2_Extensions;
88 bool Altivec_Extensions;
74 bool SS_SelfSnoop; 89 bool SS_SelfSnoop;
75 bool HT_HyperThreading; 90 bool HT_HyperThreading;
76 unsigned int HT_HyterThreadingSiblings; 91 unsigned int HT_HyterThreadingSiblings;
diff --git a/linden/indra/llcommon/llsdserialize_xml.cpp b/linden/indra/llcommon/llsdserialize_xml.cpp
index 85d3883..6d2f583 100644
--- a/linden/indra/llcommon/llsdserialize_xml.cpp
+++ b/linden/indra/llcommon/llsdserialize_xml.cpp
@@ -36,7 +36,11 @@
36 36
37extern "C" 37extern "C"
38{ 38{
39#include "expat/expat.h" 39#ifdef LL_STANDALONE
40# include <expat.h>
41#else
42# include "expat/expat.h"
43#endif
40} 44}
41 45
42/** 46/**
diff --git a/linden/indra/llcommon/llsdutil.cpp b/linden/indra/llcommon/llsdutil.cpp
index e8b3ac5..0e23054 100644
--- a/linden/indra/llcommon/llsdutil.cpp
+++ b/linden/indra/llcommon/llsdutil.cpp
@@ -35,7 +35,7 @@
35#if LL_WINDOWS 35#if LL_WINDOWS
36# define WIN32_LEAN_AND_MEAN 36# define WIN32_LEAN_AND_MEAN
37# include <winsock2.h> // for htonl 37# include <winsock2.h> // for htonl
38#elif LL_LINUX 38#elif LL_LINUX || LL_SOLARIS
39# include <netinet/in.h> 39# include <netinet/in.h>
40#elif LL_DARWIN 40#elif LL_DARWIN
41# include <arpa/inet.h> 41# include <arpa/inet.h>
diff --git a/linden/indra/llcommon/llskiplist.h b/linden/indra/llcommon/llskiplist.h
index be3385d..40d0c8a 100644
--- a/linden/indra/llcommon/llskiplist.h
+++ b/linden/indra/llcommon/llskiplist.h
@@ -28,11 +28,10 @@
28#ifndef LL_LLSKIPLIST_H 28#ifndef LL_LLSKIPLIST_H
29#define LL_LLSKIPLIST_H 29#define LL_LLSKIPLIST_H
30 30
31#include "llerror.h" 31#include "llrand.h"
32//#include "vmath.h"
33 32
34// NOTA BENE: Insert first needs to be < NOT <= 33// NOTA BENE: Insert first needs to be < NOT <=
35 34// Binary depth must be >= 2
36template <class DATA_TYPE, S32 BINARY_DEPTH = 10> 35template <class DATA_TYPE, S32 BINARY_DEPTH = 10>
37class LLSkipList 36class LLSkipList
38{ 37{
@@ -144,14 +143,11 @@ private:
144// Implementation 143// Implementation
145// 144//
146 145
146
147// Binary depth must be >= 2
147template <class DATA_TYPE, S32 BINARY_DEPTH> 148template <class DATA_TYPE, S32 BINARY_DEPTH>
148inline void LLSkipList<DATA_TYPE, BINARY_DEPTH>::init() 149inline void LLSkipList<DATA_TYPE, BINARY_DEPTH>::init()
149{ 150{
150 if (BINARY_DEPTH < 2)
151 {
152 llerrs << "Trying to create skip list with too little depth, "
153 "must be 2 or greater" << llendl;
154 }
155 S32 i; 151 S32 i;
156 for (i = 0; i < BINARY_DEPTH; i++) 152 for (i = 0; i < BINARY_DEPTH; i++)
157 { 153 {
diff --git a/linden/indra/llcommon/llstring.h b/linden/indra/llcommon/llstring.h
index adfdfb8..5f48580 100644
--- a/linden/indra/llcommon/llstring.h
+++ b/linden/indra/llcommon/llstring.h
@@ -40,7 +40,7 @@
40#include <errno.h> 40#include <errno.h>
41#include <math.h> 41#include <math.h>
42#include <stdarg.h> /* for vsnprintf */ 42#include <stdarg.h> /* for vsnprintf */
43#if LL_LINUX 43#if LL_LINUX || LL_SOLARIS
44#include <wctype.h> 44#include <wctype.h>
45#include <wchar.h> 45#include <wchar.h>
46#endif 46#endif
@@ -54,7 +54,7 @@ class LLUUID;
54class LLColor4; 54class LLColor4;
55class LLColor4U; 55class LLColor4U;
56 56
57#if (LL_DARWIN || (LL_LINUX && __GNUC__ > 2)) 57#if (LL_DARWIN || LL_SOLARIS || (LL_LINUX && __GNUC__ > 2))
58// Template specialization of char_traits for U16s. Only necessary on Mac for now (exists on Windows, unused/broken on Linux/gcc2.95) 58// Template specialization of char_traits for U16s. Only necessary on Mac for now (exists on Windows, unused/broken on Linux/gcc2.95)
59namespace std 59namespace std
60{ 60{
@@ -205,7 +205,7 @@ public:
205 LLStringBase(const T* s, size_type n); 205 LLStringBase(const T* s, size_type n);
206 LLStringBase(const T* s, size_type pos, size_type n ); 206 LLStringBase(const T* s, size_type pos, size_type n );
207 207
208#if LL_LINUX 208#if LL_LINUX || LL_SOLARIS
209 void clear() { assign(null); } 209 void clear() { assign(null); }
210 210
211 LLStringBase<T>& assign(const T* s); 211 LLStringBase<T>& assign(const T* s);
@@ -700,7 +700,7 @@ LLStringBase<T>::LLStringBase(const T* s, size_type pos, size_type n ) : std::ba
700 } 700 }
701} 701}
702 702
703#if LL_LINUX 703#if LL_LINUX || LL_SOLARIS
704template<class T> 704template<class T>
705LLStringBase<T>& LLStringBase<T>::assign(const T* s) 705LLStringBase<T>& LLStringBase<T>::assign(const T* s)
706{ 706{
@@ -1095,7 +1095,7 @@ BOOL LLStringBase<T>::read(std::basic_string<T>& string, const char* filename)
1095template<class T> 1095template<class T>
1096BOOL LLStringBase<T>::write(std::basic_string<T>& string, const char* filename) 1096BOOL LLStringBase<T>::write(std::basic_string<T>& string, const char* filename)
1097{ 1097{
1098#ifdef LL_LINUX 1098#if LL_LINUX || LL_SOLARIS
1099 printf("STUBBED: LLStringBase<T>::write at %s:%d\n", __FILE__, __LINE__); 1099 printf("STUBBED: LLStringBase<T>::write at %s:%d\n", __FILE__, __LINE__);
1100#else 1100#else
1101 llofstream ofs(filename, llofstream::binary); 1101 llofstream ofs(filename, llofstream::binary);
diff --git a/linden/indra/llcommon/llsys.cpp b/linden/indra/llcommon/llsys.cpp
index 48f2474..25749e1 100644
--- a/linden/indra/llcommon/llsys.cpp
+++ b/linden/indra/llcommon/llsys.cpp
@@ -31,9 +31,13 @@
31#include "llsys.h" 31#include "llsys.h"
32 32
33#include <iostream> 33#include <iostream>
34#include <zlib/zlib.h> 34#ifdef LL_STANDALONE
35# include <zlib.h>
36#else
37# include "zlib/zlib.h"
38#endif
35 39
36#include "processor.h" 40#include "llprocessor.h"
37 41
38#if LL_WINDOWS 42#if LL_WINDOWS
39# define WIN32_LEAN_AND_MEAN 43# define WIN32_LEAN_AND_MEAN
@@ -44,6 +48,8 @@
44# include <sys/utsname.h> 48# include <sys/utsname.h>
45#elif LL_LINUX 49#elif LL_LINUX
46# include <sys/utsname.h> 50# include <sys/utsname.h>
51# include <unistd.h>
52# include <sys/sysinfo.h>
47const char MEMINFO_FILE[] = "/proc/meminfo"; 53const char MEMINFO_FILE[] = "/proc/meminfo";
48const char CPUINFO_FILE[] = "/proc/cpuinfo"; 54const char CPUINFO_FILE[] = "/proc/cpuinfo";
49#endif 55#endif
@@ -182,7 +188,7 @@ LLOSInfo::LLOSInfo() :
182 } 188 }
183#else 189#else
184 struct utsname un; 190 struct utsname un;
185 if(0==uname(&un)) 191 if(uname(&un) != -1)
186 { 192 {
187 mOSString.append(un.sysname); 193 mOSString.append(un.sysname);
188 mOSString.append(" "); 194 mOSString.append(" ");
@@ -252,13 +258,12 @@ U32 LLOSInfo::getProcessVirtualSizeKB()
252#if LL_WINDOWS 258#if LL_WINDOWS
253#endif 259#endif
254#if LL_LINUX 260#if LL_LINUX
255 FILE* status_filep = LLFile::fopen("/proc/self/status", "r"); /* Flawfinder: ignore */ 261 FILE* status_filep = LLFile::fopen("/proc/self/status", "rb");
256 S32 numRead = 0; 262 S32 numRead = 0;
257 char buff[STATUS_SIZE]; /* Flawfinder: ignore */ 263 char buff[STATUS_SIZE]; /* Flawfinder: ignore */
258 bzero(buff, STATUS_SIZE);
259 264
260 rewind(status_filep); 265 size_t nbytes = fread(buff, 1, STATUS_SIZE-1, status_filep);
261 fread(buff, 1, STATUS_SIZE-2, status_filep); 266 buff[nbytes] = '\0';
262 267
263 // All these guys return numbers in KB 268 // All these guys return numbers in KB
264 char *memp = strstr(buff, "VmSize:"); 269 char *memp = strstr(buff, "VmSize:");
@@ -267,6 +272,24 @@ U32 LLOSInfo::getProcessVirtualSizeKB()
267 numRead += sscanf(memp, "%*s %u", &virtual_size); 272 numRead += sscanf(memp, "%*s %u", &virtual_size);
268 } 273 }
269 fclose(status_filep); 274 fclose(status_filep);
275#elif LL_SOLARIS
276 char proc_ps[LL_MAX_PATH];
277 sprintf(proc_ps, "/proc/%d/psinfo", (int)getpid());
278 int proc_fd = -1;
279 if((proc_fd = open(proc_ps, O_RDONLY)) == -1){
280 llwarns << "unable to open " << proc_ps << llendl;
281 return 0;
282 }
283 psinfo_t proc_psinfo;
284 if(read(proc_fd, &proc_psinfo, sizeof(psinfo_t)) != sizeof(psinfo_t)){
285 llwarns << "Unable to read " << proc_ps << llendl;
286 close(proc_fd);
287 return 0;
288 }
289
290 close(proc_fd);
291
292 virtual_size = proc_psinfo.pr_size;
270#endif 293#endif
271 return virtual_size; 294 return virtual_size;
272} 295}
@@ -278,15 +301,14 @@ U32 LLOSInfo::getProcessResidentSizeKB()
278#if LL_WINDOWS 301#if LL_WINDOWS
279#endif 302#endif
280#if LL_LINUX 303#if LL_LINUX
281 FILE* status_filep = LLFile::fopen("/proc/self/status", "r"); /* Flawfinder: ignore */ 304 FILE* status_filep = LLFile::fopen("/proc/self/status", "rb");
282 if (status_filep != NULL) 305 if (status_filep != NULL)
283 { 306 {
284 S32 numRead = 0; 307 S32 numRead = 0;
285 char buff[STATUS_SIZE]; /* Flawfinder: ignore */ 308 char buff[STATUS_SIZE]; /* Flawfinder: ignore */
286 bzero(buff, STATUS_SIZE);
287 309
288 rewind(status_filep); 310 size_t nbytes = fread(buff, 1, STATUS_SIZE-1, status_filep);
289 fread(buff, 1, STATUS_SIZE-2, status_filep); 311 buff[nbytes] = '\0';
290 312
291 // All these guys return numbers in KB 313 // All these guys return numbers in KB
292 char *memp = strstr(buff, "VmRSS:"); 314 char *memp = strstr(buff, "VmRSS:");
@@ -296,47 +318,126 @@ U32 LLOSInfo::getProcessResidentSizeKB()
296 } 318 }
297 fclose(status_filep); 319 fclose(status_filep);
298 } 320 }
321#elif LL_SOLARIS
322 char proc_ps[LL_MAX_PATH];
323 sprintf(proc_ps, "/proc/%d/psinfo", (int)getpid());
324 int proc_fd = -1;
325 if((proc_fd = open(proc_ps, O_RDONLY)) == -1){
326 llwarns << "unable to open " << proc_ps << llendl;
327 return 0;
328 }
329 psinfo_t proc_psinfo;
330 if(read(proc_fd, &proc_psinfo, sizeof(psinfo_t)) != sizeof(psinfo_t)){
331 llwarns << "Unable to read " << proc_ps << llendl;
332 close(proc_fd);
333 return 0;
334 }
335
336 close(proc_fd);
337
338 resident_size = proc_psinfo.pr_rssize;
299#endif 339#endif
300 return resident_size; 340 return resident_size;
301} 341}
302 342
303LLCPUInfo::LLCPUInfo() 343LLCPUInfo::LLCPUInfo()
304{ 344{
345 std::ostringstream out;
305 CProcessor proc; 346 CProcessor proc;
306 const ProcessorInfo* info = proc.GetCPUInfo(); 347 const ProcessorInfo* info = proc.GetCPUInfo();
307 mHasSSE = (info->_Ext.SSE_StreamingSIMD_Extensions != 0); 348 // proc.WriteInfoTextFile("procInfo.txt");
308 mHasSSE2 = (info->_Ext.SSE2_StreamingSIMD2_Extensions != 0); 349 mHasSSE = info->_Ext.SSE_StreamingSIMD_Extensions;
350 mHasSSE2 = info->_Ext.SSE2_StreamingSIMD2_Extensions;
351 mHasAltivec = info->_Ext.Altivec_Extensions;
309 mCPUMhz = (S32)(proc.GetCPUFrequency(50)/1000000.0); 352 mCPUMhz = (S32)(proc.GetCPUFrequency(50)/1000000.0);
310 mFamily.assign( info->strFamily ); 353 mFamily.assign( info->strFamily );
354 mCPUString = "Unknown";
355
356#if LL_WINDOWS || LL_DARWIN || LL_SOLARIS
357 out << proc.strCPUName;
358 if (200 < mCPUMhz && mCPUMhz < 10000) // *NOTE: cpu speed is often way wrong, do a sanity check
359 {
360 out << " (" << mCPUMhz << " MHz)";
361 }
362 mCPUString = out.str();
363
364#elif LL_LINUX
365 std::map< LLString, LLString > cpuinfo;
366 FILE* cpuinfo_fp = LLFile::fopen(CPUINFO_FILE, "rb");
367 if(cpuinfo_fp)
368 {
369 char line[MAX_STRING];
370 memset(line, 0, MAX_STRING);
371 while(fgets(line, MAX_STRING, cpuinfo_fp))
372 {
373 // /proc/cpuinfo on Linux looks like:
374 // name\t*: value\n
375 char* tabspot = strchr( line, '\t' );
376 if (tabspot == NULL)
377 continue;
378 char* colspot = strchr( tabspot, ':' );
379 if (colspot == NULL)
380 continue;
381 char* spacespot = strchr( colspot, ' ' );
382 if (spacespot == NULL)
383 continue;
384 char* nlspot = strchr( line, '\n' );
385 if (nlspot == NULL)
386 nlspot = line + strlen( line ); // Fallback to terminating NUL
387 std::string linename( line, tabspot );
388 LLString llinename(linename);
389 LLString::toLower(llinename);
390 std::string lineval( spacespot + 1, nlspot );
391 cpuinfo[ llinename ] = lineval;
392 }
393 fclose(cpuinfo_fp);
394 }
395# if LL_X86
396 LLString flags = " " + cpuinfo["flags"] + " ";
397 LLString::toLower(flags);
398 mHasSSE = ( flags.find( " sse " ) != std::string::npos );
399 mHasSSE2 = ( flags.find( " sse2 " ) != std::string::npos );
400
401 F64 mhz;
402 if (LLString::convertToF64(cpuinfo["cpu mhz"], mhz)
403 && 200.0 < mhz && mhz < 10000.0)
404 {
405 mCPUMhz = (S32)llrint(mhz);
406 }
407 if (!cpuinfo["model name"].empty())
408 mCPUString = cpuinfo["model name"];
409# endif // LL_X86
410#endif // LL_LINUX
311} 411}
312 412
413bool LLCPUInfo::hasAltivec() const
414{
415 return mHasAltivec;
416}
313 417
314std::string LLCPUInfo::getCPUString() const 418bool LLCPUInfo::hasSSE() const
315{ 419{
316#if LL_WINDOWS || LL_DARWIN 420 return mHasSSE;
317 std::ostringstream out; 421}
318 422
319 CProcessor proc; 423bool LLCPUInfo::hasSSE2() const
320 (void) proc.GetCPUInfo(); 424{
321 out << proc.strCPUName << " "; 425 return mHasSSE2;
322 426}
323 F32 freq = (F32)(proc.GetCPUFrequency(50) / 1000000.0);
324 427
325 // cpu speed is often way wrong, do a sanity check 428S32 LLCPUInfo::getMhz() const
326 if (200.f < freq && freq < 10000.f) 429{
327 { 430 return mCPUMhz;
328 out << "(" << (S32)(freq) << " MHz)"; 431}
329 }
330 432
331 return out.str(); 433std::string LLCPUInfo::getCPUString() const
332#else 434{
333 return "Can't get terse CPU information"; 435 return mCPUString;
334#endif
335} 436}
336 437
337void LLCPUInfo::stream(std::ostream& s) const 438void LLCPUInfo::stream(std::ostream& s) const
338{ 439{
339#if LL_WINDOWS || LL_DARWIN 440#if LL_WINDOWS || LL_DARWIN || LL_SOLARIS
340 // gather machine information. 441 // gather machine information.
341 char proc_buf[CPUINFO_BUFFER_SIZE]; /* Flawfinder: ignore */ 442 char proc_buf[CPUINFO_BUFFER_SIZE]; /* Flawfinder: ignore */
342 CProcessor proc; 443 CProcessor proc;
@@ -346,38 +447,41 @@ void LLCPUInfo::stream(std::ostream& s) const
346 } 447 }
347 else 448 else
348 { 449 {
349 s << "Unable to collect processor info"; 450 s << "Unable to collect processor information" << std::endl;
350 } 451 }
351#else 452#else
352 // *NOTE: This works on linux. What will it do on other systems? 453 // *NOTE: This works on linux. What will it do on other systems?
353 FILE* cpuinfo = LLFile::fopen(CPUINFO_FILE, "r"); /* Flawfinder: ignore */ 454 FILE* cpuinfo = LLFile::fopen(CPUINFO_FILE, "rb");
354 if(cpuinfo) 455 if(cpuinfo)
355 { 456 {
356 char line[MAX_STRING]; /* Flawfinder: ignore */ 457 char line[MAX_STRING];
357 memset(line, 0, MAX_STRING); 458 memset(line, 0, MAX_STRING);
358 while(fgets(line, MAX_STRING, cpuinfo)) 459 while(fgets(line, MAX_STRING, cpuinfo))
359 { 460 {
360 line[strlen(line)-1] = ' '; /*Flawfinder: ignore*/ 461 line[strlen(line)-1] = ' ';
361 s << line; 462 s << line;
362 } 463 }
363 fclose(cpuinfo); 464 fclose(cpuinfo);
465 s << std::endl;
364 } 466 }
365 else 467 else
366 { 468 {
367 s << "Unable to collect memory information"; 469 s << "Unable to collect processor information" << std::endl;
368 } 470 }
369#endif 471#endif
472 // These are interesting as they reflect our internal view of the
473 // CPU's attributes regardless of platform
474 s << "->mHasSSE: " << (U32)mHasSSE << std::endl;
475 s << "->mHasSSE2: " << (U32)mHasSSE2 << std::endl;
476 s << "->mHasAltivec: " << (U32)mHasAltivec << std::endl;
477 s << "->mCPUMhz: " << mCPUMhz << std::endl;
478 s << "->mCPUString: " << mCPUString << std::endl;
370} 479}
371 480
372LLMemoryInfo::LLMemoryInfo() 481LLMemoryInfo::LLMemoryInfo()
373{ 482{
374} 483}
375 484
376#if LL_LINUX
377#include <unistd.h>
378#include <sys/sysinfo.h>
379#endif
380
381U32 LLMemoryInfo::getPhysicalMemory() const 485U32 LLMemoryInfo::getPhysicalMemory() const
382{ 486{
383#if LL_WINDOWS 487#if LL_WINDOWS
@@ -399,7 +503,8 @@ U32 LLMemoryInfo::getPhysicalMemory() const
399#elif LL_LINUX 503#elif LL_LINUX
400 504
401 return getpagesize() * get_phys_pages(); 505 return getpagesize() * get_phys_pages();
402 506#elif LL_SOLARIS
507 return getpagesize() * sysconf(_SC_PHYS_PAGES);
403#else 508#else
404 return 0; 509 return 0;
405 510
@@ -433,10 +538,15 @@ void LLMemoryInfo::stream(std::ostream& s) const
433 { 538 {
434 s << "Unable to collect memory information"; 539 s << "Unable to collect memory information";
435 } 540 }
436 541#elif LL_SOLARIS
542 U64 phys = 0;
543
544 phys = (U64)(sysconf(_SC_PHYS_PAGES)) * (U64)(sysconf(_SC_PAGESIZE)/1024);
545
546 s << "Total Physical Kb: " << phys << std::endl;
437#else 547#else
438 // *NOTE: This works on linux. What will it do on other systems? 548 // *NOTE: This works on linux. What will it do on other systems?
439 FILE* meminfo = LLFile::fopen(MEMINFO_FILE,"r"); /* Flawfinder: ignore */ 549 FILE* meminfo = LLFile::fopen(MEMINFO_FILE,"rb");
440 if(meminfo) 550 if(meminfo)
441 { 551 {
442 char line[MAX_STRING]; /* Flawfinder: ignore */ 552 char line[MAX_STRING]; /* Flawfinder: ignore */
@@ -491,7 +601,11 @@ BOOL gunzip_file(const char *srcfile, const char *dstfile)
491 do 601 do
492 { 602 {
493 bytes = gzread(src, buffer, UNCOMPRESS_BUFFER_SIZE); 603 bytes = gzread(src, buffer, UNCOMPRESS_BUFFER_SIZE);
494 fwrite(buffer, sizeof(U8), bytes, dst); 604 size_t nwrit = fwrite(buffer, sizeof(U8), bytes, dst);
605 if (nwrit < (size_t) bytes)
606 {
607 llerrs << "Short write on " << tmpfile << llendl;
608 }
495 } while(gzeof(src) == 0); 609 } while(gzeof(src) == 0);
496 fclose(dst); 610 fclose(dst);
497 dst = NULL; 611 dst = NULL;
diff --git a/linden/indra/llcommon/llsys.h b/linden/indra/llcommon/llsys.h
index 2047d9a..416bd54 100644
--- a/linden/indra/llcommon/llsys.h
+++ b/linden/indra/llcommon/llsys.h
@@ -72,18 +72,21 @@ public:
72 72
73 std::string getCPUString() const; 73 std::string getCPUString() const;
74 74
75 BOOL hasSSE() const { return mHasSSE; } 75 bool hasAltivec() const;
76 BOOL hasSSE2() const { return mHasSSE2; } 76 bool hasSSE() const;
77 S32 getMhz() const { return mCPUMhz; } 77 bool hasSSE2() const;
78 S32 getMhz() const;
78 79
79 // Family is "AMD Duron" or "Intel Pentium Pro" 80 // Family is "AMD Duron" or "Intel Pentium Pro"
80 const std::string& getFamily() const { return mFamily; } 81 const std::string& getFamily() const { return mFamily; }
81 82
82private: 83private:
83 BOOL mHasSSE; 84 bool mHasSSE;
84 BOOL mHasSSE2; 85 bool mHasSSE2;
86 bool mHasAltivec;
85 S32 mCPUMhz; 87 S32 mCPUMhz;
86 std::string mFamily; 88 std::string mFamily;
89 std::string mCPUString;
87}; 90};
88 91
89class LLMemoryInfo 92class LLMemoryInfo
diff --git a/linden/indra/llcommon/llthread.cpp b/linden/indra/llcommon/llthread.cpp
index 0f833ab..d261c8b 100644
--- a/linden/indra/llcommon/llthread.cpp
+++ b/linden/indra/llcommon/llthread.cpp
@@ -32,7 +32,7 @@
32 32
33#include "lltimer.h" 33#include "lltimer.h"
34 34
35#if LL_LINUX 35#if LL_LINUX || LL_SOLARIS
36#include <sched.h> 36#include <sched.h>
37#endif 37#endif
38 38
@@ -226,7 +226,7 @@ void LLThread::setQuitting()
226// static 226// static
227void LLThread::yield() 227void LLThread::yield()
228{ 228{
229#if LL_LINUX 229#if LL_LINUX || LL_SOLARIS
230 sched_yield(); // annoyingly, apr_thread_yield is a noop on linux... 230 sched_yield(); // annoyingly, apr_thread_yield is a noop on linux...
231#else 231#else
232 apr_thread_yield(); 232 apr_thread_yield();
diff --git a/linden/indra/llcommon/lltimer.cpp b/linden/indra/llcommon/lltimer.cpp
index 21fbf0e..6077063 100644
--- a/linden/indra/llcommon/lltimer.cpp
+++ b/linden/indra/llcommon/lltimer.cpp
@@ -37,7 +37,7 @@
37# include <winsock2.h> 37# include <winsock2.h>
38# include <windows.h> 38# include <windows.h>
39# include <time.h> 39# include <time.h>
40#elif LL_LINUX 40#elif LL_LINUX || LL_SOLARIS
41# include <time.h> 41# include <time.h>
42# include <sys/time.h> 42# include <sys/time.h>
43# include <sched.h> 43# include <sched.h>
@@ -90,7 +90,7 @@ void llyield()
90{ 90{
91 SleepEx(0, TRUE); // Relinquishes time slice to any thread of equal priority, can be woken up by extended IO functions 91 SleepEx(0, TRUE); // Relinquishes time slice to any thread of equal priority, can be woken up by extended IO functions
92} 92}
93#elif LL_LINUX 93#elif LL_LINUX || LL_SOLARIS
94void ms_sleep(long ms) 94void ms_sleep(long ms)
95{ 95{
96 struct timespec t; 96 struct timespec t;
@@ -150,7 +150,7 @@ F64 calc_clock_frequency(U32 uiMeasureMSecs)
150#endif // LL_WINDOWS 150#endif // LL_WINDOWS
151 151
152 152
153#if LL_LINUX || LL_DARWIN 153#if LL_LINUX || LL_DARWIN || LL_SOLARIS
154// Both Linux and Mac use gettimeofday for accurate time 154// Both Linux and Mac use gettimeofday for accurate time
155F64 calc_clock_frequency(unsigned int uiMeasureMSecs) 155F64 calc_clock_frequency(unsigned int uiMeasureMSecs)
156{ 156{
@@ -169,7 +169,7 @@ U64 get_clock_count()
169 169
170void update_clock_frequencies() 170void update_clock_frequencies()
171{ 171{
172 gClockFrequency = calc_clock_frequency(50); 172 gClockFrequency = calc_clock_frequency(50U);
173 gClockFrequencyInv = 1.0/gClockFrequency; 173 gClockFrequencyInv = 1.0/gClockFrequency;
174 gClocksToMicroseconds = gClockFrequencyInv * SEC_TO_MICROSEC; 174 gClocksToMicroseconds = gClockFrequencyInv * SEC_TO_MICROSEC;
175} 175}
@@ -512,7 +512,7 @@ void secondsToTimecodeString(F32 current_time, char *tcstring)
512std::list<LLEventTimer*> LLEventTimer::sActiveList; 512std::list<LLEventTimer*> LLEventTimer::sActiveList;
513 513
514LLEventTimer::LLEventTimer(F32 period) 514LLEventTimer::LLEventTimer(F32 period)
515: mTimer() 515: mEventTimer()
516{ 516{
517 mPeriod = period; 517 mPeriod = period;
518 sActiveList.push_back(this); 518 sActiveList.push_back(this);
@@ -528,9 +528,9 @@ void LLEventTimer::updateClass()
528 for (std::list<LLEventTimer*>::iterator iter = sActiveList.begin(); iter != sActiveList.end(); ) 528 for (std::list<LLEventTimer*>::iterator iter = sActiveList.begin(); iter != sActiveList.end(); )
529 { 529 {
530 LLEventTimer* timer = *iter++; 530 LLEventTimer* timer = *iter++;
531 F32 et = timer->mTimer.getElapsedTimeF32(); 531 F32 et = timer->mEventTimer.getElapsedTimeF32();
532 if (et > timer->mPeriod) { 532 if (et > timer->mPeriod) {
533 timer->mTimer.reset(); 533 timer->mEventTimer.reset();
534 timer->tick(); 534 timer->tick();
535 } 535 }
536 } 536 }
diff --git a/linden/indra/llcommon/lltimer.h b/linden/indra/llcommon/lltimer.h
index 94dcbb9..37917d0 100644
--- a/linden/indra/llcommon/lltimer.h
+++ b/linden/indra/llcommon/lltimer.h
@@ -151,7 +151,7 @@ public:
151 static void updateClass(); 151 static void updateClass();
152 152
153protected: 153protected:
154 LLTimer mTimer; 154 LLTimer mEventTimer;
155 F32 mPeriod; 155 F32 mPeriod;
156 156
157private: 157private:
diff --git a/linden/indra/llcommon/lluri.cpp b/linden/indra/llcommon/lluri.cpp
index 83de022..43d2147 100644
--- a/linden/indra/llcommon/lluri.cpp
+++ b/linden/indra/llcommon/lluri.cpp
@@ -295,9 +295,10 @@ LLURI LLURI::buildHTTP(const std::string& prefix,
295 const LLSD& query) 295 const LLSD& query)
296{ 296{
297 LLURI uri = buildHTTP(prefix, path); 297 LLURI uri = buildHTTP(prefix, path);
298 uri.mEscapedQuery = mapToQueryString(query);
299 // break out and escape each query component 298 // break out and escape each query component
300 uri.mEscapedOpaque += "?" + uri.mEscapedQuery ; 299 uri.mEscapedQuery = mapToQueryString(query);
300 uri.mEscapedOpaque += uri.mEscapedQuery ;
301 uri.mEscapedQuery.erase(0,1); // trim the leading '?'
301 return uri; 302 return uri;
302} 303}
303 304
@@ -601,20 +602,30 @@ LLSD LLURI::queryMap(std::string escaped_query_string)
601std::string LLURI::mapToQueryString(const LLSD& queryMap) 602std::string LLURI::mapToQueryString(const LLSD& queryMap)
602{ 603{
603 std::string query_string; 604 std::string query_string;
604
605 if (queryMap.isMap()) 605 if (queryMap.isMap())
606 { 606 {
607 for (LLSD::map_const_iterator iter = queryMap.beginMap(); 607 bool first_element = true;
608 iter != queryMap.endMap(); 608 LLSD::map_const_iterator iter = queryMap.beginMap();
609 iter++) 609 LLSD::map_const_iterator end = queryMap.endMap();
610 std::ostringstream ostr;
611 for (; iter != end; ++iter)
610 { 612 {
611 query_string += escapeQueryVariable(iter->first) + 613 if(first_element)
612 (iter->second.isUndefined() ? "" : "=" + escapeQueryValue(iter->second.asString())) + "&" ; 614 {
615 ostr << "?";
616 first_element = false;
617 }
618 else
619 {
620 ostr << "&";
621 }
622 ostr << escapeQueryVariable(iter->first);
623 if(iter->second.isDefined())
624 {
625 ostr << "=" << escapeQueryValue(iter->second.asString());
626 }
613 } 627 }
614 //if (queryMap.size() > 0) 628 query_string = ostr.str();
615 //{
616 // query_string += "?" + query_string ;
617 //}
618 } 629 }
619 return query_string; 630 return query_string;
620} 631}
diff --git a/linden/indra/llcommon/lluri.h b/linden/indra/llcommon/lluri.h
index 3f24799..1044c48 100644
--- a/linden/indra/llcommon/lluri.h
+++ b/linden/indra/llcommon/lluri.h
@@ -58,34 +58,42 @@ public:
58 58
59 // construct from escaped string, as would be transmitted on the net 59 // construct from escaped string, as would be transmitted on the net
60 60
61 ~LLURI(); 61 ~LLURI();
62 62
63 static LLURI buildHTTP(const std::string& prefix, 63 static LLURI buildHTTP(
64 const LLSD& path); 64 const std::string& prefix,
65 static LLURI buildHTTP(const std::string& prefix, 65 const LLSD& path);
66 const LLSD& path,
67 const LLSD& query);
68 // prefix is either a full URL prefix of the form "http://example.com:8080",
69 // or it can be simply a host and optional port like "example.com" or
70 // "example.com:8080", in these cases, the "http://" will be added
71 66
72 static LLURI buildHTTP(const std::string& host, 67 static LLURI buildHTTP(
73 const U32& port, 68 const std::string& prefix,
74 const LLSD& path); 69 const LLSD& path,
75 static LLURI buildHTTP(const std::string& host, 70 const LLSD& query);
76 const U32& port, 71 ///< prefix is either a full URL prefix of the form
77 const LLSD& path, 72 /// "http://example.com:8080", or it can be simply a host and
78 const LLSD& query); 73 /// optional port like "example.com" or "example.com:8080", in
79 std::string asString() const; 74 /// these cases, the "http://" will be added
80 // the whole URI, escaped as needed 75
76 static LLURI buildHTTP(
77 const std::string& host,
78 const U32& port,
79 const LLSD& path);
80 static LLURI buildHTTP(
81 const std::string& host,
82 const U32& port,
83 const LLSD& path,
84 const LLSD& query);
85
86 std::string asString() const;
87 ///< the whole URI, escaped as needed
81 88
82 // Parts of a URI 89 /** @name Parts of a URI */
83 // These functions return parts of the decoded URI. The returned 90 //@{
84 // strings are un-escaped as needed 91 // These functions return parts of the decoded URI. The returned
92 // strings are un-escaped as needed
85 93
86 // for all schemes 94 // for all schemes
87 std::string scheme() const; // ex.: "http", note lack of colon 95 std::string scheme() const; ///< ex.: "http", note lack of colon
88 std::string opaque() const; // everything after the colon 96 std::string opaque() const; ///< everything after the colon
89 97
90 // for schemes that follow path like syntax (http, https, ftp) 98 // for schemes that follow path like syntax (http, https, ftp)
91 std::string authority() const; // ex.: "host.com:80" 99 std::string authority() const; // ex.: "host.com:80"
@@ -101,27 +109,34 @@ public:
101 const std::string& escapedQuery() const { return mEscapedQuery; } 109 const std::string& escapedQuery() const { return mEscapedQuery; }
102 LLSD queryMap() const; // above decoded into a map 110 LLSD queryMap() const; // above decoded into a map
103 static LLSD queryMap(std::string escaped_query_string); 111 static LLSD queryMap(std::string escaped_query_string);
104 static std::string mapToQueryString(const LLSD& queryMap);
105 112
106 // Escaping Utilities 113 /**
107 // Escape a string by urlencoding all the characters that aren't in the allowed string. 114 * @brief given a name value map, return a serialized query string.
108 static std::string escape(const std::string& str); 115 *
109 static std::string escape(const std::string& str, const std::string & allowed); 116
110 static std::string unescape(const std::string& str); 117 * @param query_map a map of name value. every value must be
118 * representable as a string.
119 * @return Returns an url query string of '?n1=v1&n2=v2&...'
120 */
121 static std::string mapToQueryString(const LLSD& query_map);
111 122
112 // Functions for building specific URIs for web services 123 /** @name Escaping Utilities */
113 // *NOTE: DEPRECATED. use the service builder instead. 124 //@{
114 //static LLURI buildBulkAgentNamesURI(LLApp* app); 125 // Escape a string by urlencoding all the characters that aren't
115 //static LLURI buildAgentSessionURI(const LLUUID& agent_id, LLApp* app); 126 // in the allowed string.
116 //static LLURI buildAgentLoginInfoURI(const LLUUID& agent_id, const std::string& dataserver); 127 static std::string escape(const std::string& str);
117 //static LLURI buildAgentNameURI(const LLUUID& agent_id, LLApp* app); 128 static std::string escape(
129 const std::string& str,
130 const std::string & allowed);
131 static std::string unescape(const std::string& str);
132 //@}
118 133
119private: 134private:
120 std::string mScheme; 135 std::string mScheme;
121 std::string mEscapedOpaque; 136 std::string mEscapedOpaque;
122 std::string mEscapedAuthority; 137 std::string mEscapedAuthority;
123 std::string mEscapedPath; 138 std::string mEscapedPath;
124 std::string mEscapedQuery; 139 std::string mEscapedQuery;
125}; 140};
126 141
127#endif // LL_LLURI_H 142#endif // LL_LLURI_H
diff --git a/linden/indra/llcommon/llversion.h b/linden/indra/llcommon/llversion.h
index 9739d04..555698d 100644
--- a/linden/indra/llcommon/llversion.h
+++ b/linden/indra/llcommon/llversion.h
@@ -31,7 +31,7 @@
31 31
32const S32 LL_VERSION_MAJOR = 1; 32const S32 LL_VERSION_MAJOR = 1;
33const S32 LL_VERSION_MINOR = 18; 33const S32 LL_VERSION_MINOR = 18;
34const S32 LL_VERSION_PATCH = 0; 34const S32 LL_VERSION_PATCH = 1;
35const S32 LL_VERSION_BUILD = 6; 35const S32 LL_VERSION_BUILD = 2;
36 36
37#endif 37#endif
diff --git a/linden/indra/llcommon/llworkerthread.cpp b/linden/indra/llcommon/llworkerthread.cpp
index aa0bedf..b4d9485 100644
--- a/linden/indra/llcommon/llworkerthread.cpp
+++ b/linden/indra/llcommon/llworkerthread.cpp
@@ -104,6 +104,8 @@ S32 LLWorkerThread::update(U32 max_time_ms)
104 } 104 }
105 delete *iter; 105 delete *iter;
106 } 106 }
107 // delete and aborted entries mean there's still work to do
108 res += delete_list.size() + abort_list.size();
107 return res; 109 return res;
108} 110}
109 111
diff --git a/linden/indra/llcommon/stdtypes.h b/linden/indra/llcommon/stdtypes.h
index 16b57fa..118278f 100644
--- a/linden/indra/llcommon/stdtypes.h
+++ b/linden/indra/llcommon/stdtypes.h
@@ -31,18 +31,18 @@
31#include <limits.h> 31#include <limits.h>
32#include <float.h> 32#include <float.h>
33 33
34typedef signed char S8; 34typedef signed char S8;
35typedef unsigned char U8; 35typedef unsigned char U8;
36typedef signed short S16; 36typedef signed short S16;
37typedef unsigned short U16; 37typedef unsigned short U16;
38typedef signed int S32; 38typedef signed int S32;
39typedef unsigned int U32; 39typedef unsigned int U32;
40 40
41#if LL_WINDOWS 41#if LL_WINDOWS
42// Windows wchar_t is 16-bit 42// Windows wchar_t is 16-bit
43typedef U32 llwchar; 43typedef U32 llwchar;
44#else 44#else
45typedef wchar_t llwchar; 45typedef wchar_t llwchar;
46#endif 46#endif
47 47
48#if LL_WINDOWS 48#if LL_WINDOWS
@@ -53,20 +53,20 @@ typedef unsigned __int64 U64;
53#define U64L(a) (a) 53#define U64L(a) (a)
54#else 54#else
55typedef long long int S64; 55typedef long long int S64;
56typedef long long unsigned int U64; 56typedef long long unsigned int U64;
57#if LL_DARWIN || LL_LINUX 57#if LL_DARWIN || LL_LINUX || LL_SOLARIS
58#define S64L(a) (a##LL) 58#define S64L(a) (a##LL)
59#define U64L(a) (a##ULL) 59#define U64L(a) (a##ULL)
60#endif 60#endif
61#endif 61#endif
62 62
63typedef float F32; 63typedef float F32;
64typedef double F64; 64typedef double F64;
65 65
66typedef S32 BOOL; 66typedef S32 BOOL;
67typedef U8 KEY; 67typedef U8 KEY;
68typedef U32 MASK; 68typedef U32 MASK;
69typedef U32 TPACKETID; 69typedef U32 TPACKETID;
70 70
71// Use #define instead of consts to avoid conversion headaches 71// Use #define instead of consts to avoid conversion headaches
72#define S8_MAX (SCHAR_MAX) 72#define S8_MAX (SCHAR_MAX)
diff --git a/linden/indra/llcommon/timing.h b/linden/indra/llcommon/timing.h
index 662d22b..b799001 100644
--- a/linden/indra/llcommon/timing.h
+++ b/linden/indra/llcommon/timing.h
@@ -31,7 +31,7 @@
31 31
32#include <time.h> 32#include <time.h>
33 33
34#if LL_LINUX || LL_DARWIN 34#if LL_LINUX || LL_DARWIN || LL_SOLARIS
35# include <sys/time.h> 35# include <sys/time.h>
36#endif 36#endif
37 37