- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 414
Add DragonFlyBSD support : Split PR : src/core/sys/dragonflybsd related changes #2002
Add DragonFlyBSD support : Split PR : src/core/sys/dragonflybsd related changes #2002
Conversation
| Thanks for your pull request and interest in making D better, @dkgroot!  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. | 
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.
Just checked for version and attributes at top, not for actual accuracy of the declarations, and only yielded one style nit and one attribute question.
        
          
                src/core/sys/dragonflybsd/dlfcn.d
              
                Outdated
          
        
      | version (DragonFlyBSD): | ||
| extern (C): | ||
| nothrow: | ||
| @nogc: | 
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.
You can put all three attributes on the same line, ie extern (C) nothrow @nogc: as done for some other files below, probably better style.  Also, should most of these headers be @system too, @MartinNowak?
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.
Putting the attributes on one line -> No problem.
Adding @System attribute to all of these header files, i gave that a try and all the unittests are still passed without a problem. If that is an indication that it is ok, i can commit the change.
If this change is pushed through, should this also be backported to the other sys/core/sys/${OS}/ directories (in a seperate PR) ?
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.
Proposed
diff --git a/src/core/sys/dragonflybsd/dlfcn.d b/src/core/sys/dragonflybsd/dlfcn.d
index 9a416525..86effe89 100644
--- a/src/core/sys/dragonflybsd/dlfcn.d
+++ b/src/core/sys/dragonflybsd/dlfcn.d
@@ -11,9 +11,8 @@ module core.sys.dragonflybsd.dlfcn;
 public import core.sys.posix.dlfcn;
 
 version (DragonFlyBSD):
-extern (C):
-nothrow:
-@nogc:
+
+extern (C) nothrow @nogc @system:
 
 enum __BSD_VISIBLE = true;
 
diff --git a/src/core/sys/dragonflybsd/sys/_bitset.d b/src/core/sys/dragonflybsd/sys/_bitset.d
index 079115d7..24f9d9c1 100644
--- a/src/core/sys/dragonflybsd/sys/_bitset.d
+++ b/src/core/sys/dragonflybsd/sys/_bitset.d
@@ -7,7 +7,7 @@
 module core.sys.dragonflybsd.sys._bitset;
 
 version (DragonFlyBSD):
-extern (C) pure nothrow @nogc:
+extern (C) pure nothrow @nogc @system:
 
 import core.stdc.config : c_long;
 
diff --git a/src/core/sys/dragonflybsd/sys/elf_common.d b/src/core/sys/dragonflybsd/sys/elf_common.d
index cd94832d..4bbddf24 100644
--- a/src/core/sys/dragonflybsd/sys/elf_common.d
+++ b/src/core/sys/dragonflybsd/sys/elf_common.d
@@ -7,9 +7,8 @@
 module core.sys.dragonflybsd.sys.elf_common;
 
 version (DragonFlyBSD):
-extern (C):
-pure:
-nothrow:
+
+extern (C) pure nothrow @nogc @system:
 
 import core.stdc.stdint;Etcetera for the rest of the files in this PR
Most of these could also be set to 'pure' i think, correct ?
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.
Not sure, haven't messed with @system much, will let someone who knows better answer.
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.
With the attribute reformatting, seems fine to me, just don't know if @system is merited also.
4384215    to
    5a8c45d      
    Compare
  
    | @ibuclaw, do all the C declarations need to be marked  | 
| @joakim-noah / @ibuclaw FYI: It will build/unittest correctly either way (with and without @System). Would be happy to add @System to them, if that would result in better / more correct code. Question: Who will backport these types of changes to the other OS implementations, do you guys have a sort of ledger for this. If not, this would come up over and over, but never really get fixed into the other (more important) implementations. | 
| Looking at the  | 
| @joakim-noah Done. Can you please check if this is what you intended me to do (revision: 965c1dc) | 
| Note revision: cf62ee3 , might look like a massive edit, but: 
 | 
| If you wanted to add  Seems like FreeBSD is the exception rather than the rule for defining it elsewhere. | 
| @ibuclaw It is currently defined in core.sys.dragonflybsd.sys.cdefs.d (just like freebsd), but checking for it's setting, especially inside the dragonflybsd subdirectory is a bit superfluous. | 
| BTW: We should revisit PR1937 regarding using statvfs instead of statfs when it is being finalized, and port the changes to dragonfly implementation (and maybe the other BSD's). | 
b7e151a    to
    ba90956      
    Compare
  
    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.
Checked attributes, found some mislabeling.
| module core.sys.dragonflybsd.sys._cpuset; | ||
|  | ||
| version (DragonFlyBSD): | ||
| extern (C) pure nothrow @nogc @system: | 
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.
Only aliases and enums, so all these attributes unneeded?
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.
@joakim-noah Thanks for reviewing this !
They were already defined (e.g freebsd implementation), except for the requested addition of @System.|
Does it have a negative effect to set these attributes ? It could prevent future issues (and/or request attention to think about these attributes) when a function or alias is added.
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.
Our previous modules use these attributes inconsistently, since some of them predate the attributes. Would rather get this right for this new platform from the start, attributes do affect the mangling of D functions, ie the ABI.
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.
Ok will work on removing them. Thanks for the explanation !
|  | ||
| version (DragonFlyBSD): | ||
|  | ||
| extern (C) pure nothrow @nogc @system: | 
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 functions other than the few you define below with different attributes, so all attributes other than extern (C) can be removed.
|  | ||
| version (DragonFlyBSD): | ||
|  | ||
| extern (C) pure nothrow @nogc @system: | 
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.
Same as last module.
|  | ||
| version (DragonFlyBSD): | ||
|  | ||
| extern (C) pure nothrow @nogc @system: | 
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.
Same as last two.
| }; | ||
|  | ||
|  | ||
| private alias extern(C) int function(dl_phdr_info*, size_t, void *) dl_iterate_phdr_cb; | 
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.
extern (C) up top not enough?
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.
For aliases, maybe not.
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 It seems ok (unittest wise) when i remove the extra extern (C), so going for that.
        
          
                src/core/sys/dragonflybsd/sys/mman.d
              
                Outdated
          
        
      | module core.sys.dragonflybsd.sys.mman; | ||
|  | ||
| version (DragonFlyBSD): | ||
| extern (C) nothrow @system: | 
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.
@nogc?
        
          
                src/core/sys/dragonflybsd/time.d
              
                Outdated
          
        
      |  | ||
| version(DragonFlyBSD): | ||
|  | ||
| extern (C) nothrow @nogc @system: | 
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.
Only enums, no need for attributes.
3c26c17    to
    607a2bd      
    Compare
  
    607a2bd    to
    ad4ad37      
    Compare
  
    ad4ad37    to
    b116a70      
    Compare
  
    b116a70    to
    ddb040b      
    Compare
  
    ddb040b    to
    fcd001b      
    Compare
  
    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.
OK let's get things rolling here. We need to be more active when porters do their initial port. It's all in version(DragonFlyBSD) - so it really doesn't affect us at all. And in this case @dkgroot even setup a CI to show that everything is passing nicely.
|  | ||
| public import core.sys.posix.netinet.in_; | ||
|  | ||
| version(DragonFlyBSD): | 
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.
Why don't you move this five lines higher?
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.
Done thanks !
aed805e    to
    6416582      
    Compare
  
    | Thanks everyone for your reviews / input / suggestions and 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.
Couple nits left.
| module core.sys.dragonflybsd.sys._cpuset; | ||
|  | ||
| version (DragonFlyBSD): | ||
| extern (C): | 
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.
Enums are not placed in an object file, so extern(C) makes no sense, think the same for aliases too?
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.
Remarked out 'extern(C):'
        
          
                src/core/sys/dragonflybsd/time.d
              
                Outdated
          
        
      |  | ||
| public import core.sys.posix.time; | ||
|  | ||
| extern (C): | 
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.
Enums are like preprocessor defines in C/C++, they're pasted in and have no linkage, so this does nothing.
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.
Remarked out 'extern(C):'
| }; | ||
|  | ||
|  | ||
| private alias int function(dl_phdr_info*, size_t, void *) dl_iterate_phdr_cb; | 
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.
When I asked about the extern(C) here, I honestly didn't know if it was required.  You said the tests didn't need it, but that's understandable since you don't call the function it's used from below.  Thinking about it, I guess since it's a type for an extern(C) function, which don't mangle their types anyway, I suppose the extern(C) adds nothing.  I tested it on linux by removing this attribute there and the tests ran fine.
If anyone knows why it might be needed, comment here.
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.
Should I remove the second 'extern', ie:
extern (C) nothrow @system:
...
extern int dl_iterate_phdr(dl_iterate_phdr_cb __callback, void*__data);
extern int ...
should become:
extern (C) nothrow @system:
...
int dl_iterate_phdr(dl_iterate_phdr_cb __callback, void*__data);
int ...
Is that what you want to tell me ?
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, I was talking about the extern(C) you already removed above.  I don't think you need to change it again, but I'm not sure, so I left it open if anybody else wanted to comment here.
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.
Removing the extern(C) at the top of link_elf.d is also possible, but i would have to add notrown to the extern's at the bottom. So this is almost more of a style issue.
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.
It has nothing to do with style, these attributes normally affect linkage and functionality. However, I think they don't do anything in these cases so it's good you removed them from the bottom. The one up top is needed though.
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.
Ok Reverting the last change. Thanks for the update and review !
| int dl_iterate_phdr(dl_iterate_phdr_cb __callback, void*__data); | ||
| int dl_iterate_phdr(dl_iterate_phdr_cb_ngc __callback, void*__data) @nogc; | ||
| int _rtld_addr_phdr(const void*, dl_phdr_info*) @nogc; | ||
| int _rtld_get_stack_prot() @nogc; | 
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 wasn't referring to these, but it seems to be a good catch: the extern here was meaningless as applied to functions?
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.
Moved the extern(C) to the bottom to only pertain to these fout functions.
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, move it back up, I wasn't talking about the attributes up top. You need those there.
| Don't we check for D style in new patches? I guess not. | 
| @ibuclaw Did i miss something ? Did make some style error ? Will correct it, if you tell me where. | 
67401d4    to
    2110fc8      
    Compare
  
    | Congratulations @dkgroot and many thanks to all reviewers! | 
| Thanks to all reviewers / Thanks Andrei ! | 
Split PR : #1999
Moved the src/core/sys/dragonflybsd related changes into this PR
Related PR: