Commit 2645bc1b authored by Adam Wujek's avatar Adam Wujek

sdb-lib: add move htonll and ntohll from libsdbfs.h to libsdbfs-user.h

Signed-off-by: 's avatarAdam Wujek <dev_public@wujek.eu>
parent 487309ff
......@@ -14,6 +14,8 @@
# define htons(x) (x)
# define ntohl(x) (x)
# define htonl(x) (x)
# define ntohll(x) (x)
# define htonll(x) (x)
#elif CPU_ARCH == RISCV
/* FIXME: fix for riscv */
#warning FIXME: fix sdbfs for riscv
......
......@@ -12,4 +12,21 @@
#define sdb_print(format, ...) fprintf(stderr, format, __VA_ARGS__)
/* This is needed to convert endianness. Hoping it is not defined elsewhere */
static inline uint64_t htonll(uint64_t ll)
{
uint64_t res;
if (htonl(1) == 1)
return ll;
res = htonl(ll >> 32);
res |= (uint64_t)(htonl((uint32_t)ll)) << 32;
return res;
}
static inline uint64_t ntohll(uint64_t ll)
{
return htonll(ll);
}
#endif /* __LIBSDBFS_USER_H__ */
......@@ -72,20 +72,4 @@ int sdbfs_fread(struct sdbfs *fs, int offset, void *buf, int count);
int sdbfs_fwrite(struct sdbfs *fs, int offset, void *buf, int count);
int sdbfs_ferase(struct sdbfs *fs, int offset, int count);
/* This is needed to convert endianness. Hoping it is not defined elsewhere */
static inline uint64_t htonll(uint64_t ll)
{
uint64_t res;
if (htonl(1) == 1)
return ll;
res = htonl(ll >> 32);
res |= (uint64_t)(htonl((uint32_t)ll)) << 32;
return res;
}
static inline uint64_t ntohll(uint64_t ll)
{
return htonll(ll);
}
#endif /* __LIBSDBFS_H__ */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment