Fix compile on Linux

This commit is contained in:
Roy Marples 2014-06-02 17:10:13 +00:00
parent 45a33d2f3e
commit 5da48f00a7
2 changed files with 34 additions and 3 deletions

2
configure vendored
View File

@ -844,7 +844,7 @@ int main(void) {
EOF
# We only want to link to libmd if it exists in /lib
set -- $(ls /lib/libmd.so.* 2>/dev/null)
if $XCC _sha256.c -o _sha256 3>/dev/null; then
if $XCC _sha256.c -o _sha256 2>/dev/null; then
SHA2=yes
SHA2_RENAMED=yes
elif [ -e "$1" ] && $XCC _sha256.c -lmd -o _sha256 2>/dev/null

View File

@ -24,8 +24,7 @@
* SUCH DAMAGE.
*/
#include <sys/endian.h>
#include <sys/types.h>
#include <inttypes.h>
#include <string.h>
@ -43,6 +42,38 @@
#else /* BYTE_ORDER != BIG_ENDIAN */
static inline void
be32enc(uint8_t *buf, uint32_t u)
{
buf[0] = (uint8_t)((u >> 24) & 0xff);
buf[1] = (uint8_t)((u >> 16) & 0xff);
buf[2] = (uint8_t)((u >> 8) & 0xff);
buf[3] = (uint8_t)(u & 0xff);
}
static inline void
be64enc(uint8_t *buf, uint64_t u)
{
be32enc(buf, (uint32_t)(u >> 32));
be32enc(buf + sizeof(uint32_t), (uint32_t)(u & 0xffffffffULL));
}
static inline uint16_t
be16dec(const uint8_t *buf)
{
return (uint16_t)(buf[0] << 8 | buf[1]);
}
static inline uint32_t
be32dec(const uint8_t *buf)
{
return (uint32_t)(be16dec(buf) << 16 | be16dec(buf + 2));
}
/*
* Encode a length len/4 vector of (uint32_t) into a length len vector of
* (unsigned char) in big-endian form. Assumes len is a multiple of 4.