Make Skein_{Get,Put}64_LSB_First inline functions

Turn the generic versions into inline functions and avoid
SKEIN_PORT_CODE trickery.

Also drop the PLATFORM_MUST_ALIGN check for using the fast bcopy
variants. bcopy doesn't assume alignment, and the userspace version is
currently different because the _ALIGNMENT_REQUIRED macro is only
defined by the kernelspace headers.

Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
Closes #10470
This commit is contained in:
Arvind Sankar 2020-06-16 18:56:47 -04:00 committed by Brian Behlendorf
parent 0ce2de637b
commit eebba5d8f4
2 changed files with 2 additions and 15 deletions

View File

@ -5,8 +5,6 @@
*/
/* Copyright 2013 Doug Whiting. This code is released to the public domain. */
#define SKEIN_PORT_CODE /* instantiate any code in skein_port.h */
#include <sys/sysmacros.h>
#include <sys/types.h>
#include <sys/skein.h> /* get the Skein API definitions */

View File

@ -44,19 +44,16 @@
#include <sys/isa_defs.h> /* get endianness selection */
#define PLATFORM_MUST_ALIGN _ALIGNMENT_REQUIRED
#if defined(_BIG_ENDIAN)
/* here for big-endian CPUs */
#define SKEIN_NEED_SWAP (1)
#else
/* here for x86 and x86-64 CPUs (and other detected little-endian CPUs) */
#define SKEIN_NEED_SWAP (0)
#if PLATFORM_MUST_ALIGN == 0 /* ok to use "fast" versions? */
#define Skein_Put64_LSB_First(dst08, src64, bCnt) bcopy(src64, dst08, bCnt)
#define Skein_Get64_LSB_First(dst64, src08, wCnt) \
bcopy(src08, dst64, 8 * (wCnt))
#endif
#endif
#endif /* ifndef SKEIN_NEED_SWAP */
@ -80,9 +77,8 @@
#endif /* ifndef Skein_Swap64 */
#ifndef Skein_Put64_LSB_First
void
static inline void
Skein_Put64_LSB_First(uint8_t *dst, const uint64_t *src, size_t bCnt)
#ifdef SKEIN_PORT_CODE /* instantiate the function code here? */
{
/*
* this version is fully portable (big-endian or little-endian),
@ -93,15 +89,11 @@ Skein_Put64_LSB_First(uint8_t *dst, const uint64_t *src, size_t bCnt)
for (n = 0; n < bCnt; n++)
dst[n] = (uint8_t)(src[n >> 3] >> (8 * (n & 7)));
}
#else
; /* output only the function prototype */
#endif
#endif /* ifndef Skein_Put64_LSB_First */
#ifndef Skein_Get64_LSB_First
void
static inline void
Skein_Get64_LSB_First(uint64_t *dst, const uint8_t *src, size_t wCnt)
#ifdef SKEIN_PORT_CODE /* instantiate the function code here? */
{
/*
* this version is fully portable (big-endian or little-endian),
@ -119,9 +111,6 @@ Skein_Get64_LSB_First(uint64_t *dst, const uint8_t *src, size_t wCnt)
(((uint64_t)src[n + 6]) << 48) +
(((uint64_t)src[n + 7]) << 56);
}
#else
; /* output only the function prototype */
#endif
#endif /* ifndef Skein_Get64_LSB_First */
#endif /* _SKEIN_PORT_H_ */