This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
Harald Welte gerrit-no-reply at lists.osmocom.orgHarald Welte has submitted this change and it was merged. ( https://gerrit.osmocom.org/11719 ) Change subject: Streamline glibc version check ...................................................................... Streamline glibc version check * use macro for version check * report glibc version upon random.h detection * comment where various #endif belongs to * explicitly check for embedded build (our target toolchain don't use libc so there's no point in checking its version) Change-Id: Ia54f0b7a861f955be65bb0cf06eb10af9372d062 --- M src/gsm/gsm_utils.c 1 file changed, 11 insertions(+), 7 deletions(-) Approvals: Harald Welte: Looks good to me, approved Pau Espin Pedrol: Looks good to me, but someone else must approve Jenkins Builder: Verified diff --git a/src/gsm/gsm_utils.c b/src/gsm/gsm_utils.c index 9eb41fb..14331e5 100644 --- a/src/gsm/gsm_utils.c +++ b/src/gsm/gsm_utils.c @@ -98,15 +98,18 @@ #include "../../config.h" +#if (!EMBEDDED) /* FIXME: this can be removed once we bump glibc requirements to 2.25: */ -#if defined(__GLIBC__) && (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 25) +#if defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2,25) +#pragma message ("glibc " OSMO_STRINGIFY_VAL(__GLIBC__) "." OSMO_STRINGIFY_VAL(__GLIBC_MINOR__) " random detected") #include <sys/random.h> #elif HAVE_DECL_SYS_GETRANDOM #include <sys/syscall.h> #ifndef GRND_NONBLOCK #define GRND_NONBLOCK 0x0001 -#endif -#endif +#endif /* ifndef GRND_NONBLOCK */ +#endif /* if __GLIBC_PREREQ */ +#endif /* !EMBEDDED */ #if (USE_GNUTLS) #pragma message ("including GnuTLS for getrandom fallback.") @@ -131,7 +134,8 @@ if (!gnutls_check_version("3.3.0")) gnutls_global_deinit(); } -#endif + +#endif /* if (USE_GNUTLS) */ /* ETSI GSM 03.38 6.2.1 and 6.2.1.1 default alphabet * Greek symbols at hex positions 0x10 and 0x12-0x1a @@ -441,19 +445,19 @@ /* this function is intended for generating short identifiers only, not arbitrary-length random data */ if (len > OSMO_MAX_RAND_ID_LEN) return -E2BIG; - -#if defined(__GLIBC__) && (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 25) +#if (!EMBEDDED) +#if defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2,25) rc = getrandom(out, len, GRND_NONBLOCK); #elif HAVE_DECL_SYS_GETRANDOM #pragma message ("Using direct syscall access for getrandom(): consider upgrading to glibc >= 2.25") /* FIXME: this can be removed once we bump glibc requirements to 2.25: */ rc = syscall(SYS_getrandom, out, len, GRND_NONBLOCK); #endif +#endif /* !EMBEDDED */ /* getrandom() failed entirely: */ if (rc < 0) { #if (USE_GNUTLS) -#pragma message ("Secure random failed: using GnuTLS fallback.") return gnutls_rnd(GNUTLS_RND_RANDOM, out, len); #endif return -errno; -- To view, visit https://gerrit.osmocom.org/11719 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-MessageType: merged Gerrit-Change-Id: Ia54f0b7a861f955be65bb0cf06eb10af9372d062 Gerrit-Change-Number: 11719 Gerrit-PatchSet: 10 Gerrit-Owner: Max <msuraev at sysmocom.de> Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org> Gerrit-Reviewer: Jenkins Builder (1000002) Gerrit-Reviewer: Max <msuraev at sysmocom.de> Gerrit-Reviewer: Pau Espin Pedrol <pespin at sysmocom.de> Gerrit-Reviewer: Vadim Yanitskiy <axilirator at gmail.com> Gerrit-Reviewer: daniel <dwillmann at sysmocom.de> -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190107/c2766948/attachment.htm>