#include <stdio.h>
#include <sys/types.h>
#include <stdint.h>
+#include <endian.h>
#include "system.h"
-#include <byteswap.h>
-#ifdef WORDS_BIGENDIAN
-# define SWAP(n) (n)
-#else
-# define SWAP(n) bswap_32 (n)
-#endif
-
#ifdef CRCTAB
# define BIT(x) ((uint_fast32_t) 1 << (x))
while (bytes_read >= 8)
{
uint32_t first = *datap++, second = *datap++;
- crc ^= SWAP (first);
- second = SWAP (second);
+ crc ^= htobe32 (first);
+ second = htobe32 (second);
crc = (crctab[7][(crc >> 24) & 0xFF]
^ crctab[6][(crc >> 16) & 0xFF]
^ crctab[5][(crc >> 8) & 0xFF]
if (raw)
{
/* Output in network byte order (big endian). */
- uint32_t out_int = SWAP (*(uint32_t *)digest);
+ uint32_t out_int = htobe32 (*(uint32_t *)digest);
fwrite (&out_int, 1, 32/8, stdout);
return;
}
#include <stdio.h>
#include <sys/types.h>
+#include <endian.h>
#include "system.h"
#include "human.h"
#include "sum.h"
-#include <byteswap.h>
-#ifdef WORDS_BIGENDIAN
-# define SWAP(n) (n)
-#else
-# define SWAP(n) bswap_16 (n)
-#endif
-
/* Calculate the checksum and the size in bytes of stream STREAM.
Return -1 on error, 0 on success. */
{
/* Output in network byte order (big endian). */
uint16_t out_int = *(int *)digest;
- out_int = SWAP (out_int);
+ out_int = htobe16 (out_int);
fwrite (&out_int, 1, 16/8, stdout);
return;
}
{
/* Output in network byte order (big endian). */
uint16_t out_int = *(int *)digest;
- out_int = SWAP (out_int);
+ out_int = htobe16 (out_int);
fwrite (&out_int, 1, 16/8, stdout);
return;
}