aboutsummaryrefslogtreecommitdiff
path: root/jim-aio.c
diff options
context:
space:
mode:
authorSteve Bennett <steveb@workware.net.au>2016-08-19 08:54:29 +1000
committerSteve Bennett <steveb@workware.net.au>2016-08-20 11:24:28 +1000
commitdef038d816120c9281e8001c24170047996ebfbc (patch)
tree17afdef43c7f1b46cb5130eca47bd349cf341c2c /jim-aio.c
parentdc7c2751eb01e8aa37740ce494e2857ce11b5ad3 (diff)
downloadjimtcl-def038d816120c9281e8001c24170047996ebfbc.zip
jimtcl-def038d816120c9281e8001c24170047996ebfbc.tar.gz
jimtcl-def038d816120c9281e8001c24170047996ebfbc.tar.bz2
Fix aio locking on non-linux platforms
And improve the tests Signed-off-by: Steve Bennett <steveb@workware.net.au>
Diffstat (limited to 'jim-aio.c')
-rw-r--r--jim-aio.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/jim-aio.c b/jim-aio.c
index 7619e3d..fb8577f 100644
--- a/jim-aio.c
+++ b/jim-aio.c
@@ -1159,10 +1159,16 @@ static int aio_cmd_verify(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
}
#endif /* JIM_BOOTSTRAP */
+#if defined(HAVE_STRUCT_FLOCK) && !defined(JIM_BOOTSTRAP)
static int aio_cmd_lock(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
AioFile *af = Jim_CmdPrivData(interp);
- struct flock fl = { F_WRLCK, SEEK_SET, 0, 0 };
+ struct flock fl;
+
+ fl.l_start = 0;
+ fl.l_len = 0;
+ fl.l_type = F_WRLCK;
+ fl.l_whence = SEEK_SET;
switch (fcntl(af->fd, F_SETLK, &fl))
{
@@ -1190,11 +1196,16 @@ static int aio_cmd_lock(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
static int aio_cmd_unlock(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
AioFile *af = Jim_CmdPrivData(interp);
- struct flock fl = { F_UNLCK, SEEK_SET, 0, 0 };
+ struct flock fl;
+ fl.l_start = 0;
+ fl.l_len = 0;
+ fl.l_type = F_UNLCK;
+ fl.l_whence = SEEK_SET;
Jim_SetResultInt(interp, fcntl(af->fd, F_SETLK, &fl) == 0);
return JIM_OK;
}
+#endif /* JIM_BOOTSTRAP */
static const jim_subcmd_type aio_command_table[] = {
{ "read",
@@ -1370,8 +1381,9 @@ static const jim_subcmd_type aio_command_table[] = {
/* Description: Verifies the certificate of a SSL/TLS channel */
},
#endif /* JIM_BOOTSTRAP */
+#if defined(HAVE_STRUCT_FLOCK) && !defined(JIM_BOOTSTRAP)
{ "lock",
- NULL,
+ NULL,
aio_cmd_lock,
0,
0,
@@ -1384,6 +1396,7 @@ static const jim_subcmd_type aio_command_table[] = {
0,
/* Description: Relase a lock. */
},
+#endif /* JIM_BOOTSTRAP */
{ NULL }
};