• Kirill Smelkov's avatar
    bigfile/ram_shmfs: Try to support compiling on older systems · 48defba0
    Kirill Smelkov authored
    For example on Debian 7 Wheezy the kernel (linux 3.2) supports holepunching,
    because holepunching was added in linux 2.6.38:
    
        http://git.kernel.org/linus/79124f18b335172e1916075c633745e12dae1dac
    
    but glibc does not provide fallocate mode constants, and compilation fails:
    
        gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -D_GNU_SOURCE -I./include -I./3rdparty/ccan -I./3rdparty/include -I/opt/slapgrid/f2a5f59d0d2b521681b9333ee76a2859/parts/python2.7/include/python2.7 -c bigfile/ram_shmfs.c -o build/temp.linux-x86_64-2.7/bigfile/ram_shmfs.o -std=gnu99 -fplan9-extensions -fvisibility=hidden -Wno-declaration-after-statement -Wno-error=declaration-after-statement
        bigfile/ram_shmfs.c: In function ‘shmfs_drop_memory’:
        bigfile/ram_shmfs.c:135:31: error: ‘FALLOC_FL_PUNCH_HOLE’ undeclared (first use in this function)
        bigfile/ram_shmfs.c:135:31: note: each undeclared identifier is reported only once for each function it appears in
        bigfile/ram_shmfs.c:135:54: error: ‘FALLOC_FL_KEEP_SIZE’ undeclared (first use in this function)
        error: command 'gcc' failed with exit status 1
    
    Try to fix it via fallbacking to provide the needed defines on older systems ourselves.
    
    Cc: Klaus Wölfel <klaus@nexedi.com>
    Cc: Ivan Tyagov <ivan@tyagov.com>
    48defba0
ram_shmfs.c 7.04 KB