-
-
Notifications
You must be signed in to change notification settings - Fork 423
Separate linux kernel and glibc APIs as much as possible #1010
Conversation
Updated this pull so that it separates out all linux/Android blocks from my original Android pulls #681 and #734, plus some low-hanging fruit from This pull is now ready for review. I'll submit a separate pull for the remaining |
Now that dmd pull #4111 has been merged, this pull passes the auto-tester. I just updated I haven't tested this pull on Android yet, as I have to separate the rest of the linux/Android blocks before it can compile for Android, but this pull should be a drop-in replacement on non-Android linux, with the exception of the new arch check in I'll submit a separate pull for the rest of the linux/Android blocks in druntime, then check it on Android and fix whatever's necessary in that pull. For now, this pull works on non-Android linux and can be merged. |
Oh, the other change that could possibly affect someone is the renaming of the internal modules |
btw, can someone explain what the point of completely redundant version blocks like these are for? @complexmath or @MartinNowak, I don't see the point. I'd rather combine them all into one declaration and only specialize when necessary for some new OS. |
The approach in this pull looks good. |
Yes, default cases are terribly bad for porting because you'll notice incorrect declarations only at runtime. The first druntime port to MIPS almost took me more than a week of debugging to find all wrong numbers. |
Not using default cases doesn't mean you have to copy+paste the declarations - define an in-module version symbol for the common-code case. |
I don't understand: are you saying all these have been found to be different for some as yet unsupported Posix platform? They are all exactly the same for the supported platforms, I see no reason to define them over and over again. |
We had that discussion already and I will not start it again.
You shouldn't copy paste anything but find the relevant C headers and use the declarations from there.
That would be fine with me, as long as it remains neat. |
If you're talking about me, we once discussed constants that you found to be different on a certain arch, MIPS, not OSs, which are being prematurely separated for no apparent reason in these examples I gave.
Simply writing the same thing for every OS cannot possibly help anything, as has been done so far in many cases, it's just busywork for no reason. |
There is no point, it's stupid. And it's partly caused by not being able to do this: The workaround is to just do this: version(This)
version = thisOrThat;
else version(That)
version = thisOrThat;
version(thisOrThat)
{
}
else
static assert(0); Which is ugly, but works, removes the duplication, and avoids having any code in 'else block'. |
@yebblies, yes, I'm aware that boolean logic inside version statements is not allowed, but I'm asking the larger question: why are we differentiating these OSs at all? There are many examples like this, where we have 5-6 OS blocks with no meaningful difference between them and often no default Did someone see that these declarations were different on some OS when druntime was first started and planned ahead by separating them? Otherwise, it seems like Sean probably put the first one inside a version block just in case, and we've been blindly adding more OS blocks to that first one for no reason. I ask because I'd rather submit a pull to combine each case like the three above into a single declaration, rather than have to sit here and add another one onto them again for Android. |
Updated this pull so it doesn't rename |
There should be at least one per module. Otherwise, it's a bug. |
This is definitely not the case. You will find it hard to argue that you haven't been told this already. |
Then there's a lot of bugs in druntime.
Being told something and actually providing a reason are two different things. If you believe that one of the three linked examples above needs to be separated for a reason, please make a case. The fact that no case has been made, either here or on the forum, suggests that there is none. In any case, this pull has little to do with such repeated OS blocks. If you have something to say, take a look at the in-progress #1069, where I remove all such redundantly repeated OS blocks. |
enum EOWNERDEAD = 130; // Owner died | ||
enum ENOTRECOVERABLE = 131; // State not recoverable | ||
enum EPERM = 1; | ||
enum ENOENT = 2; |
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.
No comments?
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.
Yep, you are right in that. @ibuclaw, the problem is that code comments could be copyrightable, whereas the API itself definitely isn't.
Yes, there are lots of bugs, but we are dealing with that as and when we stumble across them. |
Patches are welcome.
As Martin said, we did make a case for the current policy already, and if I remember correctly more than once. I don't get why you claim that nobody ever gave you any reasons and then conclude that our current strategy must clearly be unfounded. That's simply not the case, and refusing to acknowledge the arguments of your opponent in a debate is just rude. Sure, you can still disagree and try to convince us that we chose the wrong trade-off in favoring explicitness over conciseness of code. But not even making an effort to understand the arguments and then criticizing that none are given isn't going to work. Sorry for being very direct, but I'm afraid this is going to turn into quite the waste of time for all involved parties otherwise. |
Just so we're clear, precisely what is the "current policy" that you believe has been adequately explained? In one of my first PRs, we had a disagreement about whether new declarations should be speculatively protected by version(arch) statements with a static assert as the default, particularly for one case where Martin found some constants varied for one arch on a different Android API version. You two are conflating that discussion with the current linked examples of version(OS) statements, where none of the supported OS's actually differ. I'd say that conflation by the two of you and then refusing to acknowledge that this situation is different, since it's by OS and not by arch, is what's rude, not my pointing out that the two situations are different and asking for a specific reason why you believe any one of the three linked examples should not be collapsed. If your claim is that all C declarations should be speculatively separated in this way, druntime would be 10 times larger and nobody would attempt to port it to a new platform. If you haven't looked at my linked examples above, I'm talking about blocks like this, which are littered around druntime:
No difference in any of the supported OSs, no static assert, and that function is unused anywhere in druntime/phobos. The only reason it has an Android block is because I'm a stickler for completeness and grepped for it. In my PR #1069, I collapse it down to a single declaration, as it's separated by OS for no apparent reason. Now, the question is: why was it ever separated? Is it known that |
Updated this pull so that the remaining linux/Android blocks use the appropriate Update: Added one last tweak, defining |
Any reason this pull has been sitting unmerged for almost two months now? |
Lack of time, sorry, scheduled for review next week. |
No need to be sorry. I was just worried that the controversy above was mistakenly presumed to be about this pull, when most of the discussion above was about changes made in #1069. |
Updated this pull to deal with the new modules |
Ping, this pull was marked as ready for review more than two months ago when it passed the auto-tester. Unless someone is planning on checking all the APIs to see where they actually come from, which I doubt since it took me days to do so in the first place, should be pretty straightforward to check for other, smaller mistakes and merge. |
Been a couple months, @MartinNowak, what is the status of this? I know you've been busy pushing out the stable release, but hopefully this can get in now. |
…ong with CRuntime_Bionic
Can someone merge this? I don't see what the holdup is, most of it is simple renaming. I'm about to submit another PR for Android/ARM support, but I need the |
I noticed you removed all the docs for the errnos for linux. Was that on purpose? |
Yep. |
Ugh... How annoying. But I guess that's life. |
enum CLOCK_MONOTONIC = 1; | ||
enum CLOCK_MONOTONIC_HR = 5; | ||
enum CLOCK_MONOTONIC = 1; | ||
enum CLOCK_MONOTONIC_RAW = 4; |
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.
Better move this non-standard thing to core.sys.linux.time.CLOCK_MONOTONIC_RAW.
No, you finally seem to hit the sweet spot ;). |
Separate linux kernel and glibc APIs as much as possible
This PR caused a regression. https://issues.dlang.org/show_bug.cgi?id=22689 |
This pull uses the new
CRuntime_Glibc
andCRuntime_Bionic
predefined global versions from dmd pulls #4111 and #3643 to start separating out linux kernel APIs from glibc and bionic APIs. I used dstep and a modified Dscanner to help find type and struct declarations, but had to check enums again by hand. dmd pull #4111 will have to be merged before this one.