From 015d26f8be6e27d96c536eb9f1ef7275898e3603 Mon Sep 17 00:00:00 2001 From: Sanjay Ghemawat Date: Mon, 5 Mar 2012 10:35:46 -0800 Subject: [PATCH] add .gitignore; support for building on a few BSD variants --- .gitignore | 5 +++++ build_detect_platform | 15 +++++++++++++++ port/port_posix.h | 14 +++++++++++--- 3 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..46769e0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +build_config.mk +*.a +*.o +*_test +db_bench diff --git a/build_detect_platform b/build_detect_platform index d8d9ba1..5f9e021 100644 --- a/build_detect_platform +++ b/build_detect_platform @@ -39,6 +39,21 @@ case `uname -s` in echo "PLATFORM_CFLAGS=-D_REENTRANT -DOS_FREEBSD" >> build_config.mk echo "PLATFORM_LDFLAGS=-lpthread" >> build_config.mk ;; + NetBSD) + PLATFORM=OS_NETBSD + echo "PLATFORM_CFLAGS=-D_REENTRANT -DOS_NETBSD" >> build_config.mk + echo "PLATFORM_LDFLAGS=-lpthread -lgcc_s" >> build_config.mk + ;; + OpenBSD) + PLATFORM=OS_OPENBSD + echo "PLATFORM_CFLAGS=-D_REENTRANT -DOS_OPENBSD" >> build_config.mk + echo "PLATFORM_LDFLAGS=-pthread" >> build_config.mk + ;; + DragonFly) + PLATFORM=OS_DRAGONFLYBSD + echo "PLATFORM_CFLAGS=-D_REENTRANT -DOS_DRAGONFLYBSD" >> build_config.mk + echo "PLATFORM_LDFLAGS=-lpthread" >> build_config.mk + ;; *) echo "Unknown platform!" exit 1 diff --git a/port/port_posix.h b/port/port_posix.h index 9666391..485ad10 100644 --- a/port/port_posix.h +++ b/port/port_posix.h @@ -7,7 +7,7 @@ #ifndef STORAGE_LEVELDB_PORT_PORT_POSIX_H_ #define STORAGE_LEVELDB_PORT_PORT_POSIX_H_ -#if defined(OS_MACOSX) || defined(OS_FREEBSD) +#if defined(OS_MACOSX) #include #elif defined(OS_SOLARIS) #include @@ -16,6 +16,10 @@ #else #define BIG_ENDIAN #endif +#elif defined(OS_FREEBSD) || defined(OS_OPENBSD) || defined(OS_NETBSD) ||\ + defined(OS_DRAGONFLYBSD) + #include + #include #else #include #endif @@ -33,13 +37,17 @@ #define IS_LITTLE_ENDIAN (__BYTE_ORDER == __LITTLE_ENDIAN) #endif -#if defined(OS_MACOSX) || defined(OS_SOLARIS) || defined(OS_FREEBSD) +#if defined(OS_MACOSX) || defined(OS_SOLARIS) || defined(OS_FREEBSD) ||\ + defined(OS_NETBSD) || defined(OS_OPENBSD) || defined(OS_DRAGONFLYBSD) +// Use fread/fwrite/fflush on platforms without _unlocked variants #define fread_unlocked fread #define fwrite_unlocked fwrite #define fflush_unlocked fflush #endif -#if defined(OS_MACOSX) || defined(OS_FREEBSD) +#if defined(OS_MACOSX) || defined(OS_FREEBSD) ||\ + defined(OS_OPENBSD) || defined(OS_DRAGONFLYBSD) +// Use fsync() on platforms without fdatasync() #define fdatasync fsync #endif