Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
sds
abt-io
Commits
86749092
Commit
86749092
authored
May 01, 2019
by
Matthieu Dorier
Browse files
added read, write, read_nb, and write_nb
parent
f1a65039
Changes
4
Hide whitespace changes
Inline
Side-by-side
configure.ac
View file @
86749092
...
...
@@ -2,7 +2,7 @@
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.67])
AC_INIT([abt-io], [0.
1
], [],[],[])
AC_INIT([abt-io], [0.
2
], [],[],[])
AC_CONFIG_MACRO_DIRS([m4])
LT_INIT
...
...
include/abt-io.h
View file @
86749092
...
...
@@ -90,6 +90,25 @@ abt_io_op_t* abt_io_pwrite_nb(
off_t
offset
,
ssize_t
*
ret
);
/**
* wrapper for write()
*/
ssize_t
abt_io_write
(
abt_io_instance_id
aid
,
int
fd
,
const
void
*
buf
,
size_t
count
);
/**
* non-blocking wrapper for write()
*/
abt_io_op_t
*
abt_io_write_nb
(
abt_io_instance_id
aid
,
int
fd
,
const
void
*
buf
,
size_t
count
,
ssize_t
*
ret
);
/**
* wrapper for pread()
*/
...
...
@@ -111,6 +130,25 @@ abt_io_op_t* abt_io_pread_nb(
off_t
offset
,
ssize_t
*
ret
);
/**
* wrapper for read()
*/
ssize_t
abt_io_read
(
abt_io_instance_id
aid
,
int
fd
,
void
*
buf
,
size_t
count
);
/**
* non-blocking wrapper for read()
*/
abt_io_op_t
*
abt_io_read_nb
(
abt_io_instance_id
aid
,
int
fd
,
void
*
buf
,
size_t
count
,
ssize_t
*
ret
);
/**
* wrapper for mkostemp()
*/
...
...
maint/abt-io.pc.in
View file @
86749092
...
...
@@ -5,7 +5,7 @@ includedir=@includedir@
Name: abt-io
Description: Argobots bindings for common POSIX I/O functions
Version: 0.
1
Version: 0.
2
URL: https://xgitlab.cels.anl.gov/sds/abt-io
Requires: argobots
Libs: -L${libdir} -labt-io
...
...
src/abt-io.c
View file @
86749092
...
...
@@ -315,6 +315,93 @@ abt_io_op_t* abt_io_pread_nb(abt_io_instance_id aid, int fd, void *buf,
else
return
op
;
}
struct
abt_io_read_state
{
ssize_t
*
ret
;
int
fd
;
void
*
buf
;
size_t
count
;
ABT_eventual
eventual
;
};
static
void
abt_io_read_fn
(
void
*
foo
)
{
struct
abt_io_read_state
*
state
=
foo
;
*
state
->
ret
=
read
(
state
->
fd
,
state
->
buf
,
state
->
count
);
if
(
*
state
->
ret
<
0
)
*
state
->
ret
=
-
errno
;
ABT_eventual_set
(
state
->
eventual
,
NULL
,
0
);
return
;
}
static
int
issue_read
(
ABT_pool
pool
,
abt_io_op_t
*
op
,
int
fd
,
void
*
buf
,
size_t
count
,
ssize_t
*
ret
)
{
struct
abt_io_read_state
state
;
struct
abt_io_read_state
*
pstate
=
NULL
;
int
rc
;
if
(
op
==
NULL
)
pstate
=
&
state
;
else
{
pstate
=
malloc
(
sizeof
(
*
pstate
));
if
(
pstate
==
NULL
)
{
*
ret
=
-
ENOMEM
;
goto
err
;
}
}
*
ret
=
-
ENOSYS
;
pstate
->
ret
=
ret
;
pstate
->
fd
=
fd
;
pstate
->
buf
=
buf
;
pstate
->
count
=
count
;
pstate
->
eventual
=
NULL
;
rc
=
ABT_eventual_create
(
0
,
&
pstate
->
eventual
);
if
(
rc
!=
ABT_SUCCESS
)
{
*
ret
=
-
ENOMEM
;
goto
err
;
}
if
(
op
!=
NULL
)
op
->
e
=
pstate
->
eventual
;
rc
=
ABT_task_create
(
pool
,
abt_io_read_fn
,
pstate
,
NULL
);
if
(
rc
!=
ABT_SUCCESS
)
{
*
ret
=
-
EINVAL
;
goto
err
;
}
if
(
op
==
NULL
)
{
rc
=
ABT_eventual_wait
(
pstate
->
eventual
,
NULL
);
// what error should we use here?
if
(
rc
!=
ABT_SUCCESS
)
{
*
ret
=
-
EINVAL
;
goto
err
;
}
}
else
{
op
->
e
=
pstate
->
eventual
;
op
->
state
=
pstate
;
op
->
free_fn
=
free
;
}
return
0
;
err:
if
(
pstate
->
eventual
!=
NULL
)
ABT_eventual_free
(
&
pstate
->
eventual
);
if
(
pstate
!=
NULL
&&
op
!=
NULL
)
free
(
pstate
);
return
-
1
;
}
ssize_t
abt_io_read
(
abt_io_instance_id
aid
,
int
fd
,
void
*
buf
,
size_t
count
)
{
ssize_t
ret
=
-
1
;
issue_read
(
aid
->
progress_pool
,
NULL
,
fd
,
buf
,
count
,
&
ret
);
return
ret
;
}
abt_io_op_t
*
abt_io_read_nb
(
abt_io_instance_id
aid
,
int
fd
,
void
*
buf
,
size_t
count
,
ssize_t
*
ret
)
{
abt_io_op_t
*
op
;
int
iret
;
op
=
malloc
(
sizeof
(
*
op
));
if
(
op
==
NULL
)
return
NULL
;
iret
=
issue_read
(
aid
->
progress_pool
,
op
,
fd
,
buf
,
count
,
ret
);
if
(
iret
!=
0
)
{
free
(
op
);
return
NULL
;
}
else
return
op
;
}
struct
abt_io_pwrite_state
{
...
...
@@ -407,6 +494,95 @@ abt_io_op_t* abt_io_pwrite_nb(abt_io_instance_id aid, int fd, const void *buf,
else
return
op
;
}
struct
abt_io_write_state
{
ssize_t
*
ret
;
int
fd
;
const
void
*
buf
;
size_t
count
;
ABT_eventual
eventual
;
};
static
void
abt_io_write_fn
(
void
*
foo
)
{
struct
abt_io_write_state
*
state
=
foo
;
*
state
->
ret
=
write
(
state
->
fd
,
state
->
buf
,
state
->
count
);
if
(
*
state
->
ret
<
0
)
*
state
->
ret
=
-
errno
;
ABT_eventual_set
(
state
->
eventual
,
NULL
,
0
);
return
;
}
static
int
issue_write
(
ABT_pool
pool
,
abt_io_op_t
*
op
,
int
fd
,
const
void
*
buf
,
size_t
count
,
ssize_t
*
ret
)
{
struct
abt_io_write_state
state
;
struct
abt_io_write_state
*
pstate
=
NULL
;
int
rc
;
if
(
op
==
NULL
)
pstate
=
&
state
;
else
{
pstate
=
malloc
(
sizeof
(
*
pstate
));
if
(
pstate
==
NULL
)
{
*
ret
=
-
ENOMEM
;
goto
err
;
}
}
*
ret
=
-
ENOSYS
;
pstate
->
ret
=
ret
;
pstate
->
fd
=
fd
;
pstate
->
buf
=
buf
;
pstate
->
count
=
count
;
pstate
->
eventual
=
NULL
;
rc
=
ABT_eventual_create
(
0
,
&
pstate
->
eventual
);
if
(
rc
!=
ABT_SUCCESS
)
{
*
ret
=
-
ENOMEM
;
goto
err
;
}
if
(
op
!=
NULL
)
op
->
e
=
pstate
->
eventual
;
rc
=
ABT_task_create
(
pool
,
abt_io_write_fn
,
pstate
,
NULL
);
if
(
rc
!=
ABT_SUCCESS
)
{
*
ret
=
-
EINVAL
;
goto
err
;
}
if
(
op
==
NULL
)
{
rc
=
ABT_eventual_wait
(
pstate
->
eventual
,
NULL
);
// what error should we use here?
if
(
rc
!=
ABT_SUCCESS
)
{
*
ret
=
-
EINVAL
;
goto
err
;
}
}
else
{
op
->
e
=
pstate
->
eventual
;
op
->
state
=
pstate
;
op
->
free_fn
=
free
;
}
return
0
;
err:
if
(
pstate
->
eventual
!=
NULL
)
ABT_eventual_free
(
&
pstate
->
eventual
);
if
(
pstate
!=
NULL
&&
op
!=
NULL
)
free
(
pstate
);
return
-
1
;
}
ssize_t
abt_io_write
(
abt_io_instance_id
aid
,
int
fd
,
const
void
*
buf
,
size_t
count
)
{
ssize_t
ret
=
-
1
;
issue_write
(
aid
->
progress_pool
,
NULL
,
fd
,
buf
,
count
,
&
ret
);
return
ret
;
}
abt_io_op_t
*
abt_io_write_nb
(
abt_io_instance_id
aid
,
int
fd
,
const
void
*
buf
,
size_t
count
,
ssize_t
*
ret
)
{
abt_io_op_t
*
op
;
int
iret
;
op
=
malloc
(
sizeof
(
*
op
));
if
(
op
==
NULL
)
return
NULL
;
iret
=
issue_write
(
aid
->
progress_pool
,
op
,
fd
,
buf
,
count
,
ret
);
if
(
iret
!=
0
)
{
free
(
op
);
return
NULL
;
}
else
return
op
;
}
struct
abt_io_mkostemp_state
{
int
*
ret
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment