Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • alchemy/viewer
  • Miezhiko/alchemy-next
  • JennaHuntsman/xdg-integration
  • logue/alchemy-next
  • FelixWolf/alchemy-viewer
  • XenHat/xdg-integration
6 results
Show changes
Commits on Source (25)
Showing
with 62 additions and 253 deletions
......@@ -19,7 +19,7 @@ variables:
- pipenv install
script:
- |
pipenv run autobuild configure -c ReleaseOS -- -DUSE_FMODSTUDIO=ON -DUSE_NVAPI=ON -DUSE_LTO=ON -DVS_DISABLE_FATAL_WARNINGS=ON
pipenv run autobuild configure -c ReleaseOS -- -DUSE_FMODSTUDIO=ON -DUSE_NVAPI=ON -DUSE_LTO=ON -DVS_DISABLE_FATAL_WARNINGS=ON -DREVISION_FROM_VCS=FALSE
pipenv run autobuild build -c ReleaseOS --no-configure
artifacts:
name: "$env:CI_COMMIT_REF_NAME-$env:CI_COMMIT_SHORT_SHA"
......@@ -39,7 +39,7 @@ variables:
- docker
script:
- |
autobuild configure -c ReleaseOS -- -DUSE_FMODSTUDIO=ON -DUSE_NVAPI=ON -DUSE_LTO=ON -DUNIX_DISABLE_FATAL_WARNINGS=ON
autobuild configure -c ReleaseOS -- -DUSE_FMODSTUDIO=ON -DUSE_NVAPI=ON -DUSE_LTO=ON -DUNIX_DISABLE_FATAL_WARNINGS=ON -DREVISION_FROM_VCS=FALSE
autobuild build -c ReleaseOS --no-configure
artifacts:
name: "$env:CI_COMMIT_REF_NAME-$env:CI_COMMIT_SHORT_SHA"
......
......@@ -604,9 +604,11 @@
<key>archive</key>
<map>
<key>hash</key>
<string>fdbbbfc377e28cba664f2b1c54ea6086</string>
<string>5a0a13703381052c75eeec82b203b48d</string>
<key>hash_algorithm</key>
<string>md5</string>
<key>url</key>
<string>http://automated-builds-secondlife-com.s3.amazonaws.com/ct2/62331/588162/dullahan-1.7.0.202006241556_81.3.10_gb223419_chromium-81.0.4044.138-windows-544091.tar.bz2</string>
<string>https://pkg.alchemyviewer.org/repository/autobuild-external/dullahan/windows/dullahan-1.7.0.202010052042_81.3.10_gb223419_chromium-81.0.4044.138-windows-477.tar.bz2</string>
</map>
<key>name</key>
<string>windows</string>
......@@ -616,18 +618,18 @@
<key>archive</key>
<map>
<key>hash</key>
<string>3a1bf9b1ded325f872fefa4ade23efd8</string>
<string>96c40f7012521bbd67e6eb391a5f4b6f</string>
<key>hash_algorithm</key>
<string>md5</string>
<key>url</key>
<string>https://pkg.alchemyviewer.org/repository/autobuild-external/dullahan/windows64/dullahan-1.7.0.202009180903_85.3.9_gb045a6e_chromium-85.0.4183.102-windows64-342.tar.bz2</string>
<string>https://pkg.alchemyviewer.org/repository/autobuild-external/dullahan/windows64/dullahan-1.7.0.202010052050_85.3.9_gb045a6e_chromium-85.0.4183.102-windows64-477.tar.bz2</string>
</map>
<key>name</key>
<string>windows64</string>
</map>
</map>
<key>version</key>
<string>1.7.0.202009180903_85.3.9_gb045a6e_chromium-85.0.4183.102</string>
<string>1.7.0.202010052050_85.3.9_gb045a6e_chromium-85.0.4183.102</string>
</map>
<key>elfio</key>
<map>
......
# -*- cmake -*-
option(REVISION_FROM_VCS "Get current revision from vcs" ON)
find_package(Git)
# Construct the viewer channel from environment variables or defaults
if(NOT DEFINED VIEWER_CHANNEL)
if(DEFINED ENV{VIEWER_CHANNEL_BASE})
......@@ -55,6 +53,10 @@ if(NOT DEFINED VIEWER_SHORT_VERSION) # will be true in indra/, false in indra/ne
string(REGEX REPLACE "^[0-9]+\\.([0-9]+)\\.[0-9]+" "\\1" VIEWER_VERSION_MINOR ${VIEWER_SHORT_VERSION})
string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+)" "\\1" VIEWER_VERSION_PATCH ${VIEWER_SHORT_VERSION})
if(REVISION_FROM_VCS)
find_package(Git)
endif()
if((NOT REVISION_FROM_VCS) AND DEFINED ENV{revision})
set(VIEWER_VERSION_REVISION $ENV{revision})
message(STATUS "Revision (from environment): ${VIEWER_VERSION_REVISION}")
......
......@@ -24,12 +24,6 @@
* $/LicenseInfo$
*/
#if LL_MSVC
// disable warning about boost::lexical_cast returning uninitialized data
// when it fails to parse the string
#pragma warning (disable:4701)
#endif
#include "linden_common.h"
#include "llavatarappearance.h"
......@@ -46,14 +40,6 @@
#include "boost/bind.hpp"
#include "boost/tokenizer.hpp"
#if LL_MSVC
// disable boost::lexical_cast warning
#pragma warning (disable:4702)
#endif
#include <boost/lexical_cast.hpp>
using namespace LLAvatarAppearanceDefines;
//-----------------------------------------------------------------------------
......@@ -233,7 +219,7 @@ void LLAvatarAppearance::initInstance()
for (U32 lod = 0; lod < mesh_dict->mLOD; lod++)
{
LLAvatarJointMesh* mesh = createAvatarJointMesh();
std::string mesh_name = "m" + mesh_dict->mName + boost::lexical_cast<std::string>(lod);
std::string mesh_name = absl::StrCat("m", mesh_dict->mName, lod);
// We pre-pended an m - need to capitalize first character for camelCase
mesh_name[1] = toupper(mesh_name[1]);
mesh->setName(mesh_name);
......
......@@ -880,8 +880,6 @@ void LLPolyMesh::dumpDiagInfo()
U32 total_faces = 0;
U32 total_kb = 0;
std::string buf;
LL_INFOS() << "-----------------------------------------------------" << LL_ENDL;
LL_INFOS() << " Global PolyMesh Table (DEBUG only)" << LL_ENDL;
LL_INFOS() << " Verts Faces Mem(KB) Name" << LL_ENDL;
......@@ -898,8 +896,7 @@ void LLPolyMesh::dumpDiagInfo()
S32 num_faces = mesh->mNumFaces;
U32 num_kb = mesh->getNumKB();
buf = llformat("%8d %8d %8d %s", num_verts, num_faces, num_kb, mesh_name.c_str());
LL_INFOS() << buf << LL_ENDL;
LL_INFOS() << absl::StreamFormat("%8d %8d %8d %s", num_verts, num_faces, num_kb, mesh_name) << LL_ENDL;
total_verts += num_verts;
total_faces += num_faces;
......@@ -907,8 +904,7 @@ void LLPolyMesh::dumpDiagInfo()
}
LL_INFOS() << "-----------------------------------------------------" << LL_ENDL;
buf = llformat("%8d %8d %8d TOTAL", total_verts, total_faces, total_kb );
LL_INFOS() << buf << LL_ENDL;
LL_INFOS() << absl::StreamFormat("%8d %8d %8d TOTAL", total_verts, total_faces, total_kb) << LL_ENDL;
LL_INFOS() << "-----------------------------------------------------" << LL_ENDL;
}
......
......@@ -776,7 +776,7 @@ void LLWearable::writeToAvatar(LLAvatarAppearance* avatarp)
std::string terse_F32_to_string(F32 f)
{
std::string r = llformat("%.2f", f);
std::string r = absl::StrFormat("%.2f", f);
S32 len = r.length();
// "1.20" -> "1.2"
......
......@@ -263,7 +263,7 @@ std::string LLAudioEngine_FMODSTUDIO::getDriverName(bool verbose)
U32 version;
if(!Check_FMOD_Error(mSystem->getVersion(&version), "FMOD::System::getVersion"))
{
return llformat("FMOD Studio %1x.%02x.%02x", version >> 16, version >> 8 & 0x000000FF, version & 0x000000FF);
return absl::StrFormat("FMOD Studio %1x.%02x.%02x", version >> 16, version >> 8 & 0x000000FF, version & 0x000000FF);
}
}
return "FMOD Studio";
......
......@@ -166,7 +166,7 @@ class LLWindGen
F32 mLastSample;
};
template<class T> inline const F32 LLWindGen<T>::getNextSample() { return (F32)rand() * (1.0f / (F32)(RAND_MAX / (U16_MAX / 8))) + (F32)(S16_MIN / 8); }
template<class T> inline const F32 LLWindGen<T>::getNextSample() { return (F32)ll_rand() * (1.0f / (F32)(RAND_MAX / (U16_MAX / 8))) + (F32)(S16_MIN / 8); }
template<> inline const F32 LLWindGen<F32>::getNextSample() { return ll_frand()-.5f; }
template<class T> inline const F32 LLWindGen<T>::getClampedSample(bool clamp, F32 sample) { return clamp ? (F32)llclamp((S32)sample,(S32)S16_MIN,(S32)S16_MAX) : sample; }
template<> inline const F32 LLWindGen<F32>::getClampedSample(bool clamp, F32 sample) { return sample; }
......
......@@ -2058,7 +2058,7 @@ BOOL LLKeyframeMotion::serialize(LLDataPacker& dp) const
success &= dp.packU8(shared_constraintp->mChainLength, "chain_length");
success &= dp.packU8(shared_constraintp->mConstraintType, "constraint_type");
char source_volume[16]; /* Flawfinder: ignore */
snprintf(source_volume, sizeof(source_volume), "%s", /* Flawfinder: ignore */
absl::SNPrintF(source_volume, sizeof(source_volume), "%s", /* Flawfinder: ignore */
mCharacter->findCollisionVolume(shared_constraintp->mSourceConstraintVolume)->getName().c_str());
success &= dp.packBinaryDataFixed((U8*)source_volume, 16, "source_volume");
......@@ -2066,11 +2066,11 @@ BOOL LLKeyframeMotion::serialize(LLDataPacker& dp) const
char target_volume[16]; /* Flawfinder: ignore */
if (shared_constraintp->mConstraintTargetType == CONSTRAINT_TARGET_TYPE_GROUND)
{
snprintf(target_volume,sizeof(target_volume), "%s", "GROUND"); /* Flawfinder: ignore */
absl::SNPrintF(target_volume,sizeof(target_volume), "%s", "GROUND"); /* Flawfinder: ignore */
}
else
{
snprintf(target_volume, sizeof(target_volume),"%s", /* Flawfinder: ignore */
absl::SNPrintF(target_volume, sizeof(target_volume),"%s", /* Flawfinder: ignore */
mCharacter->findCollisionVolume(shared_constraintp->mTargetConstraintVolume)->getName().c_str());
}
success &= dp.packBinaryDataFixed((U8*)target_volume, 16, "target_volume");
......@@ -2383,8 +2383,6 @@ void LLKeyframeDataCache::dumpDiagInfo()
// keep track of totals
U32 total_size = 0;
char buf[1024]; /* Flawfinder: ignore */
LL_INFOS() << "-----------------------------------------------------" << LL_ENDL;
LL_INFOS() << " Global Motion Table (DEBUG only)" << LL_ENDL;
LL_INFOS() << "-----------------------------------------------------" << LL_ENDL;
......@@ -2406,8 +2404,7 @@ void LLKeyframeDataCache::dumpDiagInfo()
LL_INFOS() << "-----------------------------------------------------" << LL_ENDL;
LL_INFOS() << "Motions\tTotal Size" << LL_ENDL;
snprintf(buf, sizeof(buf), "%d\t\t%d bytes", (S32)sKeyframeDataMap.size(), total_size ); /* Flawfinder: ignore */
LL_INFOS() << buf << LL_ENDL;
LL_INFOS() << absl::StreamFormat("%d\t\t%d bytes", (S32)sKeyframeDataMap.size(), total_size) << LL_ENDL;
LL_INFOS() << "-----------------------------------------------------" << LL_ENDL;
}
......
......@@ -466,24 +466,24 @@ BOOL LLGestureStepWait::deserialize(LLDataPacker& dp)
std::vector<std::string> LLGestureStepWait::getLabel() const
{
std::vector<std::string> strings;
strings.push_back( "Wait" );
strings.emplace_back( "Wait" );
// std::string label("--- Wait: ");
if (mFlags & WAIT_FLAG_TIME)
{
char buffer[64]; /* Flawfinder: ignore */
snprintf(buffer, sizeof(buffer), "%.1f seconds", (double)mWaitSeconds); /* Flawfinder: ignore */
strings.push_back(buffer);
std::string str = absl::StrFormat("%.1f seconds", mWaitSeconds);
strings.push_back(std::move(str));
// label += buffer;
}
else if (mFlags & WAIT_FLAG_ALL_ANIM)
{
strings.push_back("until animations are done");
strings.emplace_back("until animations are done");
// label += "until animations are done";
}
else
{
strings.push_back("");
strings.emplace_back("");
}
return strings;
......
......@@ -287,6 +287,8 @@ target_link_libraries(
absl::node_hash_map
absl::strings
absl::str_format
absl::random_random
absl::random_bit_gen_ref
nlohmann_json::nlohmann_json
${DL_LIBRARY}
${RT_LIBRARY}
......@@ -344,6 +346,7 @@ if (LL_TESTS)
LL_ADD_INTEGRATION_TEST(lltreeiterators "" "${test_libs}")
LL_ADD_INTEGRATION_TEST(lluri "" "${test_libs}")
LL_ADD_INTEGRATION_TEST(llunits "" "${test_libs}")
LL_ADD_INTEGRATION_TEST(lluuid "" "${test_libs}")
LL_ADD_INTEGRATION_TEST(stringize "" "${test_libs}")
## llexception_test.cpp isn't a regression test, and doesn't need to be run
......
......@@ -281,7 +281,7 @@ void LLCoros::winlevel(const callable_t& callable)
// Note: it might be better to use _se_set_translator
// if you want exception to inherit full callstack
char integer_string[32];
sprintf(integer_string, "SEH, code: %lu\n", GetExceptionCode());
snprintf(integer_string, 32, "SEH, code: %lu\n", GetExceptionCode());
throw std::exception(integer_string);
}
}
......
......@@ -232,7 +232,7 @@ namespace {
}
else
{
fprintf(stderr, "%s\n", message.c_str());
absl::FPrintF(stderr, "%s\n", message);
}
}
......@@ -245,7 +245,7 @@ namespace {
static std::string s_ansi_reset = createANSI("0"); // reset
// ANSI color code escape sequence, message, and reset in one fprintf call
// Default all message levels to bold so we can distinguish our own messages from those dumped by subprocesses and libraries.
fprintf(stderr, "%s%s%s\n%s", s_ansi_bold.c_str(), ansi_code.c_str(), message.c_str(), s_ansi_reset.c_str() );
absl::FPrintF(stderr, "%s%s%s\n%s", s_ansi_bold, ansi_code, message, s_ansi_reset);
}
static bool checkANSI(void)
......
......@@ -178,8 +178,7 @@ int LLFile::mkdir(const std::string& dirname, int perms)
{
#if LL_WINDOWS
// permissions are ignored on Windows
std::string utf8dirname = dirname;
std::wstring utf16dirname = ll_convert_string_to_wide(utf8dirname);
std::wstring utf16dirname = ll_convert_string_to_wide(dirname);
int rc = _wmkdir(utf16dirname.c_str());
#else
int rc = ::mkdir(dirname.c_str(), (mode_t)perms);
......@@ -201,8 +200,7 @@ int LLFile::rmdir(const std::string& dirname)
{
#if LL_WINDOWS
// permissions are ignored on Windows
std::string utf8dirname = dirname;
std::wstring utf16dirname = ll_convert_string_to_wide(utf8dirname);
std::wstring utf16dirname = ll_convert_string_to_wide(dirname);
int rc = _wrmdir(utf16dirname.c_str());
#else
int rc = ::rmdir(dirname.c_str());
......@@ -214,10 +212,8 @@ int LLFile::rmdir(const std::string& dirname)
LLFILE* LLFile::fopen(const std::string& filename, const char* mode) /* Flawfinder: ignore */
{
#if LL_WINDOWS
std::string utf8filename = filename;
std::string utf8mode = std::string(mode);
std::wstring utf16filename = ll_convert_string_to_wide(utf8filename);
std::wstring utf16mode = ll_convert_string_to_wide(utf8mode);
std::wstring utf16filename = ll_convert_string_to_wide(filename);
std::wstring utf16mode = ll_convert_string_to_wide(mode);
return _wfopen(utf16filename.c_str(),utf16mode.c_str());
#else
return ::fopen(filename.c_str(),mode); /* Flawfinder: ignore */
......@@ -227,10 +223,8 @@ LLFILE* LLFile::fopen(const std::string& filename, const char* mode) /* Flawfind
LLFILE* LLFile::_fsopen(const std::string& filename, const char* mode, int sharingFlag)
{
#if LL_WINDOWS
std::string utf8filename = filename;
std::string utf8mode = std::string(mode);
std::wstring utf16filename = ll_convert_string_to_wide(utf8filename);
std::wstring utf16mode = ll_convert_string_to_wide(utf8mode);
std::wstring utf16filename = ll_convert_string_to_wide(filename);
std::wstring utf16mode = ll_convert_string_to_wide(mode);
return _wfsopen(utf16filename.c_str(),utf16mode.c_str(),sharingFlag);
#else
llassert(0);//No corresponding function on non-windows
......@@ -252,8 +246,7 @@ int LLFile::close(LLFILE * file)
int LLFile::remove(const std::string& filename, int supress_error)
{
#if LL_WINDOWS
std::string utf8filename = filename;
std::wstring utf16filename = ll_convert_string_to_wide(utf8filename);
std::wstring utf16filename = ll_convert_string_to_wide(filename);
int rc = _wremove(utf16filename.c_str());
#else
int rc = ::remove(filename.c_str());
......@@ -264,10 +257,8 @@ int LLFile::remove(const std::string& filename, int supress_error)
int LLFile::rename(const std::string& filename, const std::string& newname, int supress_error)
{
#if LL_WINDOWS
std::string utf8filename = filename;
std::string utf8newname = newname;
std::wstring utf16filename = ll_convert_string_to_wide(utf8filename);
std::wstring utf16newname = ll_convert_string_to_wide(utf8newname);
std::wstring utf16filename = ll_convert_string_to_wide(filename);
std::wstring utf16newname = ll_convert_string_to_wide(newname);
int rc = _wrename(utf16filename.c_str(),utf16newname.c_str());
#else
int rc = ::rename(filename.c_str(),newname.c_str());
......@@ -309,8 +300,7 @@ bool LLFile::copy(const std::string& from, const std::string& to)
int LLFile::stat(const std::string& filename, llstat* filestatus)
{
#if LL_WINDOWS
std::string utf8filename = filename;
std::wstring utf16filename = ll_convert_string_to_wide(utf8filename);
std::wstring utf16filename = ll_convert_string_to_wide(filename);
int rc = _wstat(utf16filename.c_str(),filestatus);
#else
int rc = ::stat(filename.c_str(),filestatus);
......
......@@ -28,6 +28,8 @@
#ifndef LL_LLFORMAT_H
#define LL_LLFORMAT_H
#include "absl/strings/str_format.h"
// Use as follows:
// LL_INFOS() << llformat("Test:%d (%.2f %.2f)", idx, x, y) << LL_ENDL;
//
......
......@@ -193,7 +193,7 @@ namespace LLInitParam
{
if (!silent)
{
p.parserWarning(llformat("Failed to parse parameter \"%s\"", p.getCurrentElementName().c_str()));
p.parserWarning(absl::StrFormat("Failed to parse parameter \"%s\"", p.getCurrentElementName()));
}
return false;
}
......
......@@ -107,7 +107,7 @@ class LL_COMMON_API LLMetricPerformanceTesterBasic
/**
* @return Returns the label to be used for the current count. It's "TesterName"-"Count".
*/
std::string getCurrentLabelName() const { return llformat("%s-%d", mName.c_str(), mCount) ;}
std::string getCurrentLabelName() const { return absl::StrFormat("%s-%d", mName, mCount) ;}
/**
* @brief Write a test record to the LLSD. Implementers need to overload this method.
......
......@@ -189,7 +189,7 @@ void LLQueuedThread::printQueueStats()
if (!mRequestQueue.empty())
{
QueuedRequest *req = *mRequestQueue.begin();
LL_INFOS() << llformat("Pending Requests:%d Current status:%d", mRequestQueue.size(), req->getStatus()) << LL_ENDL;
LL_INFOS() << absl::StreamFormat("Pending Requests:%d Current status:%d", mRequestQueue.size(), req->getStatus()) << LL_ENDL;
}
else
{
......@@ -224,7 +224,7 @@ bool LLQueuedThread::addRequest(QueuedRequest* req)
mRequestQueue.insert(req);
mRequestHash.insert(req);
#if _DEBUG
// LL_INFOS() << llformat("LLQueuedThread::Added req [%08d]",handle) << LL_ENDL;
// LL_INFOS() << absl::StreamFormat("LLQueuedThread::Added req [%08d]",handle) << LL_ENDL;
#endif
mRequestQueueSize = mRequestQueue.size();
unlockData();
......@@ -356,7 +356,7 @@ bool LLQueuedThread::completeRequest(handle_t handle)
llassert_always(req->getStatus() != STATUS_QUEUED);
llassert_always(req->getStatus() != STATUS_INPROGRESS);
#if _DEBUG
// LL_INFOS() << llformat("LLQueuedThread::Completed req [%08d]",handle) << LL_ENDL;
// LL_INFOS() << absl::StreamFormat("LLQueuedThread::Completed req [%08d]",handle) << LL_ENDL;
#endif
mRequestHash.erase(handle);
req->deleteRequest();
......
......@@ -29,93 +29,14 @@
#include "llrand.h"
#include "lluuid.h"
/**
* Through analysis, we have decided that we want to take values which
* are close enough to 1.0 to map back to 0.0. We came to this
* conclusion from noting that:
*
* [0.0, 1.0)
*
* when scaled to the integer set:
*
* [0, 4)
*
* there is some value close enough to 1.0 that when multiplying by 4,
* gets truncated to 4. Therefore:
*
* [0,1-eps] => 0
* [1,2-eps] => 1
* [2,3-eps] => 2
* [3,4-eps] => 3
*
* So 0 gets uneven distribution if we simply clamp. The actual
* clamp utilized in this file is to map values out of range back
* to 0 to restore uniform distribution.
*
* Also, for clamping floats when asking for a distribution from
* [0.0,g) we have determined that for values of g < 0.5, then
* rand*g=g, which is not the desired result. As above, we clamp to 0
* to restore uniform distribution.
*/
// *NOTE: The system rand implementation is probably not correct.
#define LL_USE_SYSTEM_RAND 0
#if LL_USE_SYSTEM_RAND
#include <cstdlib>
#endif
#if LL_USE_SYSTEM_RAND
class LLSeedRand
{
public:
LLSeedRand()
{
#if LL_WINDOWS
srand(LLUUID::getRandomSeed());
#else
srand48(LLUUID::getRandomSeed());
#endif
}
};
static LLSeedRand sRandomSeeder;
inline F64 ll_internal_random_double()
{
#if LL_WINDOWS
return (F64)rand() / (F64)RAND_MAX;
#else
return drand48();
#endif
}
inline F32 ll_internal_random_float()
{
#if LL_WINDOWS
return (F32)rand() / (F32)RAND_MAX;
#else
return (F32)drand48();
#endif
}
#else
static LLRandLagFib2281 gRandomGenerator(LLUUID::getRandomSeed());
inline F64 ll_internal_random_double()
{
// *HACK: Through experimentation, we have found that dual core
// CPUs (or at least multi-threaded processes) seem to
// occasionally give an obviously incorrect random number -- like
// 5^15 or something. Sooooo, clamp it as described above.
F64 rv = gRandomGenerator();
if(!((rv >= 0.0) && (rv < 1.0))) return fmod(rv, 1.0);
return rv;
}
#include <absl/random/bit_gen_ref.h>
#include <absl/random/random.h>
inline F32 ll_internal_random_float()
static absl::BitGenRef tls_bit_gen()
{
// The clamping rules are described above.
F32 rv = (F32)gRandomGenerator();
if(!((rv >= 0.0f) && (rv < 1.0f))) return fmod(rv, 1.f);
return rv;
thread_local static absl::BitGen tlsBitGen;
return tlsBitGen;
}
#endif
S32 ll_rand()
{
......@@ -124,48 +45,25 @@ S32 ll_rand()
S32 ll_rand(S32 val)
{
// The clamping rules are described above.
S32 rv = (S32)(ll_internal_random_double() * val);
if(rv == val) return 0;
return rv;
return absl::Uniform<S32>(absl::IntervalClosedOpen, tls_bit_gen(), 0, val);
}
F32 ll_frand()
{
return ll_internal_random_float();
return absl::Uniform<float>(absl::IntervalClosedOpen, tls_bit_gen(), 0.f, 1.f);
}
F32 ll_frand(F32 val)
{
// The clamping rules are described above.
F32 rv = ll_internal_random_float() * val;
if(val > 0)
{
if(rv >= val) return 0.0f;
}
else
{
if(rv <= val) return 0.0f;
}
return rv;
return absl::Uniform<float>(absl::IntervalClosedOpen, tls_bit_gen(), 0.f, val);
}
F64 ll_drand()
{
return ll_internal_random_double();
return absl::Uniform<double>(absl::IntervalClosedOpen, tls_bit_gen(), 0.0, 1.0);
}
F64 ll_drand(F64 val)
{
// The clamping rules are described above.
F64 rv = ll_internal_random_double() * val;
if(val > 0)
{
if(rv >= val) return 0.0;
}
else
{
if(rv <= val) return 0.0;
}
return rv;
return absl::Uniform<double>(absl::IntervalClosedOpen, tls_bit_gen(), 0.0, val);
}
......@@ -27,35 +27,6 @@
#ifndef LL_LLRAND_H
#define LL_LLRAND_H
#include <boost/random/lagged_fibonacci.hpp>
#include <boost/random/mersenne_twister.hpp>
/**
* Use the boost random number generators if you want a stateful
* random numbers. If you want more random numbers, use the
* c-functions since they will generate faster/better randomness
* across the process.
*
* I tested some of the boost random engines, and picked a good double
* generator and a good integer generator. I also took some timings
* for them on linux using gcc 3.3.5. The harness also did some other
* fairly trivial operations to try to limit compiler optimizations,
* so these numbers are only good for relative comparisons.
*
* usec/inter algorithm
* 0.21 boost::minstd_rand0
* 0.039 boost:lagged_fibonacci19937
* 0.036 boost:lagged_fibonacci607
* 0.44 boost::hellekalek1995
* 0.44 boost::ecuyer1988
* 0.042 boost::rand48
* 0.043 boost::mt11213b
* 0.028 stdlib random()
* 0.05 stdlib lrand48()
* 0.034 stdlib rand()
* 0.020 the old & lame LLRand
*/
/**
*@brief Generate a float from [0, RAND_MAX).
*/
......@@ -86,42 +57,4 @@ F64 LL_COMMON_API ll_drand();
*/
F64 LL_COMMON_API ll_drand(F64 val);
/**
* @brief typedefs for good boost lagged fibonacci.
* @see boost::lagged_fibonacci
*
* These generators will quickly generate doubles. Note the memory
* requirements, because they are somewhat high. I chose the smallest
* one, and one comparable in speed but higher periodicity without
* outrageous memory requirements.
* To use:
* LLRandLagFib607 foo((U32)time(NULL));
* double bar = foo();
*/
typedef boost::lagged_fibonacci607 LLRandLagFib607;
/**<
* lengh of cycle: 2^32,000
* memory: 607*sizeof(double) (about 5K)
*/
typedef boost::lagged_fibonacci2281 LLRandLagFib2281;
/**<
* lengh of cycle: 2^120,000
* memory: 2281*sizeof(double) (about 17K)
*/
/**
* @breif typedefs for a good boost mersenne twister implementation.
* @see boost::mersenne_twister
*
* This fairly quickly generates U32 values
* To use:
* LLRandMT19937 foo((U32)time(NULL));
* U32 bar = foo();
*
* lengh of cycle: 2^19,937-1
* memory: about 2496 bytes
*/
typedef boost::mt11213b LLRandMT19937;
#endif