svn commit: r431623 - branches/2017Q1/security/gnutls/files

Tijl Coosemans tijl at FreeBSD.org
Mon Jan 16 10:21:53 UTC 2017


Author: tijl
Date: Mon Jan 16 10:21:52 2017
New Revision: 431623
URL: https://svnweb.freebsd.org/changeset/ports/431623

Log:
  MFH: r431622
  
  Make atomic operations explicit to support old gcc.
  
  PR:		216122
  Approved by:	ports-secteam (build fix blanket)

Added:
  branches/2017Q1/security/gnutls/files/patch-lib-random.c
     - copied unchanged from r431622, head/security/gnutls/files/patch-lib-random.c
Modified:
Directory Properties:
  branches/2017Q1/   (props changed)

Copied: branches/2017Q1/security/gnutls/files/patch-lib-random.c (from r431622, head/security/gnutls/files/patch-lib-random.c)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ branches/2017Q1/security/gnutls/files/patch-lib-random.c	Mon Jan 16 10:21:52 2017	(r431623, copy of r431622, head/security/gnutls/files/patch-lib-random.c)
@@ -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);
+ }


More information about the svn-ports-branches mailing list