Skip to content

Commit

Permalink
Use ntohll and htonll from libplatform
Browse files Browse the repository at this point in the history
Change-Id: I182e88f26ab833b2568c478b3f37204208ecc6b9
Reviewed-on: http://review.couchbase.org/30954
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
Tested-by: Trond Norbye <trond.norbye@gmail.com>
  • Loading branch information
trondn committed Dec 21, 2013
1 parent 86920c6 commit b769df8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 37 deletions.
2 changes: 1 addition & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ endif
moxi_CPPFLAGS = -DCONFLATE_DB_PATH=\"$(CONFLATE_DB_PATH)\" $(AM_CPPFLAGS)
moxi_LDADD =
moxi_LDFLAGS = $(LTLIBEVENT) $(LTLIBCONFLATE) $(LTLIBHASHKIT) \
$(LTLIBVBUCKET) $(LTLIBMCD)
$(LTLIBVBUCKET) $(LTLIBMCD) -lplatform
moxi_DEPENDENCIES =

CLEANFILES=
Expand Down
34 changes: 0 additions & 34 deletions util.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,37 +181,3 @@ void vperror(const char *fmt, ...) {

perror(buf);
}

/* The following are from libmemcached/byteorder.c */

/* Byte swap a 64-bit number. */
#ifndef swap64
static uint64_t swap64(uint64_t in)
{
# ifndef BYTEORDER_BIG_ENDIAN
/* Little endian, flip the bytes around until someone makes a faster/better
* way to do this. */
uint64_t rv= 0;
uint8_t x= 0;
for(x= 0; x < 8; x++)
{
rv= (rv << 8) | (in & 0xff);
in >>= 8;
}
return rv;
# else
/* big-endian machines don't need byte swapping */
return in;
# endif
}
#endif

uint64_t ntohll(uint64_t value)
{
return swap64(value);
}

uint64_t htonll(uint64_t value)
{
return swap64(value);
}
8 changes: 6 additions & 2 deletions util.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
#include <platform/platform.h>

#ifndef MOXI_UTIL_H
#define MOXI_UTIL_H

/*
* Wrappers around strtoull/strtoll that are safer and easier to
* use. For tests and assumptions, see internal_tests.c.
Expand Down Expand Up @@ -66,5 +71,4 @@ void vperror(const char *fmt, ...)

#undef __gcc_attribute__

uint64_t ntohll(uint64_t value);
uint64_t htonll(uint64_t value);
#endif

0 comments on commit b769df8

Please sign in to comment.