diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2003-12-01 17:26:28 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2003-12-01 17:26:28 +0000 |
commit | dc3998682acd295299bffc3c544af74503e1dc02 (patch) | |
tree | 9d483f863e7902630121a627e6db18f632e3ad60 /winsup/cygwin/fcntl.cc | |
parent | 6c2b7846124572ffed3ce4fea074cc89e732651c (diff) | |
download | cygnal-dc3998682acd295299bffc3c544af74503e1dc02.tar.gz cygnal-dc3998682acd295299bffc3c544af74503e1dc02.tar.bz2 cygnal-dc3998682acd295299bffc3c544af74503e1dc02.zip |
* Makefile.in (OBSOLETE_FUNCTIONS): Add fcntl.
(NEW_FUNCTIONS): Add fcntl64.
* cygwin.din: Export fcntl64. Make fcntl being SIGFE.
* fcntl.cc (fcntl_worker): New function.
(fcntl64): New function.
(_fcntl): Call fcntl_worker. Convert 32 bit flock structure into
64 bit flock structure and vice versa.
* fhandler.cc (fhandler_base::lock): Change 2nd parameter to
struct __flock64 *.
* fhandler_disk_file.cc (fhandler_disk_file::lock): Ditto. Rework
to be 64 bit aware.
* fhandler.h: Accomodate above method argument changes.
* include/cygwin/types.h: Add struct __flock32 and __flock64.
Define struct flock according to setting of __CYGWIN_USE_BIG_TYPES__.
* include/cygwin/version.h: Bump API minor number.
Diffstat (limited to 'winsup/cygwin/fcntl.cc')
-rw-r--r-- | winsup/cygwin/fcntl.cc | 56 |
1 files changed, 47 insertions, 9 deletions
diff --git a/winsup/cygwin/fcntl.cc b/winsup/cygwin/fcntl.cc index b1afb57d3..89287b647 100644 --- a/winsup/cygwin/fcntl.cc +++ b/winsup/cygwin/fcntl.cc @@ -19,11 +19,9 @@ details. */ #include "cygheap.h" #include "thread.h" -extern "C" int -_fcntl (int fd, int cmd,...) +static int +fcntl_worker (int fd, int cmd, void *arg) { - void *arg = NULL; - va_list args; int res; cygheap_fdget cfd (fd, true); @@ -32,16 +30,56 @@ _fcntl (int fd, int cmd,...) res = -1; goto done; } - - va_start (args, cmd); - arg = va_arg (args, void *); if (cmd != F_DUPFD) res = cfd->fcntl(cmd, arg); else res = dup2 (fd, cygheap_fdnew (((int) arg) - 1)); - va_end (args); - done: syscall_printf ("%d = fcntl (%d, %d, %p)", res, fd, cmd, arg); return res; } + +extern "C" int +fcntl64 (int fd, int cmd,...) +{ + void *arg = NULL; + va_list args; + + va_start (args, cmd); + arg = va_arg (args, void *); + va_end (args); + return fcntl_worker (fd, cmd, arg); +} + +extern "C" int +_fcntl (int fd, int cmd,...) +{ + void *arg = NULL; + va_list args; + struct __flock32 *src; + struct __flock64 dst; + + va_start (args, cmd); + arg = va_arg (args, void *); + va_end (args); + if (cmd == F_GETLK || cmd == F_SETLK || cmd == F_SETLKW) + { + src = (struct __flock32 *)arg; + dst.l_type = src->l_type; + dst.l_whence = src->l_whence; + dst.l_start = src->l_start; + dst.l_len = src->l_len; + dst.l_pid = src->l_pid; + arg = &dst; + } + int res = fcntl_worker (fd, cmd, arg); + if (cmd == F_GETLK) + { + src->l_type = dst.l_type; + src->l_whence = dst.l_whence; + src->l_start = dst.l_start; + src->l_len = dst.l_len; + src->l_pid = (short)dst.l_pid; + } + return res; +} |