diff mbox series

[meta-oe] android-tools: scope 'write' macro to prevent conflict with std::basic_ostream::write

Message ID 20251029065258.3394808-1-quic_sasikuma@quicinc.com
State Under Review
Headers show
Series [meta-oe] android-tools: scope 'write' macro to prevent conflict with std::basic_ostream::write | expand

Commit Message

Sasi Kumar Maddineni Oct. 29, 2025, 6:52 a.m. UTC
The build fails with a compiler error due to a macro redefinition of 'write'
to '___xxx_write'. This macro substitution interferes with the standard C++
library's definition of std::basic_ostream::write, leading to a mismatch
between function declarations and definitions in <ostream.tcc>.

Wrap the `#undef write` and `#define write ___xxx_write` directives with
`#if defined(__ANDROID__)` to ensure they are only applied when building
for
Android.

Signed-off-by: Sasi Kumar Maddineni <quic_sasikuma@quicinc.com>
---
 ...ope-write-macro-to-prevent-conflict-.patch | 52 +++++++++++++++++++
 .../android-tools/android-tools_29.0.6.r14.bb |  1 +
 2 files changed, 53 insertions(+)
 create mode 100644 meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/system/core/android-tools-scope-write-macro-to-prevent-conflict-.patch
diff mbox series

Patch

diff --git a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/system/core/android-tools-scope-write-macro-to-prevent-conflict-.patch b/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/system/core/android-tools-scope-write-macro-to-prevent-conflict-.patch
new file mode 100644
index 0000000000..61032944d8
--- /dev/null
+++ b/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/system/core/android-tools-scope-write-macro-to-prevent-conflict-.patch
@@ -0,0 +1,52 @@ 
+From 72b53f2d5c6e1b462a288cef3d84dd302fe603d6 Mon Sep 17 00:00:00 2001
+From: Sasi Kumar Maddineni <quic_sasikuma@quicinc.com>
+Date: Wed, 29 Oct 2025 11:58:20 +0530
+Subject: [PATCH] android-tools: scope 'write' macro to prevent conflict with
+ std::basic_ostream::write
+
+The build fails with a compiler error due to a macro redefinition of 'write'
+to '___xxx_write'. This macro substitution interferes with the standard C++
+library's definition of std::basic_ostream::write, leading to a mismatch
+between function declarations and definitions in <ostream.tcc>.
+
+Wrap the `#undef write` and `#define write ___xxx_write` directives with
+`#if defined(__ANDROID__)` to ensure they are only applied when building
+for
+Android.
+
+Upstream-Status: Pending
+
+Signed-off-by: Sasi Kumar Maddineni <quic_sasikuma@quicinc.com>
+---
+ system/core/adb/sysdeps.h | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/system/core/adb/sysdeps.h b/system/core/adb/sysdeps.h
+index a4827b8a..ff51d574 100644
+--- a/system/core/adb/sysdeps.h
++++ b/system/core/adb/sysdeps.h
+@@ -127,8 +127,10 @@ static __inline__ int unix_read(borrowed_fd fd, void* buf, size_t len) {
+ static __inline__ int unix_write(borrowed_fd fd, const void* buf, size_t len) {
+     return write(fd.get(), buf, len);
+ }
++#if defined(__ANDROID__)
+ #undef   write
+ #define  write  ___xxx_write
++#endif
+ 
+ #undef pwrite
+ #define pwrite ___xxx_pwrite
+@@ -463,8 +465,10 @@ static __inline__ int adb_pwrite(int fd, const void* buf, size_t len, off64_t of
+ #endif
+ }
+ 
++#if defined(__ANDROID__)
+ #undef   write
+ #define  write  ___xxx_write
++#endif
+ #undef pwrite
+ #define pwrite ___xxx_pwrite
+ 
+-- 
+2.34.1
+
diff --git a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools_29.0.6.r14.bb b/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools_29.0.6.r14.bb
index 24b6822433..47c8e08b62 100644
--- a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools_29.0.6.r14.bb
+++ b/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools_29.0.6.r14.bb
@@ -39,6 +39,7 @@  SRC_URI += " \
     file://debian/system/core/stub-out-fastdeploy.patch \
     file://debian/system/core/fix-standard-namespace-errors.patch \
     file://debian/system/core/Add-riscv64-support.patch \
+    file://debian/system/core/android-tools-scope-write-macro-to-prevent-conflict-.patch \
     \
 "