X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fflock.c;h=f643f32d374345ec3c1219ad76aa6f1d8b958285;hb=14b6d70139486b63e66257aad1abe2a9615f4d96;hp=5aa7690bd8732286a86531ca56aecb3abb04cb83;hpb=e69247d77e183da8d4d1d20e8993933aa420cbca;p=gnulib.git diff --git a/lib/flock.c b/lib/flock.c index 5aa7690bd..f643f32d3 100644 --- a/lib/flock.c +++ b/lib/flock.c @@ -6,7 +6,7 @@ Written by Richard W.M. Jones - Copyright (C) 2008 Free Software Foundation, Inc. + Copyright (C) 2008-2010 Free Software Foundation, Inc. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -130,27 +130,27 @@ flock (int fd, int operation) { DWORD err = GetLastError (); switch (err) - { - /* This means someone else is holding a lock. */ - case ERROR_LOCK_VIOLATION: - errno = EAGAIN; - break; - - /* Out of memory. */ - case ERROR_NOT_ENOUGH_MEMORY: - errno = ENOMEM; - break; - - case ERROR_BAD_COMMAND: - errno = EINVAL; - break; - - /* Unlikely to be other errors, but at least don't lose the - * error code. - */ - default: - errno = err; - } + { + /* This means someone else is holding a lock. */ + case ERROR_LOCK_VIOLATION: + errno = EAGAIN; + break; + + /* Out of memory. */ + case ERROR_NOT_ENOUGH_MEMORY: + errno = ENOMEM; + break; + + case ERROR_BAD_COMMAND: + errno = EINVAL; + break; + + /* Unlikely to be other errors, but at least don't lose the + * error code. + */ + default: + errno = err; + } return -1; } @@ -160,7 +160,7 @@ flock (int fd, int operation) #else /* !Windows */ -#ifdef HAVE_FLOCK_L_TYPE +#ifdef HAVE_STRUCT_FLOCK_L_TYPE /* We know how to implement flock in terms of fcntl. */ #ifdef HAVE_FCNTL_H @@ -171,6 +171,9 @@ flock (int fd, int operation) #include #endif +#include +#include + int flock (int fd, int operation) { @@ -210,10 +213,10 @@ flock (int fd, int operation) return r; } -#else /* !HAVE_FLOCK_L_TYPE */ +#else /* !HAVE_STRUCT_FLOCK_L_TYPE */ #error "This platform lacks flock function, and Gnulib doesn't provide a replacement. This is a bug in Gnulib." -#endif /* !HAVE_FLOCK_L_TYPE */ +#endif /* !HAVE_STRUCT_FLOCK_L_TYPE */ #endif /* !Windows */