History log of /freebsd-current/sys/compat/linuxkpi/common/include/linux/compiler.h
Revision Date Author Comments
# 2a8c5059 02-Apr-2024 Bjoern A. Zeeb <bz@FreeBSD.org>

LinuxKPI: add __counted_by() and __nonstring

Add checks for __counted_by(_x) and __nonstring as and depending
on compiler support enable the attribute/feature.

This is needed to make mtk76 and ath1xk drivers compile.

Sposnored by: The FreeBSD Foundation
MFC after: 3 days
Reviewed by: emaste, dim
Differential Revision: https://reviews.freebsd.org/D44587


# 3208d4ad 08-Apr-2024 Vladimir Kondratyev <wulf@FreeBSD.org>

LinuxKPI: Import vanilla linux/overflow.h

It is dual-licensed (GPLv2 & MIT) and self-contained header file.
No need to reimplement it.

Sponsored by: Serenity CyberSecurity, LLC
Reviewed by: emaste
MFC after: 1 week


# 95ee2897 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

sys: Remove $FreeBSD$: two-line .h pattern

Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/


# 046d8d89 13-May-2023 Bjoern A. Zeeb <bz@FreeBSD.org>

LinuxKPI: fix WRITE_ONCE(), remove ACCESS_ONCE()

Fix a gcc warning: "to be safe all intermediate pointers in cast from
'...' to '...' must be 'const' qualified [-Wcast-qual]".
Doing what is essentially a __DECONST() adding the uintptr_t gets
rid of the massive amount of warnings we get in LinuxKPI and lets
us see the actual problems a lot better.
This is a follow-up to 74e908b3c63b28de1d590dc42502fbe959a6da2e which
fixed READ_ONCE().
ACCESS_ONCE() seems to be an obsolete KPI these days in Linux and
FreeBSD does not use it either directly so we can entirely remove
it now.

Sponsored by: The FreeBSD Foundation
Suggested by: jhb
Reviewed by: hselasky
MFC after: 10 days
Differential Revision: https://reviews.freebsd.org/D40084


# 53d821d6 22-Apr-2023 Vladimir Kondratyev <wulf@FreeBSD.org>

LinuxKPI: Define noinline_for_stack compiler attribute

It is identical to noinline and used for documentation reasons.

Required by: drm-kmod 5.15-lts
Reviewed by: manu
Differential Revision: https://reviews.freebsd.org/D39553


# 74e908b3 19-Apr-2023 Bjoern A. Zeeb <bz@FreeBSD.org>

LinuxKPI: fix READ_ONCE() -Wcast-equal warnings

Rather than using ACCESS_ONCE() in READ_ONCE() add a missing cast
to const in order to satisfy -Wcast-equal by gcc.
Sadly we cannot do the same to WRITE_ONCE() which still is very
noisy.

Sponsored by: The FreeBSD Foundation
MFC after: 3 days
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D39706


# e5b95b22 09-Feb-2022 Bjoern A. Zeeb <bz@FreeBSD.org>

LinuxKPI: add sizeof_field()

Add sizeof_field() to linux/compiler.h needed by a driver.

MFC after: 3 days
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D34226


# 307f78f3 19-Dec-2021 Vladimir Kondratyev <wulf@FreeBSD.org>

LinuxKPI: Constantly use _LINUXKPI_ prefix in include guards

MFC after: 1 week
Reviewed by: bz, emaste, hselasky, manu
Differential Revision: https://reviews.freebsd.org/D33562


# 2fb5be79 04-Jul-2021 Vladimir Kondratyev <wulf@FreeBSD.org>

LinuxKPI: Implement smp_*mb barriers with atomic_thread_fence_*

for x86 and move them to asm/barrier.h

MFC after: 1 week
Reviewed by: bz, hselasky, manu
Differential Revision: https://reviews.freebsd.org/D33296


# da717031 24-May-2021 Bjoern A. Zeeb <bz@FreeBSD.org>

LinuxKPI: compiler.h add three more defines

Add fallthrough, ____cacheline_aligned_in_smp, and smp_mb() to
linux/compiler.h.

Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D30420


# 43b4c006 24-May-2021 Bjoern A. Zeeb <bz@FreeBSD.org>

LinuxKPI: extract stringify() in their own header file

Add linux/stringify.h as directly included by drivers. Remove the
definitions from compiler.h and include the new header in places
where the stringify macros are already used without linuxkpi.

I have adjusted the Copyright of the new file according to the commit
originaly adding the macros (99e690772adbcb78c9e8441bedcf1913d72ea72f).

Sposnored by: The FreeBSD Foundation
MFC after: 2 weeks
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D30440


# 3b1ecc9f 23-Mar-2021 Bjoern A. Zeeb <bz@FreeBSD.org>

LinuxKPI: remove < 5.0 version support

We are not aware of any out-of-tree consumers anymore
which would need KPI support for before Linux version 5.
Update the two in-tree consumers to use the new KPI.
This allows us to remove the extra version check and
will also give access to {lower,upper}_32_bits() unconditionally.

Sponsored-by: The FreeBSD Foundation
Reviewed-by: hselasky, rlibby, rstone
MFC-after: 2 weeks
X-MFC: to 13 only
Differential Revision: https://reviews.freebsd.org/D29391


# 93d70cd3 24-May-2020 Emmanuel Vadot <manu@FreeBSD.org>

linuxkpi: Add __same_type and __must_be_array macros

The same_type macro simply wraps around builtin_types_compatible_p which
exist for both GCC and CLANG, which returns 1 if both types are the same.
The __must_be_array macros returns 1 if the argument is an array.

This is needed for DRM v5.3

Sponsored-by: The FreeBSD Foundation
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D24953


# 482f0c02 15-Dec-2019 Conrad Meyer <cem@FreeBSD.org>

Revert r355760, r355759

And remove the inline/deprecated attribute use entirely in stdlib.h, from
r355747. The intent was to provide a buildable API transitionary period, but
clearly that was counter-productive.

Reported by: delphij, imp, others


# 9d471059 14-Dec-2019 Conrad Meyer <cem@FreeBSD.org>

linuxkpi: Drop incompatible __deprecated definition

Probably all of these linuxkpi stubs should be '#ifndef' guarded, but maybe
that would prevent people from noticing when they are defined.

Introduced in r355759. For some reason I only ran a buildworld and not a
kernel. Mea culpa.

Reported by: Mark Millard
X-MFC-with: r355759


# 0bb30b3a 15-May-2019 Johannes Lundberg <johalun@FreeBSD.org>

LinuxKPI: Move {lower|upper}_32_bits macros from port to base.

This patch is part of D19565

Reviewed by: hps
Approved by: imp (mentor), hps
MFC after: 1 week


# cbea4f29 30-May-2018 Hans Petter Selasky <hselasky@FreeBSD.org>

Define __initconst in the LinuxKPI.

Submitted by: Johannes Lundberg <johalun0@gmail.com>
MFC after: 1 week
Sponsored by: Mellanox Technologies


# 83630517 23-Mar-2018 Ed Maste <emaste@FreeBSD.org>

linuxkpi whitespace cleanup

Reviewed by: hselasky, markj
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D14807


# dc354b15 04-Mar-2018 Hans Petter Selasky <hselasky@FreeBSD.org>

Define noinline and __maybe_unused macros in the LinuxKPI.

MFC after: 1 week
Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Mellanox Technologies
Sponsored by: Limelight Networks


# 2060ca65 17-Feb-2018 Hans Petter Selasky <hselasky@FreeBSD.org>

Add support for __percpu and __weak macros in the LinuxKPI.

MFC after: 1 week
Submitted by: Johannes Lundberg <johalun0@gmail.com>
Sponsored by: Mellanox Technologies


# 4e64c625 22-Jul-2017 Ryan Libby <rlibby@FreeBSD.org>

linuxkpi compiler.h: avoid gcc -Wunused-value in dummy expressions

It looks like the __acquire and __release macros are for the consumption
of static analysis tools and have no semantic effect. Transform the
definitions from constant expressions to empty statements in order to
avoid -Wunused-value from gcc.

Likewise avoid future warnings for __chk_{user,io}_ptr, but with a cast
to void, because it looks like some linux kernel code may use those in
expression contexts.

Reviewed by: hselasky, markj
Approved by: markj (mentor)
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D11695


# cb564d24 30-May-2017 Mark Johnston <markj@FreeBSD.org>

Add some miscellaneous definitions to support DRM drivers.

Reviewed by: hselasky
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D10985


# 99e69077 06-Apr-2017 Hans Petter Selasky <hselasky@FreeBSD.org>

The __stringify() macro in the LinuxKPI should expand any macros
before stringifying.

MFC after: 1 week
Sponsored by: Mellanox Technologies


# a767c188 07-Mar-2017 Hans Petter Selasky <hselasky@FreeBSD.org>

Add support for constant pointer constructs to READ_ONCE() in the
LinuxKPI. When the type of the argument is constant the temporary
variable cannot be assigned after the barrier. Instead assign the
temporary variable by initialization.

MFC after: 1 week
Sponsored by: Mellanox Technologies


# 21b73749 27-Jan-2017 Mateusz Guzik <mjg@FreeBSD.org>

Introduce __read_mostly and __exclusive_cache_line macros.

The intended use is to annotate frequently used globals which either rarely
change (and thus can be grouped in the same cacheline) or are an atomic counter
(which means it may benefit from being the only variable in the cacheline).

Linker script support is provided only for amd64. Architectures without it risk
having other variables put in, i.e. as if they were not annotated. This is
harmless from correctness point of view.

Reviewed by: bde (previous version)
MFC after: 1 month


# abb14a54 13-May-2016 Hans Petter Selasky <hselasky@FreeBSD.org>

Add more Linux defines. Improve some existing ones.

Obtained from: kmacy @
MFC after: 1 week
Sponsored by: Mellanox Technologies


# cee21041 21-Dec-2015 Hans Petter Selasky <hselasky@FreeBSD.org>

Implement ACCESS_ONCE(), WRITE_ONCE() and READ_ONCE().

MFC after: 1 week
Sponsored by: Mellanox Technologies


# 8d59ecb2 29-Oct-2015 Hans Petter Selasky <hselasky@FreeBSD.org>

Finish process of moving the LinuxKPI module into the default kernel build.

- Move all files related to the LinuxKPI into sys/compat/linuxkpi and
its subfolders.
- Update sys/conf/files and some Makefiles to use new file locations.
- Added description of COMPAT_LINUXKPI to sys/conf/NOTES which in turn
adds the LinuxKPI to all LINT builds.
- The LinuxKPI can be added to the kernel by setting the
COMPAT_LINUXKPI option. The OFED kernel option no longer builds the
LinuxKPI into the kernel. This was done to keep the build rules for
the LinuxKPI in sys/conf/files simple.
- Extend the LinuxKPI module to include support for USB by moving the
Linux USB compat from usb.ko to linuxkpi.ko.
- Bump the FreeBSD_version.
- A universe kernel build has been done.

Reviewed by: np @ (cxgb and cxgbe related changes only)
Sponsored by: Mellanox Technologies