Skip to content

Port to OSX. #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ check: check.o
$(CXX) $(LDFLAGS) -o $@ $^ $(LDADD) && ./$@

example: example.o
$(MKDIR) env
$(CXX) $(LDFLAGS) -o $@ $^ $(LDADD) && ./$@

%.o: %.cc lmdb++.h
Expand All @@ -51,6 +52,7 @@ uninstall:
$(RM) $(DESTDIR)$(includedir)/lmdb++.h

clean:
$(RM) env/*
$(RM) README.html README.md check example $(PACKAGE_TARSTRING).tar.* *.o *~

README: README.html README.md
Expand Down
3 changes: 2 additions & 1 deletion example.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ int main() {
/* Create and open the LMDB environment: */
auto env = lmdb::env::create();
env.set_mapsize(1UL * 1024UL * 1024UL * 1024UL); /* 1 GiB */
env.open("./example.mdb", 0, 0664);
//env.open("./example.mdb", 0, 0664);
env.open( "./env" );

/* Insert some key/value pairs in a write transaction: */
auto wtxn = lmdb::txn::begin(env);
Expand Down
12 changes: 11 additions & 1 deletion lmdb++.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@
#endif // _MSC_VER check
#endif

#if HAS_CXX11_THREAD_LOCAL
#define ATTRIBUTE_TLS thread_local
#elif defined (__GNUC__)
#define ATTRIBUTE_TLS __thread
#elif defined (_MSC_VER)
#define ATTRIBUTE_TLS __declspec(thread)
#else // !C++11 && !__GNUC__ && !_MSC_VER
#error "Define a thread local storage qualifier for your compiler/platform!"
#endif

////////////////////////////////////////////////////////////////////////////////

#include <lmdb.h> /* for MDB_*, mdb_*() */
Expand Down Expand Up @@ -96,7 +106,7 @@ class lmdb::error : public std::runtime_error {
* Returns the underlying LMDB error code.
*/
virtual const char* what() const noexcept {
static thread_local char buffer[1024];
static ATTRIBUTE_TLS char buffer[1024];
std::snprintf(buffer, sizeof(buffer),
"%s: %s", origin(), ::mdb_strerror(code()));
return buffer;
Expand Down