libbsd: Branch 'main' - 4 commits

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Sat Jul 26 11:17:53 UTC 2025


 README                  |    4 ++--
 include/bsd/sys/cdefs.h |   12 +++++++-----
 include/bsd/sys/tree.h  |    4 ++--
 src/chacha_private.h    |   12 ++++++++++--
 4 files changed, 21 insertions(+), 11 deletions(-)

New commits:
commit 22fddb16f8430d64b82a1ea08602be5e61ac203b
Author: Guillem Jover <guillem at hadrons.org>
Date:   Sat Jul 26 12:41:23 2025 +0200

    Mark tau and sigma Chacha variables as nonstring
    
    These contain a sequence of bytes, and are not a NUL-terminated string.
    Help the compiler understand the intent of the code.

diff --git a/src/chacha_private.h b/src/chacha_private.h
index ef1b931..97e9020 100644
--- a/src/chacha_private.h
+++ b/src/chacha_private.h
@@ -48,8 +48,16 @@ typedef struct
   a = PLUS(a,b); d = ROTATE(XOR(d,a), 8); \
   c = PLUS(c,d); b = ROTATE(XOR(b,c), 7);
 
-static const char sigma[16] = "expand 32-byte k";
-static const char tau[16] = "expand 16-byte k";
+#if defined(__has_attribute)
+#if __has_attribute(__nonstring__)
+#define ATTRIBUTE_NONSTRING __attribute__((__nonstring__))
+#else
+#define ATTRIBUTE_NONSTRING
+#endif
+#endif
+
+static const char sigma[16] ATTRIBUTE_NONSTRING = "expand 32-byte k";
+static const char tau[16] ATTRIBUTE_NONSTRING = "expand 16-byte k";
 
 static void
 chacha_keysetup(chacha_ctx *x,const u8 *k,u32 kbits)
commit abe3c8c33289e15e235aff120399ede316270a52
Author: Guillem Jover <guillem at hadrons.org>
Date:   Sat Nov 2 23:14:11 2024 +0100

    include: Switch from __unused to new LIBBSD_UNUSED
    
    Because we do not define __unused, as on GNU systems Linux and glibc
    providing conflicting symbols, declarations for imported functions that
    use that attribute cause build failures when used.
    
    Ref: https://bugs.debian.org/1083196
    Fixes: #34

diff --git a/include/bsd/sys/tree.h b/include/bsd/sys/tree.h
index 325b382..1a39b88 100644
--- a/include/bsd/sys/tree.h
+++ b/include/bsd/sys/tree.h
@@ -385,7 +385,7 @@ struct {								\
 #define	RB_PROTOTYPE(name, type, field, cmp)				\
 	RB_PROTOTYPE_INTERNAL(name, type, field, cmp,)
 #define	RB_PROTOTYPE_STATIC(name, type, field, cmp)			\
-	RB_PROTOTYPE_INTERNAL(name, type, field, cmp, __unused static)
+	RB_PROTOTYPE_INTERNAL(name, type, field, cmp, LIBBSD_UNUSED static)
 #define RB_PROTOTYPE_INTERNAL(name, type, field, cmp, attr)		\
 attr void name##_RB_INSERT_COLOR(struct name *, struct type *);		\
 attr void name##_RB_REMOVE_COLOR(struct name *, struct type *, struct type *);\
@@ -404,7 +404,7 @@ attr struct type *name##_RB_MINMAX(struct name *, int);			\
 #define	RB_GENERATE(name, type, field, cmp)				\
 	RB_GENERATE_INTERNAL(name, type, field, cmp,)
 #define	RB_GENERATE_STATIC(name, type, field, cmp)			\
-	RB_GENERATE_INTERNAL(name, type, field, cmp, __unused static)
+	RB_GENERATE_INTERNAL(name, type, field, cmp, LIBBSD_UNUSED static)
 #define RB_GENERATE_INTERNAL(name, type, field, cmp, attr)		\
 attr void								\
 name##_RB_INSERT_COLOR(struct name *head, struct type *elm)		\
commit 1d711a2ced0d087ad1a7da23499c7ded4b4903db
Author: Guillem Jover <guillem at hadrons.org>
Date:   Sat Nov 2 23:12:40 2024 +0100

    include: Refactor «unused» attribute into new LIBBSD_UNUSED macro
    
    This make it possible to declare function arguments in headers as
    potentially unused, so that they do not emit warnings. We will use this
    instead of the BSD __unused, which we cannot currently enable on GNU
    systems due to Linux and glibc having conflicting symbols.

diff --git a/include/bsd/sys/cdefs.h b/include/bsd/sys/cdefs.h
index d2627c4..3df88b5 100644
--- a/include/bsd/sys/cdefs.h
+++ b/include/bsd/sys/cdefs.h
@@ -99,6 +99,12 @@
 #define LIBBSD_GCC_VERSION 0
 #endif
 
+#if LIBBSD_GCC_VERSION >= 0x0300 || __has_attribute(__unused__)
+# define LIBBSD_UNUSED __attribute__((__unused__))
+#else
+# define LIBBSD_UNUSED
+#endif
+
 #if LIBBSD_GCC_VERSION >= 0x0405 || __has_attribute(__deprecated__)
 #define LIBBSD_DEPRECATED(x) __attribute__((__deprecated__(x)))
 #elif LIBBSD_GCC_VERSION >= 0x0301
@@ -150,11 +156,7 @@
  * Disable for now. */
 #if 0
 #ifndef __unused
-# if LIBBSD_GCC_VERSION >= 0x0300
-#  define __unused __attribute__((__unused__))
-# else
-#  define __unused
-# endif
+# define __unused LIBBSD_UNUSED
 #endif
 #endif
 
commit aff40cae08e329ea975eba26bcc9fd815cf2dca2
Author: Alan Coopersmith <alan.coopersmith at oracle.com>
Date:   Sat Sep 7 13:19:35 2024 -0700

    doc: Update anongit & cgit URLs to use gitlab instead
    
    Closes: !30
    Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
    Signed-off-by: Guillem Jover <guillem at hadrons.org>

diff --git a/README b/README
index c545bdc..56dbb11 100644
--- a/README
+++ b/README
@@ -33,11 +33,11 @@ Source Repository
 
 The primary repository can be browsed at:
 
-  <https://cgit.freedesktop.org/libbsd>
+  <https://gitlab.freedesktop.org/libbsd/libbsd>
 
 and cloned from:
 
-  <https://anongit.freedesktop.org/git/libbsd>
+  <https://gitlab.freedesktop.org/libbsd/libbsd.git>
 
 
 Building from git source


More information about the libbsd mailing list