]> git.saurik.com Git - apple/libc.git/blob - gen/FreeBSD/lockf.c.patch
Libc-498.1.5.tar.gz
[apple/libc.git] / gen / FreeBSD / lockf.c.patch
1 --- lockf.c.orig 2006-09-16 19:12:39.000000000 -0700
2 +++ lockf.c 2006-09-16 20:35:36.000000000 -0700
3 @@ -38,6 +38,13 @@
4 #include <sys/cdefs.h>
5 __FBSDID("$FreeBSD: src/lib/libc/gen/lockf.c,v 1.8 2002/02/01 00:57:29 obrien Exp $");
6
7 +#ifdef VARIANT_CANCELABLE
8 +int __fcntl(int, int, void *);
9 +#else /* !VARIANT_CANCELABLE */
10 +int __fcntl_nocancel(int, int, void *);
11 +#endif /* VARIANT_CANCELABLE */
12 +
13 +
14 #include "namespace.h"
15 #include <errno.h>
16 #include <fcntl.h>
17 @@ -53,6 +60,7 @@
18 struct flock fl;
19 int cmd;
20
21 +
22 fl.l_start = 0;
23 fl.l_len = size;
24 fl.l_whence = SEEK_CUR;
25 @@ -72,8 +80,13 @@
26 break;
27 case F_TEST:
28 fl.l_type = F_WRLCK;
29 - if (_fcntl(filedes, F_GETLK, &fl) == -1)
30 +#ifdef VARIANT_CANCELABLE
31 + if (__fcntl(filedes, F_GETLK, &fl) == -1)
32 return (-1);
33 +#else /* !VARIANT_CANCELABLE */
34 + if (__fcntl_nocancel(filedes, F_GETLK, &fl) == -1)
35 + return (-1);
36 +#endif /* VARIANT_CANCELABLE */
37 if (fl.l_type == F_UNLCK || fl.l_pid == getpid())
38 return (0);
39 errno = EAGAIN;
40 @@ -85,5 +98,10 @@
41 /* NOTREACHED */
42 }
43
44 - return (_fcntl(filedes, cmd, &fl));
45 +#ifdef VARIANT_CANCELABLE
46 + return (__fcntl(filedes, cmd, &fl));
47 +#else /* !VARIANT_CANCELABLE */
48 + return (__fcntl_nocancel(filedes, cmd, &fl));
49 +#endif /* VARIANT_CANCELABLE */
50 }
51 +