From: Nicholas Nethercote Date: Tue, 2 Nov 2004 13:29:50 +0000 (+0000) Subject: 64-bit cleanness: X-Git-Tag: svn/VALGRIND_3_0_0~1401 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c73601d666f296db7a9655a0674d5a339eac443d;p=thirdparty%2Fvalgrind.git 64-bit cleanness: - Use SizeT instead of UInt for new_mem_stack and all the related functions. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2908 --- diff --git a/coregrind/core.h b/coregrind/core.h index 3c792f16e9..d9583d55d3 100644 --- a/coregrind/core.h +++ b/coregrind/core.h @@ -1012,10 +1012,10 @@ extern Int VG_(fcntl) ( Int fd, Int cmd, Int arg ); extern Int VG_(poll)( struct vki_pollfd *, UInt nfds, Int timeout); /* system/mman.h */ -extern void* VG_(mmap)( void* start, UInt length, UInt prot, UInt flags, +extern void* VG_(mmap)( void* start, SizeT length, UInt prot, UInt flags, UInt sf_flags, UInt fd, UInt offset ); -extern Int VG_(munmap)( void* start, Int length ); -extern Int VG_(mprotect)( void *start, Int length, UInt prot ); +extern Int VG_(munmap)( void* start, SizeT length ); +extern Int VG_(mprotect)( void *start, SizeT length, UInt prot ); /* Move an fd into the Valgrind-safe range */ @@ -1308,19 +1308,19 @@ struct _Segment { }; /* segment mapped from a file descriptor */ -extern void VG_(map_fd_segment) (Addr addr, UInt len, UInt prot, UInt flags, +extern void VG_(map_fd_segment) (Addr addr, SizeT len, UInt prot, UInt flags, Int fd, ULong off, const Char *filename); /* segment mapped from a file */ -extern void VG_(map_file_segment)(Addr addr, UInt len, UInt prot, UInt flags, +extern void VG_(map_file_segment)(Addr addr, SizeT len, UInt prot, UInt flags, UInt dev, UInt ino, ULong off, const Char *filename); /* simple segment */ -extern void VG_(map_segment) (Addr addr, UInt len, UInt prot, UInt flags); +extern void VG_(map_segment) (Addr addr, SizeT len, UInt prot, UInt flags); -extern void VG_(unmap_range) (Addr addr, UInt len); -extern void VG_(mprotect_range)(Addr addr, UInt len, UInt prot); -extern Addr VG_(find_map_space)(Addr base, UInt len, Bool for_client); +extern void VG_(unmap_range) (Addr addr, SizeT len); +extern void VG_(mprotect_range)(Addr addr, SizeT len, UInt prot); +extern Addr VG_(find_map_space)(Addr base, SizeT len, Bool for_client); extern Segment *VG_(find_segment)(Addr a); extern Segment *VG_(first_segment)(void); diff --git a/coregrind/vg_memory.c b/coregrind/vg_memory.c index 43915e18c5..e111dc7fbd 100644 --- a/coregrind/vg_memory.c +++ b/coregrind/vg_memory.c @@ -154,7 +154,7 @@ Segment *VG_(split_segment)(Addr a) /* This unmaps all the segments in the range [addr, addr+len); any partial mappings at the ends are truncated. */ -void VG_(unmap_range)(Addr addr, UInt len) +void VG_(unmap_range)(Addr addr, SizeT len) { Segment *s; Segment *next; @@ -281,7 +281,7 @@ static inline Bool neighbours(Segment *s1, Segment *s2) /* If possible, merge segment with its neighbours - some segments, including s, may be destroyed in the process */ -static void merge_segments(Addr a, UInt len) +static void merge_segments(Addr a, SizeT len) { Segment *s; Segment *next; @@ -314,7 +314,7 @@ static void merge_segments(Addr a, UInt len) } } -void VG_(map_file_segment)(Addr addr, UInt len, UInt prot, UInt flags, +void VG_(map_file_segment)(Addr addr, SizeT len, UInt prot, UInt flags, UInt dev, UInt ino, ULong off, const Char *filename) { Segment *s; @@ -322,8 +322,8 @@ void VG_(map_file_segment)(Addr addr, UInt len, UInt prot, UInt flags, Bool recycled; if (debug) - VG_(printf)("map_file_segment(%p, %d, %x, %x, %4x, %d, %ld, %s)\n", - addr, len, prot, flags, dev, ino, off, filename); + VG_(printf)("map_file_segment(%p, %llu, %x, %x, %4x, %d, %ld, %s)\n", + addr, (ULong)len, prot, flags, dev, ino, off, filename); /* Everything must be page-aligned */ vg_assert((addr & (VKI_PAGE_SIZE-1)) == 0); @@ -421,7 +421,7 @@ void VG_(map_file_segment)(Addr addr, UInt len, UInt prot, UInt flags, merge_segments(addr, len); } -void VG_(map_fd_segment)(Addr addr, UInt len, UInt prot, UInt flags, +void VG_(map_fd_segment)(Addr addr, SizeT len, UInt prot, UInt flags, Int fd, ULong off, const Char *filename) { struct vki_stat st; @@ -449,7 +449,7 @@ void VG_(map_fd_segment)(Addr addr, UInt len, UInt prot, UInt flags, VG_(arena_free)(VG_AR_CORE, name); } -void VG_(map_segment)(Addr addr, UInt len, UInt prot, UInt flags) +void VG_(map_segment)(Addr addr, SizeT len, UInt prot, UInt flags) { flags &= ~SF_FILE; @@ -457,7 +457,7 @@ void VG_(map_segment)(Addr addr, UInt len, UInt prot, UInt flags) } /* set new protection flags on an address range */ -void VG_(mprotect_range)(Addr a, UInt len, UInt prot) +void VG_(mprotect_range)(Addr a, SizeT len, UInt prot) { Segment *s, *next; static const Bool debug = False || mem_debug; @@ -486,7 +486,7 @@ void VG_(mprotect_range)(Addr a, UInt len, UInt prot) merge_segments(a, len); } -Addr VG_(find_map_space)(Addr addr, UInt len, Bool for_client) +Addr VG_(find_map_space)(Addr addr, SizeT len, Bool for_client) { static const Bool debug = False || mem_debug; Segment *s; diff --git a/coregrind/vg_mylibc.c b/coregrind/vg_mylibc.c index 260afac7fb..77dcf2189b 100644 --- a/coregrind/vg_mylibc.c +++ b/coregrind/vg_mylibc.c @@ -273,7 +273,7 @@ static Int munmap_inner(void *start, UInt length) return VG_(do_syscall)(__NR_munmap, (UInt)start, (UInt)length ); } -static Addr mmap_inner(void *start, UInt length, UInt prot, UInt flags, UInt fd, UInt offset) +static Addr mmap_inner(void *start, SizeT length, UInt prot, UInt flags, UInt fd, UInt offset) { Int ret; @@ -284,7 +284,7 @@ static Addr mmap_inner(void *start, UInt length, UInt prot, UInt flags, UInt fd, } /* Returns -1 on failure. */ -void* VG_(mmap)( void* start, UInt length, +void* VG_(mmap)( void* start, SizeT length, UInt prot, UInt flags, UInt sf_flags, UInt fd, UInt offset) { Addr res; @@ -321,7 +321,7 @@ void* VG_(mmap)( void* start, UInt length, } /* Returns -1 on failure. */ -Int VG_(munmap)( void* start, Int length ) +Int VG_(munmap)( void* start, SizeT length ) { Int res = munmap_inner(start, length); if (!VG_(is_kerror)(res)) @@ -329,9 +329,9 @@ Int VG_(munmap)( void* start, Int length ) return VG_(is_kerror)(res) ? -1 : 0; } -Int VG_(mprotect)( void *start, Int length, UInt prot ) +Int VG_(mprotect)( void *start, SizeT length, UInt prot ) { - Int res = VG_(do_syscall)(__NR_mprotect, (UInt)start, (UInt)length, prot ); + Int res = VG_(do_syscall)(__NR_mprotect, (UWord)start, length, prot ); if (!VG_(is_kerror)(res)) VG_(mprotect_range)((Addr)start, length, prot); return VG_(is_kerror)(res) ? -1 : 0; @@ -1682,9 +1682,9 @@ UInt VG_(read_millisecond_timer) ( void ) Primitive support for bagging memory via mmap. ------------------------------------------------------------------ */ -void* VG_(get_memory_from_mmap) ( Int nBytes, Char* who ) +void* VG_(get_memory_from_mmap) ( SizeT nBytes, Char* who ) { - static UInt tot_alloc = 0; + static SizeT tot_alloc = 0; void* p; p = VG_(mmap)(0, nBytes, VKI_PROT_READ|VKI_PROT_WRITE|VKI_PROT_EXEC, @@ -1695,16 +1695,16 @@ void* VG_(get_memory_from_mmap) ( Int nBytes, Char* who ) tot_alloc += (UInt)nBytes; if (0) VG_(printf)( - "get_memory_from_mmap: %d tot, %d req = %p .. %p, caller %s\n", - tot_alloc, nBytes, p, ((char*)p) + nBytes - 1, who ); + "get_memory_from_mmap: %llu tot, %llu req = %p .. %p, caller %s\n", + (ULong)tot_alloc, (ULong)nBytes, p, ((char*)p) + nBytes - 1, who ); return p; } VG_(printf)("\n"); - VG_(printf)("VG_(get_memory_from_mmap): %s's request for %d bytes failed.\n", - who, nBytes); - VG_(printf)("VG_(get_memory_from_mmap): %d bytes already allocated.\n", - tot_alloc); + VG_(printf)("VG_(get_memory_from_mmap): %s's request for %llu bytes failed.\n", + who, (ULong)nBytes); + VG_(printf)("VG_(get_memory_from_mmap): %llu bytes already allocated.\n", + (ULong)tot_alloc); VG_(printf)("\n"); VG_(printf)("Sorry. You could try using a tool that uses less memory;\n"); VG_(printf)("eg. addrcheck instead of memcheck.\n"); diff --git a/include/basic_types.h b/include/basic_types.h index 01f38e31ba..4e8c769e33 100644 --- a/include/basic_types.h +++ b/include/basic_types.h @@ -37,7 +37,7 @@ // By choosing the right types, we can get these right for 32-bit and 64-bit // platforms without having to do any conditional compilation or anything. -// +// // Size in bits on: 32-bit archs 64-bit archs // ------------ ------------ typedef unsigned char UChar; // 8 8 diff --git a/include/tool.h.base b/include/tool.h.base index af7b351b63..89d66ad008 100644 --- a/include/tool.h.base +++ b/include/tool.h.base @@ -485,7 +485,7 @@ extern void VG_(skin_assert_fail) ( const Char* expr, const Char* file, /* ------------------------------------------------------------------ */ /* Get memory by anonymous mmap. */ -extern void* VG_(get_memory_from_mmap) ( Int nBytes, Char* who ); +extern void* VG_(get_memory_from_mmap) ( SizeT nBytes, Char* who ); extern Bool VG_(is_client_addr) (Addr a); extern Addr VG_(get_client_base)(void); diff --git a/massif/ms_main.c b/massif/ms_main.c index ca3a28d0cc..fdb39d04f8 100644 --- a/massif/ms_main.c +++ b/massif/ms_main.c @@ -244,7 +244,7 @@ static Char buf [BUF_LEN]; static Char buf2[BUF_LEN]; static Char buf3[BUF_LEN]; -static UInt sigstacks_space = 0; // Current signal stacks space sum +static SizeT sigstacks_space = 0; // Current signal stacks space sum static VgHashTable malloc_list = NULL; // HP_Chunks @@ -1113,12 +1113,12 @@ static void hp_census(void) /*--- Tracked events ---*/ /*------------------------------------------------------------*/ -static void new_mem_stack_signal(Addr a, UInt len) +static void new_mem_stack_signal(Addr a, SizeT len) { sigstacks_space += len; } -static void die_mem_stack_signal(Addr a, UInt len) +static void die_mem_stack_signal(Addr a, SizeT len) { sk_assert(sigstacks_space >= len); sigstacks_space -= len;