From 6e2f6d1ace7490a200dcff70c52acf2af59c5bc3 Mon Sep 17 00:00:00 2001 From: Alex Smith Date: Sun, 29 Jul 2012 09:31:14 +0100 Subject: [PATCH] Changed cookie type for get_next_area_info() to ssize_t. The cookie is used to store the base address of the area that was just visited. On 64-bit systems, int32 is not sufficient. Therefore, changed to ssize_t which retains compatibility on x86 while expanding to a sufficient size on x86_64. --- headers/os/kernel/OS.h | 2 +- headers/private/kernel/vm/vm.h | 2 +- headers/private/system/syscalls.h | 2 +- src/apps/processcontroller/MemoryBarMenuItem.cpp | 2 +- src/bin/listarea.c | 2 +- src/kits/debug/SymbolLookup.cpp | 2 +- src/servers/debug/DebugServer.cpp | 2 +- src/system/kernel/team.cpp | 12 +++++++----- src/system/kernel/vm/vm.cpp | 13 ++++++------- src/system/libroot/os/area.c | 2 +- 10 files changed, 21 insertions(+), 20 deletions(-) diff --git a/headers/os/kernel/OS.h b/headers/os/kernel/OS.h index 633e4541b5..6fc6a3badd 100644 --- a/headers/os/kernel/OS.h +++ b/headers/os/kernel/OS.h @@ -96,7 +96,7 @@ extern status_t set_area_protection(area_id id, uint32 newProtection); /* system private, use macros instead */ extern status_t _get_area_info(area_id id, area_info *areaInfo, size_t size); -extern status_t _get_next_area_info(team_id team, int32 *cookie, +extern status_t _get_next_area_info(team_id team, ssize_t *cookie, area_info *areaInfo, size_t size); #define get_area_info(id, areaInfo) \ diff --git a/headers/private/kernel/vm/vm.h b/headers/private/kernel/vm/vm.h index 9163e3bca1..ef1b829915 100644 --- a/headers/private/kernel/vm/vm.h +++ b/headers/private/kernel/vm/vm.h @@ -176,7 +176,7 @@ status_t _user_get_memory_properties(team_id teamID, const void *address, area_id _user_area_for(void *address); area_id _user_find_area(const char *name); status_t _user_get_area_info(area_id area, area_info *info); -status_t _user_get_next_area_info(team_id team, int32 *cookie, area_info *info); +status_t _user_get_next_area_info(team_id team, ssize_t *cookie, area_info *info); status_t _user_resize_area(area_id area, size_t newSize); area_id _user_transfer_area(area_id area, void **_address, uint32 addressSpec, team_id target); diff --git a/headers/private/system/syscalls.h b/headers/private/system/syscalls.h index b104bb6cf8..0e588b2cd3 100644 --- a/headers/private/system/syscalls.h +++ b/headers/private/system/syscalls.h @@ -411,7 +411,7 @@ extern status_t _kern_delete_area(area_id area); extern area_id _kern_area_for(void *address); extern area_id _kern_find_area(const char *name); extern status_t _kern_get_area_info(area_id area, area_info *info); -extern status_t _kern_get_next_area_info(team_id team, int32 *cookie, +extern status_t _kern_get_next_area_info(team_id team, ssize_t *cookie, area_info *info); extern status_t _kern_resize_area(area_id area, size_t newSize); extern area_id _kern_transfer_area(area_id area, void **_address, diff --git a/src/apps/processcontroller/MemoryBarMenuItem.cpp b/src/apps/processcontroller/MemoryBarMenuItem.cpp index c51cd750be..34fca14177 100644 --- a/src/apps/processcontroller/MemoryBarMenuItem.cpp +++ b/src/apps/processcontroller/MemoryBarMenuItem.cpp @@ -246,7 +246,7 @@ void MemoryBarMenuItem::BarUpdate() { area_info areaInfo; - int32 cookie = 0; + ssize_t cookie = 0; int64 lram_size = 0; int64 lwram_size = 0; bool exists = false; diff --git a/src/bin/listarea.c b/src/bin/listarea.c index 00ab99bfd5..f381bb16ee 100644 --- a/src/bin/listarea.c +++ b/src/bin/listarea.c @@ -41,7 +41,7 @@ show_memory_totals(void) static void list_areas_for_id(team_id id) { - int32 cookie = 0; + ssize_t cookie = 0; team_info teamInfo; area_info areaInfo; diff --git a/src/kits/debug/SymbolLookup.cpp b/src/kits/debug/SymbolLookup.cpp index 930ac95a9f..d29f4e8f1b 100644 --- a/src/kits/debug/SymbolLookup.cpp +++ b/src/kits/debug/SymbolLookup.cpp @@ -86,7 +86,7 @@ RemoteMemoryAccessor::Init() // get a list of the team's areas area_info areaInfo; - int32 cookie = 0; + ssize_t cookie = 0; status_t error; while ((error = get_next_area_info(fTeam, &cookie, &areaInfo)) == B_OK) { TRACE(("area %ld: address: %p, size: %ld, name: %s\n", areaInfo.area, diff --git a/src/servers/debug/DebugServer.cpp b/src/servers/debug/DebugServer.cpp index 83e49709c5..8abb4c7a64 100644 --- a/src/servers/debug/DebugServer.cpp +++ b/src/servers/debug/DebugServer.cpp @@ -734,7 +734,7 @@ TeamDebugHandler::_LookupSymbolAddress( // lookup failed: find area containing the IP bool useAreaInfo = false; area_info info; - int32 cookie = 0; + ssize_t cookie = 0; while (get_next_area_info(fTeam, &cookie, &info) == B_OK) { if ((addr_t)info.address <= (addr_t)address && (addr_t)info.address + info.size > (addr_t)address) { diff --git a/src/system/kernel/team.cpp b/src/system/kernel/team.cpp index acdc915f26..b8fbde285e 100644 --- a/src/system/kernel/team.cpp +++ b/src/system/kernel/team.cpp @@ -1942,7 +1942,8 @@ fork_team(void) struct area_info info; thread_id threadID; status_t status; - int32 cookie; + ssize_t areaCookie; + int32 imageCookie; TRACE(("fork_team(): team %" B_PRId32 "\n", parentTeam->id)); @@ -2030,8 +2031,8 @@ fork_team(void) // TODO: should be able to handle stack areas differently (ie. don't have // them copy-on-write) - cookie = 0; - while (get_next_area_info(B_CURRENT_TEAM, &cookie, &info) == B_OK) { + areaCookie = 0; + while (get_next_area_info(B_CURRENT_TEAM, &areaCookie, &info) == B_OK) { if (info.area == parentTeam->user_data_area) { // don't clone the user area; just create a new one status = create_team_user_data(team); @@ -2077,8 +2078,9 @@ fork_team(void) // copy image list image_info imageInfo; - cookie = 0; - while (get_next_image_info(parentTeam->id, &cookie, &imageInfo) == B_OK) { + imageCookie = 0; + while (get_next_image_info(parentTeam->id, &imageCookie, &imageInfo) + == B_OK) { image_id image = register_image(team, &imageInfo, sizeof(imageInfo)); if (image < 0) goto err5; diff --git a/src/system/kernel/vm/vm.cpp b/src/system/kernel/vm/vm.cpp index 5d5f936459..7aaafabcdc 100644 --- a/src/system/kernel/vm/vm.cpp +++ b/src/system/kernel/vm/vm.cpp @@ -5750,7 +5750,7 @@ _get_area_info(area_id id, area_info* info, size_t size) status_t -_get_next_area_info(team_id team, int32* cookie, area_info* info, size_t size) +_get_next_area_info(team_id team, ssize_t* cookie, area_info* info, size_t size) { addr_t nextBase = *(addr_t*)cookie; @@ -5779,8 +5779,7 @@ _get_next_area_info(team_id team, int32* cookie, area_info* info, size_t size) } fill_area_info(area, info, size); - *cookie = (int32)(area->Base()); - // TODO: Not 64 bit safe! + *cookie = (ssize_t)(area->Base()); return B_OK; } @@ -5987,13 +5986,13 @@ _user_get_area_info(area_id area, area_info* userInfo) status_t -_user_get_next_area_info(team_id team, int32* userCookie, area_info* userInfo) +_user_get_next_area_info(team_id team, ssize_t* userCookie, area_info* userInfo) { - int32 cookie; + ssize_t cookie; if (!IS_USER_ADDRESS(userCookie) || !IS_USER_ADDRESS(userInfo) - || user_memcpy(&cookie, userCookie, sizeof(int32)) < B_OK) + || user_memcpy(&cookie, userCookie, sizeof(ssize_t)) < B_OK) return B_BAD_ADDRESS; area_info info; @@ -6004,7 +6003,7 @@ _user_get_next_area_info(team_id team, int32* userCookie, area_info* userInfo) //info.protection &= B_USER_PROTECTION; - if (user_memcpy(userCookie, &cookie, sizeof(int32)) < B_OK + if (user_memcpy(userCookie, &cookie, sizeof(ssize_t)) < B_OK || user_memcpy(userInfo, &info, sizeof(area_info)) < B_OK) return B_BAD_ADDRESS; diff --git a/src/system/libroot/os/area.c b/src/system/libroot/os/area.c index bb28838a91..0fedf2fc48 100644 --- a/src/system/libroot/os/area.c +++ b/src/system/libroot/os/area.c @@ -70,7 +70,7 @@ _get_area_info(area_id id, area_info *areaInfo, size_t size) status_t -_get_next_area_info(team_id team, int32 *cookie, area_info *areaInfo, size_t size) +_get_next_area_info(team_id team, ssize_t *cookie, area_info *areaInfo, size_t size) { // size is not yet used, but may, if area_info changes (void)size;