From 838dbfc496a2940b060c19f7bfc8e080f7b68e40 Mon Sep 17 00:00:00 2001 From: Sasi Kumar Maddineni Date: Wed, 29 Oct 2025 12:22:58 +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 . 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 Signed-off-by: Khem Raj --- ...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 --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 +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 . + +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 +--- + 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 63e31e90cc..0e25c39bc2 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 @@ -38,6 +38,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 \ \ "