summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Obser <florian@cvs.openbsd.org>2020-01-26 11:24:20 +0000
committerFlorian Obser <florian@cvs.openbsd.org>2020-01-26 11:24:20 +0000
commit5b3e70777d59c3ba70ac06b60b8dc82417ec0169 (patch)
treeb72ef3751b1777599ea0e50ce287c7f51d911fb3
parent3cce5223d4a9bc76ccc72a8e90d43e50346ac6a3 (diff)
Switch once to isc_boolean_t in preparation of nothreads removal
OK tedu, jca
-rw-r--r--usr.sbin/bind/lib/dns/dst_result.c13
-rw-r--r--usr.sbin/bind/lib/dns/lib.c28
-rw-r--r--usr.sbin/bind/lib/dns/result.c13
-rw-r--r--usr.sbin/bind/lib/isc/hash.c17
-rw-r--r--usr.sbin/bind/lib/isc/result.c10
5 files changed, 34 insertions, 47 deletions
diff --git a/usr.sbin/bind/lib/dns/dst_result.c b/usr.sbin/bind/lib/dns/dst_result.c
index c3f3683d4aa..99c631f3f48 100644
--- a/usr.sbin/bind/lib/dns/dst_result.c
+++ b/usr.sbin/bind/lib/dns/dst_result.c
@@ -16,14 +16,10 @@
/*%
* Principal Author: Brian Wellington
- * $Id: dst_result.c,v 1.5 2020/01/22 13:02:09 florian Exp $
+ * $Id: dst_result.c,v 1.6 2020/01/26 11:24:19 florian Exp $
*/
-
-
-#include <isc/once.h>
#include <isc/util.h>
-
#include <dst/result.h>
static const char *text[DST_R_NRESULTS] = {
@@ -54,7 +50,7 @@ static const char *text[DST_R_NRESULTS] = {
#define DST_RESULT_RESULTSET 2
-static isc_once_t once = ISC_ONCE_INIT;
+static isc_boolean_t once = ISC_FALSE;
static void
initialize_action(void) {
@@ -69,7 +65,10 @@ initialize_action(void) {
static void
initialize(void) {
- RUNTIME_CHECK(isc_once_do(&once, initialize_action) == ISC_R_SUCCESS);
+ if (!once) {
+ once = ISC_TRUE;
+ initialize_action();
+ }
}
const char *
diff --git a/usr.sbin/bind/lib/dns/lib.c b/usr.sbin/bind/lib/dns/lib.c
index 47155a278f2..a09fd609e9f 100644
--- a/usr.sbin/bind/lib/dns/lib.c
+++ b/usr.sbin/bind/lib/dns/lib.c
@@ -14,28 +14,19 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: lib.c,v 1.10 2020/01/22 13:02:09 florian Exp $ */
+/* $Id: lib.c,v 1.11 2020/01/26 11:24:19 florian Exp $ */
/*! \file */
-
-
#include <stddef.h>
#include <isc/hash.h>
-
-
-#include <isc/once.h>
#include <isc/util.h>
-
-
#include <dns/lib.h>
#include <dns/result.h>
-
#include <dst/dst.h>
-
/***
*** Globals
***/
@@ -46,7 +37,7 @@ unsigned int dns_pps = 0U;
*** Functions
***/
-static isc_once_t init_once = ISC_ONCE_INIT;
+static isc_boolean_t init_once = ISC_FALSE;
static isc_boolean_t initialize_done = ISC_FALSE;
static unsigned int references = 0;
@@ -74,17 +65,10 @@ initialize(void) {
isc_result_t
dns_lib_init(void) {
- isc_result_t result;
-
- /*
- * Since this routine is expected to be used by a normal application,
- * it should be better to return an error, instead of an emergency
- * abort, on any failure.
- */
- result = isc_once_do(&init_once, initialize);
- if (result != ISC_R_SUCCESS)
- return (result);
-
+ if (!init_once) {
+ init_once = ISC_TRUE;
+ initialize();
+ }
if (!initialize_done)
return (ISC_R_FAILURE);
diff --git a/usr.sbin/bind/lib/dns/result.c b/usr.sbin/bind/lib/dns/result.c
index f9cb6ef5dcd..df0377ebbed 100644
--- a/usr.sbin/bind/lib/dns/result.c
+++ b/usr.sbin/bind/lib/dns/result.c
@@ -14,13 +14,9 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: result.c,v 1.8 2020/01/22 13:02:09 florian Exp $ */
+/* $Id: result.c,v 1.9 2020/01/26 11:24:19 florian Exp $ */
/*! \file */
-
-
-
-#include <isc/once.h>
#include <isc/util.h>
#include <dns/result.h>
@@ -200,7 +196,7 @@ static const char *rcode_text[DNS_R_NRCODERESULTS] = {
#define DNS_RESULT_RESULTSET 2
#define DNS_RESULT_RCODERESULTSET 3
-static isc_once_t once = ISC_ONCE_INIT;
+static isc_boolean_t once = ISC_FALSE;
static void
initialize_action(void) {
@@ -220,7 +216,10 @@ initialize_action(void) {
static void
initialize(void) {
- RUNTIME_CHECK(isc_once_do(&once, initialize_action) == ISC_R_SUCCESS);
+ if (!once) {
+ once = ISC_TRUE;
+ initialize_action();
+ }
}
const char *
diff --git a/usr.sbin/bind/lib/isc/hash.c b/usr.sbin/bind/lib/isc/hash.c
index 379a29fcbe8..2815e708402 100644
--- a/usr.sbin/bind/lib/isc/hash.c
+++ b/usr.sbin/bind/lib/isc/hash.c
@@ -14,7 +14,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: hash.c,v 1.13 2020/01/22 13:02:09 florian Exp $ */
+/* $Id: hash.c,v 1.14 2020/01/26 11:24:19 florian Exp $ */
/*! \file
* Some portion of this code was derived from universal hash function
@@ -59,10 +59,7 @@ if advised of the possibility of such damage.
#include <stdlib.h>
#include <isc/hash.h>
-
#include <isc/magic.h>
-#include <isc/once.h>
-
#include <isc/refcount.h>
#include <string.h>
#include <isc/util.h>
@@ -328,7 +325,7 @@ isc__hash_setvec(const uint16_t *vec) {
}
static uint32_t fnv_offset_basis;
-static isc_once_t fnv_once = ISC_ONCE_INIT;
+static isc_boolean_t fnv_once = ISC_FALSE;
static void
fnv_initialize(void) {
@@ -352,7 +349,10 @@ isc_hash_function(const void *data, size_t length,
const unsigned char *be;
REQUIRE(length == 0 || data != NULL);
- RUNTIME_CHECK(isc_once_do(&fnv_once, fnv_initialize) == ISC_R_SUCCESS);
+ if (!fnv_once) {
+ fnv_once = ISC_TRUE;
+ fnv_initialize();
+ }
hval = previous_hashp != NULL ?
*previous_hashp : fnv_offset_basis;
@@ -419,7 +419,10 @@ isc_hash_function_reverse(const void *data, size_t length,
const unsigned char *be;
REQUIRE(length == 0 || data != NULL);
- RUNTIME_CHECK(isc_once_do(&fnv_once, fnv_initialize) == ISC_R_SUCCESS);
+ if (!fnv_once) {
+ fnv_once = ISC_TRUE;
+ fnv_initialize();
+ }
hval = previous_hashp != NULL ?
*previous_hashp : fnv_offset_basis;
diff --git a/usr.sbin/bind/lib/isc/result.c b/usr.sbin/bind/lib/isc/result.c
index e01cde307ab..11c38e45f2d 100644
--- a/usr.sbin/bind/lib/isc/result.c
+++ b/usr.sbin/bind/lib/isc/result.c
@@ -14,7 +14,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: result.c,v 1.6 2020/01/22 13:02:10 florian Exp $ */
+/* $Id: result.c,v 1.7 2020/01/26 11:24:19 florian Exp $ */
/*! \file */
@@ -25,7 +25,6 @@
#include <isc/lib.h>
#include <isc/msgs.h>
-#include <isc/once.h>
#include <isc/resultclass.h>
#include <isc/util.h>
@@ -107,7 +106,7 @@ static const char *description[ISC_R_NRESULTS] = {
#define ISC_RESULT_RESULTSET 2
#define ISC_RESULT_UNAVAILABLESET 3
-static isc_once_t once = ISC_ONCE_INIT;
+static isc_boolean_t once = ISC_FALSE;
static ISC_LIST(resulttable) tables;
static isc_result_t
@@ -154,7 +153,10 @@ initialize_action(void) {
static void
initialize(void) {
- RUNTIME_CHECK(isc_once_do(&once, initialize_action) == ISC_R_SUCCESS);
+ if (!once) {
+ once = ISC_TRUE;
+ initialize_action();
+ }
}
const char *