Skip to content

[CF] DT_WHT is unavailable on OpenBSD. #2589

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 5, 2020

Conversation

3405691582
Copy link
Member

Here we duplicate this extended conditional to not reference DT_WHT,
which is not available on OpenBSD. It is probably harmless to actually
remove DT_WHT entirely here unconditionally, but would require grokking
more context for a simple buildfix.

It also seems more readable to duplicate the entire line in the ifdef
despite being able to squish the ifdef in the clause.

Here we duplicate this extended conditional to not reference DT_WHT,
which is not available on OpenBSD. It is probably harmless to actually
remove DT_WHT entirely here unconditionally, but would require grokking
more context for a simple buildfix.

It also seems more readable to duplicate the entire line in the ifdef
despite being able to squish the ifdef in the clause.
@3405691582
Copy link
Member Author

Let me know if you'd prefer adding some additional preprocessor symbols in (maybe) CoreFoundation_Prefix.h instead of injecting actual OS preprocessor symbols.

@parkera
Copy link
Contributor

parkera commented Dec 18, 2019

Is TARGET_OS_BSD from TargetConditionals.h not appropriate?

@3405691582
Copy link
Member Author

3405691582 commented Dec 18, 2019

DT_WHT is available on FreeBSD (source) and NetBSD (source), but not OpenBSD (source), so TARGET_OS_BSD on its own is too broad here.

(I'm also wondering what the ideal stylistic choice is for future PRs as well; for example, Linux doesn't have xlocale, FreeBSD does, but the other BSDs do not...)

@3405691582
Copy link
Member Author

3405691582 commented Dec 19, 2019

Perhaps it's better stylistically to leave granular portability decisions to CoreFoundation_Prefix.h: so, for this example,

#if TARGET_OS_BSD && defined(__OpenBSD__)
#define __HAS_DT_WHT__ 1
#else
#define __HAS_DT_WHT__ 0
#endif  

and then use __HAS_DT_WHT__ in CFFileUtilities instead? This means macros in the dependent files are focused on features as opposed to operating systems. It does make the prefix file a lot more verbose though (but on the other hand it's already rather verbose to begin with), and can lead to some twisty and/or lengthy preprocessor conditionals...

@parkera
Copy link
Contributor

parkera commented Dec 19, 2019

I tried that approach in the past (focus on features instead of platforms) but was never happy with the result. It just results in a lot of extra macros, most of which are just aliases for "platform X".

@3405691582
Copy link
Member Author

Sounds good. I'll keep this commit as-is and use that pattern for future PRs.

@compnerd
Copy link
Member

compnerd commented Jan 2, 2020

@swift-ci please test

@compnerd
Copy link
Member

compnerd commented Jan 5, 2020

I wish that there was a better way to write this, but I suppose it will do for now.

@compnerd compnerd merged commit 62809e9 into swiftlang:master Jan 5, 2020
@3405691582
Copy link
Member Author

It'll possibly look better if refactored slightly, but I'll think about circling back around to that after I'm done with all the portability tweaks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants