* fcntl.cc (fcntl_worker): Remove static storage class.

* flock.cc (flock): Use struct __flock64. Call fcntl_worker.
	Use Cygwin errno functions instead of accessing errno directly.
	* winsup.h: Declare fcntl_worker.
This commit is contained in:
Corinna Vinschen 2003-12-03 09:55:42 +00:00
parent 941c9bf805
commit e2a39e2efa
4 changed files with 24 additions and 15 deletions

View File

@ -1,6 +1,13 @@
2003-12-03 Corinna Vinschen <corinna@vinschen.de> 2003-12-03 Corinna Vinschen <corinna@vinschen.de>
* fcntl.cc (_fcntl): Whitespace cleanup. * fcntl.cc (fcntl_worker): Remove static storage class.
* flock.cc (flock): Use struct __flock64. Call fcntl_worker.
Use Cygwin errno functions instead of accessing errno directly.
* winsup.h: Declare fcntl_worker.
2003-12-03 Corinna Vinschen <corinna@vinschen.de>
* fcntl.cc: Whitespace cleanup.
2003-12-03 Christopher Faylor <cgf@redhat.com> 2003-12-03 Christopher Faylor <cgf@redhat.com>

View File

@ -19,7 +19,7 @@ details. */
#include "cygheap.h" #include "cygheap.h"
#include "thread.h" #include "thread.h"
static int int
fcntl_worker (int fd, int cmd, void *arg) fcntl_worker (int fd, int cmd, void *arg)
{ {
int res; int res;

View File

@ -15,9 +15,9 @@
Cygwin license. Please consult the file "CYGWIN_LICENSE" for Cygwin license. Please consult the file "CYGWIN_LICENSE" for
details. */ details. */
#include "winsup.h"
#include "cygerrno.h"
#include <sys/file.h> #include <sys/file.h>
#include <sys/types.h>
#include <errno.h>
#include <fcntl.h> #include <fcntl.h>
#include <unistd.h> #include <unistd.h>
@ -25,7 +25,7 @@ int
flock (int fd, int operation) flock (int fd, int operation)
{ {
int i, cmd; int i, cmd;
struct flock l = { 0, 0, 0, 0, 0 }; struct __flock64 l = { 0, 0, 0, 0, 0 };
if (operation & LOCK_NB) if (operation & LOCK_NB)
{ {
cmd = F_SETLK; cmd = F_SETLK;
@ -39,40 +39,40 @@ flock (int fd, int operation)
{ {
case LOCK_EX: case LOCK_EX:
l.l_type = F_WRLCK; l.l_type = F_WRLCK;
i = fcntl (fd, cmd, &l); i = fcntl_worker (fd, cmd, &l);
if (i == -1) if (i == -1)
{ {
if ((errno == EAGAIN) || (errno == EACCES)) if ((get_errno () == EAGAIN) || (get_errno () == EACCES))
{ {
errno = EWOULDBLOCK; set_errno (EWOULDBLOCK);
} }
} }
break; break;
case LOCK_SH: case LOCK_SH:
l.l_type = F_RDLCK; l.l_type = F_RDLCK;
i = fcntl (fd, cmd, &l); i = fcntl_worker (fd, cmd, &l);
if (i == -1) if (i == -1)
{ {
if ((errno == EAGAIN) || (errno == EACCES)) if ((get_errno () == EAGAIN) || (get_errno () == EACCES))
{ {
errno = EWOULDBLOCK; set_errno (EWOULDBLOCK);
} }
} }
break; break;
case LOCK_UN: case LOCK_UN:
l.l_type = F_UNLCK; l.l_type = F_UNLCK;
i = fcntl (fd, cmd, &l); i = fcntl_worker (fd, cmd, &l);
if (i == -1) if (i == -1)
{ {
if ((errno == EAGAIN) || (errno == EACCES)) if ((get_errno () == EAGAIN) || (get_errno () == EACCES))
{ {
errno = EWOULDBLOCK; set_errno (EWOULDBLOCK);
} }
} }
break; break;
default: default:
i = -1; i = -1;
errno = EINVAL; set_errno (EINVAL);
break; break;
} }
return i; return i;

View File

@ -298,6 +298,8 @@ int symlink_worker (const char *, const char *, bool, bool)
class path_conv; class path_conv;
int access_worker (path_conv&, int) __attribute__ ((regparm (2))); int access_worker (path_conv&, int) __attribute__ ((regparm (2)));
int fcntl_worker (int fd, int cmd, void *arg);
extern "C" int low_priority_sleep (DWORD) __attribute__ ((regparm (1))); extern "C" int low_priority_sleep (DWORD) __attribute__ ((regparm (1)));
#define SLEEP_0_STAY_LOW INFINITE #define SLEEP_0_STAY_LOW INFINITE