OLD | NEW |
1 diff --git a/Makefile b/Makefile | 1 diff --git a/Makefile b/Makefile |
2 --- a/Makefile | 2 --- a/Makefile |
3 +++ b/Makefile | 3 +++ b/Makefile |
4 @@ -90,7 +90,11 @@ endif # PLATFORM_SHARED_EXT | 4 @@ -99,7 +99,11 @@ endif # PLATFORM_SHARED_EXT |
5 | 5 |
6 all: $(SHARED) $(LIBRARY) | 6 all: $(SHARED) $(LIBRARY) |
7 | 7 |
8 -check: all $(PROGRAMS) $(TESTS) | 8 -check: all $(PROGRAMS) $(TESTS) |
9 +tests: $(TESTS) | 9 +tests: $(TESTS) |
10 + | 10 + |
11 +programs: $(PROGRAMS) | 11 +programs: $(PROGRAMS) |
12 + | 12 + |
13 +check: all programs tests | 13 +check: all programs tests |
14 for t in $(TESTS); do echo "***** Running $$t"; ./$$t || exit 1; done | 14 for t in $(TESTS); do echo "***** Running $$t"; ./$$t || exit 1; done |
15 | 15 |
16 clean: | 16 clean: |
17 diff --git a/build_detect_platform b/build_detect_platform | 17 diff --git a/build_detect_platform b/build_detect_platform |
18 --- a/build_detect_platform | 18 --- a/build_detect_platform |
19 +++ b/build_detect_platform | 19 +++ b/build_detect_platform |
20 @@ -98,6 +98,22 @@ case "$TARGET_OS" in | 20 @@ -104,6 +104,31 @@ case "$TARGET_OS" in |
21 PLATFORM_LIBS="-lpthread" | 21 PLATFORM_LIBS="-lpthread" |
22 PORT_FILE=port/port_posix.cc | 22 PORT_FILE=port/port_posix.cc |
23 ;; | 23 ;; |
24 + NaCl) | 24 + NaCl) |
25 + PLATFORM=OS_NACL | 25 + PLATFORM=OS_NACL |
26 + COMMON_FLAGS="$MEMCMP_FLAG -D_REENTRANT -DOS_NACL -DLEVELDB_PLATFORM_PO
SIX" | 26 + COMMON_FLAGS="$MEMCMP_FLAG -D_REENTRANT -DOS_NACL -DLEVELDB_PLATFORM_PO
SIX" |
27 + PLATFORM_LDFLAGS="-pthread" | 27 + PLATFORM_LDFLAGS="-pthread" |
28 + PORT_FILE=port/port_posix.cc | 28 + PORT_FILE=port/port_posix.cc |
29 + CROSS_COMPILE=true | 29 + CROSS_COMPILE=true |
30 + if [ "$NACL_ARCH" = arm -o "$NACL_ARCH" = pnacl ]; then | 30 + if [ "$TOOLCHAIN" = "pnacl" -o "$TOOLCHAIN" = "clang-newlib" ]; then |
31 + COMMON_FLAGS="$COMMON_FLAGS -DLEVELDB_ATOMIC_PRESENT" | 31 + COMMON_FLAGS="$COMMON_FLAGS -DLEVELDB_ATOMIC_PRESENT" |
32 + # Would use -std=c++11 here but its broken on PNaCl: | 32 + # Would use -std=c++11 here but its broken on PNaCl: |
33 + # http://crbug.com/314944 | 33 + # http://crbug.com/314944 |
34 + PLATFORM_CXXFLAGS="-std=gnu++11" | 34 + PLATFORM_CXXFLAGS="-std=gnu++11" |
35 + fi | 35 + fi |
| 36 + if [ "$TOOLCHAIN" = "glibc" ]; then |
| 37 + if [ "$NACL_ARCH" = "arm" ]; then |
| 38 + COMMON_FLAGS="$COMMON_FLAGS -DLEVELDB_ATOMIC_PRESENT" |
| 39 + PLATFORM_CXXFLAGS="-std=c++11" |
| 40 + else |
| 41 + COMMON_FLAGS="$COMMON_FLAGS -D__STDC_LIMIT_MACROS" |
| 42 + PLATFORM_CXXFLAGS="-std=c++0x" |
| 43 + fi |
| 44 + fi |
36 + if [ "$NACL_SHARED" != 1 ]; then | 45 + if [ "$NACL_SHARED" != 1 ]; then |
37 + PLATFORM_SHARED_EXT="" | 46 + PLATFORM_SHARED_EXT="" |
38 + fi | 47 + fi |
39 + ;; | 48 + ;; |
40 NetBSD) | 49 NetBSD) |
41 PLATFORM=OS_NETBSD | 50 PLATFORM=OS_NETBSD |
42 COMMON_FLAGS="$MEMCMP_FLAG -D_REENTRANT -DOS_NETBSD" | 51 COMMON_FLAGS="$MEMCMP_FLAG -D_REENTRANT -DOS_NETBSD" |
43 diff --git a/port/atomic_pointer.h b/port/atomic_pointer.h | |
44 --- a/port/atomic_pointer.h | |
45 +++ b/port/atomic_pointer.h | |
46 @@ -20,6 +20,9 @@ | |
47 #define PORT_ATOMIC_POINTER_H_ | |
48 | |
49 #include <stdint.h> | |
50 +#ifdef LEVELDB_ATOMIC_PRESENT | |
51 +#include <atomic> | |
52 +#endif | |
53 #ifdef LEVELDB_CSTDATOMIC_PRESENT | |
54 #include <cstdatomic> | |
55 #endif | |
56 @@ -125,8 +128,8 @@ class AtomicPointer { | |
57 } | |
58 }; | |
59 | |
60 -// AtomicPointer based on <cstdatomic> | |
61 -#elif defined(LEVELDB_CSTDATOMIC_PRESENT) | |
62 +// AtomicPointer based on <cstdatomic> or <atomic> | |
63 +#elif defined(LEVELDB_CSTDATOMIC_PRESENT) || defined(LEVELDB_ATOMIC_PRESENT) | |
64 class AtomicPointer { | |
65 private: | |
66 std::atomic<void*> rep_; | |
67 diff --git a/port/port_posix.h b/port/port_posix.h | 52 diff --git a/port/port_posix.h b/port/port_posix.h |
68 --- a/port/port_posix.h | 53 --- a/port/port_posix.h |
69 +++ b/port/port_posix.h | 54 +++ b/port/port_posix.h |
70 @@ -37,6 +37,14 @@ | 55 @@ -34,6 +34,14 @@ |
71 // See http://code.google.com/p/android/issues/detail?id=39824 | 56 // See http://code.google.com/p/android/issues/detail?id=39824 |
72 #include <endian.h> | 57 #include <endian.h> |
73 #define PLATFORM_IS_LITTLE_ENDIAN (_BYTE_ORDER == _LITTLE_ENDIAN) | 58 #define PLATFORM_IS_LITTLE_ENDIAN (_BYTE_ORDER == _LITTLE_ENDIAN) |
74 +#elif defined(OS_NACL) | 59 +#elif defined(OS_NACL) |
75 + #include <sys/types.h> | 60 + #include <sys/types.h> |
76 + #if defined(_NEWLIB_VERSION) | 61 + #if defined(_NEWLIB_VERSION) |
77 + #include <machine/endian.h> | 62 + #include <machine/endian.h> |
78 + #define PLATFORM_IS_LITTLE_ENDIAN (BYTE_ORDER == LITTLE_ENDIAN) | 63 + #define PLATFORM_IS_LITTLE_ENDIAN (BYTE_ORDER == LITTLE_ENDIAN) |
79 + #else | 64 + #else |
80 + #include <endian.h> | 65 + #include <endian.h> |
81 + #endif | 66 + #endif |
82 #else | 67 #else |
83 #include <endian.h> | 68 #include <endian.h> |
84 #endif | 69 #endif |
85 @@ -55,7 +63,7 @@ | 70 @@ -52,7 +60,7 @@ |
86 | 71 |
87 #if defined(OS_MACOSX) || defined(OS_SOLARIS) || defined(OS_FREEBSD) ||\ | 72 #if defined(OS_MACOSX) || defined(OS_SOLARIS) || defined(OS_FREEBSD) ||\ |
88 defined(OS_NETBSD) || defined(OS_OPENBSD) || defined(OS_DRAGONFLYBSD) ||\ | 73 defined(OS_NETBSD) || defined(OS_OPENBSD) || defined(OS_DRAGONFLYBSD) ||\ |
89 - defined(OS_ANDROID) || defined(OS_HPUX) | 74 - defined(OS_ANDROID) || defined(OS_HPUX) || defined(CYGWIN) |
90 + defined(OS_ANDROID) || defined(OS_HPUX) || (defined(OS_NACL) && (defined(_N
EWLIB_VERSION) || defined(__BIONIC__))) | 75 + defined(OS_ANDROID) || defined(OS_HPUX) || defined(CYGWIN) || (defined(OS_N
ACL) && (defined(_NEWLIB_VERSION) || defined(__BIONIC__))) |
91 // Use fread/fwrite/fflush on platforms without _unlocked variants | 76 // Use fread/fwrite/fflush on platforms without _unlocked variants |
92 #define fread_unlocked fread | 77 #define fread_unlocked fread |
93 #define fwrite_unlocked fwrite | 78 #define fwrite_unlocked fwrite |
94 diff --git a/util/env_posix.cc b/util/env_posix.cc | 79 diff --git a/util/env_posix.cc b/util/env_posix.cc |
95 --- a/util/env_posix.cc | 80 --- a/util/env_posix.cc |
96 +++ b/util/env_posix.cc | 81 +++ b/util/env_posix.cc |
97 @@ -27,6 +27,32 @@ | 82 @@ -24,6 +24,32 @@ |
98 #include "util/mutexlock.h" | 83 #include "util/mutexlock.h" |
99 #include "util/posix_logger.h" | 84 #include "util/posix_logger.h" |
100 | 85 |
101 +#ifdef __native_client__ | 86 +#ifdef __native_client__ |
102 +// TODO(sbc): remove once fsync/fdatasync get implemented in sel_ldr. | 87 +// TODO(sbc): remove once fsync/fdatasync get implemented in sel_ldr. |
103 +#define fsync(X) 0 | 88 +#define fsync(X) 0 |
104 +#define fdatasync(X) 0 | 89 +#define fdatasync(X) 0 |
105 +#ifdef __GLIBC__ | 90 +#ifdef __GLIBC__ |
106 +#define geteuid(X) 0 | 91 +#define geteuid(X) 0 |
107 +ssize_t pread(int fd, char* buf, size_t n, off_t off) { | 92 +ssize_t pread(int fd, char* buf, size_t n, off_t off) { |
(...skipping 12 matching lines...) Expand all Loading... |
120 + return -1; | 105 + return -1; |
121 + | 106 + |
122 + return num_read; | 107 + return num_read; |
123 +} | 108 +} |
124 +#endif | 109 +#endif |
125 +#endif | 110 +#endif |
126 + | 111 + |
127 namespace leveldb { | 112 namespace leveldb { |
128 | 113 |
129 namespace { | 114 namespace { |
130 @@ -257,6 +283,9 @@ class PosixWritableFile : public WritableFile { | 115 @@ -254,6 +280,9 @@ class PosixWritableFile : public WritableFile { |
131 }; | 116 }; |
132 | 117 |
133 static int LockOrUnlock(int fd, bool lock) { | 118 static int LockOrUnlock(int fd, bool lock) { |
134 +#ifdef __native_client__ | 119 +#ifdef __native_client__ |
135 + return 0; | 120 + return 0; |
136 +#else | 121 +#else |
137 errno = 0; | 122 errno = 0; |
138 struct flock f; | 123 struct flock f; |
139 memset(&f, 0, sizeof(f)); | 124 memset(&f, 0, sizeof(f)); |
140 @@ -265,6 +294,7 @@ static int LockOrUnlock(int fd, bool lock) { | 125 @@ -262,6 +291,7 @@ static int LockOrUnlock(int fd, bool lock) { |
141 f.l_start = 0; | 126 f.l_start = 0; |
142 f.l_len = 0; // Lock/unlock entire file | 127 f.l_len = 0; // Lock/unlock entire file |
143 return fcntl(fd, F_SETLK, &f); | 128 return fcntl(fd, F_SETLK, &f); |
144 +#endif | 129 +#endif |
145 } | 130 } |
146 | 131 |
147 class PosixFileLock : public FileLock { | 132 class PosixFileLock : public FileLock { |
OLD | NEW |