Compare commits

..

4 Commits
0.12.2 ... main

Author SHA1 Message Date
Guillem Jover
22fddb16f8 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.
2025-07-26 12:41:23 +02:00
Guillem Jover
abe3c8c332 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
2025-07-26 12:26:01 +02:00
Guillem Jover
1d711a2ced 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.
2025-07-26 12:25:40 +02:00
Alan Coopersmith
aff40cae08 doc: Update anongit & cgit URLs to use gitlab instead
Closes: !30
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Signed-off-by: Guillem Jover <guillem@hadrons.org>
2024-11-02 23:22:22 +01:00
4 changed files with 21 additions and 11 deletions

4
README
View File

@@ -33,11 +33,11 @@ Source Repository
The primary repository can be browsed at: The primary repository can be browsed at:
<https://cgit.freedesktop.org/libbsd> <https://gitlab.freedesktop.org/libbsd/libbsd>
and cloned from: and cloned from:
<https://anongit.freedesktop.org/git/libbsd> <https://gitlab.freedesktop.org/libbsd/libbsd.git>
Building from git source Building from git source

View File

@@ -99,6 +99,12 @@
#define LIBBSD_GCC_VERSION 0 #define LIBBSD_GCC_VERSION 0
#endif #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__) #if LIBBSD_GCC_VERSION >= 0x0405 || __has_attribute(__deprecated__)
#define LIBBSD_DEPRECATED(x) __attribute__((__deprecated__(x))) #define LIBBSD_DEPRECATED(x) __attribute__((__deprecated__(x)))
#elif LIBBSD_GCC_VERSION >= 0x0301 #elif LIBBSD_GCC_VERSION >= 0x0301
@@ -150,11 +156,7 @@
* Disable for now. */ * Disable for now. */
#if 0 #if 0
#ifndef __unused #ifndef __unused
# if LIBBSD_GCC_VERSION >= 0x0300 # define __unused LIBBSD_UNUSED
# define __unused __attribute__((__unused__))
# else
# define __unused
# endif
#endif #endif
#endif #endif

View File

@@ -385,7 +385,7 @@ struct { \
#define RB_PROTOTYPE(name, type, field, cmp) \ #define RB_PROTOTYPE(name, type, field, cmp) \
RB_PROTOTYPE_INTERNAL(name, type, field, cmp,) RB_PROTOTYPE_INTERNAL(name, type, field, cmp,)
#define RB_PROTOTYPE_STATIC(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) \ #define RB_PROTOTYPE_INTERNAL(name, type, field, cmp, attr) \
attr void name##_RB_INSERT_COLOR(struct name *, struct type *); \ attr void name##_RB_INSERT_COLOR(struct name *, struct type *); \
attr void name##_RB_REMOVE_COLOR(struct name *, struct type *, 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) \ #define RB_GENERATE(name, type, field, cmp) \
RB_GENERATE_INTERNAL(name, type, field, cmp,) RB_GENERATE_INTERNAL(name, type, field, cmp,)
#define RB_GENERATE_STATIC(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) \ #define RB_GENERATE_INTERNAL(name, type, field, cmp, attr) \
attr void \ attr void \
name##_RB_INSERT_COLOR(struct name *head, struct type *elm) \ name##_RB_INSERT_COLOR(struct name *head, struct type *elm) \

View File

@@ -48,8 +48,16 @@ typedef struct
a = PLUS(a,b); d = ROTATE(XOR(d,a), 8); \ a = PLUS(a,b); d = ROTATE(XOR(d,a), 8); \
c = PLUS(c,d); b = ROTATE(XOR(b,c), 7); c = PLUS(c,d); b = ROTATE(XOR(b,c), 7);
static const char sigma[16] = "expand 32-byte k"; #if defined(__has_attribute)
static const char tau[16] = "expand 16-byte k"; #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 static void
chacha_keysetup(chacha_ctx *x,const u8 *k,u32 kbits) chacha_keysetup(chacha_ctx *x,const u8 *k,u32 kbits)