diff --git a/plugins/devel/eventExample.cpp b/plugins/devel/eventExample.cpp index 35c5253b4..d64969c91 100644 --- a/plugins/devel/eventExample.cpp +++ b/plugins/devel/eventExample.cpp @@ -128,26 +128,26 @@ void jobCompleted(color_ostream& out, void* job) { } void timePassed(color_ostream& out, void* ptr) { - out.print("Time: %d\n", (int32_t)(ptr)); + out.print("Time: %d\n", (intptr_t)(ptr)); } void unitDeath(color_ostream& out, void* ptr) { - out.print("Death: %d\n", (int32_t)(ptr)); + out.print("Death: %d\n", (intptr_t)(ptr)); } void itemCreate(color_ostream& out, void* ptr) { - int32_t item_index = df::item::binsearch_index(df::global::world->items.all, (int32_t)ptr); + int32_t item_index = df::item::binsearch_index(df::global::world->items.all, (intptr_t)ptr); if ( item_index == -1 ) { out.print("%s, %d: Error.\n", __FILE__, __LINE__); } df::item* item = df::global::world->items.all[item_index]; df::item_type type = item->getType(); df::coord pos = item->pos; - out.print("Item created: %d, %s, at (%d,%d,%d)\n", (int32_t)(ptr), ENUM_KEY_STR(item_type, type).c_str(), pos.x, pos.y, pos.z); + out.print("Item created: %d, %s, at (%d,%d,%d)\n", (intptr_t)(ptr), ENUM_KEY_STR(item_type, type).c_str(), pos.x, pos.y, pos.z); } void building(color_ostream& out, void* ptr) { - out.print("Building created/destroyed: %d\n", (int32_t)ptr); + out.print("Building created/destroyed: %d\n", (intptr_t)ptr); } void construction(color_ostream& out, void* ptr) { @@ -168,7 +168,7 @@ void syndrome(color_ostream& out, void* ptr) { } void invasion(color_ostream& out, void* ptr) { - out.print("New invasion! %d\n", (int32_t)ptr); + out.print("New invasion! %d\n", (intptr_t)ptr); } void unitAttack(color_ostream& out, void* ptr) { diff --git a/plugins/devel/memview.cpp b/plugins/devel/memview.cpp index 07158babc..f33ff110f 100644 --- a/plugins/devel/memview.cpp +++ b/plugins/devel/memview.cpp @@ -51,7 +51,7 @@ size_t convert(const std::string& p,bool ishex=false) conv>>ret; return ret; } -bool isAddr(uint32_t *trg,vector & ranges) +bool isAddr(uintptr_t *trg,vector & ranges) { if(trg[0]%4==0) for(size_t i=0;i & parameters) int c = sizeof(*rd) / sizeof(int32_t); for (int j = 0; j < c; j++) { if (j % 8 == 0) - out << endl << setfill('0') << setw(8) << hex << (int)(rd+j) << ": "; + out << endl << setfill('0') << setw(8) << hex << (intptr_t)(rd+j) << ": "; out << " " << setfill('0') << setw(8) << hex << p[j]; } out << setfill(' ') << setw(0) << dec << endl; diff --git a/plugins/devel/vectors.cpp b/plugins/devel/vectors.cpp index c7e81dfe7..52c74e83b 100644 --- a/plugins/devel/vectors.cpp +++ b/plugins/devel/vectors.cpp @@ -50,7 +50,7 @@ DFhackCExport command_result plugin_shutdown ( color_ostream &out ) return CR_OK; } -static bool hexOrDec(string &str, uint32_t &value) +static bool hexOrDec(string &str, uintptr_t &value) { if (str.find("0x") == 0 && sscanf(str.c_str(), "%x", &value) == 1) return true; @@ -69,7 +69,7 @@ static bool mightBeVec(vector &ranges, // Vector length might not be a multiple of 4 if, for example, // it's a vector of uint8_t or uint16_t. However, the actual memory // allocated to the vector should be 4 byte aligned. - if (((int)vec->start % 4 != 0) || ((int)vec->alloc_end % 4 != 0)) + if (((intptr_t)vec->start % 4 != 0) || ((intptr_t)vec->alloc_end % 4 != 0)) return false; for (size_t i = 0; i < ranges.size(); i++) @@ -130,7 +130,7 @@ static void vectorsUsage(color_ostream &con) static void printVec(color_ostream &con, const char* msg, t_vecTriplet *vec, uint32_t start, uint32_t pos, std::vector &ranges) { - uint32_t length = (int)vec->end - (int)vec->start; + uint32_t length = (intptr_t)vec->end - (intptr_t)vec->start; uint32_t offset = pos - start; con.print("%8s offset %06p, addr %010p, start %010p, length %u", @@ -158,7 +158,7 @@ command_result df_vectors (color_ostream &con, vector & parameters) return CR_FAILURE; } - uint32_t start = 0, bytes = 0; + uintptr_t start = 0, bytes = 0; if (!hexOrDec(parameters[0], start)) { @@ -172,7 +172,7 @@ command_result df_vectors (color_ostream &con, vector & parameters) return CR_FAILURE; } - uint32_t end = start + bytes; + uintptr_t end = start + bytes; // 4 byte alignment. while (start % 4 != 0) @@ -200,10 +200,10 @@ command_result df_vectors (color_ostream &con, vector & parameters) { con.print("Scanning %u bytes would read past end of memory " "range.\n", bytes); - uint32_t diff = end - (int)range.end; + size_t diff = end - (intptr_t)range.end; con.print("Cutting bytes down by %u.\n", diff); - end = (uint32_t) range.end; + end = (uintptr_t) range.end; } startInRange = true; break; @@ -215,11 +215,11 @@ command_result df_vectors (color_ostream &con, vector & parameters) return CR_FAILURE; } - uint32_t pos = start; + uintptr_t pos = start; - const uint32_t ptr_size = sizeof(void*); + const size_t ptr_size = sizeof(void*); - for (uint32_t pos = start; pos < end; pos += ptr_size) + for (uintptr_t pos = start; pos < end; pos += ptr_size) { // Is it an embeded vector? if (pos <= ( end - sizeof(t_vecTriplet) )) @@ -238,7 +238,7 @@ command_result df_vectors (color_ostream &con, vector & parameters) // Is it a vector pointer? if (pos <= (end - ptr_size)) { - uint32_t ptr = * ( (uint32_t*) pos); + uintptr_t ptr = * ( (uintptr_t*) pos); if (inAnyRange(ranges, (void *) ptr)) { @@ -275,7 +275,7 @@ command_result df_clearvec (color_ostream &con, vector & parameters) return CR_FAILURE; } - uint32_t start = 0, bytes = 0; + uintptr_t start = 0, bytes = 0; if (!hexOrDec(parameters[0], start)) { @@ -301,7 +301,7 @@ command_result df_clearvec (color_ostream &con, vector & parameters) for (size_t i = 0; i < parameters.size(); i++) { std::string addr_str = parameters[i]; - uint32_t addr; + uintptr_t addr; if (!hexOrDec(addr_str, addr)) { con << "'" << addr_str << "' not a number." << std::endl; @@ -329,7 +329,7 @@ command_result df_clearvec (color_ostream &con, vector & parameters) else { // Is it a pointer to a vector? - addr = * ( (uint32_t*) addr); + addr = * ( (uintptr_t*) addr); vec = (t_vecTriplet*) addr; if (inAnyRange(ranges, (void *) addr) && mightBeVec(ranges, vec))