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>