-#if defined(USE_POSIX_FCNTL)
- static struct flock lock; /* zero-initialized */
-#endif
-
-#if !defined(USE_POSIX_FCNTL) && defined(USE_FLOCK)
-# ifdef HAVE_SYS_FILE_H
-# include <sys/file.h>
-# endif
-
-# if !defined(HAVE_FLOCK_DECL) && !defined(CONFIGURE_TEST)
- extern int flock P((int fd, int operation));
-# endif
-#endif
-
-
-#if !defined(USE_POSIX_FCNTL) && !defined(USE_FLOCK) && defined(USE_LOCKF)
-
-/* XPG4-UNIX (eg, SGI IRIX, DEC DU) has F_ULOCK instead of F_UNLOCK */
-#if defined(F_ULOCK) && !defined(F_UNLOCK)
-# define F_UNLOCK F_ULOCK
-#endif
-
-/* Lock a file using lockf().
-** Notes:
-** - returns errors for some non-files like pipes.
-** - probably only works for files open for writing.
-*/
-int use_lockf(fd, op)
-int fd; /* fd of file to operate on */
-int op; /* true to lock; false to unlock */
-{
- off_t pos;
-
- if (op) {
- /* lock from here on */
- if (lockf(fd, F_LOCK, (off_t)0) == -1) return -1;
- }
- else {
- /* unlock from here on */
- if (lockf(fd, F_UNLOCK, (off_t)0) == -1) return -1;
-
- /* unlock from bof to here */
- pos = lseek(fd, (off_t)0, SEEK_CUR);
- if (pos == (off_t)-1) {
- if (errno == ESPIPE) pos = (off_t)0;
- else return -1;
- }
-
- if (pos > (off_t)0 &&
- lockf(fd, F_UNLOCK, -pos) == -1) return -1;
- }
-
- return 0;
-}
-
-#endif