On 10/3/21 9:34 AM, Ammar Faizi wrote: > Hi Jens, > > This is the v5 of the kernel style return value implementation for > liburing. > > The main purpose of these changes is to make it possible to remove > the dependency of `errno` variable in the liburing C sources. If we > can land this on liburing, we will start working on adding support > build liburing without 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. > > To completely remove the `errno` variable dependency from liburing C > files. We wrap all syscalls in a kernel style return value as well. > > Currently we have 5 other syscalls in liburing. We wrapped all of > them as these 5 functions: > 1) `uring_mmap` > 2) `uring_munmap` > 3) `uring_madvise` > 4) `uring_getrlimit` > 5) `uring_setrlimit` > > All of them are `static inline` and will return a negative value of > error code in case error happens. > > Extra new helpers: > 1) `ERR_PTR()` > 2) `PTR_ERR()` > 3) `IS_ERR()` > > These helpers are used to deal with syscalls that return a pointer. > Currently only `uring_mmap()` that depends on these. Thanks, let's give this a go. I've applied the 3 patches. -- Jens Axboe