Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 15 Jul 2024 12:38:21 GMT
From:      Andrew Turner <andrew@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: e63ac0eb580b - stable/14 - sys/sys: Fix __builtin_is_aligned fallback
Message-ID:  <202407151238.46FCcLog060924@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/14 has been updated by andrew:

URL: https://cgit.FreeBSD.org/src/commit/?id=e63ac0eb580b287201eb7a8aa3644d6c249a9cce

commit e63ac0eb580b287201eb7a8aa3644d6c249a9cce
Author:     Andrew Turner <andrew@FreeBSD.org>
AuthorDate: 2024-05-22 08:18:26 +0000
Commit:     Andrew Turner <andrew@FreeBSD.org>
CommitDate: 2024-07-15 12:26:34 +0000

    sys/sys: Fix __builtin_is_aligned fallback
    
    When the compiler doesn't provide __builtin_is_aligned we use
    macro as a fallback. The macro was missing brackets around one
    argument. This could lead to incorrect results when the argument is
    more complex than a single stagement.
    
    Fix this by adding the needed brackets.
    
    Reviewed by:    brooks, imp, jhb
    Sponsored by:   Arm Ltd
    Differential Revision:  https://reviews.freebsd.org/D45260
    
    (cherry picked from commit 940155d24afb5c80ce7fde59c856c5c0d5c6dbe1)
---
 sys/sys/cdefs.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys/sys/cdefs.h b/sys/sys/cdefs.h
index 4893ae1662b8..84411e8e4b16 100644
--- a/sys/sys/cdefs.h
+++ b/sys/sys/cdefs.h
@@ -913,7 +913,7 @@
 /* Provide fallback versions for other compilers (GCC/Clang < 10): */
 #if !__has_builtin(__builtin_is_aligned)
 #define __builtin_is_aligned(x, align)	\
-	(((__uintptr_t)x & ((align) - 1)) == 0)
+	(((__uintptr_t)(x) & ((align) - 1)) == 0)
 #endif
 #if !__has_builtin(__builtin_align_up)
 #define __builtin_align_up(x, align)	\



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202407151238.46FCcLog060924>