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..5c81db66b4 --- /dev/null +++ b/src/core/sys/posix/aio.d @@ -0,0 +1,74 @@ +/** + * D header file to interface with the + * $(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) + * Authors: $(HTTPS github.com/darredevil, Alexandru Razvan Caciulescu) + */ +module core.sys.posix.aio; + +private import core.sys.posix.signal; + +version (Posix): + +extern (C): +@system: +@nogc: +nothrow: + +version (CRuntime_Glibc) +{ + 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; + } + } + else + static assert(0); +} +else + static assert(false, "Unsupported platform"); + +/* 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(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, const(aiocb*)* aiocb_list, int nitems, sigevent *sevp); 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 $** $@