1 /* test whether 64 bit fcntl locking really works on this system */
3 #if defined(HAVE_UNISTD_H)
15 #ifdef HAVE_SYS_FCNTL_H
16 #include <sys/fcntl.h>
21 #define DATA "conftest.fcntl64"
23 /* lock a byte range in a open file */
24 int main(int argc, char *argv[])
27 int fd, ret, status=1;
32 fd = open64(DATA, O_RDONLY);
34 if (fd == -1) exit(1);
36 lock.l_type = F_WRLCK;
37 lock.l_whence = SEEK_SET;
40 lock.l_pid = getpid();
42 lock.l_type = F_WRLCK;
44 /* check if a lock applies */
45 ret = fcntl(fd,F_GETLK64,&lock);
48 (lock.l_type == F_UNLCK)) {
49 /* printf("No lock conflict\n"); */
52 /* printf("lock conflict\n"); */
57 fd = open64(DATA, O_RDWR|O_CREAT|O_TRUNC, 0600);
59 lock.l_type = F_WRLCK;
60 lock.l_whence = SEEK_SET;
61 #if defined(COMPILER_SUPPORTS_LL)
62 lock.l_start = 0x100000000LL;
64 lock.l_start = 0x100000000;
67 lock.l_pid = getpid();
69 /* set a 4 byte write lock */
70 fcntl(fd,F_SETLK64,&lock);
72 sys_waitpid(pid, &status, 0);
74 #if defined(WIFEXITED) && defined(WEXITSTATUS)
75 if(WIFEXITED(status)) {
76 status = WEXITSTATUS(status);
80 #else /* defined(WIFEXITED) && defined(WEXITSTATUS) */
81 status = (status == 0) ? 0 : 1;
82 #endif /* defined(WIFEXITED) && defined(WEXITSTATUS) */