GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Build fixes to allow using the epoll native transport on Android by faenil · Pull Request #16016 · netty/netty

Conversation

@faenil

@faenil faenil commented Dec 11, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Note: more details are provided in the single commit messages.

Motivation:

the epoll native transport currently fails to compile on Android, due to a couple of compilation failures

transport-native-unix-common/src/main/c/netty_unix_errors.c:47:15: error: incompatible integer to pointer conversion initializing 'char *' with an expression of type 'int' [-Wint-conversion]
   47 |         char* tmp = strerror_r(errnum, strerrbuf, buflen);
      |               ^     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

and

transport-native-unix-common/src/main/c/netty_unix_socket.c:449:9: error: call to undeclared library function 'bzero' with type 'void (void *, unsigned long)'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
  449 |         bzero(&addr, sizeof(addr)); // Zap addr so we can strlen(addr.sun_path) later. See unix(4).
      |         ^
transport-native-unix-common/src/main/c/netty_unix_socket.c:449:9: note: include the header <strings.h> or explicitly provide a declaration for 'bzero'
  • netty_unix_socket.c uses bzero (in a single place). bzero is defined in strings.h, which however does not seem to be pulled in by default in Android with the current includes.
    Moreover, bzero is deprecated and was dropped in POSIX 2018. See POSIX 2018 docs and relevant AOSP 16 code.
  • netty_unix_errors.c currently uses the GNU strerror_r on Android.
    Android, however, only exposes the GNU strerror_r when _GNU_SOURCE is defined and only on API level 23+.
    See relevant AOSP 16 code

Modification:

  • a dedicated repository was spun up to allow reproducing the build failures
    • it is an Android project containing the necessary plumbing to build the epoll native transport
    • it can be easily built by following the instructions in the README in the project repo
  • replace the deprecated bzero with memset, already used for the very same purpose in many places in the same file.
  • use the XSI strerror_r on Android, when _GNU_SOURCE is not defined

Result:

  • epoll native transport builds and Epoll.ensureAvailability() succeeds on Android.
    Tested on Android 16 emulator image BP41.250916.009.A1 (x86_64), NDK 27.0.12077973

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
faenil added 2 commits December 11, 2025 10:10
@faenil
Use the XSI compliant strerror_r on Android when !_GNU_SOURCE
477923d
Motivation:

netty_unix_errors.c fails to build on Android platforms due to the
the current logic defaulting to the GNU strerror_r, which is not
exposed on Android when _GNU_SOURCE is not defined.

Android exposes the XSI strerror_r by default, so it can be used directly.
https://cs.android.com/android/platform/superproject/+/android16-release:bionic/libc/include/string.h;l=145?q=string.h

The GNU version is also available but only on API level 23+ (and
only when _GNU_SOURCE is defined), as explained at the link above.

Modifications:

- add __ANDROID__ to the platforms that use the XSI strerror_r when
  _GNU_SOURCE is not defined

Result:

netty_unix_errors.c compiles successfully on Android.
Tested on Android 16 emulator image, NDK 27.0.12077973
@faenil
netty_unix_socket: replace deprecated bzero with memset
3bf8868
Motivations:
- netty_unix_socket.c fails to compile on Android (NDK 27.0.12077973).
- bzero is deprecated and was removed in POSIX 2018.
  The recommendation is to replace it with memset
  See https://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_xsh_chap03.html
  and https://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_xsh_chap01.html

Modifications:
- replace bzero with memset, already used elsewhere in the same file.
  The alternative would be to include <strings.h> on __ANDROID__, which
  provides a definition for bzero
  https://cs.android.com/android/platform/superproject/+/android16-release:bionic/libc/include/strings.h;l=69
  but given that bzero is deprecated and this .c file already uses memset
  extensively for the very same purpose of zeroing out address structs,
  then it was deemed more sensible to bring consistency and replace the
  deprecated call.

Result:
- netty_unix_socket.c compiles successfully on Android.
  Tested on Android 16 emulator and NDK 27.0.12077973
- higher level result: the epoll native transport now can be
  compiled and used on Android (see tested environment above)
@faenil

faenil commented Dec 11, 2025

Copy link
Copy Markdown
Contributor Author

cc @chrisvest FYI, as author of the commit introducing the bzero line that's being changed
d1a8cd2

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@faenil

faenil commented Dec 11, 2025

Copy link
Copy Markdown
Contributor Author

There is also the option of using memset_s but I haven't gone in that direction as the rest of the file is relying on memset so I leaned towards caution and consistency to any potential of regressions.

Let me know if you feel otherwise 👍

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

normanmaurer
normanmaurer approved these changes Dec 11, 2025
View reviewed changes
chrisvest
chrisvest approved these changes Dec 11, 2025
View reviewed changes
normanmaurer
normanmaurer approved these changes Dec 11, 2025
View reviewed changes
@normanmaurer
normanmaurer merged commit d011634 into netty:4.2 Dec 11, 2025
normanmaurer pushed a commit that referenced this pull request Dec 11, 2025
@faenil @normanmaurer
Build fixes to allow using the epoll native transport on Android (#16016
0c78792
)

**Note**: more details are provided in the single commit messages.

## Motivation:
the epoll native transport currently fails to compile on Android, due to
a couple of compilation failures
```
transport-native-unix-common/src/main/c/netty_unix_errors.c:47:15: error: incompatible integer to pointer conversion initializing 'char *' with an expression of type 'int' [-Wint-conversion]
   47 |         char* tmp = strerror_r(errnum, strerrbuf, buflen);
      |               ^     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```
and
```
transport-native-unix-common/src/main/c/netty_unix_socket.c:449:9: error: call to undeclared library function 'bzero' with type 'void (void *, unsigned long)'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
  449 |         bzero(&addr, sizeof(addr)); // Zap addr so we can strlen(addr.sun_path) later. See unix(4).
      |         ^
transport-native-unix-common/src/main/c/netty_unix_socket.c:449:9: note: include the header <strings.h> or explicitly provide a declaration for 'bzero'
```
- `netty_unix_socket.c` uses `bzero` (in a single place). `bzero` is
defined in `strings.h`, which however does not seem to be pulled in by
default in Android with the current includes.
Moreover, `bzero` is deprecated and was dropped in POSIX 2018. See
[POSIX 2018
docs](https://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_xsh_chap03.html)
and [relevant AOSP 16
code](https://cs.android.com/android/platform/superproject/+/android16-release:bionic/libc/include/strings.h;l=69).
- `netty_unix_errors.c` currently uses the GNU `strerror_r` on Android.
Android, however, only exposes the GNU `strerror_r` when `_GNU_SOURCE`
is defined and only on API level 23+.
See [relevant AOSP 16
code](https://cs.android.com/android/platform/superproject/+/android16-release:bionic/libc/include/string.h;l=145?q=string.h)

## Modification:
- a [dedicated
repository](https://github.com/faenil/NettyEpollAndroidBuildFailureTest)
was spun up to allow reproducing the build failures
- it is an Android project containing the necessary plumbing to build
the epoll native transport
- it can be easily built by following the instructions in the `README`
in the project repo
- replace the deprecated `bzero` with `memset`, already used for the
very same purpose in many places in the same file.
- use the XSI `strerror_r` on Android, when `_GNU_SOURCE` is not defined

## Result:
- epoll native transport builds and `Epoll.ensureAvailability()`
succeeds on Android.
Tested on Android 16 emulator image `BP41.250916.009.A1` (x86_64), NDK
`27.0.12077973`
normanmaurer pushed a commit that referenced this pull request Dec 11, 2025
@faenil @normanmaurer
Build fixes to allow using the epoll native transport on Android (#16016
decf710
)

**Note**: more details are provided in the single commit messages.

## Motivation:
the epoll native transport currently fails to compile on Android, due to
a couple of compilation failures
```
transport-native-unix-common/src/main/c/netty_unix_errors.c:47:15: error: incompatible integer to pointer conversion initializing 'char *' with an expression of type 'int' [-Wint-conversion]
   47 |         char* tmp = strerror_r(errnum, strerrbuf, buflen);
      |               ^     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```
and
```
transport-native-unix-common/src/main/c/netty_unix_socket.c:449:9: error: call to undeclared library function 'bzero' with type 'void (void *, unsigned long)'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
  449 |         bzero(&addr, sizeof(addr)); // Zap addr so we can strlen(addr.sun_path) later. See unix(4).
      |         ^
transport-native-unix-common/src/main/c/netty_unix_socket.c:449:9: note: include the header <strings.h> or explicitly provide a declaration for 'bzero'
```
- `netty_unix_socket.c` uses `bzero` (in a single place). `bzero` is
defined in `strings.h`, which however does not seem to be pulled in by
default in Android with the current includes.
Moreover, `bzero` is deprecated and was dropped in POSIX 2018. See
[POSIX 2018
docs](https://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_xsh_chap03.html)
and [relevant AOSP 16
code](https://cs.android.com/android/platform/superproject/+/android16-release:bionic/libc/include/strings.h;l=69).
- `netty_unix_errors.c` currently uses the GNU `strerror_r` on Android.
Android, however, only exposes the GNU `strerror_r` when `_GNU_SOURCE`
is defined and only on API level 23+.
See [relevant AOSP 16
code](https://cs.android.com/android/platform/superproject/+/android16-release:bionic/libc/include/string.h;l=145?q=string.h)

## Modification:
- a [dedicated
repository](https://github.com/faenil/NettyEpollAndroidBuildFailureTest)
was spun up to allow reproducing the build failures
- it is an Android project containing the necessary plumbing to build
the epoll native transport
- it can be easily built by following the instructions in the `README`
in the project repo
- replace the deprecated `bzero` with `memset`, already used for the
very same purpose in many places in the same file.
- use the XSI `strerror_r` on Android, when `_GNU_SOURCE` is not defined

## Result:
- epoll native transport builds and `Epoll.ensureAvailability()`
succeeds on Android.
Tested on Android 16 emulator image `BP41.250916.009.A1` (x86_64), NDK
`27.0.12077973`
@chrisvest

chrisvest commented Dec 11, 2025

Copy link
Copy Markdown
Member

thanks, @faenil !

normanmaurer reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@normanmaurer normanmaurer added this to the 4.2.8.Final milestone Dec 11, 2025
@faenil

faenil commented Dec 11, 2025

Copy link
Copy Markdown
Contributor Author

thanks for the quick reviews! Happy to help!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@normanmaurer normanmaurer mentioned this pull request Oct 1, 2026
child5 #17695
Closed
@normanmaurer normanmaurer mentioned this pull request Oct 26, 2026
crisp nova cceda091 #18109
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@chrisvest chrisvest chrisvest approved these changes
@normanmaurer normanmaurer normanmaurer approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

4.2.8.Final

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@faenil @chrisvest @normanmaurer
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.