Fuchsia: Prepare for OS_POSIX removal in base/

This cleans up multi-platform code paths selection and prepares for
the removal of OS_POSIX for the Fuchsia build.

Bug: 836416
Change-Id: I3a8e6393d0a9981aa890fb6d8c302ed8d2bdd69d
Reviewed-on: https://chromium-review.googlesource.com/1031099
Commit-Queue: Fabrice de Gans-Riberi <fdegans@chromium.org>
Reviewed-by: Kinuko Yasuda <kinuko@chromium.org>
Reviewed-by: Nico Weber <thakis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#559230}
diff --git a/base/allocator/partition_allocator/address_space_randomization.cc b/base/allocator/partition_allocator/address_space_randomization.cc
index dc90824..a7e17c7c 100644
--- a/base/allocator/partition_allocator/address_space_randomization.cc
+++ b/base/allocator/partition_allocator/address_space_randomization.cc
@@ -83,10 +83,7 @@
 
 // The kASLRMask and kASLROffset constants will be suitable for the
 // OS and build configuration.
-#if defined(MEMORY_TOOL_REPLACES_ALLOCATOR) || defined(OS_POSIX)
-  random &= internal::kASLRMask;
-  random += internal::kASLROffset;
-#else   // defined(OS_WIN)
+#if defined(OS_WIN) && !defined(MEMORY_TOOL_REPLACES_ALLOCATOR)
   // Windows >= 8.1 has the full 47 bits. Use them where available.
   static bool windows_81 = false;
   static bool windows_81_initialized = false;
@@ -100,7 +97,10 @@
     random &= internal::kASLRMask;
   }
   random += internal::kASLROffset;
-#endif  // defined(OS_WIN)
+#else
+  random &= internal::kASLRMask;
+  random += internal::kASLROffset;
+#endif  // defined(OS_WIN) && !defined(MEMORY_TOOL_REPLACES_ALLOCATOR)
 #else   // defined(ARCH_CPU_32_BITS)
 #if defined(OS_WIN)
   // On win32 host systems the randomization plus huge alignment causes
diff --git a/base/allocator/partition_allocator/address_space_randomization.h b/base/allocator/partition_allocator/address_space_randomization.h
index d5d497d..1245f4a4 100644
--- a/base/allocator/partition_allocator/address_space_randomization.h
+++ b/base/allocator/partition_allocator/address_space_randomization.h
@@ -77,7 +77,7 @@
     constexpr uintptr_t kASLRMask = AslrMask(38);
     constexpr uintptr_t kASLROffset = AslrAddress(0x1000000000ULL);
 
-  #elif defined(OS_POSIX)
+  #elif defined(OS_POSIX) || defined(OS_FUCHSIA)
 
     #if defined(ARCH_CPU_X86_64)
 
diff --git a/base/allocator/partition_allocator/page_allocator.cc b/base/allocator/partition_allocator/page_allocator.cc
index 0d3b068f..328384e 100644
--- a/base/allocator/partition_allocator/page_allocator.cc
+++ b/base/allocator/partition_allocator/page_allocator.cc
@@ -22,10 +22,10 @@
 #include <windows.h>
 #endif
 
-#if defined(OS_POSIX)
-#include "base/allocator/partition_allocator/page_allocator_internals_posix.h"
-#elif defined(OS_WIN)
+#if defined(OS_WIN)
 #include "base/allocator/partition_allocator/page_allocator_internals_win.h"
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
+#include "base/allocator/partition_allocator/page_allocator_internals_posix.h"
 #else
 #error Platform not supported.
 #endif
diff --git a/base/allocator/partition_allocator/spin_lock.cc b/base/allocator/partition_allocator/spin_lock.cc
index fd062c3..46f4965 100644
--- a/base/allocator/partition_allocator/spin_lock.cc
+++ b/base/allocator/partition_allocator/spin_lock.cc
@@ -3,10 +3,11 @@
 // found in the LICENSE file.
 
 #include "base/allocator/partition_allocator/spin_lock.h"
+#include "build/build_config.h"
 
 #if defined(OS_WIN)
 #include <windows.h>
-#elif defined(OS_POSIX)
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
 #include <sched.h>
 #endif
 
@@ -23,9 +24,12 @@
 // you really should be using a proper lock (such as |base::Lock|)rather than
 // these spinlocks.
 #if defined(OS_WIN)
+
 #define YIELD_PROCESSOR YieldProcessor()
 #define YIELD_THREAD SwitchToThread()
-#elif defined(COMPILER_GCC) || defined(__clang__)
+
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
+
 #if defined(ARCH_CPU_X86_64) || defined(ARCH_CPU_X86)
 #define YIELD_PROCESSOR __asm__ __volatile__("pause")
 #elif (defined(ARCH_CPU_ARMEL) && __ARM_ARCH >= 6) || defined(ARCH_CPU_ARM64)
@@ -44,22 +48,21 @@
 #elif defined(ARCH_CPU_S390_FAMILY)
 // just do nothing
 #define YIELD_PROCESSOR ((void)0)
-#endif
-#endif
+#endif  // ARCH
 
 #ifndef YIELD_PROCESSOR
 #warning "Processor yield not supported on this architecture."
 #define YIELD_PROCESSOR ((void)0)
 #endif
 
-#ifndef YIELD_THREAD
-#if defined(OS_POSIX)
 #define YIELD_THREAD sched_yield()
-#else
+
+#else  // Other OS
+
 #warning "Thread yield not supported on this OS."
 #define YIELD_THREAD ((void)0)
-#endif
-#endif
+
+#endif  // OS_WIN
 
 namespace base {
 namespace subtle {
diff --git a/base/base_paths.h b/base/base_paths.h
index b4a19b4..2a163f4 100644
--- a/base/base_paths.h
+++ b/base/base_paths.h
@@ -18,7 +18,7 @@
 #include "base/base_paths_android.h"
 #endif
 
-#if defined(OS_POSIX)
+#if defined(OS_POSIX) || defined(OS_FUCHSIA)
 #include "base/base_paths_posix.h"
 #endif
 
diff --git a/base/command_line.cc b/base/command_line.cc
index 3a5d089b..aec89f5 100644
--- a/base/command_line.cc
+++ b/base/command_line.cc
@@ -38,7 +38,7 @@
 // value by changing the value of switch_prefix_count to be one less than
 // the array size.
 const CommandLine::CharType* const kSwitchPrefixes[] = {L"--", L"-", L"/"};
-#elif defined(OS_POSIX)
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
 // Unixes don't use slash as a switch.
 const CommandLine::CharType* const kSwitchPrefixes[] = {"--", "-"};
 #endif
@@ -79,7 +79,7 @@
     CommandLine::StringType arg = argv[i];
 #if defined(OS_WIN)
     TrimWhitespace(arg, TRIM_ALL, &arg);
-#else
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
     TrimWhitespaceASCII(arg, TRIM_ALL, &arg);
 #endif
 
@@ -90,8 +90,10 @@
 #if defined(OS_WIN)
       command_line->AppendSwitchNative(UTF16ToASCII(switch_string),
                                        switch_value);
-#elif defined(OS_POSIX)
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
       command_line->AppendSwitchNative(switch_string, switch_value);
+#else
+#error Unsupported platform
 #endif
     } else {
       command_line->AppendArgNative(arg);
@@ -212,8 +214,10 @@
   current_process_commandline_ = new CommandLine(NO_PROGRAM);
 #if defined(OS_WIN)
   current_process_commandline_->ParseFromString(::GetCommandLineW());
-#elif defined(OS_POSIX)
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
   current_process_commandline_->InitFromArgv(argc, argv);
+#else
+#error Unsupported platform
 #endif
 
   return true;
@@ -269,8 +273,10 @@
 void CommandLine::SetProgram(const FilePath& program) {
 #if defined(OS_WIN)
   TrimWhitespace(program.value(), TRIM_ALL, &argv_[0]);
-#else
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
   TrimWhitespaceASCII(program.value(), TRIM_ALL, &argv_[0]);
+#else
+#error Unsupported platform
 #endif
 }
 
@@ -292,7 +298,7 @@
   }
 #if defined(OS_WIN)
   return UTF16ToASCII(value);
-#else
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
   return value;
 #endif
 }
@@ -323,7 +329,7 @@
 #if defined(OS_WIN)
   const std::string switch_key = ToLowerASCII(switch_string);
   StringType combined_switch_string(ASCIIToUTF16(switch_key));
-#elif defined(OS_POSIX)
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
   const std::string& switch_key = switch_string;
   StringType combined_switch_string(switch_key);
 #endif
@@ -345,8 +351,10 @@
                                     const std::string& value_string) {
 #if defined(OS_WIN)
   AppendSwitchNative(switch_string, ASCIIToUTF16(value_string));
-#elif defined(OS_POSIX)
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
   AppendSwitchNative(switch_string, value_string);
+#else
+#error Unsupported platform
 #endif
 }
 
@@ -374,8 +382,10 @@
 #if defined(OS_WIN)
   DCHECK(IsStringUTF8(value));
   AppendArgNative(UTF8ToWide(value));
-#elif defined(OS_POSIX)
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
   AppendArgNative(value);
+#else
+#error Unsupported platform
 #endif
 }
 
diff --git a/base/command_line.h b/base/command_line.h
index aef9bad..25fd7d9 100644
--- a/base/command_line.h
+++ b/base/command_line.h
@@ -34,7 +34,7 @@
 #if defined(OS_WIN)
   // The native command line string type.
   using StringType = string16;
-#elif defined(OS_POSIX)
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
   using StringType = std::string;
 #endif
 
diff --git a/base/command_line_unittest.cc b/base/command_line_unittest.cc
index 6785350..3718cd9 100644
--- a/base/command_line_unittest.cc
+++ b/base/command_line_unittest.cc
@@ -208,7 +208,7 @@
   CommandLine::StringType expected_third_arg(UTF8ToUTF16(kThirdArgName));
   CommandLine::StringType expected_fourth_arg(UTF8ToUTF16(kFourthArgName));
   CommandLine::StringType expected_fifth_arg(UTF8ToUTF16(kFifthArgName));
-#elif defined(OS_POSIX)
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
   CommandLine::StringType expected_first_arg(kFirstArgName);
   CommandLine::StringType expected_second_arg(kSecondArgName);
   CommandLine::StringType expected_third_arg(kThirdArgName);
diff --git a/base/environment.cc b/base/environment.cc
index f6655d9..cdea53c8 100644
--- a/base/environment.cc
+++ b/base/environment.cc
@@ -14,10 +14,10 @@
 #include "base/strings/utf_string_conversions.h"
 #include "build/build_config.h"
 
-#if defined(OS_POSIX)
-#include <stdlib.h>
-#elif defined(OS_WIN)
+#if defined(OS_WIN)
 #include <windows.h>
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
+#include <stdlib.h>
 #endif
 
 namespace base {
@@ -56,15 +56,7 @@
 
  private:
   bool GetVarImpl(StringPiece variable_name, std::string* result) {
-#if defined(OS_POSIX)
-    const char* env_value = getenv(variable_name.data());
-    if (!env_value)
-      return false;
-    // Note that the variable may be defined but empty.
-    if (result)
-      *result = env_value;
-    return true;
-#elif defined(OS_WIN)
+#if defined(OS_WIN)
     DWORD value_length =
         ::GetEnvironmentVariable(UTF8ToWide(variable_name).c_str(), nullptr, 0);
     if (value_length == 0)
@@ -76,29 +68,35 @@
       *result = WideToUTF8(value.get());
     }
     return true;
-#else
-#error need to port
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
+    const char* env_value = getenv(variable_name.data());
+    if (!env_value)
+      return false;
+    // Note that the variable may be defined but empty.
+    if (result)
+      *result = env_value;
+    return true;
 #endif
   }
 
   bool SetVarImpl(StringPiece variable_name, const std::string& new_value) {
-#if defined(OS_POSIX)
-    // On success, zero is returned.
-    return !setenv(variable_name.data(), new_value.c_str(), 1);
-#elif defined(OS_WIN)
+#if defined(OS_WIN)
     // On success, a nonzero value is returned.
     return !!SetEnvironmentVariable(UTF8ToWide(variable_name).c_str(),
                                     UTF8ToWide(new_value).c_str());
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
+    // On success, zero is returned.
+    return !setenv(variable_name.data(), new_value.c_str(), 1);
 #endif
   }
 
   bool UnSetVarImpl(StringPiece variable_name) {
-#if defined(OS_POSIX)
-    // On success, zero is returned.
-    return !unsetenv(variable_name.data());
-#elif defined(OS_WIN)
+#if defined(OS_WIN)
     // On success, a nonzero value is returned.
     return !!SetEnvironmentVariable(UTF8ToWide(variable_name).c_str(), nullptr);
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
+    // On success, zero is returned.
+    return !unsetenv(variable_name.data());
 #endif
   }
 };
@@ -124,7 +122,7 @@
 
 namespace env_vars {
 
-#if defined(OS_POSIX)
+#if defined(OS_POSIX) || defined(OS_FUCHSIA)
 // On Posix systems, this variable contains the location of the user's home
 // directory. (e.g, /home/username/).
 const char kHome[] = "HOME";
@@ -183,7 +181,7 @@
   return result;
 }
 
-#elif defined(OS_POSIX)
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
 
 std::unique_ptr<char* []> AlterEnvironment(const char* const* const env,
                                            const EnvironmentMap& changes) {
@@ -235,6 +233,6 @@
   return result;
 }
 
-#endif  // OS_POSIX
+#endif  // OS_WIN
 
 }  // namespace base
diff --git a/base/environment.h b/base/environment.h
index 3a4ed04..e842ab08 100644
--- a/base/environment.h
+++ b/base/environment.h
@@ -18,7 +18,7 @@
 
 namespace env_vars {
 
-#if defined(OS_POSIX)
+#if defined(OS_POSIX) || defined(OS_FUCHSIA)
 BASE_EXPORT extern const char kHome[];
 #endif
 
@@ -66,7 +66,7 @@
 BASE_EXPORT string16 AlterEnvironment(const wchar_t* env,
                                       const EnvironmentMap& changes);
 
-#elif defined(OS_POSIX)
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
 
 typedef std::string NativeEnvironmentString;
 typedef std::map<NativeEnvironmentString, NativeEnvironmentString>
diff --git a/base/files/file.cc b/base/files/file.cc
index c1ce182f..1a4ee370 100644
--- a/base/files/file.cc
+++ b/base/files/file.cc
@@ -9,7 +9,7 @@
 #include "base/timer/elapsed_timer.h"
 #include "build/build_config.h"
 
-#if defined(OS_POSIX)
+#if defined(OS_POSIX) || defined(OS_FUCHSIA)
 #include <errno.h>
 #endif
 
@@ -41,7 +41,7 @@
       error_details_(FILE_OK),
       created_(false),
       async_(false) {
-#if defined(OS_POSIX)
+#if defined(OS_POSIX) || defined(OS_FUCHSIA)
   DCHECK_GE(platform_file, -1);
 #endif
 }
@@ -88,7 +88,7 @@
   if (path.ReferencesParent()) {
 #if defined(OS_WIN)
     ::SetLastError(ERROR_ACCESS_DENIED);
-#elif defined(OS_POSIX)
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
     errno = EACCES;
 #else
 #error Unsupported platform
diff --git a/base/files/file.h b/base/files/file.h
index bb46aa0f..c3a31d8 100644
--- a/base/files/file.h
+++ b/base/files/file.h
@@ -18,7 +18,7 @@
 #include "base/time/time.h"
 #include "build/build_config.h"
 
-#if defined(OS_POSIX)
+#if defined(OS_POSIX) || defined(OS_FUCHSIA)
 #include <sys/stat.h>
 #endif
 
@@ -27,7 +27,7 @@
 #if defined(OS_BSD) || defined(OS_MACOSX) || defined(OS_NACL) || \
     defined(OS_ANDROID) && __ANDROID_API__ < 21
 typedef struct stat stat_wrapper_t;
-#elif defined(OS_POSIX)
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
 typedef struct stat64 stat_wrapper_t;
 #endif
 
@@ -122,7 +122,7 @@
   struct BASE_EXPORT Info {
     Info();
     ~Info();
-#if defined(OS_POSIX)
+#if defined(OS_POSIX) || defined(OS_FUCHSIA)
     // Fills this struct with values from |stat_info|.
     void FromStat(const stat_wrapper_t& stat_info);
 #endif
@@ -331,7 +331,7 @@
 
 #if defined(OS_WIN)
   static Error OSErrorToFileError(DWORD last_error);
-#elif defined(OS_POSIX)
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
   static Error OSErrorToFileError(int saved_errno);
 #endif
 
diff --git a/base/files/file_enumerator.h b/base/files/file_enumerator.h
index 190a0612..0fa99a68 100644
--- a/base/files/file_enumerator.h
+++ b/base/files/file_enumerator.h
@@ -19,7 +19,7 @@
 
 #if defined(OS_WIN)
 #include <windows.h>
-#elif defined(OS_POSIX)
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
 #include <sys/stat.h>
 #include <unistd.h>
 #endif
@@ -60,7 +60,7 @@
     // of the WIN32_FIND_DATA will be empty. Since we don't use short file
     // names, we tell Windows to omit it which speeds up the query slightly.
     const WIN32_FIND_DATA& find_data() const { return find_data_; }
-#elif defined(OS_POSIX)
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
     const struct stat& stat() const { return stat_; }
 #endif
 
@@ -69,18 +69,18 @@
 
 #if defined(OS_WIN)
     WIN32_FIND_DATA find_data_;
-#elif defined(OS_POSIX)
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
     struct stat stat_;
     FilePath filename_;
 #endif
   };
 
   enum FileType {
-    FILES                 = 1 << 0,
-    DIRECTORIES           = 1 << 1,
-    INCLUDE_DOT_DOT       = 1 << 2,
-#if defined(OS_POSIX)
-    SHOW_SYM_LINKS        = 1 << 4,
+    FILES = 1 << 0,
+    DIRECTORIES = 1 << 1,
+    INCLUDE_DOT_DOT = 1 << 2,
+#if defined(OS_POSIX) || defined(OS_FUCHSIA)
+    SHOW_SYM_LINKS = 1 << 4,
 #endif
   };
 
@@ -149,7 +149,7 @@
   bool has_find_data_ = false;
   WIN32_FIND_DATA find_data_;
   HANDLE find_handle_ = INVALID_HANDLE_VALUE;
-#elif defined(OS_POSIX)
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
   // The files in the current directory
   std::vector<FileInfo> directory_entries_;
 
diff --git a/base/files/file_path.cc b/base/files/file_path.cc
index 29a0b40..14f9251 100644
--- a/base/files/file_path.cc
+++ b/base/files/file_path.cc
@@ -423,7 +423,7 @@
   DCHECK(IsStringASCII(suffix));
 #if defined(OS_WIN)
   return InsertBeforeExtension(ASCIIToUTF16(suffix));
-#elif defined(OS_POSIX)
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
   return InsertBeforeExtension(suffix);
 #endif
 }
@@ -526,7 +526,7 @@
   DCHECK(base::IsStringASCII(component));
 #if defined(OS_WIN)
   return Append(ASCIIToUTF16(component));
-#elif defined(OS_POSIX)
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
   return Append(component);
 #endif
 }
@@ -586,7 +586,38 @@
   return false;
 }
 
-#if defined(OS_POSIX)
+#if defined(OS_WIN)
+
+string16 FilePath::LossyDisplayName() const {
+  return path_;
+}
+
+std::string FilePath::MaybeAsASCII() const {
+  if (base::IsStringASCII(path_))
+    return UTF16ToASCII(path_);
+  return std::string();
+}
+
+std::string FilePath::AsUTF8Unsafe() const {
+  return WideToUTF8(value());
+}
+
+string16 FilePath::AsUTF16Unsafe() const {
+  return value();
+}
+
+// static
+FilePath FilePath::FromUTF8Unsafe(StringPiece utf8) {
+  return FilePath(UTF8ToWide(utf8));
+}
+
+// static
+FilePath FilePath::FromUTF16Unsafe(StringPiece16 utf16) {
+  return FilePath(utf16);
+}
+
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
+
 // See file_path.h for a discussion of the encoding of paths on POSIX
 // platforms.  These encoding conversion functions are not quite correct.
 
@@ -634,41 +665,15 @@
 #endif
 }
 
-#elif defined(OS_WIN)
-string16 FilePath::LossyDisplayName() const {
-  return path_;
-}
-
-std::string FilePath::MaybeAsASCII() const {
-  if (base::IsStringASCII(path_))
-    return UTF16ToASCII(path_);
-  return std::string();
-}
-
-std::string FilePath::AsUTF8Unsafe() const {
-  return WideToUTF8(value());
-}
-
-string16 FilePath::AsUTF16Unsafe() const {
-  return value();
-}
-
-// static
-FilePath FilePath::FromUTF8Unsafe(StringPiece utf8) {
-  return FilePath(UTF8ToWide(utf8));
-}
-
-// static
-FilePath FilePath::FromUTF16Unsafe(StringPiece16 utf16) {
-  return FilePath(utf16);
-}
-#endif
+#endif  // defined(OS_WIN)
 
 void FilePath::WriteToPickle(Pickle* pickle) const {
 #if defined(OS_WIN)
   pickle->WriteString16(path_);
-#else
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
   pickle->WriteString(path_);
+#else
+#error Unsupported platform
 #endif
 }
 
@@ -676,9 +681,11 @@
 #if defined(OS_WIN)
   if (!iter->ReadString16(&path_))
     return false;
-#else
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
   if (!iter->ReadString(&path_))
     return false;
+#else
+#error Unsupported platform
 #endif
 
   if (path_.find(kStringTerminator) != StringType::npos)
@@ -1268,7 +1275,7 @@
   return HFSFastUnicodeCompare(hfs1, hfs2);
 }
 
-#else  // << WIN. MACOSX | other (POSIX) >>
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
 
 // Generic Posix system comparisons.
 int FilePath::CompareIgnoreCase(StringPieceType string1,
diff --git a/base/files/file_path.h b/base/files/file_path.h
index 6cb2e75..2dc15f9 100644
--- a/base/files/file_path.h
+++ b/base/files/file_path.h
@@ -127,10 +127,10 @@
 // To print path names portably use PRIsFP (based on PRIuS and friends from
 // C99 and format_macros.h) like this:
 // base::StringPrintf("Path is %" PRIsFP ".\n", path.value().c_str());
-#if defined(OS_POSIX)
-#define PRIsFP "s"
-#elif defined(OS_WIN)
+#if defined(OS_WIN)
 #define PRIsFP "ls"
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
+#define PRIsFP "s"
 #endif  // OS_WIN
 
 namespace base {
@@ -142,15 +142,15 @@
 // pathnames on different platforms.
 class BASE_EXPORT FilePath {
  public:
-#if defined(OS_POSIX)
+#if defined(OS_WIN)
+  // On Windows, for Unicode-aware applications, native pathnames are wchar_t
+  // arrays encoded in UTF-16.
+  typedef std::wstring StringType;
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
   // On most platforms, native pathnames are char arrays, and the encoding
   // may or may not be specified.  On Mac OS X, native pathnames are encoded
   // in UTF-8.
   typedef std::string StringType;
-#elif defined(OS_WIN)
-  // On Windows, for Unicode-aware applications, native pathnames are wchar_t
-  // arrays encoded in UTF-16.
-  typedef std::wstring StringType;
 #endif  // OS_WIN
 
   typedef BasicStringPiece<StringType> StringPieceType;
@@ -457,12 +457,12 @@
 
 // Macros for string literal initialization of FilePath::CharType[], and for
 // using a FilePath::CharType[] in a printf-style format string.
-#if defined(OS_POSIX)
-#define FILE_PATH_LITERAL(x) x
-#define PRFilePath "s"
-#elif defined(OS_WIN)
+#if defined(OS_WIN)
 #define FILE_PATH_LITERAL(x) L ## x
 #define PRFilePath "ls"
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
+#define FILE_PATH_LITERAL(x) x
+#define PRFilePath "s"
 #endif  // OS_WIN
 
 namespace std {
diff --git a/base/files/file_path_unittest.cc b/base/files/file_path_unittest.cc
index 6ca652c..e722c68 100644
--- a/base/files/file_path_unittest.cc
+++ b/base/files/file_path_unittest.cc
@@ -13,7 +13,7 @@
 #include "testing/gtest/include/gtest/gtest.h"
 #include "testing/platform_test.h"
 
-#if defined(OS_POSIX)
+#if defined(OS_POSIX) || defined(OS_FUCHSIA)
 #include "base/test/scoped_locale.h"
 #endif
 
@@ -321,7 +321,7 @@
     // handle the case when AppendASCII is passed UTF8
 #if defined(OS_WIN)
     std::string ascii = WideToUTF8(leaf);
-#elif defined(OS_POSIX)
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
     std::string ascii = leaf;
 #endif
     observed_str = root.AppendASCII(ascii);
diff --git a/base/files/file_util.h b/base/files/file_util.h
index cd8a1ba5..78e666b 100644
--- a/base/files/file_util.h
+++ b/base/files/file_util.h
@@ -16,6 +16,11 @@
 #include <string>
 #include <vector>
 
+#if defined(OS_POSIX) || defined(OS_FUCHSIA)
+#include <sys/stat.h>
+#include <unistd.h>
+#endif
+
 #include "base/base_export.h"
 #include "base/files/file.h"
 #include "base/files/file_path.h"
@@ -24,12 +29,7 @@
 
 #if defined(OS_WIN)
 #include "base/win/windows_types.h"
-#elif defined(OS_POSIX)
-#include <sys/stat.h>
-#include <unistd.h>
-#endif
-
-#if defined(OS_POSIX)
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
 #include "base/file_descriptor_posix.h"
 #include "base/logging.h"
 #include "base/posix/eintr_wrapper.h"
@@ -178,7 +178,7 @@
                                              std::string* contents,
                                              size_t max_size);
 
-#if defined(OS_POSIX)
+#if defined(OS_POSIX) || defined(OS_FUCHSIA)
 
 // Read exactly |bytes| bytes from file descriptor |fd|, storing the result
 // in |buffer|. This function is protected against EINTR and partial reads.
@@ -191,9 +191,12 @@
 BASE_EXPORT int CreateAndOpenFdForTemporaryFileInDir(const FilePath& dir,
                                                      FilePath* path);
 
+#endif  // OS_POSIX || OS_FUCHSIA
+
 // The following functions use POSIX functionality that isn't supported by
 // Fuchsia.
-#if !defined(OS_FUCHSIA)
+// TODO(crbug/836416): Remove OS_FUCHSIA here.
+#if defined(OS_POSIX) && !defined(OS_FUCHSIA)
 
 // Creates a symbolic link at |symlink| pointing to |target|.  Returns
 // false on failure.
@@ -235,8 +238,7 @@
 BASE_EXPORT bool ExecutableExistsInPath(Environment* env,
                                         const FilePath::StringType& executable);
 
-#endif  // !OS_FUCHSIA
-#endif  // OS_POSIX
+#endif  // OS_POSIX && !OS_FUCHSIA
 
 // Returns true if the given directory is empty
 BASE_EXPORT bool IsDirectoryEmpty(const FilePath& dir_path);
@@ -363,7 +365,7 @@
 BASE_EXPORT int WriteFile(const FilePath& filename, const char* data,
                           int size);
 
-#if defined(OS_POSIX)
+#if defined(OS_POSIX) || defined(OS_FUCHSIA)
 // Appends |data| to |fd|. Does not close |fd| when done.  Returns true iff
 // |size| bytes of |data| were written to |fd|.
 BASE_EXPORT bool WriteFileDescriptor(const int fd, const char* data, int size);
@@ -393,7 +395,7 @@
 // false.
 BASE_EXPORT bool SetNonBlocking(int fd);
 
-#if defined(OS_POSIX)
+#if defined(OS_POSIX) || defined(OS_FUCHSIA)
 // Creates a non-blocking, close-on-exec pipe.
 // This creates a non-blocking pipe that is not intended to be shared with any
 // child process. This will be done atomically if the operating system supports
@@ -420,7 +422,7 @@
                                             const base::FilePath& path,
                                             uid_t owner_uid,
                                             const std::set<gid_t>& group_gids);
-#endif  // defined(OS_POSIX)
+#endif  // defined(OS_POSIX) || defined(OS_FUCHSIA)
 
 #if defined(OS_MACOSX) && !defined(OS_IOS)
 // Is |path| writable only by a user with administrator privileges?
@@ -457,7 +459,7 @@
 BASE_EXPORT bool GetFileSystemType(const FilePath& path, FileSystemType* type);
 #endif
 
-#if defined(OS_POSIX)
+#if defined(OS_POSIX) || defined(OS_FUCHSIA)
 // Get a temporary directory for shared memory files. The directory may depend
 // on whether the destination is intended for executable files, which in turn
 // depends on how /dev/shmem was mounted. As a result, you must supply whether
diff --git a/base/files/file_util_unittest.cc b/base/files/file_util_unittest.cc
index d80c6cba..08d3df6 100644
--- a/base/files/file_util_unittest.cc
+++ b/base/files/file_util_unittest.cc
@@ -50,7 +50,7 @@
 #include "base/win/win_util.h"
 #endif
 
-#if defined(OS_POSIX)
+#if defined(OS_POSIX) || defined(OS_FUCHSIA)
 #include <errno.h>
 #include <fcntl.h>
 #include <sys/ioctl.h>
@@ -324,7 +324,7 @@
   DWORD info = 0;
   ASSERT_EQ(TRUE, ::GetHandleInformation(handle, &info));
   *is_inheritable = ((info & HANDLE_FLAG_INHERIT) != 0);
-#elif defined(OS_POSIX)
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
   int fd = fileno(stream);
   ASSERT_NE(-1, fd);
   int flags = fcntl(fd, F_GETFD, 0);
@@ -637,6 +637,7 @@
 
 #endif  // defined(OS_WIN)
 
+// TODO(crbug/836416): Remove OS_FUCHSIA here.
 #if !defined(OS_FUCHSIA) && defined(OS_POSIX)
 
 TEST_F(FileUtilTest, CreateAndReadSymlinks) {
@@ -1918,7 +1919,7 @@
 #if defined(OS_WIN)
   FilePath from_path =
       temp_dir_.GetPath().Append(FILE_PATH_LITERAL("Copy_From_Subdir\\\\\\"));
-#elif defined(OS_POSIX)
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
   FilePath from_path =
       temp_dir_.GetPath().Append(FILE_PATH_LITERAL("Copy_From_Subdir///"));
 #endif
@@ -1932,6 +1933,7 @@
   EXPECT_TRUE(PathExists(file_name_to));
 }
 
+// TODO(crbug/836416): Remove OS_FUCHSIA here.
 #if !defined(OS_FUCHSIA) && defined(OS_POSIX)
 TEST_F(FileUtilTest, CopyDirectoryWithNonRegularFiles) {
   // Create a directory.
@@ -2451,7 +2453,7 @@
   EXPECT_TRUE(DeleteFile(new_dir, false));
 }
 
-#if defined(OS_POSIX)
+#if defined(OS_POSIX) || defined(OS_FUCHSIA)
 TEST_F(FileUtilTest, GetShmemTempDirTest) {
   FilePath dir;
   EXPECT_TRUE(GetShmemTempDir(false, &dir));
@@ -2476,7 +2478,7 @@
 #if defined(OS_WIN)
   FilePath test_path =
       test_root.Append(FILE_PATH_LITERAL("dir\\tree\\likely\\doesnt\\exist\\"));
-#elif defined(OS_POSIX)
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
   FilePath test_path =
       test_root.Append(FILE_PATH_LITERAL("dir/tree/likely/doesnt/exist/"));
 #endif
@@ -3279,7 +3281,7 @@
   EXPECT_FALSE(IsDirectoryEmpty(empty_dir));
 }
 
-#if defined(OS_POSIX)
+#if defined(OS_POSIX) || defined(OS_FUCHSIA)
 
 TEST_F(FileUtilTest, SetNonBlocking) {
   const int kInvalidFd = 99999;
@@ -3307,6 +3309,7 @@
 
 #endif
 
+// TODO(crbug/836416): Remove OS_FUCHSIA here.
 #if defined(OS_POSIX) && !defined(OS_FUCHSIA)
 
 // Testing VerifyPathControlledByAdmin() is hard, because there is no
@@ -3637,7 +3640,7 @@
 }
 #endif
 
-#if defined(OS_POSIX)
+#if defined(OS_POSIX) || defined(OS_FUCHSIA)
 
 TEST(ScopedFD, ScopedFDDoesClose) {
   int fds[2];
@@ -3676,7 +3679,7 @@
 #endif
 }
 
-#endif  // defined(OS_POSIX)
+#endif  // defined(OS_POSIX) || defined(OS_FUCHSIA)
 
 }  // namespace
 
diff --git a/base/files/platform_file.h b/base/files/platform_file.h
index 4b8b539b..3929a0d 100644
--- a/base/files/platform_file.h
+++ b/base/files/platform_file.h
@@ -29,7 +29,7 @@
 // disallowed in constexpr. Visual Studio accepts this, however.
 const PlatformFile kInvalidPlatformFile = INVALID_HANDLE_VALUE;
 
-#elif defined(OS_POSIX)
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
 
 using PlatformFile = int;
 using ScopedPlatformFile = ::base::ScopedFD;
diff --git a/base/files/scoped_file.cc b/base/files/scoped_file.cc
index df702bd..627061f 100644
--- a/base/files/scoped_file.cc
+++ b/base/files/scoped_file.cc
@@ -7,7 +7,7 @@
 #include "base/logging.h"
 #include "build/build_config.h"
 
-#if defined(OS_POSIX)
+#if defined(OS_POSIX) || defined(OS_FUCHSIA)
 #include <errno.h>
 #include <unistd.h>
 
@@ -17,7 +17,7 @@
 namespace base {
 namespace internal {
 
-#if defined(OS_POSIX)
+#if defined(OS_POSIX) || defined(OS_FUCHSIA)
 
 // static
 void ScopedFDCloseTraits::Free(int fd) {
@@ -42,7 +42,7 @@
   PCHECK(0 == ret);
 }
 
-#endif  // OS_POSIX
+#endif  // OS_POSIX || OS_FUCHSIA
 
 }  // namespace internal
 }  // namespace base
diff --git a/base/files/scoped_file.h b/base/files/scoped_file.h
index 68c04158..e32a6039 100644
--- a/base/files/scoped_file.h
+++ b/base/files/scoped_file.h
@@ -18,7 +18,7 @@
 
 namespace internal {
 
-#if defined(OS_POSIX)
+#if defined(OS_POSIX) || defined(OS_FUCHSIA)
 struct BASE_EXPORT ScopedFDCloseTraits {
   static int InvalidValue() {
     return -1;
@@ -39,7 +39,7 @@
 
 // -----------------------------------------------------------------------------
 
-#if defined(OS_POSIX)
+#if defined(OS_POSIX) || defined(OS_FUCHSIA)
 // A low-level Posix file descriptor closer class. Use this when writing
 // platform-specific code, especially that does non-file-like things with the
 // FD (like sockets).
diff --git a/base/format_macros.h b/base/format_macros.h
index 0697c6d..1279ff7 100644
--- a/base/format_macros.h
+++ b/base/format_macros.h
@@ -26,19 +26,33 @@
 
 #include "build/build_config.h"
 
-#if defined(OS_POSIX) && (defined(_INTTYPES_H) || defined(_INTTYPES_H_)) && \
-    !defined(PRId64)
+#if (defined(OS_POSIX) || defined(OS_FUCHSIA)) && \
+    (defined(_INTTYPES_H) || defined(_INTTYPES_H_)) && !defined(PRId64)
 #error "inttypes.h has already been included before this header file, but "
 #error "without __STDC_FORMAT_MACROS defined."
 #endif
 
-#if defined(OS_POSIX) && !defined(__STDC_FORMAT_MACROS)
+#if (defined(OS_POSIX) || defined(OS_FUCHSIA)) && !defined(__STDC_FORMAT_MACROS)
 #define __STDC_FORMAT_MACROS
 #endif
 
 #include <inttypes.h>
 
-#if defined(OS_POSIX)
+#if defined(OS_WIN)
+
+#if !defined(PRId64) || !defined(PRIu64) || !defined(PRIx64)
+#error "inttypes.h provided by win toolchain should define these."
+#endif
+
+#define WidePRId64 L"I64d"
+#define WidePRIu64 L"I64u"
+#define WidePRIx64 L"I64x"
+
+#if !defined(PRIuS)
+#define PRIuS "Iu"
+#endif
+
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
 
 // GCC will concatenate wide and narrow strings correctly, so nothing needs to
 // be done here.
@@ -50,6 +64,8 @@
 #define PRIuS "zu"
 #endif
 
+#endif  // defined(OS_WIN)
+
 // The size of NSInteger and NSUInteger varies between 32-bit and 64-bit
 // architectures and Apple does not provides standard format macros and
 // recommends casting. This has many drawbacks, so instead define macros
@@ -78,20 +94,4 @@
 #endif
 #endif  // defined(OS_MACOSX)
 
-#else  // OS_WIN
-
-#if !defined(PRId64) || !defined(PRIu64) || !defined(PRIx64)
-#error "inttypes.h provided by win toolchain should define these."
-#endif
-
-#define WidePRId64 L"I64d"
-#define WidePRIu64 L"I64u"
-#define WidePRIx64 L"I64x"
-
-#if !defined(PRIuS)
-#define PRIuS "Iu"
-#endif
-
-#endif
-
 #endif  // BASE_FORMAT_MACROS_H_
diff --git a/base/i18n/file_util_icu.cc b/base/i18n/file_util_icu.cc
index c154204..c91aea1a 100644
--- a/base/i18n/file_util_icu.cc
+++ b/base/i18n/file_util_icu.cc
@@ -119,12 +119,14 @@
     // Windows uses UTF-16 encoding for filenames.
     U16_NEXT(file_name->data(), cursor, static_cast<int>(file_name->length()),
              code_point);
-#else
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
     // Mac and Chrome OS use UTF-8 encoding for filenames.
     // Linux doesn't actually define file system encoding. Try to parse as
     // UTF-8.
     U8_NEXT(file_name->data(), cursor, static_cast<int>(file_name->length()),
             code_point);
+#else
+#error Unsupported platform
 #endif
 
     if (illegal->DisallowedEverywhere(code_point) ||
@@ -153,14 +155,12 @@
   return CompareString16WithCollator(*collator, WideToUTF16(a.value()),
                                      WideToUTF16(b.value())) == UCOL_LESS;
 
-#elif defined(OS_POSIX)
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
   // On linux, the file system encoding is not defined. We assume
   // SysNativeMBToWide takes care of it.
   return CompareString16WithCollator(
              *collator, WideToUTF16(SysNativeMBToWide(a.value())),
              WideToUTF16(SysNativeMBToWide(b.value()))) == UCOL_LESS;
-#else
-  #error Not implemented on your system
 #endif
 }
 
diff --git a/base/logging.cc b/base/logging.cc
index 2dac3e2..8eabda0 100644
--- a/base/logging.cc
+++ b/base/logging.cc
@@ -46,14 +46,23 @@
 #include <mach/mach_time.h>
 #include <mach-o/dyld.h>
 
-#elif defined(OS_POSIX)
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
 #if defined(OS_NACL)
 #include <sys/time.h>  // timespec doesn't seem to be in <time.h>
 #endif
 #include <time.h>
 #endif
 
-#if defined(OS_POSIX)
+#if defined(OS_FUCHSIA)
+#include <zircon/process.h>
+#include <zircon/syscalls.h>
+#endif
+
+#if defined(OS_ANDROID)
+#include <android/log.h>
+#endif
+
+#if defined(OS_POSIX) || defined(OS_FUCHSIA)
 #include <errno.h>
 #include <paths.h>
 #include <pthread.h>
@@ -93,19 +102,11 @@
 #include "base/synchronization/lock_impl.h"
 #include "base/threading/platform_thread.h"
 #include "base/vlog.h"
-#if defined(OS_POSIX)
+
+#if defined(OS_POSIX) || defined(OS_FUCHSIA)
 #include "base/posix/safe_strerror.h"
 #endif
 
-#if defined(OS_ANDROID)
-#include <android/log.h>
-#endif
-
-#if defined(OS_FUCHSIA)
-#include <zircon/process.h>
-#include <zircon/syscalls.h>
-#endif
-
 namespace logging {
 
 namespace {
@@ -135,7 +136,7 @@
 // first needed.
 #if defined(OS_WIN)
 typedef std::wstring PathString;
-#else
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
 typedef std::string PathString;
 #endif
 PathString* g_log_file_name = nullptr;
@@ -179,11 +180,11 @@
 uint64_t TickCount() {
 #if defined(OS_WIN)
   return GetTickCount();
-#elif defined(OS_MACOSX)
-  return mach_absolute_time();
 #elif defined(OS_FUCHSIA)
   return zx_clock_get(ZX_CLOCK_MONOTONIC) /
          static_cast<zx_time_t>(base::Time::kNanosecondsPerMicrosecond);
+#elif defined(OS_MACOSX)
+  return mach_absolute_time();
 #elif defined(OS_NACL)
   // NaCl sadly does not have _POSIX_TIMERS enabled in sys/features.h
   // So we have to use clock() for now.
@@ -204,8 +205,10 @@
   DeleteFile(log_name.c_str());
 #elif defined(OS_NACL)
   // Do nothing; unlink() isn't supported on NaCl.
-#else
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
   unlink(log_name.c_str());
+#else
+#error Unsupported platform
 #endif
 }
 
@@ -221,7 +224,7 @@
     log_name.erase(last_backslash + 1);
   log_name += L"debug.log";
   return log_name;
-#elif defined(OS_POSIX)
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
   // On other platforms we just use the current directory.
   return PathString("debug.log");
 #endif
@@ -229,7 +232,7 @@
 
 // We don't need locks on Windows for atomically appending to files. The OS
 // provides this functionality.
-#if !defined(OS_WIN)
+#if defined(OS_POSIX) || defined(OS_FUCHSIA)
 // This class acts as a wrapper for locking the logging files.
 // LoggingLock::Init() should be called from the main thread before any logging
 // is done. Then whenever logging, be sure to have a local LoggingLock
@@ -260,9 +263,7 @@
  private:
   static void LockLogging() {
     if (lock_log_file == LOCK_LOG_FILE) {
-#if defined(OS_POSIX)
       pthread_mutex_lock(&log_mutex);
-#endif
     } else {
       // use the lock
       log_lock->Lock();
@@ -271,9 +272,7 @@
 
   static void UnlockLogging() {
     if (lock_log_file == LOCK_LOG_FILE) {
-#if defined(OS_POSIX)
       pthread_mutex_unlock(&log_mutex);
-#endif
     } else {
       log_lock->Unlock();
     }
@@ -286,9 +285,7 @@
 
   // When we don't use a lock, we are using a global mutex. We need to do this
   // because LockFileEx is not thread safe.
-#if defined(OS_POSIX)
   static pthread_mutex_t log_mutex;
-#endif
 
   static bool initialized;
   static LogLockingState lock_log_file;
@@ -301,11 +298,9 @@
 // static
 LogLockingState LoggingLock::lock_log_file = LOCK_LOG_FILE;
 
-#if defined(OS_POSIX)
 pthread_mutex_t LoggingLock::log_mutex = PTHREAD_MUTEX_INITIALIZER;
-#endif
 
-#endif  // OS_WIN
+#endif  // OS_POSIX || OS_FUCHSIA
 
 // Called by logging functions to ensure that |g_log_file| is initialized
 // and can be used for writing. Returns false if the file could not be
@@ -357,10 +352,12 @@
         return false;
       }
     }
-#elif defined(OS_POSIX)
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
     g_log_file = fopen(g_log_file_name->c_str(), "a");
     if (g_log_file == nullptr)
       return false;
+#else
+#error Unsupported platform
 #endif
   }
 
@@ -370,8 +367,10 @@
 void CloseFile(FileHandle log) {
 #if defined(OS_WIN)
   CloseHandle(log);
-#else
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
   fclose(log);
+#else
+#error Unsupported platform
 #endif
 }
 
@@ -431,7 +430,7 @@
   if ((g_logging_destination & LOG_TO_FILE) == 0)
     return true;
 
-#if !defined(OS_WIN)
+#if defined(OS_POSIX) || defined(OS_FUCHSIA)
   LoggingLock::Init(settings.lock_log, settings.log_file);
   LoggingLock logging_lock;
 #endif
@@ -541,11 +540,10 @@
     return;
 
 #if defined(OS_WIN)
-  MessageBoxW(nullptr, base::UTF8ToUTF16(str).c_str(), L"Fatal error",
-              MB_OK | MB_ICONHAND | MB_TOPMOST);
-#else
   // We intentionally don't implement a dialog on other platforms.
   // You can just look at stderr.
+  MessageBoxW(nullptr, base::UTF8ToUTF16(str).c_str(), L"Fatal error",
+              MB_OK | MB_ICONHAND | MB_TOPMOST);
 #endif  // defined(OS_WIN)
 }
 #endif  // !defined(NDEBUG)
@@ -795,7 +793,7 @@
     // to do this at the same time, there will be a race condition to create
     // the lock. This is why InitLogging should be called from the main
     // thread at the beginning of execution.
-#if !defined(OS_WIN)
+#if defined(OS_POSIX) || defined(OS_FUCHSIA)
     LoggingLock::Init(LOCK_LOG_FILE, nullptr);
     LoggingLock logging_lock;
 #endif
@@ -807,10 +805,12 @@
                 static_cast<DWORD>(str_newline.length()),
                 &num_written,
                 nullptr);
-#else
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
       ignore_result(fwrite(
           str_newline.data(), str_newline.size(), 1, g_log_file));
       fflush(g_log_file);
+#else
+#error Unsupported platform
 #endif
     }
   }
@@ -872,7 +872,21 @@
   if (g_log_thread_id)
     stream_ << base::PlatformThread::CurrentId() << ':';
   if (g_log_timestamp) {
-#if defined(OS_POSIX)
+#if defined(OS_WIN)
+    SYSTEMTIME local_time;
+    GetLocalTime(&local_time);
+    stream_ << std::setfill('0')
+            << std::setw(2) << local_time.wMonth
+            << std::setw(2) << local_time.wDay
+            << '/'
+            << std::setw(2) << local_time.wHour
+            << std::setw(2) << local_time.wMinute
+            << std::setw(2) << local_time.wSecond
+            << '.'
+            << std::setw(3)
+            << local_time.wMilliseconds
+            << ':';
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
     timeval tv;
     gettimeofday(&tv, nullptr);
     time_t t = tv.tv_sec;
@@ -889,19 +903,8 @@
             << '.'
             << std::setw(6) << tv.tv_usec
             << ':';
-#elif defined(OS_WIN)
-    SYSTEMTIME local_time;
-    GetLocalTime(&local_time);
-    stream_ << std::setfill('0')
-            << std::setw(2) << local_time.wMonth
-            << std::setw(2) << local_time.wDay
-            << '/'
-            << std::setw(2) << local_time.wHour
-            << std::setw(2) << local_time.wMinute
-            << std::setw(2) << local_time.wSecond
-            << '.'
-            << std::setw(3) << local_time.wMilliseconds
-            << ':';
+#else
+#error Unsupported platform
 #endif
   }
   if (g_log_tickcount)
@@ -926,15 +929,13 @@
 SystemErrorCode GetLastSystemErrorCode() {
 #if defined(OS_WIN)
   return ::GetLastError();
-#elif defined(OS_POSIX)
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
   return errno;
-#else
-#error Not implemented
 #endif
 }
 
-#if defined(OS_WIN)
 BASE_EXPORT std::string SystemErrorCodeToString(SystemErrorCode error_code) {
+#if defined(OS_WIN)
   const int kErrorMessageBufferSize = 256;
   char msgbuf[kErrorMessageBufferSize];
   DWORD flags = FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS;
@@ -947,15 +948,11 @@
   }
   return base::StringPrintf("Error (0x%lX) while retrieving error. (0x%lX)",
                             GetLastError(), error_code);
-}
-#elif defined(OS_POSIX)
-BASE_EXPORT std::string SystemErrorCodeToString(SystemErrorCode error_code) {
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
   return base::safe_strerror(error_code) +
          base::StringPrintf(" (%d)", error_code);
-}
-#else
-#error Not implemented
 #endif  // defined(OS_WIN)
+}
 
 
 #if defined(OS_WIN)
@@ -974,7 +971,7 @@
   DWORD last_error = err_;
   base::debug::Alias(&last_error);
 }
-#elif defined(OS_POSIX)
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
 ErrnoLogMessage::ErrnoLogMessage(const char* file,
                                  int line,
                                  LogSeverity severity,
@@ -993,7 +990,7 @@
 #endif  // defined(OS_WIN)
 
 void CloseLogFile() {
-#if !defined(OS_WIN)
+#if defined(OS_POSIX) || defined(OS_FUCHSIA)
   LoggingLock logging_lock;
 #endif
   CloseLogFileUnlocked();
diff --git a/base/logging.h b/base/logging.h
index 1b97a4a..29960599 100644
--- a/base/logging.h
+++ b/base/logging.h
@@ -148,7 +148,7 @@
 // TODO(avi): do we want to do a unification of character types here?
 #if defined(OS_WIN)
 typedef wchar_t PathChar;
-#else
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
 typedef char PathChar;
 #endif
 
@@ -166,7 +166,7 @@
   // stderr.
 #if defined(OS_WIN)
   LOG_DEFAULT = LOG_TO_FILE,
-#elif defined(OS_POSIX)
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
   LOG_DEFAULT = LOG_TO_SYSTEM_DEBUG_LOG,
 #endif
 };
@@ -436,7 +436,7 @@
 #define VPLOG_STREAM(verbose_level) \
   ::logging::Win32ErrorLogMessage(__FILE__, __LINE__, -verbose_level, \
     ::logging::GetLastSystemErrorCode()).stream()
-#elif defined(OS_POSIX)
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
 #define VPLOG_STREAM(verbose_level) \
   ::logging::ErrnoLogMessage(__FILE__, __LINE__, -verbose_level, \
     ::logging::GetLastSystemErrorCode()).stream()
@@ -459,7 +459,7 @@
 #define PLOG_STREAM(severity) \
   COMPACT_GOOGLE_LOG_EX_ ## severity(Win32ErrorLogMessage, \
       ::logging::GetLastSystemErrorCode()).stream()
-#elif defined(OS_POSIX)
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
 #define PLOG_STREAM(severity) \
   COMPACT_GOOGLE_LOG_EX_ ## severity(ErrnoLogMessage, \
       ::logging::GetLastSystemErrorCode()).stream()
@@ -1050,7 +1050,7 @@
 
 #if defined(OS_WIN)
 typedef unsigned long SystemErrorCode;
-#elif defined(OS_POSIX)
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
 typedef int SystemErrorCode;
 #endif
 
@@ -1079,7 +1079,7 @@
 
   DISALLOW_COPY_AND_ASSIGN(Win32ErrorLogMessage);
 };
-#elif defined(OS_POSIX)
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
 // Appends a formatted system message of the errno type
 class BASE_EXPORT ErrnoLogMessage {
  public:
diff --git a/base/memory/shared_memory.h b/base/memory/shared_memory.h
index 2eb9ee2..1c98d816 100644
--- a/base/memory/shared_memory.h
+++ b/base/memory/shared_memory.h
@@ -17,7 +17,7 @@
 #include "base/strings/string16.h"
 #include "build/build_config.h"
 
-#if defined(OS_POSIX)
+#if defined(OS_POSIX) || defined(OS_FUCHSIA)
 #include <stdio.h>
 #include <sys/types.h>
 #include <semaphore.h>
@@ -106,6 +106,7 @@
   // primitive.
   static SharedMemoryHandle DuplicateHandle(const SharedMemoryHandle& handle);
 
+// TODO(crbug/836416): Remove OS_FUCHSIA here.
 #if defined(OS_POSIX) && !defined(OS_FUCHSIA)
   // This method requires that the SharedMemoryHandle is backed by a POSIX fd.
   static int GetFdFromSharedMemoryHandle(const SharedMemoryHandle& handle);
@@ -215,6 +216,7 @@
   const UnguessableToken& mapped_id() const { return mapped_id_; }
 
  private:
+// TODO(crbug/836416): Remove OS_FUCHSIA here.
 #if defined(OS_POSIX) && !defined(OS_NACL) && !defined(OS_ANDROID) && \
     !defined(OS_FUCHSIA) && (!defined(OS_MACOSX) || defined(OS_IOS))
   bool FilePathForMemoryName(const std::string& mem_name, FilePath* path);
diff --git a/base/memory/shared_memory_handle.h b/base/memory/shared_memory_handle.h
index 617ae2a..7958ccb7 100644
--- a/base/memory/shared_memory_handle.h
+++ b/base/memory/shared_memory_handle.h
@@ -19,7 +19,7 @@
 #include "base/file_descriptor_posix.h"
 #include "base/macros.h"
 #include "base/process/process_handle.h"
-#elif defined(OS_POSIX)
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
 #include <sys/types.h>
 #include "base/file_descriptor_posix.h"
 #endif
@@ -74,7 +74,31 @@
   // Returns the size of the memory region that SharedMemoryHandle points to.
   size_t GetSize() const;
 
-#if defined(OS_MACOSX) && !defined(OS_IOS)
+#if defined(OS_WIN)
+  // Takes implicit ownership of |h|.
+  // |guid| uniquely identifies the shared memory region pointed to by the
+  // underlying OS resource. If the HANDLE is associated with another
+  // SharedMemoryHandle, the caller must pass the |guid| of that
+  // SharedMemoryHandle. Otherwise, the caller should generate a new
+  // UnguessableToken.
+  // Passing the wrong |size| has no immediate consequence, but may cause errors
+  // when trying to map the SharedMemoryHandle at a later point in time.
+  SharedMemoryHandle(HANDLE h, size_t size, const base::UnguessableToken& guid);
+  HANDLE GetHandle() const;
+#elif defined(OS_FUCHSIA)
+  // Takes implicit ownership of |h|.
+  // |guid| uniquely identifies the shared memory region pointed to by the
+  // underlying OS resource. If the zx_handle_t is associated with another
+  // SharedMemoryHandle, the caller must pass the |guid| of that
+  // SharedMemoryHandle. Otherwise, the caller should generate a new
+  // UnguessableToken.
+  // Passing the wrong |size| has no immediate consequence, but may cause errors
+  // when trying to map the SharedMemoryHandle at a later point in time.
+  SharedMemoryHandle(zx_handle_t h,
+                     size_t size,
+                     const base::UnguessableToken& guid);
+  zx_handle_t GetHandle() const;
+#elif defined(OS_MACOSX) && !defined(OS_IOS)
   enum Type {
     // The SharedMemoryHandle is backed by a POSIX fd.
     POSIX,
@@ -105,31 +129,7 @@
   // On success, |memory| is an output variable that contains the start of the
   // mapped memory.
   bool MapAt(off_t offset, size_t bytes, void** memory, bool read_only);
-#elif defined(OS_FUCHSIA)
-  // Takes implicit ownership of |h|.
-  // |guid| uniquely identifies the shared memory region pointed to by the
-  // underlying OS resource. If the zx_handle_t is associated with another
-  // SharedMemoryHandle, the caller must pass the |guid| of that
-  // SharedMemoryHandle. Otherwise, the caller should generate a new
-  // UnguessableToken.
-  // Passing the wrong |size| has no immediate consequence, but may cause errors
-  // when trying to map the SharedMemoryHandle at a later point in time.
-  SharedMemoryHandle(zx_handle_t h,
-                     size_t size,
-                     const base::UnguessableToken& guid);
-  zx_handle_t GetHandle() const;
-#elif defined(OS_WIN)
-  // Takes implicit ownership of |h|.
-  // |guid| uniquely identifies the shared memory region pointed to by the
-  // underlying OS resource. If the HANDLE is associated with another
-  // SharedMemoryHandle, the caller must pass the |guid| of that
-  // SharedMemoryHandle. Otherwise, the caller should generate a new
-  // UnguessableToken.
-  // Passing the wrong |size| has no immediate consequence, but may cause errors
-  // when trying to map the SharedMemoryHandle at a later point in time.
-  SharedMemoryHandle(HANDLE h, size_t size, const base::UnguessableToken& guid);
-  HANDLE GetHandle() const;
-#else
+#elif defined(OS_POSIX)
   // Creates a SharedMemoryHandle from an |fd| supplied from an external
   // service.
   // Passing the wrong |size| has no immediate consequence, but may cause errors
@@ -161,6 +161,7 @@
   bool SetRegionReadOnly() const;
 #endif
 
+// TODO(crbug/836416): Remove OS_FUCHSIA here.
 #if defined(OS_POSIX) && !defined(OS_FUCHSIA)
   // Constructs a SharedMemoryHandle backed by a FileDescriptor. The newly
   // created instance has the same ownership semantics as base::FileDescriptor.
@@ -182,7 +183,19 @@
 #endif
 
  private:
-#if defined(OS_MACOSX) && !defined(OS_IOS)
+#if defined(OS_WIN)
+  HANDLE handle_ = nullptr;
+
+  // Whether passing this object as a parameter to an IPC message passes
+  // ownership of |handle_| to the IPC stack. This is meant to mimic the
+  // behavior of the |auto_close| parameter of FileDescriptor. This member only
+  // affects attachment-brokered SharedMemoryHandles.
+  // Defaults to |false|.
+  bool ownership_passes_to_ipc_ = false;
+#elif defined(OS_FUCHSIA)
+  zx_handle_t handle_ = ZX_HANDLE_INVALID;
+  bool ownership_passes_to_ipc_ = false;
+#elif defined(OS_MACOSX) && !defined(OS_IOS)
   friend class SharedMemory;
   friend bool CheckReadOnlySharedMemoryHandleForTesting(
       SharedMemoryHandle handle);
@@ -209,19 +222,7 @@
 
   FileDescriptor file_descriptor_;
   bool read_only_ = false;
-#elif defined(OS_FUCHSIA)
-  zx_handle_t handle_ = ZX_HANDLE_INVALID;
-  bool ownership_passes_to_ipc_ = false;
-#elif defined(OS_WIN)
-  HANDLE handle_ = nullptr;
-
-  // Whether passing this object as a parameter to an IPC message passes
-  // ownership of |handle_| to the IPC stack. This is meant to mimic the
-  // behavior of the |auto_close| parameter of FileDescriptor. This member only
-  // affects attachment-brokered SharedMemoryHandles.
-  // Defaults to |false|.
-  bool ownership_passes_to_ipc_ = false;
-#else
+#elif defined(OS_POSIX)
   FileDescriptor file_descriptor_;
 #endif
 
diff --git a/base/message_loop/message_loop_current.cc b/base/message_loop/message_loop_current.cc
index 0255a770..cd70348 100644
--- a/base/message_loop/message_loop_current.cc
+++ b/base/message_loop/message_loop_current.cc
@@ -226,7 +226,7 @@
   DCHECK_CALLED_ON_VALID_THREAD(current_->bound_thread_checker_);
   return pump_->WaitForIOCompletion(timeout, filter);
 }
-#elif defined(OS_POSIX)  // defined(OS_WIN)
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
 bool MessageLoopCurrentForIO::WatchFileDescriptor(
     int fd,
     bool persistent,
@@ -236,7 +236,7 @@
   DCHECK_CALLED_ON_VALID_THREAD(current_->bound_thread_checker_);
   return pump_->WatchFileDescriptor(fd, persistent, mode, controller, delegate);
 }
-#endif                   // defined(OS_WIN)
+#endif  // defined(OS_WIN)
 
 #endif  // !defined(OS_NACL_SFI)
 
diff --git a/base/message_loop/message_loop_current.h b/base/message_loop/message_loop_current.h
index 2bbad5d..3631a8ff 100644
--- a/base/message_loop/message_loop_current.h
+++ b/base/message_loop/message_loop_current.h
@@ -274,7 +274,7 @@
   void RegisterIOHandler(HANDLE file, MessagePumpForIO::IOHandler* handler);
   bool RegisterJobObject(HANDLE job, MessagePumpForIO::IOHandler* handler);
   bool WaitForIOCompletion(DWORD timeout, MessagePumpForIO::IOHandler* filter);
-#elif defined(OS_POSIX)
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
   // Please see WatchableIOMessagePumpPosix for definition.
   // Prefer base::FileDescriptorWatcher for non-critical IO.
   bool WatchFileDescriptor(int fd,
@@ -282,7 +282,7 @@
                            MessagePumpForIO::Mode mode,
                            MessagePumpForIO::FdWatchController* controller,
                            MessagePumpForIO::FdWatcher* delegate);
-#endif  // defined(OS_WIN) || defined(OS_POSIX)
+#endif  // defined(OS_WIN)
 
 #if defined(OS_FUCHSIA)
   // Additional watch API for native platform resources.
diff --git a/base/metrics/persistent_memory_allocator.cc b/base/metrics/persistent_memory_allocator.cc
index 065c028..9b18a00 100644
--- a/base/metrics/persistent_memory_allocator.cc
+++ b/base/metrics/persistent_memory_allocator.cc
@@ -10,7 +10,7 @@
 #if defined(OS_WIN)
 #include <windows.h>
 #include "winbase.h"
-#elif defined(OS_POSIX)
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
 #include <sys/mman.h>
 #endif
 
@@ -969,7 +969,7 @@
     return Memory(address, MEM_VIRTUAL);
   UmaHistogramSparse("UMA.LocalPersistentMemoryAllocator.Failures.Win",
                      ::GetLastError());
-#elif defined(OS_POSIX)
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
   // MAP_ANON is deprecated on Linux but MAP_ANONYMOUS is not universal on Mac.
   // MAP_SHARED is not available on Linux <2.4 but required on Mac.
   address = ::mmap(nullptr, size, PROT_READ | PROT_WRITE,
@@ -1005,7 +1005,7 @@
 #if defined(OS_WIN)
   BOOL success = ::VirtualFree(memory, 0, MEM_DECOMMIT);
   DCHECK(success);
-#elif defined(OS_POSIX)
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
   int result = ::munmap(memory, size);
   DCHECK_EQ(0, result);
 #else
@@ -1083,7 +1083,7 @@
   int result =
       ::msync(const_cast<void*>(data()), length, sync ? MS_SYNC : MS_ASYNC);
   DCHECK_NE(EINVAL, result);
-#elif defined(OS_POSIX)
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
   // On POSIX, "invalidate" forces _other_ processes to recognize what has
   // been written to disk and so is applicable to "flush".
   int result = ::msync(const_cast<void*>(data()), length,
diff --git a/base/native_library.h b/base/native_library.h
index eaf827c..04356d96 100644
--- a/base/native_library.h
+++ b/base/native_library.h
@@ -46,7 +46,7 @@
   };
 };
 using NativeLibrary = NativeLibraryStruct*;
-#elif defined(OS_POSIX)
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
 using NativeLibrary = void*;
 #endif  // OS_*
 
@@ -60,7 +60,7 @@
 
 #if defined(OS_WIN)
   DWORD code;
-#else
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
   std::string message;
 #endif  // OS_WIN
 };
diff --git a/base/native_library_unittest.cc b/base/native_library_unittest.cc
index 8b400171..2bfb9ec 100644
--- a/base/native_library_unittest.cc
+++ b/base/native_library_unittest.cc
@@ -28,28 +28,28 @@
 
 TEST(NativeLibraryTest, GetNativeLibraryName) {
   const char kExpectedName[] =
-#if defined(OS_IOS)
+#if defined(OS_WIN)
+      "mylib.dll";
+#elif defined(OS_IOS)
       "mylib";
 #elif defined(OS_MACOSX)
       "libmylib.dylib";
-#elif defined(OS_POSIX)
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
       "libmylib.so";
-#elif defined(OS_WIN)
-      "mylib.dll";
 #endif
   EXPECT_EQ(kExpectedName, GetNativeLibraryName("mylib"));
 }
 
 TEST(NativeLibraryTest, GetLoadableModuleName) {
   const char kExpectedName[] =
-#if defined(OS_IOS)
+#if defined(OS_WIN)
+      "mylib.dll";
+#elif defined(OS_IOS)
       "mylib";
 #elif defined(OS_MACOSX)
       "mylib.so";
-#elif defined(OS_POSIX)
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
       "libmylib.so";
-#elif defined(OS_WIN)
-      "mylib.dll";
 #endif
   EXPECT_EQ(kExpectedName, GetLoadableModuleName("mylib"));
 }
@@ -60,14 +60,14 @@
 #if !defined(OS_IOS) && !defined(ADDRESS_SANITIZER)
 
 const char kTestLibraryName[] =
-#if defined(OS_MACOSX)
+#if defined(OS_WIN)
+    "test_shared_library.dll";
+#elif defined(OS_MACOSX)
     "libtest_shared_library.dylib";
 #elif defined(OS_ANDROID) && defined(COMPONENT_BUILD)
     "libtest_shared_library.cr.so";
-#elif defined(OS_POSIX)
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
     "libtest_shared_library.so";
-#elif defined(OS_WIN)
-    "test_shared_library.dll";
 #endif
 
 class TestLibrary {
diff --git a/base/process/launch.h b/base/process/launch.h
index 2afba23..0251f07 100644
--- a/base/process/launch.h
+++ b/base/process/launch.h
@@ -21,41 +21,38 @@
 #include "base/strings/string_piece.h"
 #include "build/build_config.h"
 
-#if defined(OS_POSIX)
-#include "base/posix/file_descriptor_shuffle.h"
-#elif defined(OS_WIN)
+#if defined(OS_WIN)
 #include <windows.h>
-#endif
-
-#if defined(OS_FUCHSIA)
+#elif defined(OS_FUCHSIA)
 #include <launchpad/launchpad.h>
 #include <zircon/types.h>
 #endif
 
+#if defined(OS_POSIX) || defined(OS_FUCHSIA)
+#include "base/posix/file_descriptor_shuffle.h"
+#endif
+
 namespace base {
 
 class CommandLine;
 
 #if defined(OS_WIN)
 typedef std::vector<HANDLE> HandlesToInheritVector;
-#endif
-
-#if defined(OS_FUCHSIA)
+#elif defined(OS_FUCHSIA)
 struct HandleToTransfer {
   uint32_t id;
   zx_handle_t handle;
 };
 typedef std::vector<HandleToTransfer> HandlesToTransferVector;
-#endif
-
-#if defined(OS_POSIX)
 typedef std::vector<std::pair<int, int>> FileHandleMappingVector;
-#endif
+#elif defined(OS_POSIX)
+typedef std::vector<std::pair<int, int>> FileHandleMappingVector;
+#endif  // defined(OS_WIN)
 
 // Options for launching a subprocess that are passed to LaunchProcess().
 // The default constructor constructs the object with default options.
 struct BASE_EXPORT LaunchOptions {
-#if defined(OS_POSIX)
+#if defined(OS_POSIX) || defined(OS_FUCHSIA)
   // Delegate to be run in between fork and exec in the subprocess (see
   // pre_exec_delegate below)
   class BASE_EXPORT PreExecDelegate {
@@ -151,7 +148,7 @@
   // CREATE_BREAKAWAY_FROM_JOB flag which allows it to breakout of the parent
   // job if any.
   bool force_breakaway_from_job_ = false;
-#else  // !defined(OS_WIN)
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
   // Set/unset environment variables. These are applied on top of the parent
   // process environment.  Empty (the default) means to inherit the same
   // environment. See AlterEnvironment().
@@ -164,6 +161,7 @@
   // Remap file descriptors according to the mapping of src_fd->dest_fd to
   // propagate FDs into the child process.
   FileHandleMappingVector fds_to_remap;
+#endif  // defined(OS_WIN)
 
 #if defined(OS_LINUX)
   // If non-zero, start the process using clone(), using flags as provided.
@@ -210,6 +208,7 @@
   std::vector<FilePath> paths_to_map;
 #endif  // defined(OS_FUCHSIA)
 
+// TODO(crbug/836416): Remove OS_FUCHSIA here.
 #if defined(OS_POSIX) && !defined(OS_FUCHSIA)
   // If not empty, launch the specified executable instead of
   // cmdline.GetProgram(). This is useful when it is necessary to pass a custom
@@ -240,7 +239,6 @@
   // process' controlling terminal.
   int ctrl_terminal_fd = -1;
 #endif  // defined(OS_CHROMEOS)
-#endif  // !defined(OS_WIN)
 };
 
 // Launch a process via the command line |cmdline|.
@@ -281,7 +279,7 @@
 BASE_EXPORT Process LaunchElevatedProcess(const CommandLine& cmdline,
                                           const LaunchOptions& options);
 
-#elif defined(OS_POSIX)
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
 // A POSIX-specific version of LaunchProcess that takes an argv array
 // instead of a CommandLine.  Useful for situations where you need to
 // control the command line arguments directly, but prefer the
@@ -293,7 +291,7 @@
 // given multimap. Only call this function in a child process where you know
 // that there aren't any other threads.
 BASE_EXPORT void CloseSuperfluousFds(const InjectiveMultimap& saved_map);
-#endif  // defined(OS_POSIX)
+#endif  // defined(OS_WIN)
 
 #if defined(OS_WIN)
 // Set |job_object|'s JOBOBJECT_EXTENDED_LIMIT_INFORMATION
@@ -327,9 +325,7 @@
 // instead of a CommandLine object. Useful for situations where you need to
 // control the command line arguments directly.
 BASE_EXPORT bool GetAppOutput(const StringPiece16& cl, std::string* output);
-#endif
-
-#if defined(OS_POSIX)
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
 // A POSIX-specific version of GetAppOutput that takes an argv array
 // instead of a CommandLine.  Useful for situations where you need to
 // control the command line arguments directly.
@@ -340,7 +336,7 @@
 // stderr.
 BASE_EXPORT bool GetAppOutputAndError(const std::vector<std::string>& argv,
                                       std::string* output);
-#endif  // defined(OS_POSIX)
+#endif  // defined(OS_WIN)
 
 // If supported on the platform, and the user has sufficent rights, increase
 // the current process's scheduling priority to a high priority.
diff --git a/base/process/process_iterator.h b/base/process/process_iterator.h
index 54a4ec6..b30ad41 100644
--- a/base/process/process_iterator.h
+++ b/base/process/process_iterator.h
@@ -26,7 +26,7 @@
 #include <sys/sysctl.h>
 #elif defined(OS_FREEBSD)
 #include <sys/user.h>
-#elif defined(OS_POSIX)
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
 #include <dirent.h>
 #endif
 
@@ -38,7 +38,7 @@
   ProcessId parent_pid() const { return th32ParentProcessID; }
   const wchar_t* exe_file() const { return szExeFile; }
 };
-#elif defined(OS_POSIX)
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
 struct BASE_EXPORT ProcessEntry {
   ProcessEntry();
   ProcessEntry(const ProcessEntry& other);
@@ -58,7 +58,7 @@
   std::string exe_file_;
   std::vector<std::string> cmd_line_args_;
 };
-#endif  // defined(OS_POSIX)
+#endif  // defined(OS_WIN)
 
 // Used to filter processes by process ID.
 class ProcessFilter {
@@ -112,7 +112,7 @@
 #elif defined(OS_MACOSX) || defined(OS_BSD)
   std::vector<kinfo_proc> kinfo_procs_;
   size_t index_of_kinfo_proc_;
-#elif defined(OS_POSIX)
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
   DIR* procfs_dir_;
 #endif
   ProcessEntry entry_;
diff --git a/base/process/process_util_unittest.cc b/base/process/process_util_unittest.cc
index fcb89d8..b2d550b 100644
--- a/base/process/process_util_unittest.cc
+++ b/base/process/process_util_unittest.cc
@@ -43,15 +43,16 @@
 #include <sched.h>
 #include <sys/syscall.h>
 #endif
-#if defined(OS_POSIX)
+// TODO(crbug/836416): Remove OS_FUCHSIA here.
+#if defined(OS_POSIX) && !defined(OS_FUCHSIA)
+#include <sys/resource.h>
+#endif
+#if defined(OS_POSIX) || defined(OS_FUCHSIA)
 #include <dlfcn.h>
 #include <errno.h>
 #include <fcntl.h>
 #include <sched.h>
 #include <signal.h>
-#if !defined(OS_FUCHSIA)
-#include <sys/resource.h>
-#endif
 #include <sys/socket.h>
 #include <sys/types.h>
 #include <sys/wait.h>
@@ -82,18 +83,18 @@
 const char kSignalFileKill[] = "KilledChildProcess.die";
 const char kTestHelper[] = "test_child_process";
 
-#if defined(OS_POSIX)
+#if defined(OS_POSIX) || defined(OS_FUCHSIA)
 const char kSignalFileTerm[] = "TerminatedChildProcess.die";
+#endif
 
 #if defined(OS_FUCHSIA)
 const char kSignalFileClone[] = "ClonedTmpDir.die";
 #endif
-#endif  // defined(OS_POSIX)
 
 #if defined(OS_WIN)
 const int kExpectedStillRunningExitCode = 0x102;
 const int kExpectedKilledExitCode = 1;
-#else
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
 const int kExpectedStillRunningExitCode = 0;
 #endif
 
@@ -145,7 +146,7 @@
     test_helper_path_ = test_helper_path_.AppendASCII(kTestHelper);
   }
 
-#if defined(OS_POSIX)
+#if defined(OS_POSIX) || defined(OS_FUCHSIA)
   // Spawn a child process that counts how many file descriptors are open.
   int CountOpenFDsInChild();
 #endif
@@ -283,7 +284,7 @@
   EXPECT_EQ(1, exit_code);
 }
 
-#endif
+#endif  // defined(OS_FUCHSIA)
 
 // On Android SpawnProcess() doesn't use LaunchProcess() and doesn't support
 // LaunchOptions::current_directory.
@@ -351,7 +352,7 @@
 
 MULTIPROCESS_TEST_MAIN(CrashingChildProcess) {
   WaitToDie(ProcessUtilTest::GetSignalFilePath(kSignalFileCrash).c_str());
-#if defined(OS_POSIX)
+#if defined(OS_POSIX) || defined(OS_FUCHSIA)
   // Have to disable to signal handler for segv so we can get a crash
   // instead of an abnormal termination through the crash dump handler.
   ::signal(SIGSEGV, SIG_DFL);
@@ -389,7 +390,7 @@
 
 #if defined(OS_WIN)
   EXPECT_EQ(static_cast<int>(0xc0000005), exit_code);
-#elif defined(OS_POSIX)
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
   int signaled = WIFSIGNALED(exit_code);
   EXPECT_NE(0, signaled);
   int signal = WTERMSIG(exit_code);
@@ -408,21 +409,21 @@
   // Kill ourselves.
   HANDLE handle = ::OpenProcess(PROCESS_ALL_ACCESS, 0, ::GetCurrentProcessId());
   ::TerminateProcess(handle, kExpectedKilledExitCode);
-#elif defined(OS_POSIX)
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
   // Send a SIGKILL to this process, just like the OOM killer would.
   ::kill(getpid(), SIGKILL);
 #endif
   return 1;
 }
 
-#if defined(OS_POSIX)
+#if defined(OS_POSIX) || defined(OS_FUCHSIA)
 MULTIPROCESS_TEST_MAIN(TerminatedChildProcess) {
   WaitToDie(ProcessUtilTest::GetSignalFilePath(kSignalFileTerm).c_str());
   // Send a SIGTERM to this process.
   ::kill(getpid(), SIGTERM);
   return 1;
 }
-#endif  // defined(OS_POSIX)
+#endif  // defined(OS_POSIX) || defined(OS_FUCHSIA)
 
 TEST_F(ProcessUtilTest, GetTerminationStatusSigKill) {
   const std::string signal_file =
@@ -448,7 +449,7 @@
 
 #if defined(OS_WIN)
   EXPECT_EQ(kExpectedKilledExitCode, exit_code);
-#elif defined(OS_POSIX)
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
   int signaled = WIFSIGNALED(exit_code);
   EXPECT_NE(0, signaled);
   int signal = WTERMSIG(exit_code);
@@ -457,7 +458,7 @@
   remove(signal_file.c_str());
 }
 
-#if defined(OS_POSIX)
+#if defined(OS_POSIX) || defined(OS_FUCHSIA)
 TEST_F(ProcessUtilTest, GetTerminationStatusSigTerm) {
   const std::string signal_file =
     ProcessUtilTest::GetSignalFilePath(kSignalFileTerm);
@@ -482,7 +483,7 @@
   EXPECT_EQ(SIGTERM, signal);
   remove(signal_file.c_str());
 }
-#endif  // defined(OS_POSIX)
+#endif  // defined(OS_POSIX) || defined(OS_FUCHSIA)
 
 TEST_F(ProcessUtilTest, EnsureTerminationUndying) {
   test::ScopedTaskEnvironment task_environment;
@@ -620,14 +621,14 @@
   // On Windows, anything that quits with a nonzero status code is handled as a
   // "crash", so just ignore GetAppOutputWithExitCode's return value.
   GetAppOutputWithExitCode(command, &output, &exit_code);
-#else
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
   EXPECT_TRUE(GetAppOutputWithExitCode(command, &output, &exit_code));
 #endif
   EXPECT_EQ(kEchoMessage2, output);
   EXPECT_EQ(kExpectedExitCode, exit_code);
 }
 
-#if defined(OS_POSIX)
+#if defined(OS_POSIX) || defined(OS_FUCHSIA)
 
 namespace {
 
@@ -650,7 +651,7 @@
   }
 
   return rlim.rlim_cur;
-#endif  // !defined(OS_FUCHSIA)
+#endif  // defined(OS_FUCHSIA)
 }
 
 const int kChildPipe = 20;  // FD # for write end of pipe in child process.
@@ -1072,7 +1073,7 @@
 }
 #endif  // !defined(OS_ANDROID) && !defined(OS_FUCHSIA)
 
-#endif  // defined(OS_POSIX)
+#endif  // !defined(OS_MACOSX) && !defined(OS_ANDROID)
 
 #if defined(OS_LINUX)
 MULTIPROCESS_TEST_MAIN(CheckPidProcess) {
diff --git a/base/strings/safe_sprintf.h b/base/strings/safe_sprintf.h
index d6886db..01d649d 100644
--- a/base/strings/safe_sprintf.h
+++ b/base/strings/safe_sprintf.h
@@ -11,7 +11,7 @@
 #include <stdint.h>
 #include <stdlib.h>
 
-#if defined(OS_POSIX)
+#if defined(OS_POSIX) || defined(OS_FUCHSIA)
 // For ssize_t
 #include <unistd.h>
 #endif
diff --git a/base/strings/string_util.h b/base/strings/string_util.h
index 1e69413..d6780ec 100644
--- a/base/strings/string_util.h
+++ b/base/strings/string_util.h
@@ -476,7 +476,7 @@
 
 #if defined(OS_WIN)
 #include "base/strings/string_util_win.h"
-#elif defined(OS_POSIX)
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
 #include "base/strings/string_util_posix.h"
 #else
 #error Define string operations appropriately for your platform
diff --git a/base/sync_socket.h b/base/sync_socket.h
index 59d26bb..42db9a2 100644
--- a/base/sync_socket.h
+++ b/base/sync_socket.h
@@ -24,7 +24,7 @@
 #endif
 #include <sys/types.h>
 
-#if defined(OS_POSIX)
+#if defined(OS_POSIX) || defined(OS_FUCHSIA)
 #include "base/file_descriptor_posix.h"
 #endif
 
@@ -35,7 +35,7 @@
 #if defined(OS_WIN)
   typedef HANDLE Handle;
   typedef Handle TransitDescriptor;
-#else
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
   typedef int Handle;
   typedef FileDescriptor TransitDescriptor;
 #endif
diff --git a/base/synchronization/condition_variable.h b/base/synchronization/condition_variable.h
index 6d95c678..dfcf813 100644
--- a/base/synchronization/condition_variable.h
+++ b/base/synchronization/condition_variable.h
@@ -65,16 +65,16 @@
 #ifndef BASE_SYNCHRONIZATION_CONDITION_VARIABLE_H_
 #define BASE_SYNCHRONIZATION_CONDITION_VARIABLE_H_
 
+#if defined(OS_POSIX) || defined(OS_FUCHSIA)
+#include <pthread.h>
+#endif
+
 #include "base/base_export.h"
 #include "base/logging.h"
 #include "base/macros.h"
 #include "base/synchronization/lock.h"
 #include "build/build_config.h"
 
-#if defined(OS_POSIX)
-#include <pthread.h>
-#endif
-
 #if defined(OS_WIN)
 #include "base/win/windows_types.h"
 #endif
@@ -107,12 +107,12 @@
 #if defined(OS_WIN)
   CHROME_CONDITION_VARIABLE cv_;
   CHROME_SRWLOCK* const srwlock_;
-#elif defined(OS_POSIX)
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
   pthread_cond_t condition_;
   pthread_mutex_t* user_mutex_;
 #endif
 
-#if DCHECK_IS_ON() && (defined(OS_WIN) || defined(OS_POSIX))
+#if DCHECK_IS_ON()
   base::Lock* const user_lock_;  // Needed to adjust shadow lock state on wait.
 #endif
 
diff --git a/base/synchronization/lock.h b/base/synchronization/lock.h
index 599984e..d1c647c 100644
--- a/base/synchronization/lock.h
+++ b/base/synchronization/lock.h
@@ -64,26 +64,24 @@
   // Whether Lock mitigates priority inversion when used from different thread
   // priorities.
   static bool HandlesMultipleThreadPriorities() {
-#if defined(OS_POSIX)
-    // POSIX mitigates priority inversion by setting the priority of a thread
-    // holding a Lock to the maximum priority of any other thread waiting on it.
-    return internal::LockImpl::PriorityInheritanceAvailable();
-#elif defined(OS_WIN)
+#if defined(OS_WIN)
     // Windows mitigates priority inversion by randomly boosting the priority of
     // ready threads.
     // https://msdn.microsoft.com/library/windows/desktop/ms684831.aspx
     return true;
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
+    // POSIX mitigates priority inversion by setting the priority of a thread
+    // holding a Lock to the maximum priority of any other thread waiting on it.
+    return internal::LockImpl::PriorityInheritanceAvailable();
 #else
 #error Unsupported platform
 #endif
   }
 
-#if defined(OS_POSIX) || defined(OS_WIN)
   // Both Windows and POSIX implementations of ConditionVariable need to be
   // able to see our lock and tweak our debugging counters, as they release and
   // acquire locks inside of their condition variable APIs.
   friend class ConditionVariable;
-#endif
 
  private:
 #if DCHECK_IS_ON()
diff --git a/base/synchronization/lock_impl.h b/base/synchronization/lock_impl.h
index 7ec081f4..221d763 100644
--- a/base/synchronization/lock_impl.h
+++ b/base/synchronization/lock_impl.h
@@ -12,7 +12,7 @@
 
 #if defined(OS_WIN)
 #include "base/win/windows_types.h"
-#elif defined(OS_POSIX)
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
 #include <errno.h>
 #include <pthread.h>
 #endif
@@ -27,7 +27,7 @@
  public:
 #if defined(OS_WIN)
   using NativeHandle = CHROME_SRWLOCK;
-#elif defined(OS_POSIX)
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
   using NativeHandle = pthread_mutex_t;
 #endif
 
@@ -50,7 +50,7 @@
   // unnecessary.
   NativeHandle* native_handle() { return &native_handle_; }
 
-#if defined(OS_POSIX)
+#if defined(OS_POSIX) || defined(OS_FUCHSIA)
   // Whether this lock will attempt to use priority inheritance.
   static bool PriorityInheritanceAvailable();
 #endif
@@ -65,7 +65,7 @@
 void LockImpl::Unlock() {
   ::ReleaseSRWLockExclusive(reinterpret_cast<PSRWLOCK>(&native_handle_));
 }
-#elif defined(OS_POSIX)
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
 void LockImpl::Unlock() {
   int rv = pthread_mutex_unlock(&native_handle_);
   DCHECK_EQ(rv, 0) << ". " << strerror(rv);
diff --git a/base/synchronization/waitable_event.h b/base/synchronization/waitable_event.h
index 0d1ca17..836adc0 100644
--- a/base/synchronization/waitable_event.h
+++ b/base/synchronization/waitable_event.h
@@ -23,7 +23,7 @@
 #include "base/mac/scoped_mach_port.h"
 #include "base/memory/ref_counted.h"
 #include "base/synchronization/lock.h"
-#elif defined(OS_POSIX)
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
 #include <list>
 #include <utility>
 
@@ -230,7 +230,7 @@
   // the event, unlike the receive right, since a deleted event cannot be
   // signaled.
   mac::ScopedMachSendRight send_right_;
-#else
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
   // On Windows, you must not close a HANDLE which is currently being waited on.
   // The MSDN documentation says that the resulting behaviour is 'undefined'.
   // To solve that issue each WaitableEventWatcher duplicates the given event
diff --git a/base/threading/platform_thread.h b/base/threading/platform_thread.h
index 7637e00..faeb858 100644
--- a/base/threading/platform_thread.h
+++ b/base/threading/platform_thread.h
@@ -18,10 +18,10 @@
 
 #if defined(OS_WIN)
 #include "base/win/windows_types.h"
-#elif defined(OS_MACOSX)
-#include <mach/mach_types.h>
 #elif defined(OS_FUCHSIA)
 #include <zircon/types.h>
+#elif defined(OS_MACOSX)
+#include <mach/mach_types.h>
 #elif defined(OS_POSIX)
 #include <pthread.h>
 #include <unistd.h>
@@ -32,10 +32,10 @@
 // Used for logging. Always an integer value.
 #if defined(OS_WIN)
 typedef DWORD PlatformThreadId;
-#elif defined(OS_MACOSX)
-typedef mach_port_t PlatformThreadId;
 #elif defined(OS_FUCHSIA)
 typedef zx_handle_t PlatformThreadId;
+#elif defined(OS_MACOSX)
+typedef mach_port_t PlatformThreadId;
 #elif defined(OS_POSIX)
 typedef pid_t PlatformThreadId;
 #endif
@@ -52,7 +52,7 @@
  public:
 #if defined(OS_WIN)
   typedef DWORD RefType;
-#elif defined(OS_POSIX)
+#else  //  OS_POSIX
   typedef pthread_t RefType;
 #endif
   constexpr PlatformThreadRef() : id_(0) {}
@@ -77,7 +77,7 @@
  public:
 #if defined(OS_WIN)
   typedef void* Handle;
-#elif defined(OS_POSIX)
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
   typedef pthread_t Handle;
 #endif
 
diff --git a/base/threading/thread_local_storage.cc b/base/threading/thread_local_storage.cc
index 9cfb00c..21fd323 100644
--- a/base/threading/thread_local_storage.cc
+++ b/base/threading/thread_local_storage.cc
@@ -296,7 +296,7 @@
     return;
   OnThreadExitInternal(static_cast<TlsVectorEntry*>(tls_data));
 }
-#elif defined(OS_POSIX)
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
 void PlatformThreadLocalStorage::OnThreadExit(void* value) {
   OnThreadExitInternal(static_cast<TlsVectorEntry*>(value));
 }
diff --git a/base/threading/thread_local_storage.h b/base/threading/thread_local_storage.h
index 32021f4..f84ac33 100644
--- a/base/threading/thread_local_storage.h
+++ b/base/threading/thread_local_storage.h
@@ -14,7 +14,7 @@
 
 #if defined(OS_WIN)
 #include "base/win/windows_types.h"
-#elif defined(OS_POSIX)
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
 #include <pthread.h>
 #endif
 
@@ -46,7 +46,7 @@
 #if defined(OS_WIN)
   typedef unsigned long TLSKey;
   enum : unsigned { TLS_KEY_OUT_OF_INDEXES = TLS_OUT_OF_INDEXES };
-#elif defined(OS_POSIX)
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
   typedef pthread_key_t TLSKey;
   // The following is a "reserved key" which is used in our generic Chromium
   // ThreadLocalStorage implementation.  We expect that an OS will not return
@@ -71,7 +71,7 @@
   static void* GetTLSValue(TLSKey key) {
 #if defined(OS_WIN)
     return TlsGetValue(key);
-#elif defined(OS_POSIX)
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
     return pthread_getspecific(key);
 #endif
   }
@@ -88,7 +88,7 @@
   // Since Windows which doesn't support TLS destructor, the implementation
   // should use GetTLSValue() to retrieve the value of TLS slot.
   static void OnThreadExit();
-#elif defined(OS_POSIX)
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
   // |Value| is the data stored in TLS slot, The implementation can't use
   // GetTLSValue() to retrieve the value of slot as it has already been reset
   // in Posix.
diff --git a/base/time/pr_time_unittest.cc b/base/time/pr_time_unittest.cc
index 5c3e3fca..6fce4ab1a 100644
--- a/base/time/pr_time_unittest.cc
+++ b/base/time/pr_time_unittest.cc
@@ -80,7 +80,7 @@
 #if defined(OS_WIN)
   localtime_s(&local_time, &current_time);
   asctime_s(time_buf, arraysize(time_buf), &local_time);
-#elif defined(OS_POSIX)
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
   localtime_r(&current_time, &local_time);
   asctime_r(&local_time, time_buf);
 #endif
diff --git a/base/time/time.h b/base/time/time.h
index 6614d5e..329dbd3 100644
--- a/base/time/time.h
+++ b/base/time/time.h
@@ -77,7 +77,7 @@
 #include <jni.h>
 #endif
 
-#if defined(OS_POSIX)
+#if defined(OS_POSIX) || defined(OS_FUCHSIA)
 #include <unistd.h>
 #include <sys/time.h>
 #endif
@@ -122,12 +122,11 @@
   static constexpr TimeDelta FromMillisecondsD(double ms);
   static constexpr TimeDelta FromMicrosecondsD(double us);
   static constexpr TimeDelta FromNanosecondsD(double ns);
-#if defined(OS_POSIX)
-  static TimeDelta FromTimeSpec(const timespec& ts);
-#endif
 #if defined(OS_WIN)
   static TimeDelta FromQPCValue(LONGLONG qpc_value);
   static TimeDelta FromFileTime(FILETIME ft);
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
+  static TimeDelta FromTimeSpec(const timespec& ts);
 #endif
 
   // Converts an integer value representing TimeDelta to a class. This is used
@@ -178,7 +177,7 @@
     return delta_ == std::numeric_limits<int64_t>::min();
   }
 
-#if defined(OS_POSIX)
+#if defined(OS_POSIX) || defined(OS_FUCHSIA)
   struct timespec ToTimeSpec() const;
 #endif
 
@@ -556,7 +555,7 @@
   static Time FromDoubleT(double dt);
   double ToDoubleT() const;
 
-#if defined(OS_POSIX)
+#if defined(OS_POSIX) || defined(OS_FUCHSIA)
   // Converts the timespec structure to time. MacOS X 10.8.3 (and tentatively,
   // earlier versions) will have the |ts|'s tv_nsec component zeroed out,
   // having a 1 second resolution, which agrees with
@@ -576,7 +575,7 @@
   static Time FromJavaTime(int64_t ms_since_epoch);
   int64_t ToJavaTime() const;
 
-#if defined(OS_POSIX)
+#if defined(OS_POSIX) || defined(OS_FUCHSIA)
   static Time FromTimeVal(struct timeval t);
   struct timeval ToTimeVal() const;
 #endif
diff --git a/base/time/time_unittest.cc b/base/time/time_unittest.cc
index 6dfa634..cde5cf5 100644
--- a/base/time/time_unittest.cc
+++ b/base/time/time_unittest.cc
@@ -158,7 +158,7 @@
   struct tm tms;
 #if defined(OS_WIN)
   gmtime_s(&tms, &now_t_1);
-#elif defined(OS_POSIX)
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
   gmtime_r(&now_t_1, &tms);
 #endif
 
@@ -204,7 +204,7 @@
   struct tm tms;
 #if defined(OS_WIN)
   localtime_s(&tms, &now_t_1);
-#elif defined(OS_POSIX)
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
   localtime_r(&now_t_1, &tms);
 #endif
 
@@ -240,13 +240,13 @@
   EXPECT_EQ(800730.0, t.ToJsTime());
 }
 
-#if defined(OS_POSIX)
+#if defined(OS_POSIX) || defined(OS_FUCHSIA)
 TEST_F(TimeTest, FromTimeVal) {
   Time now = Time::Now();
   Time also_now = Time::FromTimeVal(now.ToTimeVal());
   EXPECT_EQ(now, also_now);
 }
-#endif  // OS_POSIX
+#endif  // defined(OS_POSIX) || defined(OS_FUCHSIA)
 
 TEST_F(TimeTest, FromExplodedWithMilliseconds) {
   // Some platform implementations of FromExploded are liable to drop
@@ -311,7 +311,7 @@
 #if defined(OS_WIN)
   localtime_s(&local_time, &current_time);
   asctime_s(time_buf, arraysize(time_buf), &local_time);
-#elif defined(OS_POSIX)
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
   localtime_r(&current_time, &local_time);
   asctime_r(&local_time, time_buf);
 #endif
@@ -647,7 +647,7 @@
   EXPECT_TRUE(t.is_max());
   EXPECT_EQ(std::numeric_limits<time_t>::max(), t.ToTimeT());
 
-#if defined(OS_POSIX)
+#if defined(OS_POSIX) || defined(OS_FUCHSIA)
   struct timeval tval;
   tval.tv_sec = std::numeric_limits<time_t>::max();
   tval.tv_usec = static_cast<suseconds_t>(Time::kMicrosecondsPerSecond) - 1;
@@ -719,7 +719,7 @@
   if (Time::kExplodedMinYear != std::numeric_limits<int>::min()) {
     exploded.year = Time::kExplodedMinYear;
     EXPECT_TRUE(Time::FromUTCExploded(exploded, &parsed_time));
-#if !defined(OS_WIN)
+#if defined(OS_POSIX) || defined(OS_FUCHSIA)
     // On Windows, January 1, 1601 00:00:00 is actually the null time.
     EXPECT_FALSE(parsed_time.is_null());
 #endif
@@ -1129,7 +1129,7 @@
   EXPECT_EQ(TimeDelta::FromNanosecondsD(12345.678).InNanoseconds(), 12000);
 }
 
-#if defined(OS_POSIX)
+#if defined(OS_POSIX) || defined(OS_FUCHSIA)
 TEST(TimeDelta, TimeSpecConversion) {
   TimeDelta delta = TimeDelta::FromSeconds(0);
   struct timespec result = delta.ToTimeSpec();
@@ -1155,7 +1155,7 @@
   EXPECT_EQ(result.tv_nsec, 1000);
   EXPECT_EQ(delta, TimeDelta::FromTimeSpec(result));
 }
-#endif  // OS_POSIX
+#endif  // defined(OS_POSIX) || defined(OS_FUCHSIA)
 
 // Our internal time format is serialized in things like databases, so it's
 // important that it's consistent across all our platforms.  We use the 1601
diff --git a/base/trace_event/process_memory_dump.cc b/base/trace_event/process_memory_dump.cc
index 8313caa..7442578 100644
--- a/base/trace_event/process_memory_dump.cc
+++ b/base/trace_event/process_memory_dump.cc
@@ -23,7 +23,7 @@
 #include <mach/vm_page_size.h>
 #endif
 
-#if defined(OS_POSIX)
+#if defined(OS_POSIX) || defined(OS_FUCHSIA)
 #include <sys/mman.h>
 #endif
 
@@ -92,12 +92,12 @@
   const size_t kMaxChunkSize = 8 * 1024 * 1024;
   size_t max_vec_size =
       GetSystemPageCount(std::min(mapped_size, kMaxChunkSize), page_size);
-#if defined(OS_MACOSX)
-  std::unique_ptr<char[]> vec(new char[max_vec_size]);
-#elif defined(OS_WIN)
+#if defined(OS_WIN)
   std::unique_ptr<PSAPI_WORKING_SET_EX_INFORMATION[]> vec(
       new PSAPI_WORKING_SET_EX_INFORMATION[max_vec_size]);
-#elif defined(OS_POSIX)
+#elif defined(OS_MACOSX)
+  std::unique_ptr<char[]> vec(new char[max_vec_size]);
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
   std::unique_ptr<unsigned char[]> vec(new unsigned char[max_vec_size]);
 #endif
 
@@ -106,13 +106,7 @@
     const size_t chunk_size = std::min(mapped_size - offset, kMaxChunkSize);
     const size_t page_count = GetSystemPageCount(chunk_size, page_size);
     size_t resident_page_count = 0;
-#if defined(OS_MACOSX)
-    // mincore in MAC does not fail with EAGAIN.
-    failure =
-        !!mincore(reinterpret_cast<void*>(chunk_start), chunk_size, vec.get());
-    for (size_t i = 0; i < page_count; i++)
-      resident_page_count += vec[i] & MINCORE_INCORE ? 1 : 0;
-#elif defined(OS_WIN)
+#if defined(OS_WIN)
     for (size_t i = 0; i < page_count; i++) {
       vec[i].VirtualAddress =
           reinterpret_cast<void*>(chunk_start + i * page_size);
@@ -127,6 +121,12 @@
     // TODO(fuchsia): Port, see https://crbug.com/706592.
     ALLOW_UNUSED_LOCAL(chunk_start);
     ALLOW_UNUSED_LOCAL(page_count);
+#elif defined(OS_MACOSX)
+    // mincore in MAC does not fail with EAGAIN.
+    failure =
+        !!mincore(reinterpret_cast<void*>(chunk_start), chunk_size, vec.get());
+    for (size_t i = 0; i < page_count; i++)
+      resident_page_count += vec[i] & MINCORE_INCORE ? 1 : 0;
 #elif defined(OS_POSIX)
     int error_counter = 0;
     int result = 0;
diff --git a/base/trace_event/process_memory_dump.h b/base/trace_event/process_memory_dump.h
index 345531d..a732a26 100644
--- a/base/trace_event/process_memory_dump.h
+++ b/base/trace_event/process_memory_dump.h
@@ -22,7 +22,7 @@
 
 // Define COUNT_RESIDENT_BYTES_SUPPORTED if platform supports counting of the
 // resident memory.
-#if (defined(OS_POSIX) && !defined(OS_NACL)) || defined(OS_WIN)
+#if !defined(OS_NACL)
 #define COUNT_RESIDENT_BYTES_SUPPORTED
 #endif
 
diff --git a/base/trace_event/process_memory_dump_unittest.cc b/base/trace_event/process_memory_dump_unittest.cc
index 8aed15a2..f1209ca 100644
--- a/base/trace_event/process_memory_dump_unittest.cc
+++ b/base/trace_event/process_memory_dump_unittest.cc
@@ -20,7 +20,7 @@
 #if defined(OS_WIN)
 #include <windows.h>
 #include "winbase.h"
-#elif defined(OS_POSIX)
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
 #include <sys/mman.h>
 #endif
 
@@ -47,18 +47,16 @@
 #if defined(OS_WIN)
   return ::VirtualAlloc(nullptr, size, MEM_RESERVE | MEM_COMMIT,
                         PAGE_READWRITE);
-#elif defined(OS_POSIX)
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
   return ::mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON,
                 0, 0);
-#else
-#error This architecture is not (yet) supported.
 #endif
 }
 
 void Unmap(void* addr, size_t size) {
 #if defined(OS_WIN)
   ::VirtualFree(addr, 0, MEM_DECOMMIT);
-#elif defined(OS_POSIX)
+#elif defined(OS_POSIX) || defined(OS_FUCHSIA)
   ::munmap(addr, size);
 #else
 #error This architecture is not (yet) supported.