From 70bc45e38d896c4d90d0b93bb309c701effb9ecd Mon Sep 17 00:00:00 2001 From: Trond Norbye Date: Fri, 18 Sep 2009 08:41:25 +0200 Subject: [PATCH] Fix compilation on Linux (lacks ntohll etc) --- example/Makefile.am | 5 +++++ example/common.h | 18 ------------------ example/interface_v0.c | 2 +- example/interface_v1.c | 2 +- example/memcached_light.c | 2 +- libmemcached/Makefile.am | 2 +- libmemcached/byteorder.h | 12 ++++++++++++ libmemcached/protocol/Makefile.am | 7 ++++++- libmemcached/protocol/common.h | 15 +-------------- 9 files changed, 28 insertions(+), 37 deletions(-) delete mode 100644 example/common.h diff --git a/example/Makefile.am b/example/Makefile.am index 7c93764e..0000896b 100644 --- a/example/Makefile.am +++ b/example/Makefile.am @@ -5,4 +5,9 @@ memcached_light_SOURCES= memcached_light.c \ interface_v0.c \ interface_v1.c memcached_light_LDADD= $(top_builddir)/libmemcached/protocol/libmemcachedprotocol.la +memcached_light_DEPENDENCIES= $(top_builddir)/libmemcached/protocol/libmemcachedprotocol.la +if BUILD_BYTEORDER +memcached_light_LDADD+=$(top_builddir)/libmemcached/libbyteorder.la +memcached_light_DEPENDENCIES+= $(top_builddir)/libmemcached/libbyteorder.la +endif diff --git a/example/common.h b/example/common.h deleted file mode 100644 index 6f87a025..00000000 --- a/example/common.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef EXAMPLE_COMMON_H -#define EXAMPLE_COMMON_H - -#include - -#ifdef linux -/* /usr/include/netinet/in.h defines macros from ntohs() to _bswap_nn to - * optimize the conversion functions, but the prototypes generate warnings - * from gcc. The conversion methods isn't the bottleneck for my app, so - * just remove the warnings by undef'ing the optimization .. - */ -#undef ntohs -#undef ntohl -#undef htons -#undef htonl -#endif - -#endif diff --git a/example/interface_v0.c b/example/interface_v0.c index 5971366d..8f78f34f 100644 --- a/example/interface_v0.c +++ b/example/interface_v0.c @@ -17,7 +17,7 @@ #include #include -#include "common.h" +#include #include "storage.h" static protocol_binary_response_status noop_command_handler(const void *cookie, diff --git a/example/interface_v1.c b/example/interface_v1.c index 04e62aa3..b77a0b61 100644 --- a/example/interface_v1.c +++ b/example/interface_v1.c @@ -21,7 +21,7 @@ #include #include -#include "common.h" +#include #include "storage.h" static protocol_binary_response_status add_handler(const void *cookie, diff --git a/example/memcached_light.c b/example/memcached_light.c index b373a12f..ff3e4044 100644 --- a/example/memcached_light.c +++ b/example/memcached_light.c @@ -31,7 +31,7 @@ #include #include -#include "common.h" +#include #include "storage.h" extern struct memcached_binary_protocol_callback_st interface_v0_impl; diff --git a/libmemcached/Makefile.am b/libmemcached/Makefile.am index 2ae51ec5..87d1a576 100644 --- a/libmemcached/Makefile.am +++ b/libmemcached/Makefile.am @@ -1,7 +1,7 @@ EXTRA_DIST = libmemcached_probes.d memcached/README.txt libmemcached.ver \ memcached_configure.h.in -SUBDIRS = protocol +SUBDIRS = . protocol EXTRA_HEADERS = BUILT_SOURCES= diff --git a/libmemcached/byteorder.h b/libmemcached/byteorder.h index 0964b61a..254641f8 100644 --- a/libmemcached/byteorder.h +++ b/libmemcached/byteorder.h @@ -17,4 +17,16 @@ LIBMEMCACHED_LOCAL extern uint64_t htonll(uint64_t); #endif +#ifdef linux +/* /usr/include/netinet/in.h defines macros from ntohs() to _bswap_nn to + * optimize the conversion functions, but the prototypes generate warnings + * from gcc. The conversion methods isn't the bottleneck for my app, so + * just remove the warnings by undef'ing the optimization .. + */ +#undef ntohs +#undef ntohl +#undef htons +#undef htonl +#endif + #endif /* LIBMEMCACHED_BYTEORDER_H */ diff --git a/libmemcached/protocol/Makefile.am b/libmemcached/protocol/Makefile.am index fb4b0a76..8847016e 100644 --- a/libmemcached/protocol/Makefile.am +++ b/libmemcached/protocol/Makefile.am @@ -2,7 +2,12 @@ EXTRA_DIST= libmemcachedprotocol.ver lib_LTLIBRARIES=libmemcachedprotocol.la -noinst_HEADERS = common.h +noinst_HEADERS = common.h libmemcachedprotocol_la_SOURCES= protocol_handler.c cache.c pedantic.c libmemcachedprotocol_la_LDFLAGS= -version-info $(MEMCACHEDPROTOCOL_LIBRARY_VERSION) $(LD_PROTOCOL_VERSION_SCRIPT) + +if BUILD_BYTEORDER +libmemcachedprotocol_la_LIBADD=$(top_builddir)/libmemcached/libbyteorder.la +libmemcachedprotocol_la_DEPENDENCIES= $(top_builddir)/libmemcached/libbyteorder.la +endif diff --git a/libmemcached/protocol/common.h b/libmemcached/protocol/common.h index 036a13f6..f6062422 100644 --- a/libmemcached/protocol/common.h +++ b/libmemcached/protocol/common.h @@ -7,25 +7,12 @@ #include #include -#ifdef linux -/* /usr/include/netinet/in.h defines macros from ntohs() to _bswap_nn to - * optimize the conversion functions, but the prototypes generate warnings - * from gcc. The conversion methods isn't the bottleneck for my app, so - * just remove the warnings by undef'ing the optimization .. - */ -#undef ntohs -#undef ntohl -#undef htons -#undef htonl - -#endif - - /* Define this here, which will turn on the visibilty controls while we're * building libmemcached. */ #define BUILDING_LIBMEMCACHED 1 +#include #include #include -- 2.30.2