gittup/tup — comment on commit 25646fa8bc10a6efca784c659f002003b980b990
File: src/tup/server/fuse_fs.c line 847
By gittup:

On Sat, Jan 14, 2012 at 6:36 PM, Ben Noordhuis

wrote:
> That will fail if someone compiles against glibc headers that are newer than glibc itself (like when the user installs the binary onto another system).
>
> What I'd do is to try the syscall directly and fall back to `futimesat()` if it returns ENOSYS.
>
> ```c
> #include
> #include
>
> static int utimensat(int dfd, const char *path, const struct timespec times[2], int flags)
> {
> #if __NR_utimensat
> if (!syscall(__NR_utimensat, dfd, path, times, flags)) return 0;
> if (errno != ENOSYS) return -1;
> #endif
> return fallback_futimesat(dfd, path, times);
> }
> ```
>
> It's not particularly pretty but it works. The ENOSYS case clobbers errno, you may or may not want to fix that.

Is this how programs normally handle glibc version dependencies? I
thought the __GLIBC_PREREQ macro was the preferred way of handling it.
I'd rather not use syscalls directly from tup unless that's the way it
is commonly handled.

Thanks,
-Mike