From: Taylor R Campbell Date: Sat, 4 Nov 2017 03:09:16 +0000 (+0000) Subject: Eliminate optional mhash dependency in fasdump.c. X-Git-Tag: mit-scheme-pucked-9.2.12~14^2~10^2~2 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=3810763a347decf0d924c87d0b4cd5c2ac633aa7;p=mit-scheme.git Eliminate optional mhash dependency in fasdump.c. --- diff --git a/src/microcode/fasdump.c b/src/microcode/fasdump.c index 7d922cb4c..6df8944c5 100644 --- a/src/microcode/fasdump.c +++ b/src/microcode/fasdump.c @@ -44,14 +44,12 @@ USA. static void save_gc_vars (void); # define COMPARE_GC_VARS compare_gc_vars static void compare_gc_vars (void); -# ifdef HAVE_MHASH_H -# include -# define SAVE_MEMORY_CHECKSUM save_memory_checksum - static void save_memory_checksum (void); -# define COMPARE_MEMORY_CHECKSUM compare_memory_checksum - static void compare_memory_checksum (void); - static void * compute_memory_checksum (void); -# endif +# include +# define SAVE_MEMORY_CHECKSUM save_memory_checksum + static void save_memory_checksum (void); +# define COMPARE_MEMORY_CHECKSUM compare_memory_checksum + static void compare_memory_checksum (void); + static void * compute_memory_checksum (void); #else # define SAVE_GC_VARS() do {} while (false) # define COMPARE_GC_VARS() do {} while (false) @@ -267,8 +265,6 @@ compare_gc_vars (void) COMPARE_GC_VAR (constant_end); } -#ifdef HAVE_MHASH_H - static void * fasdump_original_digest; static void @@ -289,10 +285,7 @@ compare_memory_checksum (void) outf_error ("Unable to recompute fasdump memory checksum."); else { - if ((memcmp (digest, - fasdump_original_digest, - (mhash_get_block_size (MHASH_MD5)))) - != 0) + if ((memcmp (digest, fasdump_original_digest, MD5_HASHLEN)) != 0) outf_error ("Memory mismatch after fasdump."); free (digest); } @@ -303,22 +296,25 @@ compare_memory_checksum (void) static void * compute_memory_checksum (void) { - MHASH ctx = (mhash_init (MHASH_MD5)); - if (ctx == MHASH_FAILED) - return (0); - (void) mhash (ctx, - fasdump_saved_constant_start, - ((fasdump_saved_constant_alloc_next - - fasdump_saved_constant_start) - * SIZEOF_SCHEME_OBJECT)); - (void) mhash (ctx, - fasdump_saved_heap_start, - ((fasdump_saved_Free - fasdump_saved_heap_start) - * SIZEOF_SCHEME_OBJECT)); - return (mhash_end (ctx)); + struct md5 ctx; + void * hash; + md5_init (&ctx); + md5_update ((&ctx), + fasdump_saved_constant_start, + ((fasdump_saved_constant_alloc_next + - fasdump_saved_constant_start) + * SIZEOF_SCHEME_OBJECT)); + md5_update ((&ctx), + fasdump_saved_heap_start, + ((fasdump_saved_Free - fasdump_saved_heap_start) + * SIZEOF_SCHEME_OBJECT)); + hash = (malloc (MD5_HASHLEN)); + if (hash == NULL) + return NULL; + md5_final ((&ctx), hash); + return hash; } -#endif /* HAVE_MHASH_H */ #endif /* ENABLE_GC_DEBUGGING_TOOLS */ static gc_table_t *