Skip to content

Commit 9df48b4

Browse files
committed
delete portable::xof_many and blake3_xof_many_portable
1 parent 5c4c351 commit 9df48b4

File tree

6 files changed

+24
-76
lines changed

6 files changed

+24
-76
lines changed

c/blake3_c_rust_bindings/src/lib.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -177,15 +177,6 @@ pub mod ffi {
177177
flags_end: u8,
178178
out: *mut u8,
179179
);
180-
pub fn blake3_xof_many_portable(
181-
cv: *const u32,
182-
block: *const u8,
183-
block_len: u8,
184-
counter: u64,
185-
flags: u8,
186-
out: *mut u8,
187-
outblocks: usize,
188-
);
189180
}
190181

191182
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]

c/blake3_c_rust_bindings/src/test.rs

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,7 @@ fn test_hash_many_neon() {
359359
test_hash_many_fn(crate::ffi::neon::blake3_hash_many_neon);
360360
}
361361

362+
#[cfg(unix)] // silence an unused code warning
362363
type XofManyFunction = unsafe extern "C" fn(
363364
cv: *const u32,
364365
block: *const u8,
@@ -370,6 +371,7 @@ type XofManyFunction = unsafe extern "C" fn(
370371
);
371372

372373
// A shared helper function for platform-specific tests.
374+
#[cfg(unix)] // silence an unused code warning
373375
pub fn test_xof_many_fn(xof_many_function: XofManyFunction) {
374376
let mut block = [0; BLOCK_LEN];
375377
let block_len = 42;
@@ -390,16 +392,17 @@ pub fn test_xof_many_fn(xof_many_function: XofManyFunction) {
390392
const OUTPUT_SIZE: usize = 31 * BLOCK_LEN;
391393

392394
let mut portable_out = [0u8; OUTPUT_SIZE];
393-
unsafe {
394-
crate::ffi::blake3_xof_many_portable(
395-
cv.as_ptr(),
396-
block.as_ptr(),
397-
block_len as u8,
398-
counter,
399-
flags,
400-
portable_out.as_mut_ptr(),
401-
OUTPUT_SIZE / BLOCK_LEN,
402-
);
395+
for (i, out_block) in portable_out.chunks_exact_mut(BLOCK_LEN).enumerate() {
396+
unsafe {
397+
crate::ffi::blake3_compress_xof_portable(
398+
cv.as_ptr(),
399+
block.as_ptr(),
400+
block_len as u8,
401+
counter + i as u64,
402+
flags,
403+
out_block.as_mut_ptr(),
404+
);
405+
}
403406
}
404407

405408
let mut test_out = [0u8; OUTPUT_SIZE];
@@ -445,12 +448,6 @@ pub fn test_xof_many_fn(xof_many_function: XofManyFunction) {
445448
}
446449
}
447450

448-
// Testing the portable implementation against itself is circular, but why not.
449-
#[test]
450-
fn test_xof_many_portable() {
451-
test_xof_many_fn(crate::ffi::blake3_xof_many_portable);
452-
}
453-
454451
#[test]
455452
#[cfg(unix)]
456453
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]

c/blake3_impl.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -222,14 +222,6 @@ void blake3_compress_xof_portable(const uint32_t cv[8],
222222
uint8_t block_len, uint64_t counter,
223223
uint8_t flags, uint8_t out[64]);
224224

225-
// This function is test-only. When blake3_xof_many doesn't have an optimized implementation,
226-
// it loops over blake3_compress_xof instead of falling back to this, so it still benefits
227-
// from compress optimizations.
228-
void blake3_xof_many_portable(const uint32_t cv[8],
229-
const uint8_t block[BLAKE3_BLOCK_LEN],
230-
uint8_t block_len, uint64_t counter, uint8_t flags,
231-
uint8_t out[64], size_t outblocks);
232-
233225
void blake3_hash_many_portable(const uint8_t *const *inputs, size_t num_inputs,
234226
size_t blocks, const uint32_t key[8],
235227
uint64_t counter, bool increment_counter,

c/blake3_portable.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -122,16 +122,6 @@ void blake3_compress_xof_portable(const uint32_t cv[8],
122122
store32(&out[15 * 4], state[15] ^ cv[7]);
123123
}
124124

125-
void blake3_xof_many_portable(const uint32_t cv[8],
126-
const uint8_t block[BLAKE3_BLOCK_LEN],
127-
uint8_t block_len, uint64_t counter, uint8_t flags,
128-
uint8_t out[BLAKE3_BLOCK_LEN], size_t outblocks)
129-
{
130-
for(size_t i = 0; i < outblocks; ++i) {
131-
blake3_compress_xof_portable(cv, block, block_len, counter + i, flags, out + 64*i);
132-
}
133-
}
134-
135125
INLINE void hash_one_portable(const uint8_t *input, size_t blocks,
136126
const uint32_t key[8], uint64_t counter,
137127
uint8_t flags, uint8_t flags_start,

src/portable.rs

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -177,25 +177,6 @@ pub fn hash_many<const N: usize>(
177177
}
178178
}
179179

180-
// This function is test-only. When platform::xof_many() doesn't have an optimized implementation,
181-
// it loops over platform::compress_xof() instead of falling back to this, so it still benefits
182-
// from compress optimizations.
183-
#[cfg(test)]
184-
pub fn xof_many(
185-
cv: &CVWords,
186-
block: &[u8; BLOCK_LEN],
187-
block_len: u8,
188-
mut counter: u64,
189-
flags: u8,
190-
out: &mut [u8],
191-
) {
192-
debug_assert_eq!(0, out.len() % BLOCK_LEN, "whole blocks only");
193-
for out_block in out.chunks_exact_mut(64) {
194-
out_block.copy_from_slice(&compress_xof(cv, block, block_len, counter, flags));
195-
counter += 1;
196-
}
197-
}
198-
199180
#[cfg(test)]
200181
pub mod test {
201182
use super::*;
@@ -214,10 +195,4 @@ pub mod test {
214195
fn test_hash_many() {
215196
crate::test::test_hash_many_fn(hash_many, hash_many);
216197
}
217-
218-
// Ditto.
219-
#[test]
220-
fn test_xof_many() {
221-
crate::test::test_xof_many_fn(xof_many);
222-
}
223198
}

src/test.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ pub fn test_hash_many_fn(
206206
}
207207
}
208208

209+
#[cfg(not(any(windows, feature = "pure")))] // silence an unused code warning
209210
type XofManyFunction = unsafe fn(
210211
cv: &CVWords,
211212
block: &[u8; BLOCK_LEN],
@@ -216,6 +217,7 @@ type XofManyFunction = unsafe fn(
216217
);
217218

218219
// A shared helper function for platform-specific tests.
220+
#[cfg(not(any(windows, feature = "pure")))] // silence an unused code warning
219221
pub fn test_xof_many_fn(xof_many_function: XofManyFunction) {
220222
let mut block = [0; BLOCK_LEN];
221223
let block_len = 42;
@@ -237,14 +239,15 @@ pub fn test_xof_many_fn(xof_many_function: XofManyFunction) {
237239
const OUTPUT_SIZE: usize = 31 * BLOCK_LEN;
238240

239241
let mut portable_out = [0u8; OUTPUT_SIZE];
240-
crate::portable::xof_many(
241-
&cv,
242-
&block,
243-
block_len as u8,
244-
counter,
245-
flags,
246-
&mut portable_out,
247-
);
242+
for (i, out_block) in portable_out.chunks_exact_mut(64).enumerate() {
243+
out_block.copy_from_slice(&crate::portable::compress_xof(
244+
&cv,
245+
&block,
246+
block_len as u8,
247+
counter + i as u64,
248+
flags,
249+
));
250+
}
248251

249252
let mut test_out = [0u8; OUTPUT_SIZE];
250253
unsafe {

0 commit comments

Comments
 (0)