From owner-svn-ports-head@freebsd.org Mon Jan 16 10:19:03 2017 Return-Path: Delivered-To: svn-ports-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id F3E13CAFB97; Mon, 16 Jan 2017 10:19:02 +0000 (UTC) (envelope-from tijl@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A6C5E17C7; Mon, 16 Jan 2017 10:19:02 +0000 (UTC) (envelope-from tijl@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v0GAJ13B081590; Mon, 16 Jan 2017 10:19:01 GMT (envelope-from tijl@FreeBSD.org) Received: (from tijl@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v0GAJ1w1081589; Mon, 16 Jan 2017 10:19:01 GMT (envelope-from tijl@FreeBSD.org) Message-Id: <201701161019.v0GAJ1w1081589@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: tijl set sender to tijl@FreeBSD.org using -f From: Tijl Coosemans Date: Mon, 16 Jan 2017 10:19:01 +0000 (UTC) To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r431622 - head/security/gnutls/files X-SVN-Group: ports-head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-ports-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the ports tree for head List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Jan 2017 10:19:03 -0000 Author: tijl Date: Mon Jan 16 10:19:01 2017 New Revision: 431622 URL: https://svnweb.freebsd.org/changeset/ports/431622 Log: Make atomic operations explicit to support old gcc. PR: 216122 Added: head/security/gnutls/files/patch-lib-random.c (contents, props changed) Added: head/security/gnutls/files/patch-lib-random.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/security/gnutls/files/patch-lib-random.c Mon Jan 16 10:19:01 2017 (r431622) @@ -0,0 +1,53 @@ +--- lib/random.c.orig 2017-01-08 09:27:28 UTC ++++ lib/random.c +@@ -33,24 +33,24 @@ void *gnutls_rnd_ctx; + GNUTLS_STATIC_MUTEX(gnutls_rnd_init_mutex); + + #ifdef HAVE_STDATOMIC_H +-static atomic_uint rnd_initialized = 0; ++static atomic_uint rnd_initialized = ATOMIC_VAR_INIT(0); + + inline static int _gnutls_rnd_init(void) + { +- if (unlikely(!rnd_initialized)) { ++ if (unlikely(!atomic_load(&rnd_initialized))) { + if (_gnutls_rnd_ops.init == NULL) { +- rnd_initialized = 1; ++ atomic_store(&rnd_initialized, 1); + return 0; + } + + GNUTLS_STATIC_MUTEX_LOCK(gnutls_rnd_init_mutex); +- if (!rnd_initialized) { ++ if (!atomic_load(&rnd_initialized)) { + if (_gnutls_rnd_ops.init(&gnutls_rnd_ctx) < 0) { + gnutls_assert(); + GNUTLS_STATIC_MUTEX_UNLOCK(gnutls_rnd_init_mutex); + return GNUTLS_E_RANDOM_FAILED; + } +- rnd_initialized = 1; ++ atomic_store(&rnd_initialized, 1); + } + GNUTLS_STATIC_MUTEX_UNLOCK(gnutls_rnd_init_mutex); + } +@@ -107,10 +107,10 @@ int _gnutls_rnd_preinit(void) + + void _gnutls_rnd_deinit(void) + { +- if (rnd_initialized && _gnutls_rnd_ops.deinit != NULL) { ++ if (atomic_load(&rnd_initialized) && _gnutls_rnd_ops.deinit != NULL) { + _gnutls_rnd_ops.deinit(gnutls_rnd_ctx); + } +- rnd_initialized = 0; ++ atomic_store(&rnd_initialized, 0); + + _rnd_system_entropy_deinit(); + +@@ -162,6 +162,6 @@ int gnutls_rnd(gnutls_rnd_level_t level, + **/ + void gnutls_rnd_refresh(void) + { +- if (rnd_initialized && _gnutls_rnd_ops.rnd_refresh) ++ if (atomic_load(&rnd_initialized) && _gnutls_rnd_ops.rnd_refresh) + _gnutls_rnd_ops.rnd_refresh(gnutls_rnd_ctx); + }