Hello Hans,
On Tue, 2 Jun 2020 09:45:44 +0000 (UTC) Hans Petter Selasky <hsela...@freebsd.org> wrote: > Author: hselasky > Date: Tue Jun 2 09:45:43 2020 > New Revision: 361722 > URL: https://svnweb.freebsd.org/changeset/base/361722 > > Log: > Implement BUILD_BUG_ON_ZERO() in the LinuxKPI. > Tested using gcc and clang. > > MFC after: 1 week > Sponsored by: Mellanox Technologies > > Modified: > head/sys/compat/linuxkpi/common/include/linux/kernel.h > > Modified: head/sys/compat/linuxkpi/common/include/linux/kernel.h > ============================================================================== > --- head/sys/compat/linuxkpi/common/include/linux/kernel.h Tue Jun 2 > 03:44:22 2020 (r361721) > +++ head/sys/compat/linuxkpi/common/include/linux/kernel.h Tue Jun 2 > 09:45:43 2020 (r361722) > @@ -94,6 +94,9 @@ > #define BUILD_BUG_ON_NOT_POWER_OF_2(x) BUILD_BUG_ON(!powerof2(x)) > #define BUILD_BUG_ON_INVALID(expr) while (0) { (void)(expr); } > > +extern const volatile int lkpi_build_bug_on_zero; > +#define BUILD_BUG_ON_ZERO(x) ((x) ? lkpi_build_bug_on_zero : 0) > + > #define BUG() panic("BUG at %s:%d", __FILE__, > __LINE__) > #define BUG_ON(cond) do { \ > if (cond) { \ That doesn't work for drm-kmod. One example of error : --- intel_display.o --- /usr/home/manu/Work/freebsd/drm-kmod/drivers/gpu/drm/i915/intel_display.c:14804:38: error: implicit declaration of function '__is_constexpr' is invalid in C99 [-Werror,-Wimplicit-function-declaration] val = (val & ~PANEL_UNLOCK_MASK) | PANEL_UNLOCK_REGS; ^ /usr/home/manu/Work/freebsd/drm-kmod/drivers/gpu/drm/i915/i915_reg.h:4770:29: note: expanded from macro 'PANEL_UNLOCK_REGS' #define PANEL_UNLOCK_REGS REG_FIELD_PREP(PANEL_UNLOCK_MASK, 0xabcd) ^ /usr/home/manu/Work/freebsd/drm-kmod/drivers/gpu/drm/i915/i915_reg.h:164:28: note: expanded from macro 'REG_FIELD_PREP' BUILD_BUG_ON_ZERO(!__is_constexpr(__mask)) + \ ^ /usr/home/manu/Work/freebsd/drm-kmod/drivers/gpu/drm/i915/intel_display.c:14804:38: error: '__builtin_choose_expr' requires a constant expression val = (val & ~PANEL_UNLOCK_MASK) | PANEL_UNLOCK_REGS; ^~~~~~~~~~~~~~~~~ /usr/home/manu/Work/freebsd/drm-kmod/drivers/gpu/drm/i915/i915_reg.h:4770:29: note: expanded from macro 'PANEL_UNLOCK_REGS' #define PANEL_UNLOCK_REGS REG_FIELD_PREP(PANEL_UNLOCK_MASK, 0xabcd) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/home/manu/Work/freebsd/drm-kmod/drivers/gpu/drm/i915/i915_reg.h:167:49: note: expanded from macro 'REG_FIELD_PREP' BUILD_BUG_ON_ZERO(__builtin_choose_expr(__is_constexpr(__val), (~((__mask) >> __bf_shf(__mask)) & (__val)), 0)))) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/manu/Work/freebsd/freebsd-svn/base/head/sys//compat/linuxkpi/common/include/linux/kernel.h:98:32: note: expanded from macro 'BUILD_BUG_ON_ZERO' #define BUILD_BUG_ON_ZERO(x) ((x) ? lkpi_build_bug_on_zero : 0) ^ 11 errors generated. *** [intel_display.o] Error code 1 Step to reproduce: git clone https://github.com/freebsd/drm-kmod.git edit drivers/gpu/drm/i915/i915_drv.h to remove the dummy BUILD_BUG_ON_ZERO macro. make -C i915 -- Emmanuel Vadot <m...@bidouilliste.com> <m...@freebsd.org> _______________________________________________ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"