From: "Yann E. MORIN" <yann.morin.1998@free.fr>
To: Fabrice Fontaine <fontaine.fabrice@gmail.com>
Cc: Matt Weber <matthew.weber@collins.com>, buildroot@buildroot.org
Subject: Re: [Buildroot] [PATCH 1/1] package/gnutls: fix build without threads
Date: Wed, 9 Mar 2022 22:26:18 +0100 [thread overview]
Message-ID: <20220309212618.GE23050@scaer> (raw)
In-Reply-To: <20220309173503.527227-1-fontaine.fabrice@gmail.com>
Fabrice, All,
On 2022-03-09 18:35 +0100, Fabrice Fontaine spake thusly:
> Fix the following build failure without threads raised since bump to
> version 3.7.3 in commit 212b020bb43f13121d6cde464f871d5d1cf6cfbe:
>
> kx.c: In function '_gnutls_nss_keylog_write':
> kx.c:164:33: error: 'keylog_mutex' undeclared (first use in this function); did you mean 'keylog_once'?
> 164 | if (gnutls_static_mutex_lock(&keylog_mutex) < 0) {
> | ^~~~~~~~~~~~
> | keylog_once
>
> Fixes:
> - http://autobuild.buildroot.org/results/e092bc11ce4b5908cb6285aa77a3594b8626eeec
>
> Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
Applied to master, thanks.
Regards,
Yann E. MORIN.
> ---
> ...cks-define-lock-functions-as-a-macro.patch | 179 ++++++++++++++++++
> 1 file changed, 179 insertions(+)
> create mode 100644 package/gnutls/0001-locks-define-lock-functions-as-a-macro.patch
>
> diff --git a/package/gnutls/0001-locks-define-lock-functions-as-a-macro.patch b/package/gnutls/0001-locks-define-lock-functions-as-a-macro.patch
> new file mode 100644
> index 0000000000..52965c051d
> --- /dev/null
> +++ b/package/gnutls/0001-locks-define-lock-functions-as-a-macro.patch
> @@ -0,0 +1,179 @@
> +From 5803bfa3d4febdcf32494e2c2c8f4731cb8be7cd Mon Sep 17 00:00:00 2001
> +From: Daiki Ueno <ueno@gnu.org>
> +Date: Wed, 9 Mar 2022 08:07:58 +0100
> +Subject: [PATCH] locks: define lock functions as a macro
> +
> +When threads are not supported, glthread_* functions are defined as
> +no-op and thus dereferencing lock variables in inline functions will
> +cause compilation error. This change fixes it by redefining our lock
> +functions as a macro so it will also be compiled out.
> +
> +Reported by Fabrice Fontaine in:
> +https://gitlab.com/gnutls/gnutls/-/issues/1330
> +
> +Signed-off-by: Daiki Ueno <ueno@gnu.org>
> +
> +[Retrieved from:
> +https://gitlab.com/gnutls/gnutls/-/commit/5803bfa3d4febdcf32494e2c2c8f4731cb8be7cd]
> +Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
> +---
> + lib/locks.c | 54 -----------------------------------------------
> + lib/locks.h | 28 ++++++++++++++++++------
> + lib/pkcs11.c | 2 +-
> + lib/priority.c | 2 +-
> + lib/verify-tofu.c | 2 +-
> + 5 files changed, 25 insertions(+), 63 deletions(-)
> +
> +diff --git a/lib/locks.c b/lib/locks.c
> +index d61504e077..8888ed6b12 100644
> +--- a/lib/locks.c
> ++++ b/lib/locks.c
> +@@ -63,57 +63,3 @@ gnutls_global_set_mutex(mutex_init_func init, mutex_deinit_func deinit,
> + gnutls_mutex_lock = lock;
> + gnutls_mutex_unlock = unlock;
> + }
> +-
> +-int
> +-gnutls_static_mutex_lock(gnutls_static_mutex_t lock)
> +-{
> +- if (unlikely(glthread_lock_lock(lock))) {
> +- return gnutls_assert_val(GNUTLS_E_LOCKING_ERROR);
> +- }
> +- return 0;
> +-}
> +-
> +-int
> +-gnutls_static_mutex_unlock(gnutls_static_mutex_t lock)
> +-{
> +- if (unlikely(glthread_lock_unlock(lock))) {
> +- return gnutls_assert_val(GNUTLS_E_LOCKING_ERROR);
> +- }
> +- return 0;
> +-}
> +-
> +-int
> +-gnutls_rwlock_rdlock(gnutls_rwlock_t rwlock)
> +-{
> +- if (unlikely(glthread_rwlock_rdlock(rwlock))) {
> +- return gnutls_assert_val(GNUTLS_E_LOCKING_ERROR);
> +- }
> +- return 0;
> +-}
> +-
> +-int
> +-gnutls_rwlock_wrlock(gnutls_rwlock_t rwlock)
> +-{
> +- if (unlikely(glthread_rwlock_wrlock(rwlock))) {
> +- return gnutls_assert_val(GNUTLS_E_LOCKING_ERROR);
> +- }
> +- return 0;
> +-}
> +-
> +-int
> +-gnutls_rwlock_unlock(gnutls_rwlock_t rwlock)
> +-{
> +- if (unlikely(glthread_rwlock_unlock(rwlock))) {
> +- return gnutls_assert_val(GNUTLS_E_LOCKING_ERROR);
> +- }
> +- return 0;
> +-}
> +-
> +-int
> +-gnutls_once(gnutls_once_t once, void (*init_func) (void))
> +-{
> +- if (unlikely(glthread_once(once, init_func))) {
> +- return gnutls_assert_val(GNUTLS_E_LOCKING_ERROR);
> +- }
> +- return 0;
> +-}
> +diff --git a/lib/locks.h b/lib/locks.h
> +index a1ff0fa9d7..907adfc134 100644
> +--- a/lib/locks.h
> ++++ b/lib/locks.h
> +@@ -40,8 +40,14 @@ extern mutex_unlock_func gnutls_mutex_unlock;
> + */
> + #define GNUTLS_STATIC_MUTEX(lock) gl_lock_define_initialized(static, lock)
> + typedef gl_lock_t *gnutls_static_mutex_t;
> +-int gnutls_static_mutex_lock(gnutls_static_mutex_t lock);
> +-int gnutls_static_mutex_unlock(gnutls_static_mutex_t lock);
> ++
> ++#define gnutls_static_mutex_lock(LOCK) \
> ++ (unlikely(glthread_lock_lock(LOCK)) ? \
> ++ gnutls_assert_val(GNUTLS_E_LOCKING_ERROR) : 0)
> ++
> ++#define gnutls_static_mutex_unlock(LOCK) \
> ++ (unlikely(glthread_lock_unlock(LOCK)) ? \
> ++ gnutls_assert_val(GNUTLS_E_LOCKING_ERROR) : 0)
> +
> + /* Unlike static mutexes, static rwlocks can be locked/unlocked with
> + * the functions defined below, because there is no way to replace
> +@@ -50,13 +56,23 @@ int gnutls_static_mutex_unlock(gnutls_static_mutex_t lock);
> + #define GNUTLS_RWLOCK(rwlock) gl_rwlock_define_initialized(static, rwlock)
> + typedef gl_rwlock_t *gnutls_rwlock_t;
> +
> +-int gnutls_rwlock_rdlock(gnutls_rwlock_t rwlock);
> +-int gnutls_rwlock_wrlock(gnutls_rwlock_t rwlock);
> +-int gnutls_rwlock_unlock(gnutls_rwlock_t rwlock);
> ++#define gnutls_rwlock_rdlock(RWLOCK) \
> ++ (unlikely(glthread_rwlock_rdlock(RWLOCK)) ? \
> ++ gnutls_assert_val(GNUTLS_E_LOCKING_ERROR) : 0)
> ++
> ++#define gnutls_rwlock_wrlock(RWLOCK) \
> ++ (unlikely(glthread_rwlock_wrlock(RWLOCK)) ? \
> ++ gnutls_assert_val(GNUTLS_E_LOCKING_ERROR) : 0)
> ++
> ++#define gnutls_rwlock_unlock(RWLOCK) \
> ++ (unlikely(glthread_rwlock_unlock(RWLOCK)) ? \
> ++ gnutls_assert_val(GNUTLS_E_LOCKING_ERROR) : 0)
> +
> + #define GNUTLS_ONCE(once) gl_once_define(static, once)
> + typedef gl_once_t *gnutls_once_t;
> +
> +-int gnutls_once(gnutls_once_t once, void (*init_func) (void));
> ++#define gnutls_once(ONCE, INIT_FUNC) \
> ++ (unlikely(glthread_once(ONCE, INIT_FUNC)) ? \
> ++ gnutls_assert_val(GNUTLS_E_LOCKING_ERROR) : 0)
> +
> + #endif /* GNUTLS_LIB_LOCKS_H */
> +diff --git a/lib/pkcs11.c b/lib/pkcs11.c
> +index 8dda0f07c9..ba8ac0c375 100644
> +--- a/lib/pkcs11.c
> ++++ b/lib/pkcs11.c
> +@@ -351,7 +351,7 @@ int _gnutls_pkcs11_check_init(init_level_t req_level, void *priv, pkcs11_reinit_
> + ret = sret;
> +
> + cleanup:
> +- gnutls_static_mutex_unlock(&pkcs11_mutex);
> ++ (void)gnutls_static_mutex_unlock(&pkcs11_mutex);
> +
> + return ret;
> + }
> +diff --git a/lib/priority.c b/lib/priority.c
> +index d17a923318..55ae185c1f 100644
> +--- a/lib/priority.c
> ++++ b/lib/priority.c
> +@@ -2505,7 +2505,7 @@ static int set_ciphersuite_list(gnutls_priority_t priority_cache)
> + }
> +
> + out:
> +- gnutls_rwlock_unlock(&system_wide_config_rwlock);
> ++ (void)gnutls_rwlock_unlock(&system_wide_config_rwlock);
> + return ret;
> + }
> +
> +diff --git a/lib/verify-tofu.c b/lib/verify-tofu.c
> +index 40b7acdc8a..97f47385e6 100644
> +--- a/lib/verify-tofu.c
> ++++ b/lib/verify-tofu.c
> +@@ -434,7 +434,7 @@ int store_pubkey(const char *db_name, const char *host,
> + if (fp != NULL)
> + fclose(fp);
> +
> +- gnutls_static_mutex_unlock(&file_mutex);
> ++ (void)gnutls_static_mutex_unlock(&file_mutex);
> + gnutls_free(b64key.data);
> +
> + return ret;
> +--
> +GitLab
> +
> --
> 2.34.1
>
> _______________________________________________
> buildroot mailing list
> buildroot@buildroot.org
> https://lists.buildroot.org/mailman/listinfo/buildroot
--
.-----------------.--------------------.------------------.--------------------.
| Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ |
| +33 561 099 427 `------------.-------: X AGAINST | \e/ There is no |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. |
'------------------------------^-------^------------------^--------------------'
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
next prev parent reply other threads:[~2022-03-09 21:26 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-09 17:35 [Buildroot] [PATCH 1/1] package/gnutls: fix build without threads Fabrice Fontaine
2022-03-09 21:26 ` Yann E. MORIN [this message]
2022-03-14 9:19 ` Peter Korsgaard
2022-03-18 8:31 ` Peter Korsgaard
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220309212618.GE23050@scaer \
--to=yann.morin.1998@free.fr \
--cc=buildroot@buildroot.org \
--cc=fontaine.fabrice@gmail.com \
--cc=matthew.weber@collins.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox