summaryrefslogtreecommitdiff
path: root/src/libstddjb
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstddjb')
-rw-r--r--src/libstddjb/ntp_from_tain.c6
-rw-r--r--src/libstddjb/uint16_bswap.c3
-rw-r--r--src/libstddjb/uint32_bswap.c7
-rw-r--r--src/libstddjb/uint64_bswap.c10
4 files changed, 6 insertions, 20 deletions
diff --git a/src/libstddjb/ntp_from_tain.c b/src/libstddjb/ntp_from_tain.c
index 85a338a..5fc0a57 100644
--- a/src/libstddjb/ntp_from_tain.c
+++ b/src/libstddjb/ntp_from_tain.c
@@ -12,9 +12,9 @@ int ntp_from_tain (uint64_t *u, tain const *a)
secs += NTP_OFFSET ;
if (secs < TAI_MAGIC + 2147483648UL) goto ifail ;
secs -= TAI_MAGIC ;
- if (secs >= ((uint64)3 << 31)) goto ifail ;
- secs &= (secs < ((uint64)1 << 32)) ? 0xFFFFFFFFUL : 0x7FFFFFFFUL ;
- frac = ((uint64)a->nano << 32) / 1000000000UL ;
+ if (secs >= ((uint64_t)3 << 31)) goto ifail ;
+ secs &= (secs < ((uint64_t)1 << 32)) ? 0xFFFFFFFFUL : 0x7FFFFFFFUL ;
+ frac = ((uint64_t)a->nano << 32) / 1000000000UL ;
*u = (secs << 32) + frac ;
return 1 ;
ifail:
diff --git a/src/libstddjb/uint16_bswap.c b/src/libstddjb/uint16_bswap.c
index 6ab96ed..9cc0df0 100644
--- a/src/libstddjb/uint16_bswap.c
+++ b/src/libstddjb/uint16_bswap.c
@@ -1,9 +1,8 @@
/* ISC license. */
-#include <stdint.h>
#include <skalibs/uint16.h>
uint16_t uint16_bswap (uint16_t a)
{
- return (a & 0x00ffu) << 8 | (a & 0xff00u) >> 8 ;
+ return UINT16_BSWAP(a) ;
}
diff --git a/src/libstddjb/uint32_bswap.c b/src/libstddjb/uint32_bswap.c
index b9dbcab..5348a5a 100644
--- a/src/libstddjb/uint32_bswap.c
+++ b/src/libstddjb/uint32_bswap.c
@@ -1,13 +1,8 @@
/* ISC license. */
-#include <stdint.h>
#include <skalibs/uint32.h>
uint32_t uint32_bswap (uint32_t a)
{
- return
- (a & 0x000000ffu) << 24 |
- (a & 0x0000ff00u) << 8 |
- (a & 0x00ff0000u) >> 8 |
- (a & 0xff000000u) >> 24 ;
+ return UINT32_BSWAP(a) ;
}
diff --git a/src/libstddjb/uint64_bswap.c b/src/libstddjb/uint64_bswap.c
index 3dfaf18..948d905 100644
--- a/src/libstddjb/uint64_bswap.c
+++ b/src/libstddjb/uint64_bswap.c
@@ -4,13 +4,5 @@
uint64_t uint64_bswap (uint64_t a)
{
- return
- (a & 0x00000000000000ffull) << 56 |
- (a & 0x000000000000ff00ull) << 40 |
- (a & 0x0000000000ff0000ull) << 24 |
- (a & 0x00000000ff000000ull) << 8 |
- (a & 0x000000ff00000000ull) >> 8 |
- (a & 0x0000ff0000000000ull) >> 24 |
- (a & 0x00ff000000000000ull) >> 40 |
- (a & 0xff00000000000000ull) >> 56 ;
+ return UINT64_BSWAP(a) ;
}