This repository has been archived by the owner on Oct 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
common.h
121 lines (107 loc) · 4.13 KB
/
common.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/* See LICENSE file for copyright and license details. */
#include "libblake.h"
#include <ctype.h>
#include <inttypes.h>
#include <string.h>
#if !defined(UINT_LEAST64_C) && defined(UINT64_C)
# define UINT_LEAST64_C(X) UINT64_C(X)
#elif !defined(UINT_LEAST64_C)
# define UINT_LEAST64_C(X) X##ULL
#endif
#if !defined(UINT_LEAST32_C) && defined(UINT32_C)
# define UINT_LEAST32_C(X) UINT32_C(X)
#elif !defined(UINT_LEAST32_C)
# define UINT_LEAST32_C(X) X##UL
#endif
#if !defined(UINT_LEAST16_C) && defined(UINT16_C)
# define UINT_LEAST16_C(X) UINT16_C(X)
#elif !defined(UINT_LEAST16_C)
# define UINT_LEAST16_C(X) X##U
#endif
#if defined(__GNUC__)
# define HIDDEN __attribute__((visibility("hidden")))
# define LIKELY(X) __builtin_expect(!!(X), 1)
# define UNLIKELY(X) __builtin_expect(!!(X), 0)
# define ASSUMING_CONSTANT(X) (__builtin_constant_p(X) && (X))
#else
# define HIDDEN
# define LIKELY(X) X
# define UNLIKELY(X) X
# define ASSUMING_CONSTANT(X) 0
# if defined(__has_builtin)
# if __has_builtin(__builtin_expect)
# undef LIKELY
# undef UNLIKELY
# define LIKELY(X) __builtin_expect(!!(X), 1)
# define UNLIKELY(X) __builtin_expect(!!(X), 0)
# endif
# if __has_builtin(__builtin_constant_p)
# undef ASSUMING_CONSTANT
# define ASSUMING_CONSTANT(X) (__builtin_constant_p(X) && (X))
# endif
# endif
#endif
#if defined(__has_builtin)
# define HAS_BUILTIN(X) __has_builtin(X)
#else
# define HAS_BUILTIN(X) 0
#endif
#ifndef LIBBLAKE_ENDIAN_KNOWN__
# if defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__)
# if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
# define LITTLE_ENDIAN
# define LIBBLAKE_ENDIAN_KNOWN__
# endif
# endif
#endif
#ifndef LIBBLAKE_ENDIAN_KNOWN__
# if defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__)
# if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
# define BIG_ENDIAN
# define LIBBLAKE_ENDIAN_KNOWN__
# endif
# endif
#endif
#ifndef LIBBLAKE_ENDIAN_KNOWN__
# if defined(__BYTE_ORDER__) && defined(__ORDER_PDP_ENDIAN__)
# if __BYTE_ORDER__ == __ORDER_PDP_ENDIAN__
# define PDP_ENDIAN
# define LIBBLAKE_ENDIAN_KNOWN__
# endif
# endif
#endif
#ifndef LIBBLAKE_ENDIAN_KNOWN__
# if defined(__x86_64__) || defined(__i386__)
# define LITTLE_ENDIAN
# define LIBBLAKE_ENDIAN_KNOWN__
# endif
#endif
#ifndef LIBBLAKE_ENDIAN_KNOWN__
# error Endian is unknown
#endif
#define CODE_KILLER(X) (X)
#define A 10
#define B 11
#define C 12
#define D 13
#define E 14
#define F 15
HIDDEN size_t libblake_internal_blakes_update(struct libblake_blakes_state *state, const unsigned char *data, size_t len);
HIDDEN size_t libblake_internal_blakeb_update(struct libblake_blakeb_state *state, const unsigned char *data, size_t len);
HIDDEN void libblake_internal_blakes_digest(struct libblake_blakes_state *state, unsigned char *data, size_t len,
size_t bits, const char *suffix, unsigned char *output, size_t words_out);
HIDDEN void libblake_internal_blakeb_digest(struct libblake_blakeb_state *state, unsigned char *data, size_t len,
size_t bits, const char *suffix, unsigned char *output, size_t words_out);
HIDDEN void libblake_internal_blake2s_compress(struct libblake_blake2s_state *state, const unsigned char *data);
HIDDEN void libblake_internal_blake2b_compress(struct libblake_blake2b_state *state, const unsigned char *data);
/* HIDDEN void libblake_internal_blake2b_compress_mm128_init(void); */
/* HIDDEN void libblake_internal_blake2b_compress_mm256_init(void); */
HIDDEN void libblake_internal_blake2xs_init0(struct libblake_blake2xs_state *state, const struct libblake_blake2xs_params *params);
HIDDEN void libblake_internal_blake2xb_init0(struct libblake_blake2xb_state *state, const struct libblake_blake2xb_params *params);
HIDDEN void libblake_internal_blake2s_output_digest(struct libblake_blake2s_state *state, size_t output_len, unsigned char *output);
HIDDEN void libblake_internal_blake2b_output_digest(struct libblake_blake2b_state *state, size_t output_len, unsigned char *output);
#if defined(__clang__)
# pragma clang diagnostic ignored "-Wunreachable-code"
# pragma clang diagnostic ignored "-Wvla"
# pragma clang diagnostic ignored "-Wimplicit-fallthrough"
#endif