mbox series

[liburing,v1,0/3] Fix Compilation Error on Android and Some Cleanup

Message ID 20250220143422.3597245-1-ammarfaizi2@gnuweeb.org (mailing list archive)
Headers show
Series Fix Compilation Error on Android and Some Cleanup | expand

Message

Ammar Faizi Feb. 20, 2025, 2:34 p.m. UTC
Hi Jens,

Another day in the thrilling world of cross-platform compatibility...

Alviro discovered that some Android versions are missing `aligned_alloc()`
in `<stdlib.h>`, leading to a compilation error on Termux 0.118.0:

```
cmd-discard.c:383:11: warning: call to undeclared library function \
'aligned_alloc' with type 'void *(unsigned long, unsigned long)'; ISO \
C99 and later do not support implicit function declarations \
[-Wimplicit-function-declaration]

        buffer = aligned_alloc(lba_size, lba_size);
                 ^
```

To resolve this without rewriting large portions of liburing tests,
introduce a helper function that wraps `posix_memalign()` and provides
our own `aligned_alloc()`.

While we're at it, there's a redundant double negation lurking in
`liburing.h`. Let's clean that up too.  

Also, to prevent yet another round of confusion like what happened in
PR #1336, document the history of `io_uring_get_sqe()` in the header
file.

Ref: https://github.com/axboe/liburing/pull/1336

Signed-off-by: Alviro Iskandar Setiawan <alviro.iskandar@gnuweeb.org>
Signed-off-by: Ammar Faizi <ammarfaizi2@gnuweeb.org>
---

Ammar Faizi (3):
  liburing.h: Remove redundant double negation
  liburing.h: Explain the history of `io_uring_get_sqe()`
  Fix missing `aligned_alloc()` on some Android devices

 examples/helpers.c     | 10 ++++++++++
 examples/helpers.h     |  7 +++++++
 examples/reg-wait.c    |  2 ++
 src/include/liburing.h | 21 ++++++++++++++++++++-
 test/helpers.c         | 10 ++++++++++
 test/helpers.h         |  8 ++++++++
 6 files changed, 57 insertions(+), 1 deletion(-)


base-commit: 66b071d1470ae787d47d4cb8d9cb3836249baf61

Comments

Jens Axboe Feb. 20, 2025, 2:51 p.m. UTC | #1
On Thu, 20 Feb 2025 21:34:19 +0700, Ammar Faizi wrote:
> Another day in the thrilling world of cross-platform compatibility...
> 
> Alviro discovered that some Android versions are missing `aligned_alloc()`
> in `<stdlib.h>`, leading to a compilation error on Termux 0.118.0:
> 
> ```
> cmd-discard.c:383:11: warning: call to undeclared library function \
> 'aligned_alloc' with type 'void *(unsigned long, unsigned long)'; ISO \
> C99 and later do not support implicit function declarations \
> [-Wimplicit-function-declaration]
> 
> [...]

Applied, thanks!

[1/3] liburing.h: Remove redundant double negation
      commit: 1d11475301931478bb35f2573e1741f5d9088132
[2/3] liburing.h: Explain the history of `io_uring_get_sqe()`
      commit: d1c100351ffb3483f5d3fc661b2d41d48062bec1
[3/3] Fix missing `aligned_alloc()` on some Android devices
      commit: 5c788d514b9ed6d1a3624150de8aa6db403c1c65

Best regards,