Revert "Revert "Add a way to turn off unique_fd's operator int.""
The original commit broke aosp-master-with-phones, because of
vendor libraries the depended on the int versions of libbase functions.
This patch reverts the revert, and also adds ABI-compatibility shims for
the replaced functions.
This reverts commit dfdf916d09f6583d3fd1db1e33c79ed60bff2480.
Bug: http://b/131312539
Test: treehugger
Test: forrest run of aosp-master-with-phones
Change-Id: I75cc84ec8d963e20862f7662e8e2f409471f41cc
diff --git a/sysdeps/uio.h b/sysdeps/uio.h
index d06ef89..ced884b 100644
--- a/sysdeps/uio.h
+++ b/sysdeps/uio.h
@@ -18,6 +18,8 @@
#include <sys/types.h>
+#include "adb_unique_fd.h"
+
#if defined(_WIN32)
// Layout of this struct must match struct WSABUF (verified via static assert in sysdeps_win32.cpp)
@@ -26,13 +28,15 @@
void* iov_base;
};
-ssize_t adb_writev(int fd, const adb_iovec* iov, int iovcnt);
+ssize_t adb_writev(borrowed_fd fd, const adb_iovec* iov, int iovcnt);
#else
#include <sys/uio.h>
using adb_iovec = struct iovec;
-#define adb_writev writev
+inline ssize_t adb_writev(borrowed_fd fd, const adb_iovec* iov, int iovcnt) {
+ return writev(fd.get(), iov, iovcnt);
+}
#endif