diff options
author | Mattias Andrée <maandree@kth.se> | 2022-01-16 19:58:57 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2022-01-16 19:58:57 +0100 |
commit | 8bdc2e4929068210d523c34c0b171b51ce96057f (patch) | |
tree | c77331e77b9777a37716bffb7365c4486a6df9a0 /common.h | |
download | libar2-f5e5a32bcd42f4ae9d351d8078df5e5ab971a5bc.tar.gz libar2-f5e5a32bcd42f4ae9d351d8078df5e5ab971a5bc.tar.bz2 libar2-f5e5a32bcd42f4ae9d351d8078df5e5ab971a5bc.tar.xz |
First commit1.0
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'common.h')
-rw-r--r-- | common.h | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/common.h b/common.h new file mode 100644 index 0000000..dd6f6c1 --- /dev/null +++ b/common.h @@ -0,0 +1,64 @@ +/* See LICENSE file for copyright and license details. */ +#include "libar2.h" + +#include <ctype.h> +#include <errno.h> +#include <limits.h> +#include <stdio.h> +#include <string.h> +#include <strings.h> + +#include <libblake.h> + + +#ifndef UINT_LEAST32_C +# ifdef UINT32_C +# define UINT_LEAST32_C(V) UINT32_C(V) +# else +# define UINT_LEAST32_C(V) V##UL +# endif +#endif + +#ifndef UINT_LEAST64_C +# ifdef UINT64_C +# define UINT_LEAST64_C(V) UINT64_C(V) +# else +# define UINT_LEAST64_C(V) V##ULL +# endif +#endif + + +#ifndef CACHE_LINE_SIZE +# define CACHE_LINE_SIZE 256 /* better with larger than actual than smaller than actual */ +#endif + + +#ifndef ALIGNOF +# ifdef __STDC_VERSION__ +# if __STDC_VERSION__ >= 201112L +# define ALIGNOF(X) _Alignof(X) +# endif +# endif +#endif +#ifndef ALIGNOF +# ifdef __GNUC__ +# define ALIGNOF(X) __alignof__(X) +# else +# define ALIGNOF(X) sizeof(X) +# endif +#endif + +#define ELEMSOF(ARR) (sizeof(ARR) / sizeof(*(ARR))) + +#define MAX(A, B) ((A) > (B) ? (A) : (B)) +#define MIN(A, B) ((A) < (B) ? (A) : (B)) + + +#define ERASE(PTR, N) libar2_earse(PTR, N) +#define ERASE_ARRAY(ARR) ERASE(ARR, sizeof(ARR)) +#define ERASE_STRUCT(S) ERASE(&(S), sizeof(S)) + + +struct block { + uint_least64_t w[1024 / (64 / 8)]; +}; |