Skip to content

Commit 283b312

Browse files
mdcornutkanteck
authored andcommitted
rolling_hash: deprecate old API
Use new API in perf app Signed-off-by: Marcel Cornu <[email protected]>
1 parent 81c7fee commit 283b312

File tree

2 files changed

+41
-9
lines changed

2 files changed

+41
-9
lines changed

include/rolling_hashx.h

+9
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ extern "C" {
4242
#endif
4343

4444
#include <stdint.h>
45+
#include "types.h"
4546

4647
/*
4748
* Define enums from API v2.24, so applications that were using this version
@@ -85,7 +86,9 @@ struct rh_state2 {
8586
* @param state Structure holding state info on current rolling hash
8687
* @param w Window width (1 <= w <= 32)
8788
* @returns 0 - success, -1 - failure
89+
* @deprecated Please use isal_rolling_hash2_init() instead.
8890
*/
91+
ISAL_DEPRECATED("Please use isal_rolling_hash2_init() instead")
8992
int
9093
rolling_hash2_init(struct rh_state2 *state, uint32_t w);
9194

@@ -95,7 +98,9 @@ rolling_hash2_init(struct rh_state2 *state, uint32_t w);
9598
* @param state Structure holding state info on current rolling hash
9699
* @param init_bytes Optional window size buffer to pre-init hash
97100
* @returns none
101+
* @deprecated Please use isal_rolling_hash2_reset() instead.
98102
*/
103+
ISAL_DEPRECATED("Please use isal_rolling_hash2_reset() instead")
99104
void
100105
rolling_hash2_reset(struct rh_state2 *state, uint8_t *init_bytes);
101106

@@ -110,7 +115,9 @@ rolling_hash2_reset(struct rh_state2 *state, uint8_t *init_bytes);
110115
* @param trigger Match value to compare with windowed hash at each input byte
111116
* @param offset Offset from buffer to match, set if match found
112117
* @returns ISAL_FINGERPRINT_RET_HIT - match found, ISAL_FINGERPRINT_RET_MAX - exceeded max length
118+
* @deprecated Please use isal_rolling_hash2_run() instead.
113119
*/
120+
ISAL_DEPRECATED("Please use isal_rolling_hash2_run() instead")
114121
int
115122
rolling_hash2_run(struct rh_state2 *state, uint8_t *buffer, uint32_t max_len, uint32_t mask,
116123
uint32_t trigger, uint32_t *offset);
@@ -121,7 +128,9 @@ rolling_hash2_run(struct rh_state2 *state, uint8_t *buffer, uint32_t max_len, ui
121128
* @param mean Target chunk size in bytes
122129
* @param shift Bits to rotate result to get independent masks
123130
* @returns 32-bit mask value
131+
* @deprecated Please use isal_rolling_hashx_mask_gen() instead.
124132
*/
133+
ISAL_DEPRECATED("Please use isal_rolling_hashx_mask_gen() instead")
125134
uint32_t
126135
rolling_hashx_mask_gen(long mean, int shift);
127136

rolling_hash/rolling_hash2_perf.c

+32-9
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,13 @@
5151
#endif
5252

5353
#ifndef FUT_run
54-
#define FUT_run rolling_hash2_run
54+
#define FUT_run isal_rolling_hash2_run
5555
#endif
5656
#ifndef FUT_init
57-
#define FUT_init rolling_hash2_init
57+
#define FUT_init isal_rolling_hash2_init
5858
#endif
5959
#ifndef FUT_reset
60-
#define FUT_reset rolling_hash2_reset
60+
#define FUT_reset isal_rolling_hash2_reset
6161
#endif
6262

6363
#define str(s) #s
@@ -72,9 +72,10 @@
7272
int
7373
main(int argc, char *argv[])
7474
{
75+
#ifndef FIPS_MODE
7576
uint8_t *buf;
7677
uint32_t mask, trigger, offset = 0;
77-
int i, w, ret;
78+
int i, w, ret, match;
7879
long long run_length;
7980
struct rh_state2 *state;
8081
struct perf start, stop;
@@ -105,20 +106,42 @@ main(int argc, char *argv[])
105106
printf("Start timed tests\n");
106107
fflush(0);
107108

108-
FUT_init(state, w);
109-
FUT_reset(state, buf);
110-
ret = FUT_run(state, buf, TEST_LEN, mask, trigger, &offset);
109+
ret = FUT_init(state, w);
110+
if (ret) {
111+
printf(xstr(FUT_init) " error (%d)\n", ret);
112+
return -1;
113+
}
114+
ret = FUT_reset(state, buf);
115+
if (ret) {
116+
printf(xstr(FUT_reset) " error (%d)\n", ret);
117+
return -1;
118+
}
119+
ret = FUT_run(state, buf, TEST_LEN, mask, trigger, &offset, &match);
120+
if (ret)
121+
goto run_error;
111122

112123
perf_start(&start);
113124
for (i = 0; i < TEST_LOOPS; i++) {
114-
ret = FUT_run(state, buf, TEST_LEN, mask, trigger, &offset);
125+
ret = FUT_run(state, buf, TEST_LEN, mask, trigger, &offset, &match);
115126
}
116127
perf_stop(&stop);
117128

118-
run_length = (ret == ISAL_FINGERPRINT_RET_HIT) ? offset : TEST_LEN;
129+
if (ret)
130+
goto run_error;
131+
132+
run_length = (match == ISAL_FINGERPRINT_RET_HIT) ? offset : TEST_LEN;
119133
printf(" returned %d after %lld B\n", ret, run_length);
120134
printf(xstr(FUT_run) TEST_TYPE_STR ": ");
121135
perf_print(stop, start, run_length * i);
122136

123137
return 0;
138+
139+
run_error:
140+
printf(xstr(FUT_run) " error (%d)\n", ret);
141+
return -1;
142+
#else
143+
printf("FIPS Mode enabled. Perf test not run.\n");
144+
145+
return 0;
146+
#endif /* FIPS_MODE */
124147
}

0 commit comments

Comments
 (0)