Page MenuHomeFreeBSD

Use __FreeBSD_version insted of __FreeBSD__
Needs RevisionPublic

Authored by br on Aug 10 2017, 6:30 PM.
Tags
None
Referenced Files
Unknown Object (File)
Dec 23 2023, 2:29 AM
Unknown Object (File)
Jun 16 2023, 12:56 AM
Unknown Object (File)
May 3 2023, 2:32 AM
Subscribers

Details

Reviewers
emaste
dim
cy
Summary
__FreeBSD__ is compiler built-in define that holds FBSD_MAJOR

On gcc FBSD_MAJOR comes from triple, e.g
riscv64-unknown-freebsd12.0-

The idea is to eliminate version from triple, so in result we will have this:
riscv64-unknown-freebsd-

Diff Detail

Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

br edited the summary of this revision. (Show Details)
br edited the summary of this revision. (Show Details)
contrib/llvm/tools/lldb/source/Host/posix/PipePosix.cpp
41

The problem with __FreeBSD_version is that it requires you to include <sys/param.h>, which unfortunately has a *lot* of namespace pollution. This makes it a lot less useful, in my opinion.

Since FreeBSD 9.x is now EOL, this version check might as well be dropped, but the old check really seems fine to me, and does not introduce complications. Please let this one as it is.

I have a related change for Clang in https://github.com/emaste/freebsd/commit/b03c6b060658f5fed4a2ad8511095c5f4df6e9f4 to avoid rebuilding so much when __FreeBSD_version gets bumped.

I committed my change in rS336691; if we're going to make a change like the one in this D11962 we can include lib/clang/include/llvm/Config/config.h as well.

sys/sys/sockopt.h
63

Probably this comment (introduced in rS53541) should just be removed; I don't think we need to do anything for FreeBSD < 3

emaste requested changes to this revision.Mar 21 2023, 4:16 PM

Needs to be rebased

This revision now requires changes to proceed.Mar 21 2023, 4:16 PM

Do we really want to change the code in src/contrib and src/crypto? This will make MFV more difficult due to possible merge conflicts. Let's not touch contributed (src/contrib, src/crypto) code.

Also, I can make the ipfilter changes. Looks like I missed a few when simplifying #ifdefs.

contrib/ipfilter/mlf_rule.c
16

Let's simplify by removing the test for FreeBSD_version. Also, FreeBSD_version requires sys/param.h to be included.

Seems my simplification of #ifdefs missed a few.

62

Just test for the existence of FreeBSD. We don't need to test for version anymore.

cy requested changes to this revision.Mar 21 2023, 6:29 PM

Should have asked for revisions last comment.

contrib/ipfilter/mlf_rule.c
16

Yes, __FreeBSD_version > 100000 is true on any supported version of FreeBSD

62

That's true, but this file no longer exists (mlf_rule.c)?

contrib/ipfilter/mlf_rule.c
16

I should have noticed this before. ipfilter is no longer in contrib and mlf_rule.c no longer exists in our tree.

62

Correct. I just checked.

Seems I did convert all instances.

Just to reiterate, we should not touch any contrib (contrib, crypto) code as it will complicate MFV.