Paolo Bonzini wrote: > > * About the function. Why flock() and not lockf()? > > There are three APIs for locking: > > - lockf in POSIX [1], > > - fcntl in POSIX [2], > > - flock in BSD and glibc [3][4]. > > > > According to the gnulib doc (doc/posix-functions/lockf.texi, > > doc/glibc-functions/flock.texi) lockf is supported on a wider range of > > platforms than flock. > > But lockf unlike flock does not support shared locks, which are very > useful. I can take care of implementing it in terms of fcntl when > Richard's patch goes in.
Very good point. You can write flock() in terms of fcntl()? Also, in glibc we have code for lockf() in terms of fcntl. The native OS support of these three APIs is that - fcntl with F_SETLK is supported on all Unix platforms. - lockf is supported on all Unix platforms except Cygwin, BeOS. - flock is supported on all Unix platforms except AIX, HP-UX, Solaris, BeOS. So with the two replacements for flock() and lockf() in place, and with an implementation of fcntl F_SETLK for mingw, we will get all three APIs supported in gnulib across all platforms! > I don't think having an fcntl wrapper in gnulib makes any sense). Why not? It does not need to support all possible control commands, only those that we chose to provide. Bruno
