Skip to content
Permalink
Browse files
GEODE-5744: Use fixed width int types. (#359)
  • Loading branch information
pivotal-jbarrett committed Oct 4, 2018
1 parent d76e58c commit df677ef790035256ca000075156622f7b47f5d95
Show file tree
Hide file tree
Showing 46 changed files with 258 additions and 299 deletions.
@@ -1,6 +1,6 @@
---
Checks: '-*,clang-diagnostic-*,clang-analyzer-*,-clang-analyzer-alpha*,google-*,-google-readability-todo,-google-runtime-references'
WarningsAsErrors: 'google-build-using-namespace,google-readability-redundant-smartptr-get,google-explicit-constructor,google-global-names-in-headers'
WarningsAsErrors: 'google-build-using-namespace,google-readability-redundant-smartptr-get,google-explicit-constructor,google-global-names-in-headers,google-runtime-int'
HeaderFilterRegex: '.*'
AnalyzeTemporaryDtors: false
FormatStyle: file
@@ -195,28 +195,14 @@ class APACHE_GEODE_EXPORT DataInput {
inline int64_t readInt64() {
_GEODE_CHECK_BUFFER_SIZE(8);
int64_t tmp;
if (sizeof(long) == 8) {
tmp = *(m_buf++);
tmp = (tmp << 8) | *(m_buf++);
tmp = (tmp << 8) | *(m_buf++);
tmp = (tmp << 8) | *(m_buf++);
tmp = (tmp << 8) | *(m_buf++);
tmp = (tmp << 8) | *(m_buf++);
tmp = (tmp << 8) | *(m_buf++);
tmp = (tmp << 8) | *(m_buf++);
} else {
uint32_t hword = *(m_buf++);
hword = (hword << 8) | *(m_buf++);
hword = (hword << 8) | *(m_buf++);
hword = (hword << 8) | *(m_buf++);

tmp = hword;
hword = *(m_buf++);
hword = (hword << 8) | *(m_buf++);
hword = (hword << 8) | *(m_buf++);
hword = (hword << 8) | *(m_buf++);
tmp = (tmp << 32) | hword;
}
tmp = *(m_buf++);
tmp = (tmp << 8) | *(m_buf++);
tmp = (tmp << 8) | *(m_buf++);
tmp = (tmp << 8) | *(m_buf++);
tmp = (tmp << 8) | *(m_buf++);
tmp = (tmp << 8) | *(m_buf++);
tmp = (tmp << 8) | *(m_buf++);
tmp = (tmp << 8) | *(m_buf++);
return tmp;
}

@@ -174,32 +174,14 @@ class APACHE_GEODE_EXPORT DataOutput {
*/
inline void writeInt(uint64_t value) {
ensureCapacity(8);
// the defines are not reliable and can be changed by compiler options.
// Hence using sizeof() test instead.
//#if defined(_LP64) || ( defined(__WORDSIZE) && __WORDSIZE == 64 ) ||
//( defined(_INTEGRAL_MAX_BITS) && _INTEGRAL_MAX_BITS >= 64 )
if (sizeof(long) == 8) {
*(m_buf++) = static_cast<uint8_t>(value >> 56);
*(m_buf++) = static_cast<uint8_t>(value >> 48);
*(m_buf++) = static_cast<uint8_t>(value >> 40);
*(m_buf++) = static_cast<uint8_t>(value >> 32);
*(m_buf++) = static_cast<uint8_t>(value >> 24);
*(m_buf++) = static_cast<uint8_t>(value >> 16);
*(m_buf++) = static_cast<uint8_t>(value >> 8);
*(m_buf++) = static_cast<uint8_t>(value);
} else {
uint32_t hword = static_cast<uint32_t>(value >> 32);
*(m_buf++) = static_cast<uint8_t>(hword >> 24);
*(m_buf++) = static_cast<uint8_t>(hword >> 16);
*(m_buf++) = static_cast<uint8_t>(hword >> 8);
*(m_buf++) = static_cast<uint8_t>(hword);

hword = static_cast<uint32_t>(value);
*(m_buf++) = static_cast<uint8_t>(hword >> 24);
*(m_buf++) = static_cast<uint8_t>(hword >> 16);
*(m_buf++) = static_cast<uint8_t>(hword >> 8);
*(m_buf++) = static_cast<uint8_t>(hword);
}
*(m_buf++) = static_cast<uint8_t>(value >> 56);
*(m_buf++) = static_cast<uint8_t>(value >> 48);
*(m_buf++) = static_cast<uint8_t>(value >> 40);
*(m_buf++) = static_cast<uint8_t>(value >> 32);
*(m_buf++) = static_cast<uint8_t>(value >> 24);
*(m_buf++) = static_cast<uint8_t>(value >> 16);
*(m_buf++) = static_cast<uint8_t>(value >> 8);
*(m_buf++) = static_cast<uint8_t>(value);
}

/**
@@ -415,8 +397,7 @@ class APACHE_GEODE_EXPORT DataOutput {

inline uint8_t* getBufferCopy() {
size_t size = m_buf - m_bytes.get();
uint8_t* result;
result = (uint8_t*)std::malloc(size * sizeof(uint8_t));
auto result = static_cast<uint8_t*>(std::malloc(size * sizeof(uint8_t)));
if (result == nullptr) {
throw OutOfMemoryException("Out of Memory while resizing buffer");
}
@@ -30,7 +30,12 @@

namespace {

using namespace apache::geode::client;
using apache::geode::client::CacheableString;
using apache::geode::client::CacheableStringArray;
using apache::geode::client::DataInput;
using apache::geode::client::DataOutput;
using apache::geode::client::DataSerializable;
using apache::geode::client::RegionShortcut;

class Simple : public DataSerializable {
public:
@@ -143,14 +148,15 @@ TEST(DataSerializableTest, isSerializableAndDeserializable) {

ASSERT_NE(nullptr, returnedObject);
EXPECT_EQ(dsObject->getName(), returnedObject->getName());
EXPECT_EQ(dsObject->getSimple()->getName(), returnedObject->getSimple()->getName());
EXPECT_EQ(dsObject->getSimple()->getAge(), returnedObject->getSimple()->getAge());
EXPECT_EQ(dsObject->getSimple()->getName(),
returnedObject->getSimple()->getName());
EXPECT_EQ(dsObject->getSimple()->getAge(),
returnedObject->getSimple()->getAge());
auto originalArray = dsObject->getCSArray();
auto returnedArray = returnedObject->getCSArray();
for(uint32_t index = 0; index < 4; ++index)
{
EXPECT_EQ(originalArray->operator[](index)->toString(), returnedArray->operator[](index)->toString());
for (uint32_t index = 0; index < 4; ++index) {
EXPECT_EQ(originalArray->operator[](index)->toString(),
returnedArray->operator[](index)->toString());
}

}
} // namespace
@@ -30,9 +30,16 @@

namespace {

using namespace apache::geode::client;

apache::geode::client::Cache createTestCache() {
using apache::geode::client::Cache;
using apache::geode::client::CacheableInt16;
using apache::geode::client::CacheableKey;
using apache::geode::client::CacheableString;
using apache::geode::client::CacheFactory;
using apache::geode::client::IllegalStateException;
using apache::geode::client::Region;
using apache::geode::client::RegionShortcut;

Cache createTestCache() {
CacheFactory cacheFactory;
return cacheFactory.set("log-level", "none")
.set("statistic-sampling-enabled", "false")
@@ -688,8 +688,7 @@ std::shared_ptr<Region> CacheHelper::createRegionDiscOverFlow(
sqLiteProps->insert("PageSize", "65536");
sqLiteProps->insert("MaxPageCount", "1073741823");
std::string sqlite_dir =
"SqLiteRegionData" +
std::to_string(static_cast<long long int>(ACE_OS::getpid()));
"SqLiteRegionData" + std::to_string(ACE_OS::getpid());
sqLiteProps->insert("PersistenceDirectory", sqlite_dir.c_str());
regionAttributeFactory.setPersistenceManager(
"SqLiteImpl", "createSqLiteInstance", sqLiteProps);
@@ -746,8 +745,7 @@ std::shared_ptr<Region> CacheHelper::createPooledRegionDiscOverFlow(
sqLiteProps->insert("PageSize", "65536");
sqLiteProps->insert("MaxPageCount", "1073741823");
std::string sqlite_dir =
"SqLiteRegionData" +
std::to_string(static_cast<long long int>(ACE_OS::getpid()));
"SqLiteRegionData" + std::to_string(ACE_OS::getpid());
sqLiteProps->insert("PersistenceDirectory", sqlite_dir.c_str());
regionFactory.setPersistenceManager("SqLiteImpl", "createSqLiteInstance",
sqLiteProps);
@@ -1286,10 +1284,10 @@ void CacheHelper::initServer(int instance, const char* xml,
if (!enableDelta) {
deltaProperty = "delta-propagation=false";
}
long defaultTombstone_timeout = 600000;
long defaultTombstone_gc_threshold = 100000;
long userTombstone_timeout = 1000;
long userTombstone_gc_threshold = 10;
int64_t defaultTombstone_timeout = 600000;
int64_t defaultTombstone_gc_threshold = 100000;
int64_t userTombstone_timeout = 1000;
int64_t userTombstone_gc_threshold = 10;
if (testServerGC) {
ACE_OS::mkdir("backupDirectory1");
ACE_OS::mkdir("backupDirectory2");
@@ -1306,8 +1304,10 @@ void CacheHelper::initServer(int instance, const char* xml,
"%s/bin/%s start server --classpath=%s --name=%s "
"--cache-xml-file=%s %s --dir=%s --server-port=%d --log-level=%s "
"--properties-file=%s %s %s "
"--J=-Dgemfire.tombstone-timeout=%ld "
"--J=-Dgemfire.tombstone-gc-hreshold=%ld "
"--J=-Dgemfire.tombstone-timeout=%" PRId64
" "
"--J=-Dgemfire.tombstone-gc-hreshold=%" PRId64
" "
"--J=-Dgemfire.security-log-level=%s --J=-Xmx1024m --J=-Xms128m 2>&1",
gfjavaenv, GFSH, classpath, sname.c_str(), xmlFile.c_str(),
useSecurityManager ? "--user=root --password=root-password" : "",
@@ -1322,8 +1322,10 @@ void CacheHelper::initServer(int instance, const char* xml,
cmd,
"%s/bin/%s start server --classpath=%s --name=%s "
"--cache-xml-file=%s %s --dir=%s --server-port=%d --log-level=%s %s %s "
"--J=-Dgemfire.tombstone-timeout=%ld "
"--J=-Dgemfire.tombstone-gc-hreshold=%ld "
"--J=-Dgemfire.tombstone-timeout=%" PRId64
" "
"--J=-Dgemfire.tombstone-gc-hreshold=%" PRId64
" "
"--J=-Dgemfire.security-log-level=%s --J=-Xmx1024m --J=-Xms128m 2>&1",
gfjavaenv, GFSH, classpath, sname.c_str(), xmlFile.c_str(),
useSecurityManager ? "--user=root --password=root-password" : "",
@@ -1736,7 +1738,7 @@ void CacheHelper::clearSecProp() {
tmpSecProp->remove("security-password");
}

void CacheHelper::setJavaConnectionPoolSize(long size) {
void CacheHelper::setJavaConnectionPoolSize(uint32_t size) {
CacheHelper::getHelper()
.getCache()
->getSystemProperties()
@@ -353,7 +353,7 @@ class CacheHelper {

static void clearSecProp();

static void setJavaConnectionPoolSize(long size);
static void setJavaConnectionPoolSize(uint32_t size);

static bool isSeedSet;
static bool setSeed();
@@ -15,22 +15,20 @@
* limitations under the License.
*/

#include <thread>

#include <geode/internal/geode_globals.hpp>

#include <ace/Time_Value.h>
#include <ace/OS.h>

namespace test {

void dummyFunc() {}

void millisleep(uint32_t x) {
ACE_Time_Value timeV(0);
timeV.msec(static_cast<long>(x));
ACE_OS::sleep(timeV);
}
} // namespace test

#define SLEEP(x) test::millisleep(x);
#define SLEEP(x) std::this_thread::sleep_for(std::chrono::milliseconds(x))
#define LOG LOGDEBUG

#include "TallyListener.hpp"
@@ -403,8 +403,7 @@ std::shared_ptr<Region> createOverflowRegion(const char* name, bool,
sqLiteProps->insert("PageSize", "65536");
sqLiteProps->insert("MaxPageCount", "1073741823");
std::string sqlite_dir =
"SqLiteRegionData" +
std::to_string(static_cast<long long int>(ACE_OS::getpid()));
"SqLiteRegionData" + std::to_string(ACE_OS::getpid());
sqLiteProps->insert("PersistenceDirectory", sqlite_dir.c_str());
regionAttributesFactory.setPersistenceManager(
"SqLiteImpl", "createSqLiteInstance", sqLiteProps);
@@ -213,8 +213,8 @@ class putThread : public ACE_Task_Base {

int svc(void) {
int ops = 0;
int32_t pid = ACE_OS::getpid();
ACE_thread_t thr_id = ACE_OS::thr_self();
auto pid = ACE_OS::getpid();
auto thr_id = ACE_OS::thr_self();
std::shared_ptr<CacheableKey> key;
std::shared_ptr<CacheableString> value;
std::vector<std::shared_ptr<CacheableKey>> keys0;
@@ -262,8 +262,8 @@ class putThread : public ACE_Task_Base {
m_reg->destroy(key);
}
} catch (Exception& ex) {
printf("%d: %ld exception got and exception message = %s\n", pid,
(long)thr_id, ex.what());
printf("%d: %" PRIuPTR " exception got and exception message = %s\n",
pid, (uintptr_t)thr_id, ex.what());
}
}
}
@@ -953,7 +953,7 @@ int64_t TimeStamp::msec() const { return m_msec; }

void TimeStamp::msec(int64_t t) { m_msec = t; }

Record::Record(std::string testName, const long ops, const TimeStamp& start,
Record::Record(std::string testName, int64_t ops, const TimeStamp& start,
const TimeStamp& stop)
: m_testName(testName),
m_operations(ops),
@@ -1017,7 +1017,7 @@ std::string Record::asString() {

PerfSuite::PerfSuite(const char* suiteName) : m_suiteName(suiteName) {}

void PerfSuite::addRecord(std::string testName, const long ops,
void PerfSuite::addRecord(std::string testName, int64_t ops,
const TimeStamp& start, const TimeStamp& stop) {
Record tmp(testName, ops, start, stop);
m_records[testName] = tmp;
@@ -105,7 +105,7 @@ class Record {
TimeStamp m_stopTime;

public:
Record(std::string testName, const long ops, const TimeStamp& start,
Record(std::string testName, int64_t ops, const TimeStamp& start,
const TimeStamp& stop);

Record();
@@ -135,7 +135,7 @@ class PerfSuite {
public:
explicit PerfSuite(const char* suiteName);

void addRecord(std::string testName, const long ops, const TimeStamp& start,
void addRecord(std::string testName, int64_t ops, const TimeStamp& start,
const TimeStamp& stop);

/** create a file in cwd, named "<suite>_results.<host>" */
@@ -249,7 +249,7 @@ class APACHE_GEODE_EXPORT CachePerfStats {
m_cachePerfStats->incInt(m_deltaFailedOnReceive, 1);
}

inline void incTimeSpentOnDeltaApplication(long time) {
inline void incTimeSpentOnDeltaApplication(int32_t time) {
m_cachePerfStats->incInt(m_processedDeltaMessagesTime, time);
}

@@ -357,7 +357,7 @@ TransactionId& CacheTransactionManagerImpl::suspend() {
.suspendedTxTimeout();
auto handler =
new SuspendedTxExpiryHandler(this, txState->getTransactionId());
long id = m_cache->getExpiryTaskManager().scheduleExpiryTask(
auto id = m_cache->getExpiryTaskManager().scheduleExpiryTask(
handler, suspendedTxTimeout, std::chrono::seconds::zero(), false);
txState->setSuspendedExpiryTaskId(id);

@@ -45,8 +45,7 @@ static class RandomInitializer {
RandomInitializer() {
// using current time and
// processor time would be good enough for our purpose
unsigned long seed =
ACE_OS::getpid() + ACE_OS::gettimeofday().msec() + clock();
auto seed = ACE_OS::getpid() + ACE_OS::gettimeofday().msec() + clock();
seed += ACE_OS::gettimeofday().usec();
// LOGINFO("PID %ld seed %ld ACE_OS::gettimeofday().usec() = %ld clock =
// %ld ACE_OS::gettimeofday().msec() = %ld", pid, seed ,
@@ -50,9 +50,9 @@ ExpiryTaskManager::ExpiryTaskManager() : m_reactorEventLoopRunning(false) {
#endif
}

long ExpiryTaskManager::scheduleExpiryTask(ACE_Event_Handler* handler,
uint32_t expTime, uint32_t interval,
bool cancelExistingTask) {
ExpiryTaskManager::id_type ExpiryTaskManager::scheduleExpiryTask(
ACE_Event_Handler* handler, uint32_t expTime, uint32_t interval,
bool cancelExistingTask) {
LOGFINER("ExpiryTaskManager: expTime %d, interval %d, cancelExistingTask %d",
expTime, interval, cancelExistingTask);
if (cancelExistingTask) {
@@ -65,10 +65,9 @@ long ExpiryTaskManager::scheduleExpiryTask(ACE_Event_Handler* handler,
intervalValue);
}

long ExpiryTaskManager::scheduleExpiryTask(ACE_Event_Handler* handler,
ACE_Time_Value expTimeValue,
ACE_Time_Value intervalVal,
bool cancelExistingTask) {
ExpiryTaskManager::id_type ExpiryTaskManager::scheduleExpiryTask(
ACE_Event_Handler* handler, ACE_Time_Value expTimeValue,
ACE_Time_Value intervalVal, bool cancelExistingTask) {
if (cancelExistingTask) {
m_reactor->cancel_timer(handler, 1);
}

0 comments on commit df677ef

Please sign in to comment.