Skip to content
Snippets Groups Projects
user avatar
Ammar Faizi authored
Make it possible to remove the dependency of `errno` variable (which
comes from libc).

Currently, we expose these functions to userland:
  1) `__sys_io_uring_register`
  2) `__sys_io_uring_setup`
  3) `__sys_io_uring_enter2`
  4) `__sys_io_uring_enter`

The tests in `test/io_uring_{enter,register,setup}.c` are the examples
of it. Since the userland needs to check the `errno` value to use them
properly, this means those functions always depend on libc. So we
cannot change their behavior. Don't touch them all, this ensures the
changes only affect liburing internal and no visible functionality
changes for the users.

Then we introduce new functions with the same name (with extra
underscore as prefix, 4 underscores):
  1) `____sys_io_uring_register`
  2) `____sys_io_uring_setup`
  3) `____sys_io_uring_enter2`
  4) `____sys_io_uring_enter`

These functions do not use `errno` variable *on the caller*, they use
the kernel style return value (return a negative value of error code
when errors).

These functions are defined as `static inline` in `src/syscall.h`.
They are just a wrapper to make sure liburing internal sources do not
touch `errno` variable from C files directly. We need to make C files
not to touch the `errno` variable to support build without libc.

Link: https://github.com/axboe/liburing/issues/443#issuecomment-927873932


Cc: Bedirhan KURT <windowz414@gnuweeb.org>
Suggested-by: default avatarLouvian Lyndal <louvianlyndal@gmail.com>
Signed-off-by: default avatarAmmar Faizi <ammar.faizi@students.amikom.ac.id>
Link: https://lore.kernel.org/r/20211003153428.369258-2-ammar.faizi@students.amikom.ac.id


Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
1c591c36
Name Last commit Last update