diff options
Diffstat (limited to 'missing/flock.c')
| -rw-r--r-- | missing/flock.c | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/missing/flock.c b/missing/flock.c index 7a5a58aaa7..0b76961762 100644 --- a/missing/flock.c +++ b/missing/flock.c @@ -1,8 +1,19 @@ -#include "config.h" +#include "ruby/internal/config.h" +#include "ruby/ruby.h" -#if defined HAVE_FCNTL && defined HAVE_FCNTL_H +#if defined _WIN32 +#elif defined __wasi__ +#include <errno.h> -/* These are the flock() constants. Since this sytems doesn't have +int +flock(int fd, int operation) +{ + errno = EINVAL; + return -1; +} +#elif defined HAVE_FCNTL && defined HAVE_FCNTL_H + +/* These are the flock() constants. Since this systems doesn't have flock(), the values of the constants are probably not available. */ # ifndef LOCK_SH @@ -26,7 +37,7 @@ int flock(int fd, int operation) { struct flock lock; - + switch (operation & ~LOCK_NB) { case LOCK_SH: lock.l_type = F_RDLCK; @@ -43,7 +54,7 @@ flock(int fd, int operation) } lock.l_whence = SEEK_SET; lock.l_start = lock.l_len = 0L; - + return fcntl(fd, (operation & LOCK_NB) ? F_SETLK : F_SETLKW, &lock); } @@ -71,7 +82,7 @@ flock(int fd, int operation) # define F_TEST 3 /* Test a region for other processes locks */ # endif -/* These are the flock() constants. Since this sytems doesn't have +/* These are the flock() constants. Since this systems doesn't have flock(), the values of the constants are probably not available. */ # ifndef LOCK_SH @@ -118,7 +129,7 @@ flock(int fd, int operation) return -1; } } -#elif !defined _WIN32 +#else int flock(int fd, int operation) { |
