Remove liblog/uio.c and <log/uio.h>

readv() isn't used by anyone, writev() has one easily replaced user.
uio.h can be left as a private header for windows compatibility with
struct iovec.

Test: build
Change-Id: I33d4c6bdee6fd818271f78ae06abdd2aa09430f2
diff --git a/liblog/Android.bp b/liblog/Android.bp
index e213e90..58d88df 100644
--- a/liblog/Android.bp
+++ b/liblog/Android.bp
@@ -86,7 +86,6 @@
             ldflags: ["-Wl,--hash-style=both"],
         },
         windows: {
-            srcs: ["uio.cpp"],
             enabled: true,
         },
         not_windows: {
diff --git a/liblog/fake_log_device.cpp b/liblog/fake_log_device.cpp
index 4f3a230..5daae41 100644
--- a/liblog/fake_log_device.cpp
+++ b/liblog/fake_log_device.cpp
@@ -33,7 +33,6 @@
 #include <time.h>
 
 #include <android/log.h>
-#include <log/uio.h>
 
 #include "log_portability.h"
 
diff --git a/liblog/fake_log_device.h b/liblog/fake_log_device.h
index 74d434e..ef0beb6 100644
--- a/liblog/fake_log_device.h
+++ b/liblog/fake_log_device.h
@@ -19,6 +19,7 @@
 #include <sys/types.h>
 
 #include "log_portability.h"
+#include "uio.h"
 
 struct iovec;
 
diff --git a/liblog/include/log/log.h b/liblog/include/log/log.h
index df5affb..6f93396 100644
--- a/liblog/include/log/log.h
+++ b/liblog/include/log/log.h
@@ -34,7 +34,6 @@
 #include <log/log_safetynet.h>
 #include <log/log_system.h>
 #include <log/log_time.h>
-#include <log/uio.h> /* helper to define iovec for portability */
 
 #ifdef __cplusplus
 extern "C" {
diff --git a/liblog/logd_writer.cpp b/liblog/logd_writer.cpp
index 4731487..ed906b3 100644
--- a/liblog/logd_writer.cpp
+++ b/liblog/logd_writer.cpp
@@ -38,6 +38,7 @@
 #include "config_write.h"
 #include "log_portability.h"
 #include "logger.h"
+#include "uio.h"
 
 /* branchless on many architectures. */
 #define min(x, y) ((y) ^ (((x) ^ (y)) & -((x) < (y))))
diff --git a/liblog/logger.h b/liblog/logger.h
index 25ee065..b2479d2 100644
--- a/liblog/logger.h
+++ b/liblog/logger.h
@@ -21,9 +21,9 @@
 
 #include <cutils/list.h>
 #include <log/log.h>
-#include <log/uio.h>
 
 #include "log_portability.h"
+#include "uio.h"
 
 __BEGIN_DECLS
 
diff --git a/liblog/logger_write.cpp b/liblog/logger_write.cpp
index fbe6874..af8cb2d 100644
--- a/liblog/logger_write.cpp
+++ b/liblog/logger_write.cpp
@@ -33,6 +33,7 @@
 #include "config_write.h"
 #include "log_portability.h"
 #include "logger.h"
+#include "uio.h"
 
 #define LOG_BUF_SIZE 1024
 
@@ -524,11 +525,8 @@
 
   // Log assertion failures to stderr for the benefit of "adb shell" users
   // and gtests (http://b/23675822).
-  struct iovec iov[2] = {
-      {buf, strlen(buf)},
-      {(char*)"\n", 1},
-  };
-  TEMP_FAILURE_RETRY(writev(2, iov, 2));
+  TEMP_FAILURE_RETRY(write(2, buf, strlen(buf)));
+  TEMP_FAILURE_RETRY(write(2, "\n", 1));
 
   __android_log_write(ANDROID_LOG_FATAL, tag, buf);
   abort(); /* abort so we have a chance to debug the situation */
diff --git a/liblog/pmsg_writer.cpp b/liblog/pmsg_writer.cpp
index c50c7f7..b2fc6d0 100644
--- a/liblog/pmsg_writer.cpp
+++ b/liblog/pmsg_writer.cpp
@@ -33,6 +33,7 @@
 #include "config_write.h"
 #include "log_portability.h"
 #include "logger.h"
+#include "uio.h"
 
 static int pmsgOpen();
 static void pmsgClose();
diff --git a/liblog/stderr_write.cpp b/liblog/stderr_write.cpp
index f9cb37d..28195aa 100644
--- a/liblog/stderr_write.cpp
+++ b/liblog/stderr_write.cpp
@@ -37,10 +37,10 @@
 #include <log/event_tag_map.h>
 #include <log/log.h>
 #include <log/logprint.h>
-#include <log/uio.h>
 
 #include "log_portability.h"
 #include "logger.h"
+#include "uio.h"
 
 static int stderrOpen();
 static void stderrClose();
diff --git a/liblog/tests/liblog_benchmark.cpp b/liblog/tests/liblog_benchmark.cpp
index c2f3f83..c8ac321 100644
--- a/liblog/tests/liblog_benchmark.cpp
+++ b/liblog/tests/liblog_benchmark.cpp
@@ -21,6 +21,7 @@
 #include <sys/socket.h>
 #include <sys/syscall.h>
 #include <sys/types.h>
+#include <sys/uio.h>
 #include <unistd.h>
 
 #include <unordered_set>
diff --git a/liblog/uio.cpp b/liblog/uio.cpp
deleted file mode 100644
index 05145d7..0000000
--- a/liblog/uio.cpp
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright (C) 2007-2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#if defined(_WIN32)
-
-#include <unistd.h>
-
-#include <log/uio.h>
-
-#include "log_portability.h"
-
-LIBLOG_ABI_PUBLIC int readv(int fd, struct iovec* vecs, int count) {
-  int total = 0;
-
-  for (; count > 0; count--, vecs++) {
-    char* buf = static_cast<char*>(vecs->iov_base);
-    int len = vecs->iov_len;
-
-    while (len > 0) {
-      int ret = read(fd, buf, len);
-      if (ret < 0) {
-        if (total == 0) total = -1;
-        goto Exit;
-      }
-      if (ret == 0) goto Exit;
-
-      total += ret;
-      buf += ret;
-      len -= ret;
-    }
-  }
-Exit:
-  return total;
-}
-
-LIBLOG_ABI_PUBLIC int writev(int fd, const struct iovec* vecs, int count) {
-  int total = 0;
-
-  for (; count > 0; count--, vecs++) {
-    const char* buf = static_cast<const char*>(vecs->iov_base);
-    int len = vecs->iov_len;
-
-    while (len > 0) {
-      int ret = write(fd, buf, len);
-      if (ret < 0) {
-        if (total == 0) total = -1;
-        goto Exit;
-      }
-      if (ret == 0) goto Exit;
-
-      total += ret;
-      buf += ret;
-      len -= ret;
-    }
-  }
-Exit:
-  return total;
-}
-
-#endif
diff --git a/liblog/include/log/uio.h b/liblog/uio.h
similarity index 67%
rename from liblog/include/log/uio.h
rename to liblog/uio.h
index 7feb552..c85893c 100644
--- a/liblog/include/log/uio.h
+++ b/liblog/uio.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2007-2014 The Android Open Source Project
+ * Copyright (C) 2019 The Android Open Source Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,32 +16,12 @@
 
 #pragma once
 
-#if !defined(_WIN32)
-
-#include <sys/uio.h>
-
-#else
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-//
-// Implementation of sys/uio.h for Win32.
-//
-
+#if defined(_WIN32)
 #include <stddef.h>
-
 struct iovec {
   void* iov_base;
   size_t iov_len;
 };
-
-extern int readv(int fd, struct iovec* vecs, int count);
-extern int writev(int fd, const struct iovec* vecs, int count);
-
-#ifdef __cplusplus
-}
-#endif
-
+#else
+#include <sys/uio.h>
 #endif