Skip to content

Commit

Permalink
add osx support.
Browse files Browse the repository at this point in the history
Signed-off-by: Sean Ogden <positivelyskewed.sf@gmail.com>
  • Loading branch information
seanogden committed Feb 12, 2013
1 parent 6827892 commit 62f0b41
Show file tree
Hide file tree
Showing 11 changed files with 285 additions and 47 deletions.
14 changes: 12 additions & 2 deletions Makefile.am
Expand Up @@ -28,6 +28,7 @@
ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS} ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
AM_CXXFLAGS = $(PO6_CFLAGS) $(E_CFLAGS) $(BUSYBEE_CFLAGS) $(WANAL_CXXFLAGS) -fpermissive AM_CXXFLAGS = $(PO6_CFLAGS) $(E_CFLAGS) $(BUSYBEE_CFLAGS) $(WANAL_CXXFLAGS) -fpermissive
AM_YFLAGS = -d AM_YFLAGS = -d
TARGET_OS = `uname -s`


BUILT_SOURCES = client/parse_space_y.h BUILT_SOURCES = client/parse_space_y.h


Expand Down Expand Up @@ -69,7 +70,9 @@ noinst_PROGRAMS = \
client/c/testcompile \ client/c/testcompile \
client/cc/testcompile client/cc/testcompile


if ENABLE_DOCS
dist_man_MANS = doc/man/hyperdex-daemon.1 dist_man_MANS = doc/man/hyperdex-daemon.1
endif


CONFIG_CLEAN_FILES = hyperclient.pc CONFIG_CLEAN_FILES = hyperclient.pc


Expand All @@ -83,7 +86,11 @@ JAVAROOT = $(abs_top_srcdir)
pkgconfigdir = $(libdir)/pkgconfig pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = hyperclient.pc pkgconfig_DATA = hyperclient.pc


if ENABLE_DOCS
.PHONY: coverage doc/HyperDex-$(VERSION).pdf .PHONY: coverage doc/HyperDex-$(VERSION).pdf
else
.PHONY: coverage
endif


dist-hook: dist-hook:
-rm -rf $(distdir)/doc/_build -rm -rf $(distdir)/doc/_build
Expand Down Expand Up @@ -218,7 +225,7 @@ hyperdex_daemon_SOURCES = \
hyperdex_daemon_LDADD = \ hyperdex_daemon_LDADD = \
$(E_LIBS) \ $(E_LIBS) \
$(BUSYBEE_LIBS) -lleveldb \ $(BUSYBEE_LIBS) -lleveldb \
$(REPLICANT_LIBS) -lcityhash -lpopt -lglog -lrt -lpthread $(REPLICANT_LIBS) -lcityhash -lpopt -lglog -lpthread
hyperdex_daemon_CPPFLAGS = $(CPPFLAGS) hyperdex_daemon_CPPFLAGS = $(CPPFLAGS)


#daemon_test_index_encode_SOURCES = runner.cc daemon/test/index_encode.cc daemon/index_encode.cc common/float_encode.cc #daemon_test_index_encode_SOURCES = runner.cc daemon/test/index_encode.cc daemon/index_encode.cc common/float_encode.cc
Expand Down Expand Up @@ -425,7 +432,8 @@ hyperdex_SOURCES = hyperdex.cc
hyperdex_CPPFLAGS = -DHYPERDEX_EXEC_DIR=\""$(hyperdexexecdir)\"" $(CPPFLAGS) hyperdex_CPPFLAGS = -DHYPERDEX_EXEC_DIR=\""$(hyperdexexecdir)\"" $(CPPFLAGS)


hyperdex_initialize_cluster_SOURCES = tools/initialize-cluster.cc hyperdex_initialize_cluster_SOURCES = tools/initialize-cluster.cc
hyperdex_initialize_cluster_CPPFLAGS = -DHYPERDEX_COORD_LIB=\""$(hyperdexexecdir)/libhypercoordinator.so.0\"" $(CPPFLAGS)
hyperdex_initialize_cluster_CPPFLAGS = -DHYPERDEX_COORD_LIB=\""$(hyperdexexecdir)/libhypercoordinator$(SHEXT)\"" $(CPPFLAGS)
hyperdex_initialize_cluster_LDADD = libhyperclient.la hyperdex_initialize_cluster_LDADD = libhyperclient.la


hyperdex_coordinator_SOURCES = tools/coordinator.cc hyperdex_coordinator_SOURCES = tools/coordinator.cc
Expand Down Expand Up @@ -489,10 +497,12 @@ hyperdex_simple_consistency_stress_test_LDADD = libhyperclient.la -lpopt -lpthre


# These need to be chained so that they'll only build once, and will not rely # These need to be chained so that they'll only build once, and will not rely
# upon a PHONY rule. # upon a PHONY rule.
if ENABLE_DOCS
doc/man/hyperdex-daemon.1: doc/man/hyperdex-daemon.rst doc/man/hyperdex-daemon.1: doc/man/hyperdex-daemon.rst
sphinx-build -W -d ${abs_top_builddir}/doc/_build -b man doc doc/man sphinx-build -W -d ${abs_top_builddir}/doc/_build -b man doc doc/man


doc/HyperDex-$(VERSION).pdf: doc/HyperDex-$(VERSION).pdf:
sphinx-build -W -d ${abs_top_builddir}/doc/_build -b latex ${abs_top_srcdir}/doc ${abs_top_builddir}/doc/_build/latex sphinx-build -W -d ${abs_top_builddir}/doc/_build -b latex ${abs_top_srcdir}/doc ${abs_top_builddir}/doc/_build/latex
make -C ${abs_top_builddir}/doc/_build/latex all-pdf make -C ${abs_top_builddir}/doc/_build/latex all-pdf
cp ${abs_top_builddir}/doc/_build/latex/HyperDex.pdf doc/HyperDex-$(VERSION).pdf cp ${abs_top_builddir}/doc/_build/latex/HyperDex.pdf doc/HyperDex-$(VERSION).pdf
endif
20 changes: 10 additions & 10 deletions common/configuration.cc
Expand Up @@ -170,7 +170,7 @@ configuration :: get_schema(const char* sname) const
{ {
if (strcmp(sname, m_spaces[s].name) == 0) if (strcmp(sname, m_spaces[s].name) == 0)
{ {
return &m_spaces[s].schema; return &m_spaces[s].sc;
} }
} }


Expand Down Expand Up @@ -363,7 +363,7 @@ configuration :: point_leader(const char* sname, const e::slice& key)
} }


uint64_t h; uint64_t h;
hash(m_spaces[s].schema, key, &h); hash(m_spaces[s].sc, key, &h);


for (size_t pl = 0; pl < m_spaces[s].subspaces[0].regions.size(); ++pl) for (size_t pl = 0; pl < m_spaces[s].subspaces[0].regions.size(); ++pl)
{ {
Expand Down Expand Up @@ -396,7 +396,7 @@ configuration :: point_leader(const region_id& rid, const e::slice& key)
} }


uint64_t h; uint64_t h;
hash(m_spaces[s].schema, key, &h); hash(m_spaces[s].sc, key, &h);


for (size_t pl = 0; pl < m_spaces[s].subspaces[0].regions.size(); ++pl) for (size_t pl = 0; pl < m_spaces[s].subspaces[0].regions.size(); ++pl)
{ {
Expand Down Expand Up @@ -539,15 +539,15 @@ configuration :: lookup_region(const subspace_id& ssid,
continue; continue;
} }


assert(m_spaces[s].schema.attrs_sz == hashes.size()); assert(m_spaces[s].sc.attrs_sz == hashes.size());


for (size_t r = 0; r < m_spaces[s].subspaces[ss].regions.size(); ++r) for (size_t r = 0; r < m_spaces[s].subspaces[ss].regions.size(); ++r)
{ {
bool matches = true; bool matches = true;


for (size_t a = 0; matches && a < m_spaces[s].subspaces[ss].attrs.size(); ++a) for (size_t a = 0; matches && a < m_spaces[s].subspaces[ss].attrs.size(); ++a)
{ {
assert(a < m_spaces[s].schema.attrs_sz); assert(a < m_spaces[s].sc.attrs_sz);
matches &= m_spaces[s].subspaces[ss].regions[r].lower_coord[a] <= hashes[m_spaces[s].subspaces[ss].attrs[a]] && matches &= m_spaces[s].subspaces[ss].regions[r].lower_coord[a] <= hashes[m_spaces[s].subspaces[ss].attrs[a]] &&
hashes[m_spaces[s].subspaces[ss].attrs[a]] <= m_spaces[s].subspaces[ss].regions[r].upper_coord[a]; hashes[m_spaces[s].subspaces[ss].attrs[a]] <= m_spaces[s].subspaces[ss].regions[r].upper_coord[a];
} }
Expand Down Expand Up @@ -716,10 +716,10 @@ configuration :: debug_dump(std::ostream& out)
out << " fault_tolerance=" << s.fault_tolerance << std::endl; out << " fault_tolerance=" << s.fault_tolerance << std::endl;
out << " schema" << std::endl; out << " schema" << std::endl;


for (size_t i = 0; i < s.schema.attrs_sz; ++i) for (size_t i = 0; i < s.sc.attrs_sz; ++i)
{ {
out << " attribute name=" << s.schema.attrs[i].name out << " attribute name=" << s.sc.attrs[i].name
<< " type=" << s.schema.attrs[i].type << std::endl; << " type=" << s.sc.attrs[i].type << std::endl;
} }


for (size_t x = 0; x < s.subspaces.size(); ++x) for (size_t x = 0; x < s.subspaces.size(); ++x)
Expand All @@ -730,7 +730,7 @@ configuration :: debug_dump(std::ostream& out)


for (size_t i = 0; i < ss.attrs.size(); ++i) for (size_t i = 0; i < ss.attrs.size(); ++i)
{ {
out << " " << s.schema.attrs[ss.attrs[i]].name; out << " " << s.sc.attrs[ss.attrs[i]].name;
} }


out << std::endl; out << std::endl;
Expand Down Expand Up @@ -847,7 +847,7 @@ configuration :: refill_cache()
for (size_t y = 0; y < ss.regions.size(); ++y) for (size_t y = 0; y < ss.regions.size(); ++y)
{ {
region& r(ss.regions[y]); region& r(ss.regions[y]);
m_schemas_by_region.push_back(std::make_pair(r.id.get(), &s.schema)); m_schemas_by_region.push_back(std::make_pair(r.id.get(), &s.sc));
m_subspace_ids_by_region.push_back(std::make_pair(r.id.get(), ss.id.get())); m_subspace_ids_by_region.push_back(std::make_pair(r.id.get(), ss.id.get()));


if (r.replicas.empty()) if (r.replicas.empty())
Expand Down
6 changes: 3 additions & 3 deletions common/float_encode.cc
Expand Up @@ -28,7 +28,7 @@
#define __STDC_LIMIT_MACROS #define __STDC_LIMIT_MACROS


// C // C
#include <cmath> #include <tr1/cmath>
#include <cstdlib> #include <cstdlib>


// Linux // Linux
Expand Down Expand Up @@ -102,7 +102,7 @@ hyperdex :: float_encode(double x)
{ {
uint64_t out = 0xffffffffffffffffULL; uint64_t out = 0xffffffffffffffffULL;


if (isinf(x)) if (std::isinf(x))
{ {
if (x > 0) if (x > 0)
{ {
Expand All @@ -113,7 +113,7 @@ hyperdex :: float_encode(double x)
out = 0; out = 0;
} }
} }
else if (isnan(x)) else if (std::isnan(x))
{ {
out = 0xfff0000000000000ULL + 3; out = 0xfff0000000000000ULL + 3;
} }
Expand Down
56 changes: 28 additions & 28 deletions common/hyperspace.cc
Expand Up @@ -37,7 +37,7 @@ space :: space()
: id() : id()
, name("") , name("")
, fault_tolerance() , fault_tolerance()
, schema() , sc()
, subspaces() , subspaces()
, m_c_strs() , m_c_strs()
, m_attrs() , m_attrs()
Expand All @@ -48,7 +48,7 @@ space :: space(const char* new_name, const hyperdex::schema& sc)
: id() : id()
, name(new_name) , name(new_name)
, fault_tolerance() , fault_tolerance()
, schema(sc) , sc(sc)
, subspaces() , subspaces()
, m_c_strs() , m_c_strs()
, m_attrs() , m_attrs()
Expand All @@ -60,7 +60,7 @@ space :: space(const space& other)
: id(other.id) : id(other.id)
, name(other.name) , name(other.name)
, fault_tolerance(other.fault_tolerance) , fault_tolerance(other.fault_tolerance)
, schema(other.schema) , sc(other.sc)
, subspaces(other.subspaces) , subspaces(other.subspaces)
, m_c_strs() , m_c_strs()
, m_attrs() , m_attrs()
Expand All @@ -75,11 +75,11 @@ space :: ~space() throw ()
bool bool
space :: validate() const space :: validate() const
{ {
for (size_t i = 0; i < schema.attrs_sz; ++i) for (size_t i = 0; i < sc.attrs_sz; ++i)
{ {
for (size_t j = i + 1; j < schema.attrs_sz; ++j) for (size_t j = i + 1; j < sc.attrs_sz; ++j)
{ {
if (strcmp(schema.attrs[i].name, schema.attrs[j].name) == 0) if (strcmp(sc.attrs[i].name, sc.attrs[j].name) == 0)
{ {
return false; return false;
} }
Expand All @@ -101,7 +101,7 @@ space :: validate() const


for (size_t j = 0; j < subspaces[i].attrs.size(); ++j) for (size_t j = 0; j < subspaces[i].attrs.size(); ++j)
{ {
if (subspaces[i].attrs[j] >= schema.attrs_sz) if (subspaces[i].attrs[j] >= sc.attrs_sz)
{ {
return false; return false;
} }
Expand All @@ -125,7 +125,7 @@ space :: operator = (const space& rhs)
id = rhs.id; id = rhs.id;
name = rhs.name; name = rhs.name;
fault_tolerance = rhs.fault_tolerance; fault_tolerance = rhs.fault_tolerance;
schema = rhs.schema; sc = rhs.sc;
subspaces = rhs.subspaces; subspaces = rhs.subspaces;
reestablish_backing(); reestablish_backing();
return *this; return *this;
Expand All @@ -137,30 +137,30 @@ space :: reestablish_backing()
// Compute the size of the c_strs backing // Compute the size of the c_strs backing
size_t sz = strlen(name) + 1; size_t sz = strlen(name) + 1;


for (size_t i = 0; i < schema.attrs_sz; ++i) for (size_t i = 0; i < sc.attrs_sz; ++i)
{ {
sz += strlen(schema.attrs[i].name) + 1; sz += strlen(sc.attrs[i].name) + 1;
} }


// Create the two new backings // Create the two new backings
m_c_strs = new char[sz]; m_c_strs = new char[sz];
m_attrs = new attribute[schema.attrs_sz]; m_attrs = new attribute[sc.attrs_sz];
char* ptr = m_c_strs.get(); char* ptr = m_c_strs.get();
sz = strlen(name) + 1; sz = strlen(name) + 1;
memmove(ptr, name, sz); memmove(ptr, name, sz);
name = ptr; name = ptr;
ptr += sz; ptr += sz;


for (size_t i = 0; i < schema.attrs_sz; ++i) for (size_t i = 0; i < sc.attrs_sz; ++i)
{ {
m_attrs[i].type = schema.attrs[i].type; m_attrs[i].type = sc.attrs[i].type;
sz = strlen(schema.attrs[i].name) + 1; sz = strlen(sc.attrs[i].name) + 1;
memmove(ptr, schema.attrs[i].name, sz); memmove(ptr, sc.attrs[i].name, sz);
m_attrs[i].name = ptr; m_attrs[i].name = ptr;
ptr += sz; ptr += sz;
} }


schema.attrs = m_attrs.get(); sc.attrs = m_attrs.get();
} }


e::buffer::packer e::buffer::packer
Expand All @@ -169,12 +169,12 @@ hyperdex :: operator << (e::buffer::packer pa, const space& s)
e::slice name; e::slice name;
uint16_t num_subspaces = s.subspaces.size(); uint16_t num_subspaces = s.subspaces.size();
name = e::slice(s.name, strlen(s.name)); name = e::slice(s.name, strlen(s.name));
pa = pa << s.id.get() << name << s.fault_tolerance << s.schema.attrs_sz << num_subspaces; pa = pa << s.id.get() << name << s.fault_tolerance << s.sc.attrs_sz << num_subspaces;


for (size_t i = 0; i < s.schema.attrs_sz; ++i) for (size_t i = 0; i < s.sc.attrs_sz; ++i)
{ {
name = e::slice(s.schema.attrs[i].name, strlen(s.schema.attrs[i].name)); name = e::slice(s.sc.attrs[i].name, strlen(s.sc.attrs[i].name));
pa = pa << name << static_cast<uint16_t>(s.schema.attrs[i].type); pa = pa << name << static_cast<uint16_t>(s.sc.attrs[i].type);
} }


for (size_t i = 0; i < num_subspaces; ++i) for (size_t i = 0; i < num_subspaces; ++i)
Expand All @@ -192,14 +192,14 @@ hyperdex :: operator >> (e::unpacker up, space& s)
e::slice name; e::slice name;
std::vector<e::slice> attrs; std::vector<e::slice> attrs;
uint16_t num_subspaces; uint16_t num_subspaces;
up = up >> id >> name >> s.fault_tolerance >> s.schema.attrs_sz >> num_subspaces; up = up >> id >> name >> s.fault_tolerance >> s.sc.attrs_sz >> num_subspaces;
s.id = space_id(id); s.id = space_id(id);
s.m_attrs = new attribute[s.schema.attrs_sz]; s.m_attrs = new attribute[s.sc.attrs_sz];
s.schema.attrs = s.m_attrs.get(); s.sc.attrs = s.m_attrs.get();
size_t sz = name.size() + 1; size_t sz = name.size() + 1;


// Unpack all attributes // Unpack all attributes
for (size_t i = 0; !up.error() && i < s.schema.attrs_sz; ++i) for (size_t i = 0; !up.error() && i < s.sc.attrs_sz; ++i)
{ {
e::slice attr; e::slice attr;
uint16_t type; uint16_t type;
Expand All @@ -218,7 +218,7 @@ hyperdex :: operator >> (e::unpacker up, space& s)
*ptr = '\0'; *ptr = '\0';
++ptr; ++ptr;


for (size_t i = 0; i < s.schema.attrs_sz; ++i) for (size_t i = 0; i < s.sc.attrs_sz; ++i)
{ {
s.m_attrs[i].name = ptr; s.m_attrs[i].name = ptr;
memmove(ptr, attrs[i].data(), attrs[i].size()); memmove(ptr, attrs[i].data(), attrs[i].size());
Expand All @@ -244,12 +244,12 @@ hyperdex :: pack_size(const space& s)
size_t sz = sizeof(uint64_t) /* id */ size_t sz = sizeof(uint64_t) /* id */
+ sizeof(uint32_t) + strlen(s.name) /* name */ + sizeof(uint32_t) + strlen(s.name) /* name */
+ sizeof(uint64_t) /* fault_tolerance */ + sizeof(uint64_t) /* fault_tolerance */
+ sizeof(uint16_t) /* schema.attrs_sz */ + sizeof(uint16_t) /* sc.attrs_sz */
+ sizeof(uint16_t); /* num subspaces */ + sizeof(uint16_t); /* num subspaces */


for (size_t i = 0; i < s.schema.attrs_sz; ++i) for (size_t i = 0; i < s.sc.attrs_sz; ++i)
{ {
sz += sizeof(uint32_t) + strlen(s.schema.attrs[i].name) sz += sizeof(uint32_t) + strlen(s.sc.attrs[i].name)
+ sizeof(uint16_t); + sizeof(uint16_t);
} }


Expand Down
2 changes: 1 addition & 1 deletion common/hyperspace.h
Expand Up @@ -64,7 +64,7 @@ class space
space_id id; space_id id;
const char* name; const char* name;
uint64_t fault_tolerance; uint64_t fault_tolerance;
hyperdex::schema schema; hyperdex::schema sc;
std::vector<subspace> subspaces; std::vector<subspace> subspaces;


private: private:
Expand Down
5 changes: 5 additions & 0 deletions common/serialization.cc
Expand Up @@ -50,9 +50,12 @@ hyperdex :: operator << (e::buffer::packer lhs, const po6::net::ipaddr& rhs)
rhs.pack(&sa, 0); rhs.pack(&sa, 0);
#ifdef _MSC_VER #ifdef _MSC_VER
memmove(data, &sa.sin6_addr.u.Byte, 16); memmove(data, &sa.sin6_addr.u.Byte, 16);
#elif defined __APPLE__
memmove(data, &sa.sin6_addr.__u6_addr.__u6_addr8, 16);
#else #else
memmove(data, &sa.sin6_addr.__in6_u.__u6_addr8, 16); memmove(data, &sa.sin6_addr.__in6_u.__u6_addr8, 16);
#endif #endif

} }
else else
{ {
Expand Down Expand Up @@ -88,6 +91,8 @@ hyperdex :: operator >> (e::unpacker lhs, po6::net::ipaddr& rhs)
in6_addr ia; in6_addr ia;
#ifdef _MSC_VER #ifdef _MSC_VER
memmove(ia.u.Byte, rem.data(), 16); memmove(ia.u.Byte, rem.data(), 16);
#elif defined __APPLE__
memmove(ia.__u6_addr.__u6_addr8, rem.data(), 16);
#else #else
memmove(ia.__in6_u.__u6_addr8, rem.data(), 16); memmove(ia.__in6_u.__u6_addr8, rem.data(), 16);
#endif #endif
Expand Down

0 comments on commit 62f0b41

Please sign in to comment.