https://github.com/rahul05ranjan commented:

Verified this against the existing wrappers before commenting: the new 
`linux_syscalls::semget` header and the entrypoint rewrite in 
`libc/src/sys/sem/linux/semget.cpp` match the established pattern from 
`close.cpp` / `syscall_wrappers/close.h` exactly (ErrorOr via 
`syscall_checked`, then `libc_errno = result.error()` and `return -1`).

Details I checked:

- `if (!result)` on `ErrorOr<int>` is valid because `cpp::expected` declares 
`explicit operator bool()` (`src/__support/CPP/expected.h`), same as the other 
entrypoints that go through this path.
- The errno path is equivalent to the old code: `syscall_checked` returns 
`Error(-ret)` for `ret >= -MAX_ERRNO` (`src/__support/OSUtil/linux/syscall.h`), 
so `libc_errno = result.error()` preserves the previous `libc_errno = -ret` 
semantics. The only behavioral difference is the `ret < -4095` window, which 
the old `ret < 0` check would have misclassified as an error; since semget's 
successful returns are non-negative ids, that window is unreachable here in 
practice.
- The `libc/src/sys/sem/linux/CMakeLists.txt` change correctly moves 
`libc.include.sys_syscall` and `osutil` into the new wrapper target and adds 
`libc.src.__support.libc_errno` / `macros.config`, which the entrypoint now 
actually includes.
- The two new Bazel targets mirror the existing `types_pid_t` and wrapper 
shapes in `BUILD.bazel`, and the `:__support_osutil_syscall` dep already exists.

One nit: `semctl.cpp` and `semop.cpp` still use the old `syscall_impl` + `ret < 
0` form, so this migrates only one of the three sem entrypoints — fine if 
wrapping the rest is planned separately, but the mixed styles will be a small 
reading tax until then.


https://github.com/llvm/llvm-project/pull/236722
_______________________________________________
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

Reply via email to