Skip to content

Commit 6c6d8f8

Browse files
Dr. David Alan Gilbertakpm00
authored andcommitted
lib/xxhash: remove unused functions
xxh32_digest() and xxh32_update() were added in 2017 in the original xxhash commit, but have remained unused. Remove them. Link: https://lkml.kernel.org/r/20250716133245.243363-1-linux@treblig.org Signed-off-by: Dr. David Alan Gilbert <linux@treblig.org> Reviewed-by: Christoph Hellwig <hch@lst.de> Cc: Dave Gilbert <linux@treblig.org> Cc: Nick Terrell <terrelln@fb.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent fefbeed commit 6c6d8f8

2 files changed

Lines changed: 0 additions & 133 deletions

File tree

include/linux/xxhash.h

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -177,32 +177,6 @@ struct xxh64_state {
177177
*/
178178
void xxh32_reset(struct xxh32_state *state, uint32_t seed);
179179

180-
/**
181-
* xxh32_update() - hash the data given and update the xxh32 state
182-
*
183-
* @state: The xxh32 state to update.
184-
* @input: The data to hash.
185-
* @length: The length of the data to hash.
186-
*
187-
* After calling xxh32_reset() call xxh32_update() as many times as necessary.
188-
*
189-
* Return: Zero on success, otherwise an error code.
190-
*/
191-
int xxh32_update(struct xxh32_state *state, const void *input, size_t length);
192-
193-
/**
194-
* xxh32_digest() - produce the current xxh32 hash
195-
*
196-
* @state: Produce the current xxh32 hash of this state.
197-
*
198-
* A hash value can be produced at any time. It is still possible to continue
199-
* inserting input into the hash state after a call to xxh32_digest(), and
200-
* generate new hashes later on, by calling xxh32_digest() again.
201-
*
202-
* Return: The xxh32 hash stored in the state.
203-
*/
204-
uint32_t xxh32_digest(const struct xxh32_state *state);
205-
206180
/**
207181
* xxh64_reset() - reset the xxh64 state to start a new hashing operation
208182
*

lib/xxhash.c

Lines changed: 0 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -267,113 +267,6 @@ void xxh64_reset(struct xxh64_state *statePtr, const uint64_t seed)
267267
}
268268
EXPORT_SYMBOL(xxh64_reset);
269269

270-
int xxh32_update(struct xxh32_state *state, const void *input, const size_t len)
271-
{
272-
const uint8_t *p = (const uint8_t *)input;
273-
const uint8_t *const b_end = p + len;
274-
275-
if (input == NULL)
276-
return -EINVAL;
277-
278-
state->total_len_32 += (uint32_t)len;
279-
state->large_len |= (len >= 16) | (state->total_len_32 >= 16);
280-
281-
if (state->memsize + len < 16) { /* fill in tmp buffer */
282-
memcpy((uint8_t *)(state->mem32) + state->memsize, input, len);
283-
state->memsize += (uint32_t)len;
284-
return 0;
285-
}
286-
287-
if (state->memsize) { /* some data left from previous update */
288-
const uint32_t *p32 = state->mem32;
289-
290-
memcpy((uint8_t *)(state->mem32) + state->memsize, input,
291-
16 - state->memsize);
292-
293-
state->v1 = xxh32_round(state->v1, get_unaligned_le32(p32));
294-
p32++;
295-
state->v2 = xxh32_round(state->v2, get_unaligned_le32(p32));
296-
p32++;
297-
state->v3 = xxh32_round(state->v3, get_unaligned_le32(p32));
298-
p32++;
299-
state->v4 = xxh32_round(state->v4, get_unaligned_le32(p32));
300-
p32++;
301-
302-
p += 16-state->memsize;
303-
state->memsize = 0;
304-
}
305-
306-
if (p <= b_end - 16) {
307-
const uint8_t *const limit = b_end - 16;
308-
uint32_t v1 = state->v1;
309-
uint32_t v2 = state->v2;
310-
uint32_t v3 = state->v3;
311-
uint32_t v4 = state->v4;
312-
313-
do {
314-
v1 = xxh32_round(v1, get_unaligned_le32(p));
315-
p += 4;
316-
v2 = xxh32_round(v2, get_unaligned_le32(p));
317-
p += 4;
318-
v3 = xxh32_round(v3, get_unaligned_le32(p));
319-
p += 4;
320-
v4 = xxh32_round(v4, get_unaligned_le32(p));
321-
p += 4;
322-
} while (p <= limit);
323-
324-
state->v1 = v1;
325-
state->v2 = v2;
326-
state->v3 = v3;
327-
state->v4 = v4;
328-
}
329-
330-
if (p < b_end) {
331-
memcpy(state->mem32, p, (size_t)(b_end-p));
332-
state->memsize = (uint32_t)(b_end-p);
333-
}
334-
335-
return 0;
336-
}
337-
EXPORT_SYMBOL(xxh32_update);
338-
339-
uint32_t xxh32_digest(const struct xxh32_state *state)
340-
{
341-
const uint8_t *p = (const uint8_t *)state->mem32;
342-
const uint8_t *const b_end = (const uint8_t *)(state->mem32) +
343-
state->memsize;
344-
uint32_t h32;
345-
346-
if (state->large_len) {
347-
h32 = xxh_rotl32(state->v1, 1) + xxh_rotl32(state->v2, 7) +
348-
xxh_rotl32(state->v3, 12) + xxh_rotl32(state->v4, 18);
349-
} else {
350-
h32 = state->v3 /* == seed */ + PRIME32_5;
351-
}
352-
353-
h32 += state->total_len_32;
354-
355-
while (p + 4 <= b_end) {
356-
h32 += get_unaligned_le32(p) * PRIME32_3;
357-
h32 = xxh_rotl32(h32, 17) * PRIME32_4;
358-
p += 4;
359-
}
360-
361-
while (p < b_end) {
362-
h32 += (*p) * PRIME32_5;
363-
h32 = xxh_rotl32(h32, 11) * PRIME32_1;
364-
p++;
365-
}
366-
367-
h32 ^= h32 >> 15;
368-
h32 *= PRIME32_2;
369-
h32 ^= h32 >> 13;
370-
h32 *= PRIME32_3;
371-
h32 ^= h32 >> 16;
372-
373-
return h32;
374-
}
375-
EXPORT_SYMBOL(xxh32_digest);
376-
377270
int xxh64_update(struct xxh64_state *state, const void *input, const size_t len)
378271
{
379272
const uint8_t *p = (const uint8_t *)input;

0 commit comments

Comments
 (0)