diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-05 18:37:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-05 18:37:14 +0000 |
commit | ea648e70a989cca190cd7403fe892fd2dcc290b4 (patch) | |
tree | e2b6b1c647da68b0d4d66082835e256eb30970e8 /lib/isc/nothreads | |
parent | Initial commit. (diff) | |
download | bind9-ea648e70a989cca190cd7403fe892fd2dcc290b4.tar.xz bind9-ea648e70a989cca190cd7403fe892fd2dcc290b4.zip |
Adding upstream version 1:9.11.5.P4+dfsg.upstream/1%9.11.5.P4+dfsgupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'lib/isc/nothreads')
-rw-r--r-- | lib/isc/nothreads/Makefile.in | 32 | ||||
-rw-r--r-- | lib/isc/nothreads/condition.c | 17 | ||||
-rw-r--r-- | lib/isc/nothreads/include/Makefile.in | 17 | ||||
-rw-r--r-- | lib/isc/nothreads/include/isc/Makefile.in | 34 | ||||
-rw-r--r-- | lib/isc/nothreads/include/isc/condition.h | 52 | ||||
-rw-r--r-- | lib/isc/nothreads/include/isc/mutex.h | 31 | ||||
-rw-r--r-- | lib/isc/nothreads/include/isc/once.h | 27 | ||||
-rw-r--r-- | lib/isc/nothreads/include/isc/thread.h | 40 | ||||
-rw-r--r-- | lib/isc/nothreads/mutex.c | 18 | ||||
-rw-r--r-- | lib/isc/nothreads/thread.c | 26 |
10 files changed, 294 insertions, 0 deletions
diff --git a/lib/isc/nothreads/Makefile.in b/lib/isc/nothreads/Makefile.in new file mode 100644 index 0000000..c794773 --- /dev/null +++ b/lib/isc/nothreads/Makefile.in @@ -0,0 +1,32 @@ +# Copyright (C) Internet Systems Consortium, Inc. ("ISC") +# +# 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 http://mozilla.org/MPL/2.0/. +# +# See the COPYRIGHT file distributed with this work for additional +# information regarding copyright ownership. + +top_srcdir = @top_srcdir@ +srcdir = @srcdir@ +VPATH = @srcdir@ + +CINCLUDES = -I${srcdir}/include \ + -I${srcdir}/../unix/include \ + -I../include \ + -I${srcdir}/../include \ + -I${srcdir}/.. + +CDEFINES = +CWARNINGS = + +THREADOPTOBJS = condition.@O@ mutex.@O@ +OBJS = @THREADOPTOBJS@ thread.@O@ + +THREADOPTSRCS = condition.c mutex.c +SRCS = @THREADOPTSRCS@ thread.c + +SUBDIRS = include +TARGETS = ${OBJS} + +@BIND9_MAKE_RULES@ diff --git a/lib/isc/nothreads/condition.c b/lib/isc/nothreads/condition.c new file mode 100644 index 0000000..a549c30 --- /dev/null +++ b/lib/isc/nothreads/condition.c @@ -0,0 +1,17 @@ +/* + * Copyright (C) Internet Systems Consortium, Inc. ("ISC") + * + * 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 http://mozilla.org/MPL/2.0/. + * + * See the COPYRIGHT file distributed with this work for additional + * information regarding copyright ownership. + */ + + +#include <config.h> + +#include <isc/util.h> + +EMPTY_TRANSLATION_UNIT diff --git a/lib/isc/nothreads/include/Makefile.in b/lib/isc/nothreads/include/Makefile.in new file mode 100644 index 0000000..d33c0fc --- /dev/null +++ b/lib/isc/nothreads/include/Makefile.in @@ -0,0 +1,17 @@ +# Copyright (C) Internet Systems Consortium, Inc. ("ISC") +# +# 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 http://mozilla.org/MPL/2.0/. +# +# See the COPYRIGHT file distributed with this work for additional +# information regarding copyright ownership. + +srcdir = @srcdir@ +VPATH = @srcdir@ +top_srcdir = @top_srcdir@ + +SUBDIRS = isc +TARGETS = + +@BIND9_MAKE_RULES@ diff --git a/lib/isc/nothreads/include/isc/Makefile.in b/lib/isc/nothreads/include/isc/Makefile.in new file mode 100644 index 0000000..185534f --- /dev/null +++ b/lib/isc/nothreads/include/isc/Makefile.in @@ -0,0 +1,34 @@ +# Copyright (C) Internet Systems Consortium, Inc. ("ISC") +# +# 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 http://mozilla.org/MPL/2.0/. +# +# See the COPYRIGHT file distributed with this work for additional +# information regarding copyright ownership. + +srcdir = @srcdir@ +VPATH = @srcdir@ +top_srcdir = @top_srcdir@ + +VERSION=@BIND9_VERSION@ + +HEADERS = condition.h mutex.h once.h thread.h + +SUBDIRS = +TARGETS = + +@BIND9_MAKE_RULES@ + +installdirs: + $(SHELL) ${top_srcdir}/mkinstalldirs ${DESTDIR}${includedir}/isc + +install:: installdirs + for i in ${HEADERS}; do \ + ${INSTALL_DATA} $(srcdir)/$$i ${DESTDIR}${includedir}/isc || exit 1; \ + done + +uninstall:: + for i in ${HEADERS}; do \ + rm -f ${DESTDIR}${includedir}/isc/$$i || exit 1; \ + done diff --git a/lib/isc/nothreads/include/isc/condition.h b/lib/isc/nothreads/include/isc/condition.h new file mode 100644 index 0000000..0bea23d --- /dev/null +++ b/lib/isc/nothreads/include/isc/condition.h @@ -0,0 +1,52 @@ +/* + * Copyright (C) Internet Systems Consortium, Inc. ("ISC") + * + * 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 http://mozilla.org/MPL/2.0/. + * + * See the COPYRIGHT file distributed with this work for additional + * information regarding copyright ownership. + */ + + +/* + * This provides a limited subset of the isc_condition_t + * functionality for use by single-threaded programs that + * need to block waiting for events. Only a single + * call to isc_condition_wait() may be blocked at any given + * time, and the _waituntil and _broadcast functions are not + * supported. This is intended primarily for use by the omapi + * library, and may go away once omapi goes away. Use for + * other purposes is strongly discouraged. + */ + +#ifndef ISC_CONDITION_H +#define ISC_CONDITION_H 1 + +#include <isc/mutex.h> + +typedef int isc_condition_t; + +isc_result_t isc__nothread_wait_hack(isc_condition_t *cp, isc_mutex_t *mp); +isc_result_t isc__nothread_signal_hack(isc_condition_t *cp); + +#define isc_condition_init(cp) \ + (*(cp) = 0, ISC_R_SUCCESS) + +#define isc_condition_wait(cp, mp) \ + isc__nothread_wait_hack(cp, mp) + +#define isc_condition_waituntil(cp, mp, tp) \ + ((void)(cp), (void)(mp), (void)(tp), ISC_R_NOTIMPLEMENTED) + +#define isc_condition_signal(cp) \ + isc__nothread_signal_hack(cp) + +#define isc_condition_broadcast(cp) \ + ((void)(cp), ISC_R_NOTIMPLEMENTED) + +#define isc_condition_destroy(cp) \ + (*(cp) == 0 ? (*(cp) = -1, ISC_R_SUCCESS) : ISC_R_UNEXPECTED) + +#endif /* ISC_CONDITION_H */ diff --git a/lib/isc/nothreads/include/isc/mutex.h b/lib/isc/nothreads/include/isc/mutex.h new file mode 100644 index 0000000..a9c55f6 --- /dev/null +++ b/lib/isc/nothreads/include/isc/mutex.h @@ -0,0 +1,31 @@ +/* + * Copyright (C) Internet Systems Consortium, Inc. ("ISC") + * + * 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 http://mozilla.org/MPL/2.0/. + * + * See the COPYRIGHT file distributed with this work for additional + * information regarding copyright ownership. + */ + +#ifndef ISC_MUTEX_H +#define ISC_MUTEX_H 1 + +#include <isc/result.h> /* for ISC_R_ codes */ + +typedef int isc_mutex_t; + +#define isc_mutex_init(mp) \ + (*(mp) = 0, ISC_R_SUCCESS) +#define isc_mutex_lock(mp) \ + ((*(mp))++ == 0 ? ISC_R_SUCCESS : ISC_R_UNEXPECTED) +#define isc_mutex_unlock(mp) \ + (--(*(mp)) == 0 ? ISC_R_SUCCESS : ISC_R_UNEXPECTED) +#define isc_mutex_trylock(mp) \ + (*(mp) == 0 ? ((*(mp))++, ISC_R_SUCCESS) : ISC_R_LOCKBUSY) +#define isc_mutex_destroy(mp) \ + (*(mp) == 0 ? (*(mp) = -1, ISC_R_SUCCESS) : ISC_R_UNEXPECTED) +#define isc_mutex_stats(fp) + +#endif /* ISC_MUTEX_H */ diff --git a/lib/isc/nothreads/include/isc/once.h b/lib/isc/nothreads/include/isc/once.h new file mode 100644 index 0000000..c291814 --- /dev/null +++ b/lib/isc/nothreads/include/isc/once.h @@ -0,0 +1,27 @@ +/* + * Copyright (C) Internet Systems Consortium, Inc. ("ISC") + * + * 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 http://mozilla.org/MPL/2.0/. + * + * See the COPYRIGHT file distributed with this work for additional + * information regarding copyright ownership. + */ + + +#ifndef ISC_ONCE_H +#define ISC_ONCE_H 1 + +#include <stdbool.h> + +#include <isc/result.h> + +typedef bool isc_once_t; + +#define ISC_ONCE_INIT false + +#define isc_once_do(op, f) \ + (!*(op) ? (f(), *(op) = true, ISC_R_SUCCESS) : ISC_R_SUCCESS) + +#endif /* ISC_ONCE_H */ diff --git a/lib/isc/nothreads/include/isc/thread.h b/lib/isc/nothreads/include/isc/thread.h new file mode 100644 index 0000000..8486c3f --- /dev/null +++ b/lib/isc/nothreads/include/isc/thread.h @@ -0,0 +1,40 @@ +/* + * Copyright (C) Internet Systems Consortium, Inc. ("ISC") + * + * 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 http://mozilla.org/MPL/2.0/. + * + * See the COPYRIGHT file distributed with this work for additional + * information regarding copyright ownership. + */ + + +#ifndef ISC_THREAD_H +#define ISC_THREAD_H 1 + +#include <isc/lang.h> +#include <isc/result.h> + +ISC_LANG_BEGINDECLS + +/* Placeholder types (they are not accessed) */ + +typedef void * isc_thread_t; +typedef void * isc_threadresult_t; +typedef void * isc_threadarg_t; +typedef void * isc_threadfunc_t; +typedef void * isc_thread_key_t; + +void +isc_thread_setconcurrency(unsigned int level); + +void +isc_thread_setname(isc_thread_t thread, const char *name); + +#define isc_thread_self() ((unsigned long)0) +#define isc_thread_yield() ((void)0) + +ISC_LANG_ENDDECLS + +#endif /* ISC_THREAD_H */ diff --git a/lib/isc/nothreads/mutex.c b/lib/isc/nothreads/mutex.c new file mode 100644 index 0000000..e092ac9 --- /dev/null +++ b/lib/isc/nothreads/mutex.c @@ -0,0 +1,18 @@ +/* + * Copyright (C) Internet Systems Consortium, Inc. ("ISC") + * + * 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 http://mozilla.org/MPL/2.0/. + * + * See the COPYRIGHT file distributed with this work for additional + * information regarding copyright ownership. + */ + + +#include <config.h> + +#include <isc/util.h> + +EMPTY_TRANSLATION_UNIT + diff --git a/lib/isc/nothreads/thread.c b/lib/isc/nothreads/thread.c new file mode 100644 index 0000000..671261f --- /dev/null +++ b/lib/isc/nothreads/thread.c @@ -0,0 +1,26 @@ +/* + * Copyright (C) Internet Systems Consortium, Inc. ("ISC") + * + * 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 http://mozilla.org/MPL/2.0/. + * + * See the COPYRIGHT file distributed with this work for additional + * information regarding copyright ownership. + */ + + +#include <config.h> + +#include <isc/thread.h> +#include <isc/util.h> + +void +isc_thread_setconcurrency(unsigned int level) { + UNUSED(level); +} + +void isc_thread_setname(isc_thread_t thread, const char *name) { + UNUSED(thread); + UNUSED(name); +} |