From 7fbc1fc98bb7e550f74e3ce05525197996a23795 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Tue, 22 Feb 2022 14:48:07 +0100 Subject: [PATCH] Remove isc_astack API The isc_astack API is now completely unused, just remove it. --- lib/isc/Makefile.am | 2 - lib/isc/astack.c | 85 ------------------------------------ lib/isc/include/isc/astack.h | 49 --------------------- lib/isc/include/isc/types.h | 1 - lib/isc/netmgr/netmgr-int.h | 1 - 5 files changed, 138 deletions(-) delete mode 100644 lib/isc/astack.c delete mode 100644 lib/isc/include/isc/astack.h diff --git a/lib/isc/Makefile.am b/lib/isc/Makefile.am index 3d37127fe9..65d6369906 100644 --- a/lib/isc/Makefile.am +++ b/lib/isc/Makefile.am @@ -8,7 +8,6 @@ libisc_la_HEADERS = \ include/isc/align.h \ include/isc/app.h \ include/isc/assertions.h \ - include/isc/astack.h \ include/isc/atomic.h \ include/isc/attributes.h \ include/isc/backtrace.h \ @@ -118,7 +117,6 @@ libisc_la_SOURCES = \ aes.c \ app.c \ assertions.c \ - astack.c \ backtrace.c \ base32.c \ base64.c \ diff --git a/lib/isc/astack.c b/lib/isc/astack.c deleted file mode 100644 index 484ef26e87..0000000000 --- a/lib/isc/astack.c +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (C) Internet Systems Consortium, Inc. ("ISC") - * - * SPDX-License-Identifier: MPL-2.0 - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, you can obtain one at https://mozilla.org/MPL/2.0/. - * - * See the COPYRIGHT file distributed with this work for additional - * information regarding copyright ownership. - */ - -#include -#include - -#include -#include -#include -#include -#include -#include - -struct isc_astack { - isc_mem_t *mctx; - size_t size; - size_t pos; - isc_mutex_t lock; - uintptr_t nodes[]; -}; - -isc_astack_t * -isc_astack_new(isc_mem_t *mctx, size_t size) { - isc_astack_t *stack = isc_mem_get( - mctx, sizeof(isc_astack_t) + size * sizeof(uintptr_t)); - - *stack = (isc_astack_t){ - .size = size, - }; - isc_mem_attach(mctx, &stack->mctx); - memset(stack->nodes, 0, size * sizeof(uintptr_t)); - isc_mutex_init(&stack->lock); - return (stack); -} - -bool -isc_astack_trypush(isc_astack_t *stack, void *obj) { - if (!isc_mutex_trylock(&stack->lock)) { - if (stack->pos >= stack->size) { - UNLOCK(&stack->lock); - return (false); - } - stack->nodes[stack->pos++] = (uintptr_t)obj; - UNLOCK(&stack->lock); - return (true); - } else { - return (false); - } -} - -void * -isc_astack_pop(isc_astack_t *stack) { - LOCK(&stack->lock); - uintptr_t rv; - if (stack->pos == 0) { - rv = 0; - } else { - rv = stack->nodes[--stack->pos]; - } - UNLOCK(&stack->lock); - return ((void *)rv); -} - -void -isc_astack_destroy(isc_astack_t *stack) { - LOCK(&stack->lock); - REQUIRE(stack->pos == 0); - UNLOCK(&stack->lock); - - isc_mutex_destroy(&stack->lock); - - isc_mem_putanddetach(&stack->mctx, stack, - sizeof(struct isc_astack) + - stack->size * sizeof(uintptr_t)); -} diff --git a/lib/isc/include/isc/astack.h b/lib/isc/include/isc/astack.h deleted file mode 100644 index a4f6762259..0000000000 --- a/lib/isc/include/isc/astack.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (C) Internet Systems Consortium, Inc. ("ISC") - * - * SPDX-License-Identifier: MPL-2.0 - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, you can obtain one at https://mozilla.org/MPL/2.0/. - * - * See the COPYRIGHT file distributed with this work for additional - * information regarding copyright ownership. - */ - -#pragma once - -#include - -#include -#include - -isc_astack_t * -isc_astack_new(isc_mem_t *mctx, size_t size); -/*%< - * Allocate and initialize a new array stack of size 'size'. - */ - -void -isc_astack_destroy(isc_astack_t *stack); -/*%< - * Free an array stack 'stack'. - * - * Requires: - * \li 'stack' is empty. - */ - -bool -isc_astack_trypush(isc_astack_t *stack, void *obj); -/*%< - * Try to push 'obj' onto array stack 'astack'. On failure, either - * because the stack size limit has been reached or because another - * thread has already changed the stack pointer, return 'false'. - */ - -void * -isc_astack_pop(isc_astack_t *stack); -/*%< - * Pop an object off of array stack 'stack'. If the stack is empty, - * return NULL. - */ diff --git a/lib/isc/include/isc/types.h b/lib/isc/include/isc/types.h index bd2f739ea2..a533f51f91 100644 --- a/lib/isc/include/isc/types.h +++ b/lib/isc/include/isc/types.h @@ -33,7 +33,6 @@ /* Core Types. Alphabetized by defined type. */ -typedef struct isc_astack isc_astack_t; /*%< Array-based fast stack */ typedef struct isc_appctx isc_appctx_t; /*%< Application context */ typedef struct isc_buffer isc_buffer_t; /*%< Buffer */ typedef ISC_LIST(isc_buffer_t) isc_bufferlist_t; /*%< Buffer List */ diff --git a/lib/isc/netmgr/netmgr-int.h b/lib/isc/netmgr/netmgr-int.h index bccda8fa45..7b07966b2b 100644 --- a/lib/isc/netmgr/netmgr-int.h +++ b/lib/isc/netmgr/netmgr-int.h @@ -19,7 +19,6 @@ #include #include -#include #include #include #include