Check for <sys/endian.h> functions in configure
On NetBSD stdlib.h indirectly includes sys/endian.h, causing the (be|le)32(enc|dec) functions to be already defined.
This commit is contained in:
parent
3151311af0
commit
e0867338ab
2 changed files with 29 additions and 10 deletions
13
configure.ac
13
configure.ac
|
@ -16,18 +16,25 @@ AM_PROG_CC_C_O
|
|||
AM_PROG_AS
|
||||
AC_PROG_RANLIB
|
||||
|
||||
dnl Checks for header files.
|
||||
dnl Checks for header files
|
||||
AC_HEADER_STDC
|
||||
AC_CHECK_HEADERS([sys/param.h syslog.h])
|
||||
AC_CHECK_HEADERS([sys/endian.h sys/param.h syslog.h])
|
||||
# sys/sysctl.h requires sys/types.h on FreeBSD
|
||||
# sys/sysctl.h requires sys/param.h on OpenBSD
|
||||
AC_CHECK_HEADERS([sys/sysctl.h], [], [],
|
||||
[#include <sys/types.h>
|
||||
#if HAVE_SYS_PARAM_H
|
||||
#ifdef HAVE_SYS_PARAM_H
|
||||
#include <sys/param.h>
|
||||
#endif
|
||||
])
|
||||
|
||||
AC_CHECK_DECLS([be32dec, le32dec, be32enc, le32enc], [], [],
|
||||
[AC_INCLUDES_DEFAULT
|
||||
#ifdef HAVE_SYS_ENDIAN_H
|
||||
#include <sys/endian.h>
|
||||
#endif
|
||||
])
|
||||
|
||||
AC_FUNC_ALLOCA
|
||||
|
||||
case $target in
|
||||
|
|
26
miner.h
26
miner.h
|
@ -77,13 +77,29 @@ static inline uint32_t swab32(uint32_t v)
|
|||
#endif
|
||||
}
|
||||
|
||||
#ifdef HAVE_SYS_ENDIAN_H
|
||||
#include <sys/endian.h>
|
||||
#endif
|
||||
|
||||
#if !HAVE_DECL_BE32DEC
|
||||
static inline uint32_t be32dec(const void *pp)
|
||||
{
|
||||
const uint8_t *p = (uint8_t const *)pp;
|
||||
return ((uint32_t)(p[3]) + ((uint32_t)(p[2]) << 8) +
|
||||
((uint32_t)(p[1]) << 16) + ((uint32_t)(p[0]) << 24));
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !HAVE_DECL_LE32DEC
|
||||
static inline uint32_t le32dec(const void *pp)
|
||||
{
|
||||
const uint8_t *p = (uint8_t const *)pp;
|
||||
return ((uint32_t)(p[0]) + ((uint32_t)(p[1]) << 8) +
|
||||
((uint32_t)(p[2]) << 16) + ((uint32_t)(p[3]) << 24));
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !HAVE_DECL_BE32ENC
|
||||
static inline void be32enc(void *pp, uint32_t x)
|
||||
{
|
||||
uint8_t *p = (uint8_t *)pp;
|
||||
|
@ -92,14 +108,9 @@ static inline void be32enc(void *pp, uint32_t x)
|
|||
p[1] = (x >> 16) & 0xff;
|
||||
p[0] = (x >> 24) & 0xff;
|
||||
}
|
||||
#endif
|
||||
|
||||
static inline uint32_t le32dec(const void *pp)
|
||||
{
|
||||
const uint8_t *p = (uint8_t const *)pp;
|
||||
return ((uint32_t)(p[0]) + ((uint32_t)(p[1]) << 8) +
|
||||
((uint32_t)(p[2]) << 16) + ((uint32_t)(p[3]) << 24));
|
||||
}
|
||||
|
||||
#if !HAVE_DECL_LE32ENC
|
||||
static inline void le32enc(void *pp, uint32_t x)
|
||||
{
|
||||
uint8_t *p = (uint8_t *)pp;
|
||||
|
@ -108,6 +119,7 @@ static inline void le32enc(void *pp, uint32_t x)
|
|||
p[2] = (x >> 16) & 0xff;
|
||||
p[3] = (x >> 24) & 0xff;
|
||||
}
|
||||
#endif
|
||||
|
||||
void sha256_init(uint32_t *state);
|
||||
void sha256_transform(uint32_t *state, const uint32_t *block, int swap);
|
||||
|
|
Loading…
Reference in a new issue