-
-
Notifications
You must be signed in to change notification settings - Fork 411
Conversation
|
Thanks for your pull request and interest in making D better, @Darredevil! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please see CONTRIBUTING.md for more information. If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment. Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. |
src/core/sys/posix/aio.d
Outdated
| * 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 Alexandru Razvan Caciulescu 2018. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
D Language Foundation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I took core.sys.linux.epoll as an example for the copyright, is that file not respecting the convention?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That file was written long before the DFL existed. We can't easily change the copyright for existing modules, but we can for new additions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
src/core/sys/posix/aio.d
Outdated
|
|
||
| private import core.sys.posix.signal; | ||
|
|
||
| version (linux): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CRuntime_Glibc, not linux.
| ubyte[24] internal_members_padding; | ||
| off_t aio_offset; | ||
| ubyte[32] __glibc_reserved; | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra space
src/core/sys/posix/aio.d
Outdated
| @@ -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 | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this should be in core/sys/linux then, not posix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually no, there are two instance of AIO, the POSIX aio (aio_* family) and Linux libaio.
I believe this is in the correct place.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is POSIX AIO interface except for aio_init I think.
|
@ibuclaw good to go? @CyberShadow can you please advise regarding the merge error in circleci? |
@Darredevil's fork was pretty outdated and we upgraded to CircleCi 2.0. |
|
@ibuclaw all looks good now |
src/core/sys/posix/aio.d
Outdated
| @@ -0,0 +1,65 @@ | |||
| /** | |||
| * D header file to interface with the Linux aio API (http://man7.org/linux/man-pages/man7/aio.7.html). | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any link to the posix standard that is not a Linux manpage?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also http://www2.fisica.unlp.edu.ar/electro/temas/p7/POSIX4.pdf , see page 277
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one seems best: http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/aio.h.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made the change myself. All, feel free to operate noncontroversial changes (spacing, better links) right on the spot - it takes only a bit longer than making the request and accelerates the cycle greatly.
andralex
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ibuclaw good to go?
src/core/sys/posix/aio.d
Outdated
| @@ -0,0 +1,65 @@ | |||
| /** | |||
| * D header file to interface with the Linux aio API (http://man7.org/linux/man-pages/man7/aio.7.html). | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made the change myself. All, feel free to operate noncontroversial changes (spacing, better links) right on the spot - it takes only a bit longer than making the request and accelerates the cycle greatly.
ibuclaw
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nits and C compatibly problems.
src/core/sys/posix/aio.d
Outdated
| int aio_read(aiocb *aiocbp); | ||
| int aio_write(aiocb *aiocbp); | ||
| int aio_fsync(int op, aiocb *aiocbp); | ||
| int aio_error(aiocb *aiocbp); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const(aiocb)*?
src/core/sys/posix/aio.d
Outdated
| 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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First parameter would not be the equivalent D type you're looking for. The closest approximation would be aiocb**.
Also could have const(aiocb*)* and const(timespec)*
src/core/sys/posix/aio.d
Outdated
| 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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aiocb*[] would be a dynamic array, so this should be instead const(aiocb*)*
src/core/sys/posix/aio.d
Outdated
|
|
||
| private import core.sys.posix.signal; | ||
|
|
||
| version (CRuntime_Glibc): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Top of file should be guarded with version (Posix), not glibc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the idea is that this has only been tested on linux/Glibc so far, of all Posix platforms.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't mean we should drop the convention used in every other sys/posix module. New modules that require porting should come with big alarm bells to notify those working on said unsupported platforms to check this code very carefully.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, your edit suggestions look good.
src/core/sys/posix/aio.d
Outdated
| private import core.sys.posix.signal; | ||
|
|
||
| version (CRuntime_Glibc): | ||
| version (X86_64): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should not be here, rather it should be moved to where x86_64-specific definitions are.
src/core/sys/posix/aio.d
Outdated
|
|
||
| ubyte[24] internal_members_padding; | ||
| off_t aio_offset; | ||
| ubyte[32] __glibc_reserved; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like the only platform specific part of this module here. Make a porters life easy and guard it properly with appropriate version blocks and static asserts.
i.e:
version (CRuntime_Glibc)
{
version (X86_64)
{
struct aiocb
{
//...
}
}
else
static assert(0);
}
else
static assert(false, "Unsupported platform");
src/core/sys/posix/aio.d
Outdated
| /** | ||
| * 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't you have dropped the Linux references here?
Take a look any of the other core.sys.posix module headers, eg: https://github.com/dlang/druntime/blob/master/src/core/sys/posix/pwd.d
|
@ibuclaw thanks for the suggestions, updated accordingly |
src/core/sys/posix/aio.d
Outdated
| @@ -0,0 +1,74 @@ | |||
| /** | |||
| * D header file to interface with the | |||
| * $(HTTP pubs.opengroup.org/onlinepubs/9699919799/basedefs/aio.h.html, Linux aio API). | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd still say Posix AIO here, as I've repeatedly said, this is not a linux module. ;-)
|
@Darredevil - I think just one last nit and then I'll shut up. |
|
@ibuclaw should be good to go now |
|
Ping @joakim-noah @redstar @yshui @dkgroot @rracariu FYI this module is in dire need of porting. ALL PLATFORMS WILL FTBFS until this is fixed. |
|
Not a big deal, none of our platforms are tested with this master branch, if at all. Once it moves downstream, we'll test and fix it. |
|
@joakim-noah - Yeah, depends how you build druntime also. As a litmus test, all druntime modules are built in gdc's tree regardless of compiler target. This ensures that at least |
|
How about adding some unittests, that would ease porting to other platforms. The linux implementation of posix_aio is (mostly) oriented toward async non-blocking (raw) file i/o. I am not 100% sure if i remember correctly, but using it with sockets was not supported on linux (?). On other platforms posix_aio can also be used to deal with sockets (though not often used as far as i know). Should the orientation toward file i/o be noted, or should using a socket FD not be permitted for example ? |
That's never really been done for other modules, and I can think of a few where there's good reason for that as well. Be it math functions that return a different result depending on the platform, or format functions where format specifiers may not exist on older systems. In any case, I don't think its our role to test the C runtime library here, and there's too many variations between them to really be useful, and these libraries have their own testsuite anyways. ;-) Of course, if there's something we implement, then that needs a unittest. |
|
@ibuclaw i was not looking to test the c-implementation, to to check that we present the same results on all platforms. But ok, if that is not something we normally do. I assume that once there is a phobos library using this, it would be unittested there. |
Added interface for posix aio in D (only for linux x64 for now).
The aiocb struct can have various implementations, for linux x64 I tested the following in C and created the equivalent in D: