diff options
| author | Paul Eggert | 2019-07-13 10:41:46 -0700 |
|---|---|---|
| committer | Paul Eggert | 2019-07-13 16:53:21 -0700 |
| commit | 1178f98f2c0973dd1f8a66cbb4de20c0d7af3271 (patch) | |
| tree | 0d85660fe6133895571ac48b6f1403cd8cdd58d9 /src | |
| parent | a8ffbb20da67b20a85ddca38e20c609144c3bef3 (diff) | |
| download | emacs-1178f98f2c0973dd1f8a66cbb4de20c0d7af3271.tar.gz emacs-1178f98f2c0973dd1f8a66cbb4de20c0d7af3271.zip | |
Avoid interleaving stderr in dump_fingerprint
* src/fns.c (hexbuf_digest): New function, containing most of
the old make_digest_string.
(make_digest_string): Use it.
* src/pdumper.c (dump_fingerprint): Rewrite to use a single
fprintf call, to avoid interleaving on GNU/Linux.
Diffstat (limited to 'src')
| -rw-r--r-- | src/fns.c | 19 | ||||
| -rw-r--r-- | src/lisp.h | 1 | ||||
| -rw-r--r-- | src/pdumper.c | 13 |
3 files changed, 22 insertions, 11 deletions
| @@ -5040,18 +5040,27 @@ returns nil, then (funcall TEST x1 x2) also returns nil. */) | |||
| 5040 | #include "sha256.h" | 5040 | #include "sha256.h" |
| 5041 | #include "sha512.h" | 5041 | #include "sha512.h" |
| 5042 | 5042 | ||
| 5043 | static Lisp_Object | 5043 | /* Store into HEXBUF an unterminated hexadecimal character string |
| 5044 | make_digest_string (Lisp_Object digest, int digest_size) | 5044 | representing DIGEST, which is binary data of size DIGEST_SIZE bytes. |
| 5045 | HEXBUF might equal DIGEST. */ | ||
| 5046 | void | ||
| 5047 | hexbuf_digest (char *hexbuf, void const *digest, int digest_size) | ||
| 5045 | { | 5048 | { |
| 5046 | unsigned char *p = SDATA (digest); | 5049 | unsigned char const *p = digest; |
| 5047 | 5050 | ||
| 5048 | for (int i = digest_size - 1; i >= 0; i--) | 5051 | for (int i = digest_size - 1; i >= 0; i--) |
| 5049 | { | 5052 | { |
| 5050 | static char const hexdigit[16] = "0123456789abcdef"; | 5053 | static char const hexdigit[16] = "0123456789abcdef"; |
| 5051 | int p_i = p[i]; | 5054 | int p_i = p[i]; |
| 5052 | p[2 * i] = hexdigit[p_i >> 4]; | 5055 | hexbuf[2 * i] = hexdigit[p_i >> 4]; |
| 5053 | p[2 * i + 1] = hexdigit[p_i & 0xf]; | 5056 | hexbuf[2 * i + 1] = hexdigit[p_i & 0xf]; |
| 5054 | } | 5057 | } |
| 5058 | } | ||
| 5059 | |||
| 5060 | static Lisp_Object | ||
| 5061 | make_digest_string (Lisp_Object digest, int digest_size) | ||
| 5062 | { | ||
| 5063 | hexbuf_digest (SSDATA (digest), SDATA (digest), digest_size); | ||
| 5055 | return digest; | 5064 | return digest; |
| 5056 | } | 5065 | } |
| 5057 | 5066 | ||
diff --git a/src/lisp.h b/src/lisp.h index e93a219625e..4885e26e3f3 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -3586,6 +3586,7 @@ extern ptrdiff_t list_length (Lisp_Object); | |||
| 3586 | extern EMACS_INT next_almost_prime (EMACS_INT) ATTRIBUTE_CONST; | 3586 | extern EMACS_INT next_almost_prime (EMACS_INT) ATTRIBUTE_CONST; |
| 3587 | extern Lisp_Object larger_vector (Lisp_Object, ptrdiff_t, ptrdiff_t); | 3587 | extern Lisp_Object larger_vector (Lisp_Object, ptrdiff_t, ptrdiff_t); |
| 3588 | extern bool sweep_weak_table (struct Lisp_Hash_Table *, bool); | 3588 | extern bool sweep_weak_table (struct Lisp_Hash_Table *, bool); |
| 3589 | extern void hexbuf_digest (char *, void const *, int); | ||
| 3589 | extern char *extract_data_from_object (Lisp_Object, ptrdiff_t *, ptrdiff_t *); | 3590 | extern char *extract_data_from_object (Lisp_Object, ptrdiff_t *, ptrdiff_t *); |
| 3590 | EMACS_UINT hash_string (char const *, ptrdiff_t); | 3591 | EMACS_UINT hash_string (char const *, ptrdiff_t); |
| 3591 | EMACS_UINT sxhash (Lisp_Object, int); | 3592 | EMACS_UINT sxhash (Lisp_Object, int); |
diff --git a/src/pdumper.c b/src/pdumper.c index b80757c2071..03c00bf27b7 100644 --- a/src/pdumper.c +++ b/src/pdumper.c | |||
| @@ -324,12 +324,13 @@ dump_reloc_set_offset (struct dump_reloc *reloc, dump_off offset) | |||
| 324 | } | 324 | } |
| 325 | 325 | ||
| 326 | static void | 326 | static void |
| 327 | dump_fingerprint (const char *label, unsigned char const *xfingerprint) | 327 | dump_fingerprint (char const *label, |
| 328 | unsigned char const xfingerprint[sizeof fingerprint]) | ||
| 328 | { | 329 | { |
| 329 | fprintf (stderr, "%s: ", label); | 330 | enum { hexbuf_size = 2 * sizeof fingerprint }; |
| 330 | for (int i = 0; i < 32; ++i) | 331 | char hexbuf[hexbuf_size]; |
| 331 | fprintf (stderr, "%02x", (unsigned) xfingerprint[i]); | 332 | hexbuf_digest (hexbuf, xfingerprint, sizeof fingerprint); |
| 332 | putc ('\n', stderr); | 333 | fprintf (stderr, "%s: %.*s\n", label, hexbuf_size, hexbuf); |
| 333 | } | 334 | } |
| 334 | 335 | ||
| 335 | /* Format of an Emacs portable dump file. All offsets are relative to | 336 | /* Format of an Emacs portable dump file. All offsets are relative to |
| @@ -355,7 +356,7 @@ struct dump_header | |||
| 355 | char magic[sizeof (dump_magic)]; | 356 | char magic[sizeof (dump_magic)]; |
| 356 | 357 | ||
| 357 | /* Associated Emacs binary. */ | 358 | /* Associated Emacs binary. */ |
| 358 | unsigned char fingerprint[32]; | 359 | unsigned char fingerprint[sizeof fingerprint]; |
| 359 | 360 | ||
| 360 | /* Relocation table for the dump file; each entry is a | 361 | /* Relocation table for the dump file; each entry is a |
| 361 | struct dump_reloc. */ | 362 | struct dump_reloc. */ |