From: Julian Seward Date: Tue, 5 Apr 2005 20:59:55 +0000 (+0000) Subject: Get rid of the --sloppy-malloc= flag and the functionality it X-Git-Tag: svn/VALGRIND_3_0_0~796 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=394ef03a884516a3d7d7131cd390d258ef901481;p=thirdparty%2Fvalgrind.git Get rid of the --sloppy-malloc= flag and the functionality it controlled (rounding user malloc requests up to a multiple of 4). Subsequent changes to memcheck made it more or less pointless, it is a time waster in the malloc/free path, and nobody ever used it AFAIK. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3522 --- diff --git a/coregrind/core.h b/coregrind/core.h index 7b03d96a2f..0d4da658dc 100644 --- a/coregrind/core.h +++ b/coregrind/core.h @@ -385,9 +385,6 @@ typedef Int ArenaId; // greater than 8. #define VG_MIN_MALLOC_SZB 8 -// Round-up size for --sloppy-malloc=yes. -#define VG_SLOPPY_MALLOC_SZB 4 - extern void* VG_(arena_malloc) ( ArenaId arena, SizeT nbytes ); extern void VG_(arena_free) ( ArenaId arena, void* ptr ); extern void* VG_(arena_calloc) ( ArenaId arena, @@ -500,7 +497,6 @@ struct vg_mallocfunc_info { SizeT (*arena_payload_szB) (ArenaId aid, void* payload); - Bool clo_sloppy_malloc; Bool clo_trace_malloc; }; diff --git a/coregrind/vg_malloc2.c b/coregrind/vg_malloc2.c index ae9463b8ae..1af123de84 100644 --- a/coregrind/vg_malloc2.c +++ b/coregrind/vg_malloc2.c @@ -518,13 +518,9 @@ Superblock* findSb ( Arena* a, Block* b ) /*--- Command line options ---*/ /*------------------------------------------------------------*/ -/* Round malloc sizes up to a multiple of VG_SLOPPY_MALLOC_SZB bytes? - default: NO - Nb: the allocator always rounds blocks up to a multiple of - VG_MIN_MALLOC_SZB. VG_(clo_sloppy_malloc) is relevant eg. for - Memcheck, which will be byte-precise with addressability maps on its - malloc allocations unless --sloppy-malloc=yes. */ -Bool VG_(clo_sloppy_malloc) = False; +/* Nb: the allocator always rounds blocks up to a multiple of + VG_MIN_MALLOC_SZB. +*/ /* DEBUG: print malloc details? default: NO */ Bool VG_(clo_trace_malloc) = False; @@ -550,7 +546,6 @@ Bool VG_(replacement_malloc_process_cmd_line_option)(Char* arg) } } - else VG_BOOL_CLO(arg, "--sloppy-malloc", VG_(clo_sloppy_malloc)) else VG_BOOL_CLO(arg, "--trace-malloc", VG_(clo_trace_malloc)) else return False; @@ -561,9 +556,8 @@ Bool VG_(replacement_malloc_process_cmd_line_option)(Char* arg) void VG_(replacement_malloc_print_usage)(void) { VG_(printf)( -" --sloppy-malloc=no|yes round malloc sizes to multiple of %d? [no]\n" " --alignment= set minimum alignment of allocations [%d]\n", - VG_SLOPPY_MALLOC_SZB, VG_MIN_MALLOC_SZB + VG_MIN_MALLOC_SZB ); } diff --git a/coregrind/vg_replace_malloc.c b/coregrind/vg_replace_malloc.c index 0fd0cf3a43..6d5a69807c 100644 --- a/coregrind/vg_replace_malloc.c +++ b/coregrind/vg_replace_malloc.c @@ -153,12 +153,6 @@ internal_printf(char *format, ...) if (info.clo_trace_malloc) \ internal_printf(format, ## args ) -#define MAYBE_SLOPPIFY(n) \ - if (info.clo_sloppy_malloc) { \ - n = (n+(VG_SLOPPY_MALLOC_SZB-1)) & ~(VG_SLOPPY_MALLOC_SZB-1); \ - } - - /* Below are new versions of malloc, __builtin_new, free, __builtin_delete, calloc, realloc, memalign, and friends. @@ -180,7 +174,6 @@ internal_printf(char *format, ...) void* v; \ \ MALLOC_TRACE(#fnname "(%llu)", (ULong)n ); \ - MAYBE_SLOPPIFY(n); \ if (!init_done) init(); \ \ v = (void*)VALGRIND_NON_SIMD_CALL1( info.tl_##vg_replacement, n ); \ @@ -201,7 +194,6 @@ internal_printf(char *format, ...) void* v; \ \ MALLOC_TRACE(#fnname "(%llu)", (ULong)n ); \ - MAYBE_SLOPPIFY(n); \ if (!init_done) init(); \ \ v = (void*)VALGRIND_NON_SIMD_CALL1( info.tl_##vg_replacement, n ); \ @@ -305,7 +297,6 @@ FREE(m_libc_dot_so_dot_6, _ZdaPvRKSt9nothrow_t, __builtin_vec_delete ); void* v; \ \ MALLOC_TRACE("calloc(%llu,%llu)", (ULong)nmemb, (ULong)size ); \ - MAYBE_SLOPPIFY(size); \ \ if (!init_done) init(); \ v = (void*)VALGRIND_NON_SIMD_CALL2( info.tl_calloc, nmemb, size ); \ @@ -324,7 +315,6 @@ CALLOC(m_libc_dot_so_dot_6, calloc); void* v; \ \ MALLOC_TRACE("realloc(%p,%llu)", ptrV, (ULong)new_size ); \ - MAYBE_SLOPPIFY(new_size); \ \ if (ptrV == NULL) \ /* We need to call a malloc-like function; so let's use \ @@ -354,7 +344,6 @@ REALLOC(m_libc_dot_so_dot_6, realloc); \ MALLOC_TRACE("memalign(al %llu, size %llu)", \ (ULong)alignment, (ULong)n ); \ - MAYBE_SLOPPIFY(n); \ \ /* Round up to minimum alignment if necessary. */ \ if (alignment < VG_MIN_MALLOC_SZB) \ diff --git a/coregrind/vg_scheduler.c b/coregrind/vg_scheduler.c index 0fe240cddc..63ba06aa65 100644 --- a/coregrind/vg_scheduler.c +++ b/coregrind/vg_scheduler.c @@ -1026,8 +1026,6 @@ void do_client_request ( ThreadId tid ) info->tl___builtin_vec_delete = VG_(tdict).malloc___builtin_vec_delete; info->arena_payload_szB = VG_(arena_payload_szB); - - info->clo_sloppy_malloc = VG_(clo_sloppy_malloc); info->clo_trace_malloc = VG_(clo_trace_malloc); SET_CLREQ_RETVAL( tid, 0 ); /* return value is meaningless */ diff --git a/docs/xml/manual-core.xml b/docs/xml/manual-core.xml index 3a0e79cbf1..bc524b20af 100644 --- a/docs/xml/manual-core.xml +++ b/docs/xml/manual-core.xml @@ -907,29 +907,6 @@ Addrcheck), the following options apply. and 4096 inclusive, and must be a power of two. - - --sloppy-malloc=no - [default] - --sloppy-malloc=yes - When enabled, all requests for malloc/calloc are - rounded up to a whole number of machine words -- in other - words, made divisible by 4. For example, a request for 17 - bytes of space would result in a 20-byte area being made - available. This works around bugs in sloppy libraries which - assume that they can safely rely on malloc/calloc requests - being rounded up in this fashion. Without the workaround, - these libraries tend to generate large numbers of errors when - they access the ends of these areas. - - Valgrind snapshots dated 17 Feb 2002 and later are - cleverer about this problem, and you should no longer need to - use this flag. To put it bluntly, if you do need to use this - flag, your program violates the ANSI C semantics defined for - malloc and - free, even if it appears to - work correctly, and you should fix it, at least if you hope - for maximum portability. - diff --git a/include/tool.h.base b/include/tool.h.base index 58fdcf7cad..69d187603e 100644 --- a/include/tool.h.base +++ b/include/tool.h.base @@ -920,8 +920,6 @@ extern Bool VG_(addr_is_in_block)( Addr a, Addr start, SizeT size ); The tool should call the functions in the appropriate places to give control over these aspects of Valgrind's version of malloc(). */ -/* Round malloc sizes upwards to integral number of words? default: NO */ -extern Bool VG_(clo_sloppy_malloc); /* DEBUG: print malloc details? default: NO */ extern Bool VG_(clo_trace_malloc); /* Minimum alignment in functions that don't specify alignment explicitly.