libctf: add SHA-1 support for libctf

This very thin abstraction layer provides SHA-1ing facilities to all of
libctf, almost all inlined wrappers around the libiberty functionality
other than ctf_sha1_fini.

The deduplicator will use this to recursively hash types to prove their
identity.

libctf/
	* ctf-sha1.h: New, inline wrappers around sha1_init_ctx and
	sha1_process_bytes.
	* ctf-impl.h: Include it.
	(ctf_sha1_init): New.
	(ctf_sha1_add): Likewise.
	(ctf_sha1_fini): Likewise.
	* ctf-sha1.c: New, non-inline wrapper around sha1_finish_ctx
	producing strings.
	* Makefile.am: Add file.
	* Makefile.in: Regenerate.
This commit is contained in:
Nick Alcock 2020-06-05 21:10:37 +01:00
parent 6dd2819ffc
commit 1f2e8b5b87
6 changed files with 139 additions and 12 deletions

View file

@ -25,6 +25,7 @@
#include <sys/param.h>
#include "ctf-decls.h"
#include <ctf-api.h>
#include "ctf-sha1.h"
#include <sys/types.h>
#include <stdlib.h>
#include <stdarg.h>
@ -499,6 +500,10 @@ extern int ctf_dynset_exists (ctf_dynset_t *, const void *key,
extern int ctf_dynset_next (ctf_dynset_t *, ctf_next_t **, void **key);
extern void *ctf_dynset_lookup_any (ctf_dynset_t *);
extern void ctf_sha1_init (ctf_sha1_t *);
extern void ctf_sha1_add (ctf_sha1_t *, const void *, size_t);
extern char *ctf_sha1_fini (ctf_sha1_t *, char *);
#define ctf_list_prev(elem) ((void *)(((ctf_list_t *)(elem))->l_prev))
#define ctf_list_next(elem) ((void *)(((ctf_list_t *)(elem))->l_next))