summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2018-10-24 14:06:45 -0700
committerElliott Hughes <enh@google.com>2018-10-24 14:06:45 -0700
commit32df7ee5c82a482f48c6df14ce3a77710cc0eb67 (patch)
tree43e3be483e869242b698f88602e0eb8dff0c8ac1 /base
parent48a0e186a7f5ecad06bc0929fd86fda3416cf740 (diff)
downloadsystem_core-32df7ee5c82a482f48c6df14ce3a77710cc0eb67.tar.gz
system_core-32df7ee5c82a482f48c6df14ce3a77710cc0eb67.tar.bz2
system_core-32df7ee5c82a482f48c6df14ce3a77710cc0eb67.zip
libbase: add O_CLOEXEC to <android-base/file.h>.
We already expose O_BINARY, and O_CLOEXEC seems equally legitimate. Bug: N/A Test: builds Change-Id: I7f07e1bb2a5d6b5c5f293783c39ceab148fabefb
Diffstat (limited to 'base')
-rw-r--r--base/file.cpp1
-rw-r--r--base/include/android-base/file.h8
2 files changed, 7 insertions, 2 deletions
diff --git a/base/file.cpp b/base/file.cpp
index d6fe753d1..3834ed42a 100644
--- a/base/file.cpp
+++ b/base/file.cpp
@@ -38,7 +38,6 @@
#endif
#if defined(_WIN32)
#include <windows.h>
-#define O_CLOEXEC O_NOINHERIT
#define O_NOFOLLOW 0
#endif
diff --git a/base/include/android-base/file.h b/base/include/android-base/file.h
index 908690ba6..8f9bf80a0 100644
--- a/base/include/android-base/file.h
+++ b/base/include/android-base/file.h
@@ -21,11 +21,17 @@
#include <string>
#if !defined(_WIN32) && !defined(O_BINARY)
+/** Windows needs O_BINARY, but Unix never mangles line endings. */
#define O_BINARY 0
#endif
+#if defined(_WIN32) && !defined(O_CLOEXEC)
+/** Windows has O_CLOEXEC but calls it O_NOINHERIT for some reason. */
+#define O_CLOEXEC O_NOINHERIT
+#endif
+
#if defined(__APPLE__)
-/* Mac OS has always had a 64-bit off_t, so it doesn't have off64_t. */
+/** Mac OS has always had a 64-bit off_t, so it doesn't have off64_t. */
typedef off_t off64_t;
#endif