Commit 50ce8d39 authored by Mark Olesen's avatar Mark Olesen

STYLE: use uintptr_t cast instead of long when reporting addresses

parent d933a18a
......@@ -41,8 +41,8 @@ using namespace Foam;
template<class T>
void printAddress(const UList<T>& list)
{
Info<< "list addr: " << long(&list)
<< " data addr: " << long(list.cdata()) << nl;
Info<< "list addr: " << uintptr_t(&list)
<< " data addr: " << uintptr_t(list.cdata()) << nl;
}
......
......@@ -50,7 +50,7 @@ void printInfo
Info<< " size=\"" << lst.size() << "\"";
if (lst.cdata())
{
Info<< " ptr=\"" << long(lst.cdata()) << "\"";
Info<< " ptr=\"" << uintptr_t(lst.cdata()) << "\"";
}
else
{
......@@ -76,7 +76,7 @@ void printInfo
<< "\" capacity=\"" << lst.capacity() << "\"";
if (lst.cdata())
{
Info<< " ptr=\"" << long(lst.cdata()) << "\"";
Info<< " ptr=\"" << uintptr_t(lst.cdata()) << "\"";
}
else
{
......
......@@ -50,7 +50,7 @@ Ostream& printInfo(const FixedList<List<T>, N>& list)
Info<< list << " addresses:";
for (unsigned i = 0; i < N; ++i)
{
Info<< " " << long(list[i].cdata());
Info<< " " << uintptr_t(list[i].cdata());
}
Info<< nl;
return Info;
......@@ -210,21 +210,24 @@ int main(int argc, char *argv[])
<< "list2: " << list2 << nl;
// Addresses don't change with swap
Info<< "mem: " << long(list1.data()) << " " << long(list2.data()) << nl;
Info<< "mem: "
<< uintptr_t(list1.data()) << " " << uintptr_t(list2.data()) << nl;
list1.swap(list2);
Info<< "The swap() method" << nl;
Info<< "list1: " << list1 << nl
<< "list2: " << list2 << nl;
Info<< "mem: " << long(list1.data()) << " " << long(list2.data()) << nl;
Info<< "mem: "
<< uintptr_t(list1.data()) << " " << uintptr_t(list2.data()) << nl;
Swap(list1, list2);
Info<< "The Swap() function" << nl;
Info<< "list1: " << list1 << nl
<< "list2: " << list2 << nl;
Info<< "mem: " << long(list1.data()) << " " << long(list2.data()) << nl;
Info<< "mem: "
<< uintptr_t(list1.data()) << " " << uintptr_t(list2.data()) << nl;
Info<< "====" << nl;
......
......@@ -45,7 +45,7 @@ void printTable(const HashPtrTable<T>& table)
Info<< iter.key() << " = ";
if (ptr)
{
Info<< *ptr << " (" << long(ptr) << ")";
Info<< *ptr << " (" << uintptr_t(ptr) << ")";
}
else
{
......
......@@ -172,7 +172,7 @@ int main(int argc, char *argv[])
if (iter.good())
{
Info<< "have " << k << nl
<< " addr: " << long(*iter) << nl
<< " addr: " << uintptr_t(*iter) << nl
<< " info: " << (*iter)->info() << nl
<< " info: " << iter->info() << nl
<< " incr: " << iter->increment() << nl
......@@ -214,7 +214,7 @@ int main(int argc, char *argv[])
if (iter1.good())
{
Info<< "have " << k << nl
<< " addr: " << long(*iter1) << nl
<< " addr: " << uintptr_t(*iter1) << nl
<< " info: " << (*iter1)->info() << nl
<< " info: " << iter1->info() << nl
<< " incr: " << iter1->increment() << nl
......@@ -225,7 +225,7 @@ int main(int argc, char *argv[])
if (iter2.good())
{
Info<< "have " << k << nl
<< " addr: " << long(*iter2) << nl
<< " addr: " << uintptr_t(*iter2) << nl
<< " info: " << (*iter2)->info() << nl
<< " info: " << iter2->info() << nl
// Good: does not compile
......@@ -237,7 +237,7 @@ int main(int argc, char *argv[])
if (iter3.good())
{
Info<< "have " << k << nl
<< " addr: " << long(*iter3) << nl
<< " addr: " << uintptr_t(*iter3) << nl
<< " info: " << (*iter3)->info() << nl
<< " info: " << iter3->info() << nl
// Good: does not compile
......
......@@ -69,7 +69,7 @@ void reportDetail(const IOobjectList& objects)
}
Info<< key << " (" << io->headerClassName()
<< ") = addr " << long(io) << nl;
<< ") = addr " << uintptr_t(io) << nl;
if (count != 1)
{
......
......@@ -36,7 +36,7 @@ template<class T>
Ostream& print(const IjkField<T>& fld)
{
Info<< static_cast<const Field<T>&>(fld).size()
<< " addr:" << long(fld.cdata()) << ' ' << fld.sizes() << ' '
<< " addr:" << uintptr_t(fld.cdata()) << ' ' << fld.sizes() << ' '
<< flatOutput(fld);
return Info;
......@@ -149,15 +149,15 @@ int main(int argc, char *argv[])
Info<< nl
<< "Before transfer: addr:" << long(field1.data())
<< "Before transfer: addr:" << uintptr_t(field1.data())
<< " size:" << field1.size() << nl;
Field<scalar> sfield1(std::move(field1));
field1.clear();
Info<< "After transfer to regular field" << nl
<< " source:" << long(field1.data()) << nl
<< " target:" << long(sfield1.data()) << nl
<< " source:" << uintptr_t(field1.data()) << nl
<< " target:" << uintptr_t(sfield1.data()) << nl
<< "Values"
<< " source:";
print(field1) << nl;
......
......@@ -47,15 +47,15 @@ using namespace Foam;
template<class T>
void printAddress(const UList<T>& list)
{
Info<< "list addr: " << long(&list)
<< " data addr: " << long(list.cdata()) << nl;
Info<< "list addr: " << uintptr_t(&list)
<< " data addr: " << uintptr_t(list.cdata()) << nl;
}
template<class T>
void printAddress(const SLList<T>& list)
{
Info<< "list addr: " << long(&list)
Info<< "list addr: " << uintptr_t(&list)
<< " data addr: ???" << nl;
}
......
......@@ -107,7 +107,7 @@ Ostream& printAddr
for (label i=0; i < len; ++i)
{
os << "addr=" << long(list(i)) << nl;
os << "addr=" << uintptr_t(list(i)) << nl;
}
// End delimiter
......@@ -193,7 +193,7 @@ Ostream& print
{
const T* ptr = list(i);
os << "unused " << long(ptr) << nl;
os << "unused " << uintptr_t(ptr) << nl;
}
}
......
......@@ -42,7 +42,7 @@ void printTable(const PtrMap<T>& table)
Info<< iter.key() << " = ";
if (ptr)
{
Info<< *ptr << " (" << long(ptr) << ")";
Info<< *ptr << " (" << uintptr_t(ptr) << ")";
}
else
{
......
......@@ -41,8 +41,8 @@ using namespace Foam;
template<class T>
void printAddress(const UList<T>& list)
{
Info<< "list addr: " << long(&list)
<< " data addr: " << long(list.cdata()) << nl;
Info<< "list addr: " << uintptr_t(&list)
<< " data addr: " << uintptr_t(list.cdata()) << nl;
}
......
......@@ -75,8 +75,8 @@ void printTuple2(const Tuple2<word, word>& t)
{
Info<< "tuple: " << t << nl;
Info<< "first @: " << long(t.first().data()) << nl;
Info<< "second @: " << long(t.second().data()) << nl;
Info<< "first @: " << uintptr_t(t.first().data()) << nl;
Info<< "second @: " << uintptr_t(t.second().data()) << nl;
}
......@@ -85,8 +85,8 @@ void printTuple2(const Pair<word>& t)
{
Info<< "tuple: " << t << nl;
Info<< "first @: " << long(t.first().data()) << nl;
Info<< "second @: " << long(t.second().data()) << nl;
Info<< "first @: " << uintptr_t(t.first().data()) << nl;
Info<< "second @: " << uintptr_t(t.second().data()) << nl;
}
......@@ -191,30 +191,30 @@ int main()
word word1("hello");
word word2("word");
Info<< "create with " << word1 << " @ " << long(word1.data())
<< " " << word2 << " @ " << long(word2.data()) << nl;
Info<< "create with " << word1 << " @ " << uintptr_t(word1.data())
<< " " << word2 << " @ " << uintptr_t(word2.data()) << nl;
Tuple2<word, word> tup(std::move(word2), std::move(word1));
printTuple2(tup);
Info<< "input is now " << word1 << " @ " << long(word1.data())
<< " " << word2 << " @ " << long(word2.data()) << nl;
Info<< "input is now " << word1 << " @ " << uintptr_t(word1.data())
<< " " << word2 << " @ " << uintptr_t(word2.data()) << nl;
}
{
word word1("hello");
word word2("word");
Info<< "create with " << word1 << " @ " << long(word1.data())
<< " " << word2 << " @ " << long(word2.data()) << nl;
Info<< "create with " << word1 << " @ " << uintptr_t(word1.data())
<< " " << word2 << " @ " << uintptr_t(word2.data()) << nl;
Pair<word> tup(std::move(word2), std::move(word1));
printTuple2(tup);
Info<< "input is now " << word1 << " @ " << long(word1.data())
<< " " << word2 << " @ " << long(word2.data()) << nl;
Info<< "input is now " << word1 << " @ " << uintptr_t(word1.data())
<< " " << word2 << " @ " << uintptr_t(word2.data()) << nl;
}
Info<< "\nEnd\n" << endl;
......
......@@ -46,7 +46,7 @@ using namespace Foam;
template<class ListType>
void print(const ListType& list)
{
Info << flatOutput(list) << " data addr: " << long(list.cdata()) << nl;
Info << flatOutput(list) << " data addr: " << uintptr_t(list.cdata()) << nl;
}
......
......@@ -90,16 +90,17 @@ int main(int argc, char *argv[])
{
auto source = identity(8);
Info<<"move construct from "
<< flatOutput(source) << " @ " << long(source.cdata())
<< flatOutput(source) << " @ " << uintptr_t(source.cdata())
<< nl << nl;
auto list = autoPtr<labelList>::New(std::move(source));
Info<<"created: " << flatOutput(*list) << " @ " << long(list->cdata())
Info<<"created: "
<< flatOutput(*list) << " @ " << uintptr_t(list->cdata())
<< nl << nl;
Info<<"orig: "
<< flatOutput(source) << " @ " << long(source.cdata())
<< flatOutput(source) << " @ " << uintptr_t(source.cdata())
<< nl << nl;
}
......@@ -136,7 +137,7 @@ int main(int argc, char *argv[])
auto list = autoPtr<labelList>::New(identity(8));
Info<<"forward to function from "
<< flatOutput(*list) << " @ " << long(list->cdata())
<< flatOutput(*list) << " @ " << uintptr_t(list->cdata())
<< nl << nl;
testTransfer2(std::move(list));
......@@ -146,7 +147,7 @@ int main(int argc, char *argv[])
if (list)
{
Info<< nl
<< flatOutput(*list) << " @ " << long(list->cdata())
<< flatOutput(*list) << " @ " << uintptr_t(list->cdata())
<< nl;
}
else
......@@ -184,7 +185,7 @@ int main(int argc, char *argv[])
auto list = autoPtr<labelList>::New(identity(8));
Info<<"forward to function from "
<< flatOutput(*list) << " @ " << long(list->cdata())
<< flatOutput(*list) << " @ " << uintptr_t(list->cdata())
<< nl << nl;
testTransfer2(std::move(list));
......@@ -194,7 +195,7 @@ int main(int argc, char *argv[])
if (list.valid())
{
Info<< nl
<< flatOutput(*list) << " @ " << long(list->cdata())
<< flatOutput(*list) << " @ " << uintptr_t(list->cdata())
<< nl;
}
else
......
......@@ -621,7 +621,7 @@ int main(int argc, char *argv[])
os << "file=<" << file << ">" << nl;
}
const int oldPosix = POSIX::debug;
const int oldDebug = POSIX::debug;
POSIX::debug = 1;
......@@ -687,7 +687,7 @@ int main(int argc, char *argv[])
Foam::rmDir(lnB);
}
POSIX::debug = oldPosix;
POSIX::debug = oldDebug;
// Verify that rmDir works with bad names too
Foam::rmDir(dirA);
......
......@@ -78,8 +78,8 @@ int main()
Info
<< "\nVerify memory addesses are identical:" << nl
<< "macro " << long(Foam::FOAMversion) << nl
<< "namespace " << long(&(foamVersion::version[0])) << nl;
<< "macro " << uintptr_t(Foam::FOAMversion) << nl
<< "namespace " << uintptr_t(&(foamVersion::version[0])) << nl;
// Test extraction
......
......@@ -37,7 +37,7 @@ Ostream& printInfo(const hashedWordList& list, bool withAddr=false)
Info<< flatOutput(list) << nl << list.lookup() << nl;
if (withAddr)
{
Info<< "addr=" << long(list.cdata()) << nl;
Info<< "addr=" << uintptr_t(list.cdata()) << nl;
}
return Info;
......
......@@ -55,16 +55,14 @@ public:
template<class T>
void printInfo(const UList<T>& list)
{
typedef unsigned long ptrval;
std::cout
<< nl
<< "List : addr: " << ptrval(&list)
<< "List : addr: " << uintptr_t(&list)
<< " (null: " << isNull(list) << ")" << nl
<< " size: " << list.size() << " empty: " << list.empty() << nl
<< " data: " << ptrval(list.cdata())
<< " begin=" << ptrval(list.begin())
<< " end=" << ptrval(list.end()) << nl;
<< " data: " << uintptr_t(list.cdata())
<< " begin=" << uintptr_t(list.begin())
<< " end=" << uintptr_t(list.end()) << nl;
Info<< list << nl;
}
......@@ -79,10 +77,8 @@ int main()
SimpleClass* ptrToClass = new SimpleClass;
SimpleClass& refToClass(*ptrToClass);
typedef unsigned long ptrval;
std::cout
<< "nullObject addr=" << ptrval(&(nullObjectPtr)) << nl
<< "nullObject addr=" << uintptr_t(&(nullObjectPtr)) << nl
<< " sizeof(nullObject) = " << sizeof(NullObject::nullObject) << nl
<< " sizeof(void*) = " << sizeof(void*) << nl
<< " sizeof(labelList) = " << sizeof(labelList) << nl
......@@ -90,7 +86,7 @@ int main()
std::cout
<< "nullObject" << nl
<< " pointer:" << ptrval(nullObjectPtr->pointer()) << nl
<< " pointer:" << uintptr_t(nullObjectPtr->pointer()) << nl
<< " value:" << nullObjectPtr->value() << nl << nl;
if (notNull(ptrToClass))
......
......@@ -46,7 +46,7 @@ void printInfo(const tmp<T>& tmpItem)
{
Info<< "tmp valid:" << tmpItem.valid()
<< " isTmp:" << tmpItem.isTmp()
<< " addr: " << long(tmpItem.get());
<< " addr: " << uintptr_t(tmpItem.get());
if (tmpItem.valid())
{
......
......@@ -212,8 +212,8 @@ Foam::PackedList<Width> Foam::reorder
}
// Verify addresses (for movable refs)
// Info<< "reordered in " << long(input.storage().cdata()) << nl
// << "reordered out " << long(output.storage().cdata()) << nl;
// Info<< "reordered in " << uintptr_t(input.storage().cdata()) << nl
// << "reordered out " << uintptr_t(output.storage().cdata()) << nl;
return output;
}
......@@ -230,7 +230,7 @@ void Foam::inplaceReorder
input = reorder(oldToNew, input, prune);
// Verify address (for movable refs)
// Info<< "now have " << long(input.storage().cdata()) << nl;
// Info<< "now have " << uintptr_t(input.storage().cdata()) << nl;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment