Provide stubs for htobe{32,64}() and be32toh() macros if they aren't defined on Linux.
Tested and verified by Jimmy on xbps@googlegroups.com.
This commit is contained in:
parent
ca7a0ef4b8
commit
af3a2788aa
29
lib/sha256.c
29
lib/sha256.c
@ -36,6 +36,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <sys/param.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
@ -51,6 +52,34 @@
|
|||||||
#include <xbps_api.h>
|
#include <xbps_api.h>
|
||||||
#include "sha256.h"
|
#include "sha256.h"
|
||||||
|
|
||||||
|
/* Workaround byte swap cludge on Linux systems */
|
||||||
|
#ifdef _BSD
|
||||||
|
#include <sys/endian.h>
|
||||||
|
#elif defined(__linux__)
|
||||||
|
#include <byteswap.h>
|
||||||
|
# if __BYTE_ORDER == __LITTLE_ENDIAN
|
||||||
|
# ifndef htobe32
|
||||||
|
# define htobe32(x) bswap_32 (x)
|
||||||
|
# endif
|
||||||
|
# ifndef be32toh
|
||||||
|
# define be32toh(x) bswap_32 (x)
|
||||||
|
# endif
|
||||||
|
# ifndef htobe64
|
||||||
|
# define htobe64(x) bswap_64 (x)
|
||||||
|
# endif
|
||||||
|
# else
|
||||||
|
# ifndef htobe32
|
||||||
|
# define htobe32(x) (x)
|
||||||
|
# endif
|
||||||
|
# ifndef be32toh
|
||||||
|
# define be32toh(x) (x)
|
||||||
|
# endif
|
||||||
|
# ifndef htobe64
|
||||||
|
# define htobe64(x) (x)
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
/*** SHA-256 Various Length Definitions ***********************/
|
/*** SHA-256 Various Length Definitions ***********************/
|
||||||
/* NOTE: Most of these are in sha2.h */
|
/* NOTE: Most of these are in sha2.h */
|
||||||
#define SHA256_SHORT_BLOCK_LENGTH (SHA256_BLOCK_LENGTH - 8)
|
#define SHA256_SHORT_BLOCK_LENGTH (SHA256_BLOCK_LENGTH - 8)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user