From b406ed7b51a9faa7bf3efaaefab51ecb67d7068b Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Sun, 30 Nov 2003 10:43:04 +0000 Subject: * flock.cc: Renamed from flock.c. --- winsup/cygwin/ChangeLog | 4 +++ winsup/cygwin/flock.c | 89 ------------------------------------------------- winsup/cygwin/flock.cc | 89 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 93 insertions(+), 89 deletions(-) delete mode 100644 winsup/cygwin/flock.c create mode 100644 winsup/cygwin/flock.cc (limited to 'winsup') diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index bc491a255..1ed275aa7 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,7 @@ +2003-11-30 Corinna Vinschen + + * flock.cc: Renamed from flock.c. + 2003-11-29 Christopher Faylor * pinfo.h: Remove global_sigs declaration. diff --git a/winsup/cygwin/flock.c b/winsup/cygwin/flock.c deleted file mode 100644 index 09ea2b6db..000000000 --- a/winsup/cygwin/flock.c +++ /dev/null @@ -1,89 +0,0 @@ -/* One of many ways to emulate flock() on top of real (good) POSIX locks. - * - * This flock() emulation is based upon source taken from the Red Hat - * implementation used in their imap-2002d SRPM. - * - * $RH: flock.c,v 1.2 2000/08/23 17:07:00 nalin Exp $ - */ -/* flock.c - - Copyright 2003 Red Hat, Inc. - - This file is part of Cygwin. - - This software is a copyrighted work licensed under the terms of the - Cygwin license. Please consult the file "CYGWIN_LICENSE" for - details. */ - -#include -#include -#include -#include -#include - -int -flock (int fd, int operation) -{ - int i, cmd; - struct flock l = { 0, 0, 0, 0, 0 }; - if (operation & LOCK_NB) - { - cmd = F_SETLK; - } - else - { - cmd = F_SETLKW; - } - l.l_whence = SEEK_SET; - switch (operation & (~LOCK_NB)) - { - case LOCK_EX: - l.l_type = F_WRLCK; - i = fcntl (fd, cmd, &l); - if (i == -1) - { - if ((errno == EAGAIN) || (errno == EACCES)) - { - errno = EWOULDBLOCK; - } - } - break; - case LOCK_SH: - l.l_type = F_RDLCK; - i = fcntl (fd, cmd, &l); - if (i == -1) - { - if ((errno == EAGAIN) || (errno == EACCES)) - { - errno = EWOULDBLOCK; - } - } - break; - case LOCK_UN: - l.l_type = F_UNLCK; - i = fcntl (fd, cmd, &l); - if (i == -1) - { - if ((errno == EAGAIN) || (errno == EACCES)) - { - errno = EWOULDBLOCK; - } - } - break; - default: - i = -1; - errno = EINVAL; - break; - } - return i; -} - -#ifdef FLOCK_EMULATE_IS_MAIN -int -main (int argc, char **argv) -{ - int fd = open (argv[1], O_WRONLY); - flock (fd, LOCK_EX); - return 0; -} -#endif diff --git a/winsup/cygwin/flock.cc b/winsup/cygwin/flock.cc new file mode 100644 index 000000000..09ea2b6db --- /dev/null +++ b/winsup/cygwin/flock.cc @@ -0,0 +1,89 @@ +/* One of many ways to emulate flock() on top of real (good) POSIX locks. + * + * This flock() emulation is based upon source taken from the Red Hat + * implementation used in their imap-2002d SRPM. + * + * $RH: flock.c,v 1.2 2000/08/23 17:07:00 nalin Exp $ + */ +/* flock.c + + Copyright 2003 Red Hat, Inc. + + This file is part of Cygwin. + + This software is a copyrighted work licensed under the terms of the + Cygwin license. Please consult the file "CYGWIN_LICENSE" for + details. */ + +#include +#include +#include +#include +#include + +int +flock (int fd, int operation) +{ + int i, cmd; + struct flock l = { 0, 0, 0, 0, 0 }; + if (operation & LOCK_NB) + { + cmd = F_SETLK; + } + else + { + cmd = F_SETLKW; + } + l.l_whence = SEEK_SET; + switch (operation & (~LOCK_NB)) + { + case LOCK_EX: + l.l_type = F_WRLCK; + i = fcntl (fd, cmd, &l); + if (i == -1) + { + if ((errno == EAGAIN) || (errno == EACCES)) + { + errno = EWOULDBLOCK; + } + } + break; + case LOCK_SH: + l.l_type = F_RDLCK; + i = fcntl (fd, cmd, &l); + if (i == -1) + { + if ((errno == EAGAIN) || (errno == EACCES)) + { + errno = EWOULDBLOCK; + } + } + break; + case LOCK_UN: + l.l_type = F_UNLCK; + i = fcntl (fd, cmd, &l); + if (i == -1) + { + if ((errno == EAGAIN) || (errno == EACCES)) + { + errno = EWOULDBLOCK; + } + } + break; + default: + i = -1; + errno = EINVAL; + break; + } + return i; +} + +#ifdef FLOCK_EMULATE_IS_MAIN +int +main (int argc, char **argv) +{ + int fd = open (argv[1], O_WRONLY); + flock (fd, LOCK_EX); + return 0; +} +#endif -- cgit v1.2.3