Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] sys/socket.h should not declare SOCK_CLOEXEC and SOCK_NONBLOCK before __ANDROID_API__ >= 21 #1372

Closed
guillaume-michel opened this issue Nov 12, 2020 · 1 comment

Comments

@guillaume-michel
Copy link

Description

NDK's sys/socket.h defines SOCK_CLOEXEC and SOCK_NONBLOCK unconditionally but it can only be used by accept4 syscall which is guarded by ANDROID_API >= 21.

Some application may check if SOCK_CLOEXEC and SOCK_NONBLOCK are defined to decide if they can use accept4 or if they should fallback to accept. If SOCK_CLOEXEC and SOCK_NONBLOCK are defined but not accept4, you get an error when compiling for API level < 21.

Possible solution:
Adding a guard ANDROID_API >= 21 for the defines SOCK_CLOEXEC and SOCK_NONBLOCK will prevents such error.

Environment Details

  • NDK Version: 21.3.6528147
  • Build system: any (not related to build system)
  • Host OS: any (not related to host OS)
  • ABI: Android 19
  • NDK API level: 19
  • Device API level: 19
@DanAlbert
Copy link
Member

Having a low minSdkVersion but using new APIs via dlsym is common. If we hide the constants you can't do that.

Some application may check if SOCK_CLOEXEC and SOCK_NONBLOCK are defined to decide if they can use accept4

Those applications should check for accept4 if they want to know if accept4 is available.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants