Skip to content

Commit

Permalink
add .gitignore; support for building on a few BSD variants
Browse files Browse the repository at this point in the history
  • Loading branch information
ghemawat committed Mar 5, 2012
1 parent 239ac9d commit 015d26f
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
build_config.mk
*.a
*.o
*_test
db_bench
15 changes: 15 additions & 0 deletions build_detect_platform
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 11 additions & 3 deletions port/port_posix.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <machine/endian.h>
#elif defined(OS_SOLARIS)
#include <sys/isa_defs.h>
Expand All @@ -16,6 +16,10 @@
#else
#define BIG_ENDIAN
#endif
#elif defined(OS_FREEBSD) || defined(OS_OPENBSD) || defined(OS_NETBSD) ||\
defined(OS_DRAGONFLYBSD)
#include <sys/types.h>
#include <sys/endian.h>
#else
#include <endian.h>
#endif
Expand All @@ -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

Expand Down

0 comments on commit 015d26f

Please sign in to comment.