]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commit
pybind/cephfs: replace deprecated IF with C preprocessor macro
authorKefu Chai <k.chai@proxmox.com>
Fri, 30 Jan 2026 08:43:03 +0000 (16:43 +0800)
committerKefu Chai <k.chai@proxmox.com>
Mon, 2 Feb 2026 03:14:44 +0000 (11:14 +0800)
commitf0786a7497146944d39670a6c124e3392d84ea8a
tree54a3788f5b4490444e699d0ab91b40aa94af4d67
parent2170ee12e45e0d61f39e7b4c49d5f40b9ce10019
pybind/cephfs: replace deprecated IF with C preprocessor macro

Complete the migration started in 719b74984605 by replacing
deprecated Cython IF statements with C preprocessor conditionals.

The cephfs binding used deprecated IF/ELSE statements in types.pxd
for platform-specific dirent struct definitions. The challenge was that
dirent has a d_off field on Linux but not on FreeBSD/Darwin.

Solution:
- Remove dirent declaration from types.pxd (had deprecated IF)
- Declare dirent with common fields in c_cephfs.pxd
- Define DIRENT_D_OFF(d) C macro using C preprocessor conditionals:
  - Returns d->d_off on Linux
  - Returns 0UL on FreeBSD/Darwin
- Use DIRENT_D_OFF macro in cephfs.pyx instead of conditional field access
- No Tempita preprocessing or UNAME_SYSNAME needed
- Revert setup.py to original (no changes needed)

Why C preprocessor instead of Tempita:
Tempita requires preprocessing files with setup.py, which works for .pyx
files but is problematic for .pxd files since setup.py runs in the source
directory and could overwrite sources. The C preprocessor approach is
cleaner, requires no setup.py changes, and follows the pattern used in
rados.pxd for BUILD_DOC conditionals.

This eliminates all deprecated Cython IF statements and prepares
for Cython 3.0+ compatibility. The C preprocessor approach allows
portable access to platform-specific struct fields without Cython IF.

Signed-off-by: Kefu Chai <k.chai@proxmox.com>
src/pybind/cephfs/c_cephfs.pxd
src/pybind/cephfs/cephfs.pyx
src/pybind/cephfs/mock_cephfs.pxi
src/pybind/cephfs/types.pxd