From 541b999bdd8f53876ca312474040bc713ad0acc2 Mon Sep 17 00:00:00 2001 From: Alexandru Caciulescu Date: Fri, 26 Jan 2018 17:19:59 +0200 Subject: [PATCH 1/6] add aio.d --- mak/COPY | 1 + src/core/sys/posix/aio.d | 66 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 src/core/sys/posix/aio.d diff --git a/mak/COPY b/mak/COPY index d6e9c3310d..7ca5ca2cfc 100644 --- a/mak/COPY +++ b/mak/COPY @@ -153,6 +153,7 @@ COPY=\ $(IMPDIR)\core\sys\osx\sys\mman.d \ \ $(IMPDIR)\core\sys\posix\arpa\inet.d \ + $(IMPDIR)\core\sys\posix\aio.d \ $(IMPDIR)\core\sys\posix\config.d \ $(IMPDIR)\core\sys\posix\dirent.d \ $(IMPDIR)\core\sys\posix\dlfcn.d \ diff --git a/src/core/sys/posix/aio.d b/src/core/sys/posix/aio.d new file mode 100644 index 0000000000..cded7183e9 --- /dev/null +++ b/src/core/sys/posix/aio.d @@ -0,0 +1,66 @@ +/** + * D header file to interface with the Linux aio API (http://man7.org/linux/man-pages/man7/aio.7.html). + * Available since Linux 2.6 + * + * Copyright: Copyright D Language Foundation 2018. + * License : $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) + * Authors : Alexandru Razvan Caciulescu (github.com/darredevil) + */ +module core.sys.posix.aio; + +private import core.sys.posix.signal; + +version (linux): +version(X86_64): + +extern (C): +@system: +@nogc: +nothrow: + +struct aiocb +{ + int aio_fildes; + int aio_lio_opcode; + int aio_reqprio; + void *aio_buf; //volatile + size_t aio_nbytes; + sigevent aio_sigevent; + + ubyte[24] internal_members_padding; + off_t aio_offset; + ubyte[32] __glibc_reserved; + +} + +/* Return values of cancelation function. */ +enum +{ + AIO_CANCELED, + AIO_NOTCANCELED, + AIO_ALLDONE +}; + +/* Operation codes for `aio_lio_opcode'. */ +enum +{ + LIO_READ, + LIO_WRITE, + LIO_NOP +}; + +/* Synchronization options for `lio_listio' function. */ +enum +{ + LIO_WAIT, + LIO_NOWAIT +}; + +int aio_read(aiocb *aiocbp); +int aio_write(aiocb *aiocbp); +int aio_fsync(int op, aiocb *aiocbp); +int aio_error(aiocb *aiocbp); +ssize_t aio_return(aiocb *aiocbp); +int aio_suspend(aiocb*[] aiocb_list, int nitems, timespec *timeout); +int aio_cancel(int fd, aiocb *aiocbp); +int lio_listio(int mode, aiocb*[] aiocb_list, int nitems, sigevent *sevp); From 6bc992e5b3fdfbbf48e86ca09169bb55d66ee1fd Mon Sep 17 00:00:00 2001 From: Alexandru Caciulescu Date: Sun, 4 Feb 2018 13:42:42 +0200 Subject: [PATCH 2/6] Update aio.d --- src/core/sys/posix/aio.d | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/core/sys/posix/aio.d b/src/core/sys/posix/aio.d index cded7183e9..f83a1c185f 100644 --- a/src/core/sys/posix/aio.d +++ b/src/core/sys/posix/aio.d @@ -10,8 +10,8 @@ module core.sys.posix.aio; private import core.sys.posix.signal; -version (linux): -version(X86_64): +version (CRuntime_Glibc): +version (X86_64): extern (C): @system: @@ -30,7 +30,6 @@ struct aiocb ubyte[24] internal_members_padding; off_t aio_offset; ubyte[32] __glibc_reserved; - } /* Return values of cancelation function. */ From 6d1f5fc2e8680b7f05c19446bdf267ef447d96c9 Mon Sep 17 00:00:00 2001 From: Andrei Alexandrescu Date: Mon, 12 Feb 2018 22:00:18 -0500 Subject: [PATCH 3/6] Update aio.d --- src/core/sys/posix/aio.d | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/sys/posix/aio.d b/src/core/sys/posix/aio.d index f83a1c185f..202d48809c 100644 --- a/src/core/sys/posix/aio.d +++ b/src/core/sys/posix/aio.d @@ -3,8 +3,8 @@ * Available since Linux 2.6 * * Copyright: Copyright D Language Foundation 2018. - * License : $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) - * Authors : Alexandru Razvan Caciulescu (github.com/darredevil) + * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) + * Authors: Alexandru Razvan Caciulescu (github.com/darredevil) */ module core.sys.posix.aio; From ba2157f5540aa4077716bedaacb97551ca886639 Mon Sep 17 00:00:00 2001 From: Alexandru Caciulescu Date: Tue, 13 Feb 2018 18:08:40 +0200 Subject: [PATCH 4/6] add aio.d to win*.mak --- win32.mak | 3 +++ win64.mak | 3 +++ 2 files changed, 6 insertions(+) diff --git a/win32.mak b/win32.mak index 3492355a9d..092b4ca22c 100644 --- a/win32.mak +++ b/win32.mak @@ -617,6 +617,9 @@ $(IMPDIR)\core\sys\osx\sys\mman.d : src\core\sys\osx\sys\mman.d $(IMPDIR)\core\sys\posix\arpa\inet.d : src\core\sys\posix\arpa\inet.d copy $** $@ +$(IMPDIR)\core\sys\posix\aio.d : src\core\sys\posix\aio.d + copy $** $@ + $(IMPDIR)\core\sys\posix\config.d : src\core\sys\posix\config.d copy $** $@ diff --git a/win64.mak b/win64.mak index 53d896b8df..c1c193885b 100644 --- a/win64.mak +++ b/win64.mak @@ -628,6 +628,9 @@ $(IMPDIR)\core\sys\osx\sys\mman.d : src\core\sys\osx\sys\mman.d $(IMPDIR)\core\sys\posix\arpa\inet.d : src\core\sys\posix\arpa\inet.d copy $** $@ +$(IMPDIR)\core\sys\posix\aio.d : src\core\sys\posix\aio.d + copy $** $@ + $(IMPDIR)\core\sys\posix\config.d : src\core\sys\posix\config.d copy $** $@ From 6c21ed7d758eb463895087bd41dcae86ea947335 Mon Sep 17 00:00:00 2001 From: Andrei Alexandrescu Date: Thu, 15 Feb 2018 12:40:34 -0500 Subject: [PATCH 5/6] Update aio.d --- src/core/sys/posix/aio.d | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/core/sys/posix/aio.d b/src/core/sys/posix/aio.d index 202d48809c..fd02da2b74 100644 --- a/src/core/sys/posix/aio.d +++ b/src/core/sys/posix/aio.d @@ -1,10 +1,11 @@ /** - * D header file to interface with the Linux aio API (http://man7.org/linux/man-pages/man7/aio.7.html). + * D header file to interface with the + * $(HTTP pubs.opengroup.org/onlinepubs/9699919799/basedefs/aio.h.html, Linux aio API). * Available since Linux 2.6 * * Copyright: Copyright D Language Foundation 2018. * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) - * Authors: Alexandru Razvan Caciulescu (github.com/darredevil) + * Authors: $(HTTPS github.com/darredevil, Alexandru Razvan Caciulescu) */ module core.sys.posix.aio; From 53ba9b16c45c5e371065900518b9efea7c121f92 Mon Sep 17 00:00:00 2001 From: Alexandru Caciulescu Date: Sat, 3 Mar 2018 12:51:32 +0800 Subject: [PATCH 6/6] aio.d nitpicking --- src/core/sys/posix/aio.d | 44 ++++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/src/core/sys/posix/aio.d b/src/core/sys/posix/aio.d index fd02da2b74..5c81db66b4 100644 --- a/src/core/sys/posix/aio.d +++ b/src/core/sys/posix/aio.d @@ -1,7 +1,6 @@ /** * D header file to interface with the - * $(HTTP pubs.opengroup.org/onlinepubs/9699919799/basedefs/aio.h.html, Linux aio API). - * Available since Linux 2.6 + * $(HTTP pubs.opengroup.org/onlinepubs/9699919799/basedefs/aio.h.html, Posix AIO API). * * Copyright: Copyright D Language Foundation 2018. * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) @@ -11,27 +10,36 @@ module core.sys.posix.aio; private import core.sys.posix.signal; -version (CRuntime_Glibc): -version (X86_64): +version (Posix): extern (C): @system: @nogc: nothrow: -struct aiocb +version (CRuntime_Glibc) { - int aio_fildes; - int aio_lio_opcode; - int aio_reqprio; - void *aio_buf; //volatile - size_t aio_nbytes; - sigevent aio_sigevent; + version (X86_64) + { + struct aiocb + { + int aio_fildes; + int aio_lio_opcode; + int aio_reqprio; + void *aio_buf; //volatile + size_t aio_nbytes; + sigevent aio_sigevent; - ubyte[24] internal_members_padding; - off_t aio_offset; - ubyte[32] __glibc_reserved; + ubyte[24] internal_members_padding; + off_t aio_offset; + ubyte[32] __glibc_reserved; + } + } + else + static assert(0); } +else + static assert(false, "Unsupported platform"); /* Return values of cancelation function. */ enum @@ -59,8 +67,8 @@ enum int aio_read(aiocb *aiocbp); int aio_write(aiocb *aiocbp); int aio_fsync(int op, aiocb *aiocbp); -int aio_error(aiocb *aiocbp); -ssize_t aio_return(aiocb *aiocbp); -int aio_suspend(aiocb*[] aiocb_list, int nitems, timespec *timeout); +int aio_error(const(aiocb)* aiocbp); +ssize_t aio_return(const(aiocb)* aiocbp); +int aio_suspend(const(aiocb*)* aiocb_list, int nitems, const(timespec)* timeout); int aio_cancel(int fd, aiocb *aiocbp); -int lio_listio(int mode, aiocb*[] aiocb_list, int nitems, sigevent *sevp); +int lio_listio(int mode, const(aiocb*)* aiocb_list, int nitems, sigevent *sevp);