From e119de41699601603d61ba7d869e1db1953fec64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Tue, 14 Aug 2018 10:23:50 +0200 Subject: [PATCH] Replace arch specific atomic.h with global atomic.h header using either stdatomic, __atomic or __sync primitives --- configure.in | 2 + lib/isc/Makefile.in | 3 +- lib/isc/alpha/Makefile.in | 17 -- lib/isc/alpha/include/Makefile.in | 17 -- lib/isc/alpha/include/isc/Makefile.in | 34 --- lib/isc/alpha/include/isc/atomic.h | 120 --------- lib/isc/ia64/Makefile.in | 17 -- lib/isc/ia64/include/Makefile.in | 17 -- lib/isc/ia64/include/isc/Makefile.in | 34 --- lib/isc/ia64/include/isc/atomic.h | 96 -------- lib/isc/include/isc/Makefile.in | 2 +- lib/isc/{noatomic => }/include/isc/atomic.h | 12 +- lib/isc/include/isc/stdatomic.h | 146 +++++++++++ lib/isc/mips/Makefile.in | 17 -- lib/isc/mips/include/Makefile.in | 17 -- lib/isc/mips/include/isc/Makefile.in | 34 --- lib/isc/mips/include/isc/atomic.h | 90 ------- lib/isc/noatomic/Makefile.in | 17 -- lib/isc/noatomic/include/Makefile.in | 17 -- lib/isc/noatomic/include/isc/Makefile.in | 34 --- lib/isc/powerpc/Makefile.in | 17 -- lib/isc/powerpc/include/Makefile.in | 17 -- lib/isc/powerpc/include/isc/Makefile.in | 34 --- lib/isc/powerpc/include/isc/atomic.h | 137 ----------- lib/isc/sparc64/Makefile.in | 17 -- lib/isc/sparc64/include/Makefile.in | 17 -- lib/isc/sparc64/include/isc/Makefile.in | 29 --- lib/isc/sparc64/include/isc/atomic.h | 122 --------- lib/isc/win32/include/isc/atomic.h | 75 ------ lib/isc/win32/include/isc/stdatomic.h | 260 ++++++++++++++++++++ lib/isc/win32/libisc.vcxproj.filters.in | 13 +- lib/isc/win32/libisc.vcxproj.in | 9 +- lib/isc/x86_32/Makefile.in | 17 -- lib/isc/x86_32/include/Makefile.in | 17 -- lib/isc/x86_32/include/isc/Makefile.in | 34 --- lib/isc/x86_32/include/isc/atomic.h | 176 ------------- lib/isc/x86_64/Makefile.in | 17 -- lib/isc/x86_64/include/Makefile.in | 17 -- lib/isc/x86_64/include/isc/Makefile.in | 34 --- lib/isc/x86_64/include/isc/atomic.h | 129 ---------- make/includes.in | 3 +- util/copyrights | 16 +- 42 files changed, 433 insertions(+), 1517 deletions(-) delete mode 100644 lib/isc/alpha/Makefile.in delete mode 100644 lib/isc/alpha/include/Makefile.in delete mode 100644 lib/isc/alpha/include/isc/Makefile.in delete mode 100644 lib/isc/alpha/include/isc/atomic.h delete mode 100644 lib/isc/ia64/Makefile.in delete mode 100644 lib/isc/ia64/include/Makefile.in delete mode 100644 lib/isc/ia64/include/isc/Makefile.in delete mode 100644 lib/isc/ia64/include/isc/atomic.h rename lib/isc/{noatomic => }/include/isc/atomic.h (78%) create mode 100644 lib/isc/include/isc/stdatomic.h delete mode 100644 lib/isc/mips/Makefile.in delete mode 100644 lib/isc/mips/include/Makefile.in delete mode 100644 lib/isc/mips/include/isc/Makefile.in delete mode 100644 lib/isc/mips/include/isc/atomic.h delete mode 100644 lib/isc/noatomic/Makefile.in delete mode 100644 lib/isc/noatomic/include/Makefile.in delete mode 100644 lib/isc/noatomic/include/isc/Makefile.in delete mode 100644 lib/isc/powerpc/Makefile.in delete mode 100644 lib/isc/powerpc/include/Makefile.in delete mode 100644 lib/isc/powerpc/include/isc/Makefile.in delete mode 100644 lib/isc/powerpc/include/isc/atomic.h delete mode 100644 lib/isc/sparc64/Makefile.in delete mode 100644 lib/isc/sparc64/include/Makefile.in delete mode 100644 lib/isc/sparc64/include/isc/Makefile.in delete mode 100644 lib/isc/sparc64/include/isc/atomic.h delete mode 100644 lib/isc/win32/include/isc/atomic.h create mode 100644 lib/isc/win32/include/isc/stdatomic.h delete mode 100644 lib/isc/x86_32/Makefile.in delete mode 100644 lib/isc/x86_32/include/Makefile.in delete mode 100644 lib/isc/x86_32/include/isc/Makefile.in delete mode 100644 lib/isc/x86_32/include/isc/atomic.h delete mode 100644 lib/isc/x86_64/Makefile.in delete mode 100644 lib/isc/x86_64/include/Makefile.in delete mode 100644 lib/isc/x86_64/include/isc/Makefile.in delete mode 100644 lib/isc/x86_64/include/isc/atomic.h diff --git a/configure.in b/configure.in index 9053c593e3..ff3595a5b7 100644 --- a/configure.in +++ b/configure.in @@ -2273,6 +2273,8 @@ AC_CHECK_HEADERS( ]) LIBS="$LIBS $ISC_ATOMIC_LIBS" +AC_CHECK_HEADERS([uchar.h]) + # # Check for __builtin_expect # diff --git a/lib/isc/Makefile.in b/lib/isc/Makefile.in index 8f5233fffa..0e1d0d9e63 100644 --- a/lib/isc/Makefile.in +++ b/lib/isc/Makefile.in @@ -19,7 +19,6 @@ VERSION=@BIND9_VERSION@ CINCLUDES = -I${srcdir}/unix/include \ -I${srcdir}/pthreads/include \ - -I${srcdir}/@ISC_ARCH_DIR@/include \ -I./include \ -I${srcdir}/include ${DNS_INCLUDES} @OPENSSL_INCLUDES@ CDEFINES = @@ -83,7 +82,7 @@ LIBS = @OPENSSL_LIBS@ @LIBS@ # Attempt to disable parallel processing. .NOTPARALLEL: .NO_PARALLEL: -SUBDIRS = include unix nls pthreads @ISC_ARCH_DIR@ +SUBDIRS = include unix nls pthreads TARGETS = timestamp TESTDIRS = @UNITTESTS@ diff --git a/lib/isc/alpha/Makefile.in b/lib/isc/alpha/Makefile.in deleted file mode 100644 index 419cf9f875..0000000000 --- a/lib/isc/alpha/Makefile.in +++ /dev/null @@ -1,17 +0,0 @@ -# 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 = include -TARGETS = - -@BIND9_MAKE_RULES@ diff --git a/lib/isc/alpha/include/Makefile.in b/lib/isc/alpha/include/Makefile.in deleted file mode 100644 index d33c0fcb2c..0000000000 --- a/lib/isc/alpha/include/Makefile.in +++ /dev/null @@ -1,17 +0,0 @@ -# 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/alpha/include/isc/Makefile.in b/lib/isc/alpha/include/isc/Makefile.in deleted file mode 100644 index 9f87e48935..0000000000 --- a/lib/isc/alpha/include/isc/Makefile.in +++ /dev/null @@ -1,34 +0,0 @@ -# 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 = atomic.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 ; \ - done - -uninstall:: - for i in ${HEADERS}; do \ - rm -f ${DESTDIR}${includedir}/isc/$$i ; \ - done diff --git a/lib/isc/alpha/include/isc/atomic.h b/lib/isc/alpha/include/isc/atomic.h deleted file mode 100644 index 9e60912047..0000000000 --- a/lib/isc/alpha/include/isc/atomic.h +++ /dev/null @@ -1,120 +0,0 @@ -/* - * 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 code was written based on FreeBSD's kernel source whose copyright - * follows: - */ - -/*- - * Copyright (c) 1998 Doug Rabson - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: src/sys/alpha/include/atomic.h,v 1.18.6.1 2004/09/13 21:52:04 wilko Exp $ - */ - -#ifndef ISC_ATOMIC_H -#define ISC_ATOMIC_H 1 - -#include - -#include -#include - -#if defined (ISC_PLATFORM_USEGCCASM) -static inline int32_t -isc_atomic_xadd(int32_t *p, int32_t val) { - int32_t temp, prev; - - __asm__ volatile( - "mb;" - "1:" - "ldl_l %0, %1;" /* load old value */ - "mov %0, %2;" /* copy the old value */ - "addl %0, %3, %0;" /* calculate new value */ - "stl_c %0, %1;" /* attempt to store */ - "beq %0, 1b;" /* spin if failed */ - "mb;" - : "=&r"(temp), "+m"(*p), "=&r"(prev) - : "r"(val) - : "memory"); - - return (prev); -} - -static inline void -isc_atomic_store(int32_t *p, int32_t val) { - int32_t temp; - - __asm__ volatile( - "mb;" - "1:" - "ldl_l %0, %1;" /* load old value */ - "mov %2, %0;" /* value to store */ - "stl_c %0, %1;" /* attempt to store */ - "beq %0, 1b;" /* if it failed, spin */ - "mb;" - : "=&r"(temp), "+m"(*p) - : "r"(val) - : "memory"); -} - -static inline int32_t -isc_atomic_cmpxchg(int32_t *p, int32_t cmpval, int32_t val) { - int32_t temp, prev; - - __asm__ volatile( - "mb;" - "1:" - "ldl_l %0, %1;" /* load old value */ - "mov %0, %2;" /* copy the old value */ - "cmpeq %0, %3, %0;" /* compare */ - "beq %0, 2f;" /* exit if not equal */ - "mov %4, %0;" /* value to store */ - "stl_c %0, %1;" /* attempt to store */ - "beq %0, 1b;" /* if it failed, spin */ - "2:" - "mb;" - : "=&r"(temp), "+m"(*p), "=&r"(prev) - : "r"(cmpval), "r"(val) - : "memory"); - - return (prev); -} -#else - -#error "unsupported compiler. disable atomic ops by --disable-atomic" - -#endif - -#endif /* ISC_ATOMIC_H */ diff --git a/lib/isc/ia64/Makefile.in b/lib/isc/ia64/Makefile.in deleted file mode 100644 index 419cf9f875..0000000000 --- a/lib/isc/ia64/Makefile.in +++ /dev/null @@ -1,17 +0,0 @@ -# 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 = include -TARGETS = - -@BIND9_MAKE_RULES@ diff --git a/lib/isc/ia64/include/Makefile.in b/lib/isc/ia64/include/Makefile.in deleted file mode 100644 index d33c0fcb2c..0000000000 --- a/lib/isc/ia64/include/Makefile.in +++ /dev/null @@ -1,17 +0,0 @@ -# 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/ia64/include/isc/Makefile.in b/lib/isc/ia64/include/isc/Makefile.in deleted file mode 100644 index 9f87e48935..0000000000 --- a/lib/isc/ia64/include/isc/Makefile.in +++ /dev/null @@ -1,34 +0,0 @@ -# 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 = atomic.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 ; \ - done - -uninstall:: - for i in ${HEADERS}; do \ - rm -f ${DESTDIR}${includedir}/isc/$$i ; \ - done diff --git a/lib/isc/ia64/include/isc/atomic.h b/lib/isc/ia64/include/isc/atomic.h deleted file mode 100644 index e2f4331dfb..0000000000 --- a/lib/isc/ia64/include/isc/atomic.h +++ /dev/null @@ -1,96 +0,0 @@ -/* - * 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_ATOMIC_H -#define ISC_ATOMIC_H 1 - -#include - -#include -#include - -#ifdef ISC_PLATFORM_USEGCCASM -/* - * This routine atomically increments the value stored in 'p' by 'val', and - * returns the previous value. - * - * Open issue: can 'fetchadd' make the code faster for some particular values - * (e.g., 1 and -1)? - */ -static inline int32_t -#ifdef __GNUC__ -__attribute__ ((unused)) -#endif -isc_atomic_xadd(int32_t *p, int32_t val) -{ - int32_t prev, swapped; - - for (prev = *(volatile int32_t *)p; ; prev = swapped) { - swapped = prev + val; - __asm__ volatile( - "mov ar.ccv=%2;;" - "cmpxchg4.acq %0=%4,%3,ar.ccv" - : "=r" (swapped), "=m" (*p) - : "r" (prev), "r" (swapped), "m" (*p) - : "memory"); - if (swapped == prev) - break; - } - - return (prev); -} - -/* - * This routine atomically stores the value 'val' in 'p'. - */ -static inline void -#ifdef __GNUC__ -__attribute__ ((unused)) -#endif -isc_atomic_store(int32_t *p, int32_t val) -{ - __asm__ volatile( - "st4.rel %0=%1" - : "=m" (*p) - : "r" (val) - : "memory" - ); -} - -/* - * This routine atomically replaces the value in 'p' with 'val', if the - * original value is equal to 'cmpval'. The original value is returned in any - * case. - */ -static inline int32_t -#ifdef __GNUC__ -__attribute__ ((unused)) -#endif -isc_atomic_cmpxchg(int32_t *p, int32_t cmpval, int32_t val) -{ - int32_t ret; - - __asm__ volatile( - "mov ar.ccv=%2;;" - "cmpxchg4.acq %0=%4,%3,ar.ccv" - : "=r" (ret), "=m" (*p) - : "r" (cmpval), "r" (val), "m" (*p) - : "memory"); - - return (ret); -} -#else /* !ISC_PLATFORM_USEGCCASM */ - -#error "unsupported compiler. disable atomic ops by --disable-atomic" - -#endif -#endif /* ISC_ATOMIC_H */ diff --git a/lib/isc/include/isc/Makefile.in b/lib/isc/include/isc/Makefile.in index 5c0004f8a5..f9db80aec6 100644 --- a/lib/isc/include/isc/Makefile.in +++ b/lib/isc/include/isc/Makefile.in @@ -18,7 +18,7 @@ VERSION=@BIND9_VERSION@ # machine generated. The latter are handled specially in the # install target below. # -HEADERS = aes.h app.h assertions.h backtrace.h base32.h base64.h \ +HEADERS = aes.h app.h assertions.h atomic.h backtrace.h base32.h base64.h \ bind9.h buffer.h bufferlist.h \ commandline.h counter.h crc64.h deprecated.h \ errno.h error.h event.h eventclass.h \ diff --git a/lib/isc/noatomic/include/isc/atomic.h b/lib/isc/include/isc/atomic.h similarity index 78% rename from lib/isc/noatomic/include/isc/atomic.h rename to lib/isc/include/isc/atomic.h index 5953e4b952..d6f95de111 100644 --- a/lib/isc/noatomic/include/isc/atomic.h +++ b/lib/isc/include/isc/atomic.h @@ -9,10 +9,10 @@ * information regarding copyright ownership. */ +#pragma once -#ifndef ISC_ATOMIC_H -#define ISC_ATOMIC_H 1 - -/* This file is inherently empty. */ - -#endif /* ISC_ATOMIC_H */ +#if HAVE_STDATOMIC_H +#include +#else +#include +#endif diff --git a/lib/isc/include/isc/stdatomic.h b/lib/isc/include/isc/stdatomic.h new file mode 100644 index 0000000000..723ed1e5a8 --- /dev/null +++ b/lib/isc/include/isc/stdatomic.h @@ -0,0 +1,146 @@ +/* + * 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. + */ + +#pragma once + +#if !defined(__has_feature) +#define __has_feature(x) 0 +#endif + +#if !defined(__has_extension) +#define __has_extension(x) __has_feature(x) +#endif + +#if !defined(__GNUC_PREREQ__) +#if defined(__GNUC__) && defined(__GNUC_MINOR__) +#define __GNUC_PREREQ__(maj, min) \ + ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min)) +#else +#define __GNUC_PREREQ__(maj, min) 0 +#endif +#endif + +#if !defined(__CLANG_ATOMICS) && !defined(__GNUC_ATOMICS) +#if __has_extension(c_atomic) || __has_extension(cxx_atomic) +#define __CLANG_ATOMICS +#elif __GNUC_PREREQ__(4, 7) +#define __GNUC_ATOMICS +#elif !defined(__GNUC__) +#error "isc/stdatomic.h does not support your compiler" +#endif +#endif + +#ifndef __ATOMIC_RELAXED +#define __ATOMIC_RELAXED 0 +#endif +#ifndef __ATOMIC_CONSUME +#define __ATOMIC_CONSUME 1 +#endif +#ifndef __ATOMIC_ACQUIRE +#define __ATOMIC_ACQUIRE 2 +#endif +#ifndef __ATOMIC_RELEASE +#define __ATOMIC_RELEASE 3 +#endif +#ifndef __ATOMIC_ACQ_REL +#define __ATOMIC_ACQ_REL 4 +#endif +#ifndef __ATOMIC_SEQ_CST +#define __ATOMIC_SEQ_CST 5 +#endif + + +enum memory_order { + memory_order_relaxed = __ATOMIC_RELAXED, + memory_order_consume = __ATOMIC_CONSUME, + memory_order_acquire = __ATOMIC_ACQUIRE, + memory_order_release = __ATOMIC_RELEASE, + memory_order_acq_rel = __ATOMIC_ACQ_REL, + memory_order_seq_cst = __ATOMIC_SEQ_CST +}; + +typedef enum memory_order memory_order; + +typedef int_fast32_t atomic_int_fast32_t; +typedef uint_fast32_t atomic_uint_fast32_t; +typedef int_fast64_t atomic_int_fast64_t; +typedef uint_fast64_t atomic_uint_fast64_t; + +#if defined(__CLANG_ATOMICS) /* __c11_atomic builtins */ +#define atomic_init(obj, desired) \ + __c11_atomic_init(obj, desired) +#define atomic_load_explicit(obj, order) \ + __c11_atomic_load(obj, order) +#define atomic_store_explicit(obj, desired, order) \ + __c11_atomic_store(obj, desired, order) +#define atomic_fetch_add_explicit(obj, arg, order) \ + __c11_atomic_fetch_add(obj, arg, order) +#define atomic_fetch_sub_explicit(obj, arg, order) \ + __c11_atomic_fetch_sub(obj, arg, order) +#define atomic_compare_exchange_strong_explicit(obj, expected, desired, succ, fail) \ + __c11_atomic_compare_exchange_strong_explicit(obj, expected, desired, succ, fail) +#define atomic_compare_exchange_weak_explicit(obj, expected, desired, succ, fail) \ + __c11_atomic_compare_exchange_weak_explicit(obj, expected, desired, succ, fail) +#elif defined(__GNUC_ATOMICS) /* __atomic builtins */ +#define atomic_init(obj, desired) \ + (*obj = desired) +#define atomic_load_explicit(obj, order) \ + __atomic_load_n(obj, order) +#define atomic_store_explicit(obj, desired, order) \ + __atomic_store_n(obj, desired, order) +#define atomic_fetch_add_explicit(obj, arg, order) \ + __atomic_fetch_add(obj, arg, order) +#define atomic_fetch_sub_explicit(obj, arg, order) \ + __atomic_fetch_sub(obj, arg, order) +#define atomic_compare_exchange_strong_explicit(obj, expected, desired, succ, fail) \ + __atomic_compare_exchange_n(obj, expected, desired, 0, succ, fail) +#define atomic_compare_exchange_weak_explicit(obj, expected, desired, succ, fail) \ + __atomic_compare_exchange_n(obj, expected, desired, 1, succ, fail) +#else /* __sync builtins */ +#define atomic_init(obj, desired) \ + (*obj = desired) +#define atomic_load_explicit(obj, order) \ + __sync_fetch_and_add(obj, 0) +#define atomic_store_explicit(obj, desired, order) \ + do { \ + __sync_synchronize(); \ + *obj = desired; \ + __sync_synchronize(); \ + } while (0); +#define atomic_fetch_add_explicit(obj, arg, order) \ + __sync_fetch_and_add(obj, arg) +#define atomic_fetch_sub_explicit(obj, arg, order) \ + __sync_fetch_and_sub(obj, arg, order) +#define atomic_compare_exchange_strong_explicit(obj, expected, desired, succ, fail) \ + ({ \ + __typeof__(obj) __v; \ + _Bool __r; \ + __v = __sync_val_compare_and_swap(obj, *(expected), desired); \ + __r = *(expected) == __v; \ + *(expected) = __v; \ + __r; \ + }) +#define atomic_compare_exchange_weak_explicit(obj, expected, desired, succ, fail) \ + atomic_compare_exchange_strong_explicit(obj, expected, desired, succ, fail) +#endif + +#define atomic_load(obj) \ + atomic_load_explicit(obj, memory_order_seq_cst) +#define atomic_store(obj) \ + atomic_store_explicit(obj, memory_order_seq_cst) +#define atomic_fetch_add(obj) \ + atomic_fetch_add_explicit(obj, arg, memory_order_seq_cst) +#define atomic_fetch_sub(obj) \ + atomic_fetch_sub_explicit(obj, arg, memory_order_seq_cst) +#define atomic_compare_exchange_strong(obj, expected, desired) \ + atomic_compare_exchange_strong_explicit(obj, expected, desired, memory_order_seq_cst, memory_order_seq_cst) +#define atomic_compare_exchange_weak(obj, expected, desired) \ + atomic_compare_exchange_weak_explicit(obj, expected, desired, memory_order_seq_cst, memory_order_seq_cst) diff --git a/lib/isc/mips/Makefile.in b/lib/isc/mips/Makefile.in deleted file mode 100644 index 419cf9f875..0000000000 --- a/lib/isc/mips/Makefile.in +++ /dev/null @@ -1,17 +0,0 @@ -# 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 = include -TARGETS = - -@BIND9_MAKE_RULES@ diff --git a/lib/isc/mips/include/Makefile.in b/lib/isc/mips/include/Makefile.in deleted file mode 100644 index d33c0fcb2c..0000000000 --- a/lib/isc/mips/include/Makefile.in +++ /dev/null @@ -1,17 +0,0 @@ -# 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/mips/include/isc/Makefile.in b/lib/isc/mips/include/isc/Makefile.in deleted file mode 100644 index 9f87e48935..0000000000 --- a/lib/isc/mips/include/isc/Makefile.in +++ /dev/null @@ -1,34 +0,0 @@ -# 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 = atomic.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 ; \ - done - -uninstall:: - for i in ${HEADERS}; do \ - rm -f ${DESTDIR}${includedir}/isc/$$i ; \ - done diff --git a/lib/isc/mips/include/isc/atomic.h b/lib/isc/mips/include/isc/atomic.h deleted file mode 100644 index caba82fba0..0000000000 --- a/lib/isc/mips/include/isc/atomic.h +++ /dev/null @@ -1,90 +0,0 @@ -/* - * 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_ATOMIC_H -#define ISC_ATOMIC_H 1 - -#include - -#include -#include - -#ifdef ISC_PLATFORM_USEGCCASM -/* - * This routine atomically increments the value stored in 'p' by 'val', and - * returns the previous value. - */ -static inline int32_t -isc_atomic_xadd(int32_t *p, int val) { - int32_t orig; - - __asm__ __volatile__ ( - " .set push \n" - " .set mips2 \n" - " .set noreorder \n" - " .set noat \n" - "1: ll $1, %1 \n" - " addu %0, $1, %2 \n" - " sc %0, %1 \n" - " beqz %0, 1b \n" - " move %0, $1 \n" - " .set pop \n" - : "=&r" (orig), "+R" (*p) - : "r" (val) - : "memory"); - - return (orig); -} - -/* - * This routine atomically stores the value 'val' in 'p'. - */ -static inline void -isc_atomic_store(int32_t *p, int32_t val) { - *p = val; -} - -/* - * This routine atomically replaces the value in 'p' with 'val', if the - * original value is equal to 'cmpval'. The original value is returned in any - * case. - */ -static inline int32_t -isc_atomic_cmpxchg(int32_t *p, int cmpval, int val) { - int32_t orig; - int32_t tmp; - - __asm__ __volatile__ ( - " .set push \n" - " .set mips2 \n" - " .set noreorder \n" - " .set noat \n" - "1: ll $1, %1 \n" - " bne $1, %3, 2f \n" - " move %2, %4 \n" - " sc %2, %1 \n" - " beqz %2, 1b \n" - "2: move %0, $1 \n" - " .set pop \n" - : "=&r"(orig), "+R" (*p), "=r" (tmp) - : "r"(cmpval), "r"(val) - : "memory"); - - return (orig); -} - -#else /* !ISC_PLATFORM_USEGCCASM */ - -#error "unsupported compiler. disable atomic ops by --disable-atomic" - -#endif -#endif /* ISC_ATOMIC_H */ diff --git a/lib/isc/noatomic/Makefile.in b/lib/isc/noatomic/Makefile.in deleted file mode 100644 index 419cf9f875..0000000000 --- a/lib/isc/noatomic/Makefile.in +++ /dev/null @@ -1,17 +0,0 @@ -# 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 = include -TARGETS = - -@BIND9_MAKE_RULES@ diff --git a/lib/isc/noatomic/include/Makefile.in b/lib/isc/noatomic/include/Makefile.in deleted file mode 100644 index d33c0fcb2c..0000000000 --- a/lib/isc/noatomic/include/Makefile.in +++ /dev/null @@ -1,17 +0,0 @@ -# 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/noatomic/include/isc/Makefile.in b/lib/isc/noatomic/include/isc/Makefile.in deleted file mode 100644 index 9f87e48935..0000000000 --- a/lib/isc/noatomic/include/isc/Makefile.in +++ /dev/null @@ -1,34 +0,0 @@ -# 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 = atomic.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 ; \ - done - -uninstall:: - for i in ${HEADERS}; do \ - rm -f ${DESTDIR}${includedir}/isc/$$i ; \ - done diff --git a/lib/isc/powerpc/Makefile.in b/lib/isc/powerpc/Makefile.in deleted file mode 100644 index 419cf9f875..0000000000 --- a/lib/isc/powerpc/Makefile.in +++ /dev/null @@ -1,17 +0,0 @@ -# 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 = include -TARGETS = - -@BIND9_MAKE_RULES@ diff --git a/lib/isc/powerpc/include/Makefile.in b/lib/isc/powerpc/include/Makefile.in deleted file mode 100644 index d33c0fcb2c..0000000000 --- a/lib/isc/powerpc/include/Makefile.in +++ /dev/null @@ -1,17 +0,0 @@ -# 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/powerpc/include/isc/Makefile.in b/lib/isc/powerpc/include/isc/Makefile.in deleted file mode 100644 index 9f87e48935..0000000000 --- a/lib/isc/powerpc/include/isc/Makefile.in +++ /dev/null @@ -1,34 +0,0 @@ -# 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 = atomic.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 ; \ - done - -uninstall:: - for i in ${HEADERS}; do \ - rm -f ${DESTDIR}${includedir}/isc/$$i ; \ - done diff --git a/lib/isc/powerpc/include/isc/atomic.h b/lib/isc/powerpc/include/isc/atomic.h deleted file mode 100644 index 66913d31b4..0000000000 --- a/lib/isc/powerpc/include/isc/atomic.h +++ /dev/null @@ -1,137 +0,0 @@ -/* - * 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_ATOMIC_H -#define ISC_ATOMIC_H 1 - -#include - -#include -#include - -/*!\file - * static inline int32_t - * isc_atomic_xadd(int32_t *p, int32_t val); - * - * This routine atomically increments the value stored in 'p' by 'val', and - * returns the previous value. - * - * static inline void - * isc_atomic_store(void *p, int32_t val); - * - * This routine atomically stores the value 'val' in 'p'. - * - * static inline int32_t - * isc_atomic_cmpxchg(int32_t *p, int32_t cmpval, int32_t val); - * - * This routine atomically replaces the value in 'p' with 'val', if the - * original value is equal to 'cmpval'. The original value is returned in any - * case. - */ - -#if defined(ISC_PLATFORM_USEGCCASM) || defined(ISC_PLATFORM_USEMACASM) -static inline int32_t -isc_atomic_xadd(int32_t *p, int32_t val) { - int32_t orig; - - __asm__ volatile ( -#ifdef ISC_PLATFORM_USEMACASM - "1:" - "lwarx r6, 0, %1\n" - "mr %0, r6\n" - "add r6, r6, %2\n" - "stwcx. r6, 0, %1\n" - "bne- 1b\n" - "sync" -#else - "1:" - "lwarx 6, 0, %1\n" - "mr %0, 6\n" - "add 6, 6, %2\n" - "stwcx. 6, 0, %1\n" - "bne- 1b\n" - "sync" -#endif - : "=&r"(orig) - : "r"(p), "r"(val) - : "r6", "memory" - ); - - return (orig); -} - -static inline void -isc_atomic_store(void *p, int32_t val) { - __asm__ volatile ( -#ifdef ISC_PLATFORM_USEMACASM - "1:" - "lwarx r6, 0, %0\n" - "lwz r6, %1\n" - "stwcx. r6, 0, %0\n" - "bne- 1b\n" - "sync" -#else - "1:" - "lwarx 6, 0, %0\n" - "lwz 6, %1\n" - "stwcx. 6, 0, %0\n" - "bne- 1b\n" - "sync" -#endif - : - : "r"(p), "m"(val) - : "r6", "memory" - ); -} - -static inline int32_t -isc_atomic_cmpxchg(int32_t *p, int32_t cmpval, int32_t val) { - int32_t orig; - - __asm__ volatile ( -#ifdef ISC_PLATFORM_USEMACASM - "1:" - "lwarx r6, 0, %1\n" - "mr %0,r6\n" - "cmpw r6, %2\n" - "bne 2f\n" - "mr r6, %3\n" - "stwcx. r6, 0, %1\n" - "bne- 1b\n" - "2:\n" - "sync" -#else - "1:" - "lwarx 6, 0, %1\n" - "mr %0,6\n" - "cmpw 6, %2\n" - "bne 2f\n" - "mr 6, %3\n" - "stwcx. 6, 0, %1\n" - "bne- 1b\n" - "2:\n" - "sync" -#endif - : "=&r" (orig) - : "r"(p), "r"(cmpval), "r"(val) - : "r6", "memory" - ); - - return (orig); -} - -#else - -#error "unsupported compiler. disable atomic ops by --disable-atomic" - -#endif -#endif /* ISC_ATOMIC_H */ diff --git a/lib/isc/sparc64/Makefile.in b/lib/isc/sparc64/Makefile.in deleted file mode 100644 index 419cf9f875..0000000000 --- a/lib/isc/sparc64/Makefile.in +++ /dev/null @@ -1,17 +0,0 @@ -# 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 = include -TARGETS = - -@BIND9_MAKE_RULES@ diff --git a/lib/isc/sparc64/include/Makefile.in b/lib/isc/sparc64/include/Makefile.in deleted file mode 100644 index d33c0fcb2c..0000000000 --- a/lib/isc/sparc64/include/Makefile.in +++ /dev/null @@ -1,17 +0,0 @@ -# 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/sparc64/include/isc/Makefile.in b/lib/isc/sparc64/include/isc/Makefile.in deleted file mode 100644 index 11e93a42bc..0000000000 --- a/lib/isc/sparc64/include/isc/Makefile.in +++ /dev/null @@ -1,29 +0,0 @@ -# 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 = atomic.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 ; \ - done diff --git a/lib/isc/sparc64/include/isc/atomic.h b/lib/isc/sparc64/include/isc/atomic.h deleted file mode 100644 index 21ec67e8c7..0000000000 --- a/lib/isc/sparc64/include/isc/atomic.h +++ /dev/null @@ -1,122 +0,0 @@ -/* - * 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 code was written based on FreeBSD's kernel source whose copyright - * follows: - */ - -/*- - * Copyright (c) 1998 Doug Rabson. - * Copyright (c) 2001 Jake Burkholder. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: FreeBSD: src/sys/i386/include/atomic.h,v 1.20 2001/02/11 - * $FreeBSD: src/sys/sparc64/include/atomic.h,v 1.8 2004/05/22 00:52:16 marius Exp $ - */ - -#ifndef ISC_ATOMIC_H -#define ISC_ATOMIC_H 1 - -#include - -#include -#include - -#define ASI_P 0x80 /* Primary Address Space Identifier */ - -#ifdef ISC_PLATFORM_USEGCCASM - -/* - * This routine atomically increments the value stored in 'p' by 'val', and - * returns the previous value. - */ -static inline int32_t -isc_atomic_xadd(int32_t *p, int32_t val) { - int32_t prev, swapped; - - for (prev = *(volatile int32_t *)p; ; prev = swapped) { - swapped = prev + val; - __asm__ volatile( - "casa [%2] %3, %4, %0" - : "+r"(swapped), "=m"(*p) - : "r"(p), "n"(ASI_P), "r"(prev), "m"(*p)); - if (swapped == prev) - break; - } - - return (prev); -} - -/* - * This routine atomically stores the value 'val' in 'p'. - */ -static inline void -isc_atomic_store(int32_t *p, int32_t val) { - int32_t prev, swapped; - - for (prev = *(volatile int32_t *)p; ; prev = swapped) { - swapped = val; - __asm__ volatile( - "casa [%2] %3, %4, %0" - : "+r"(swapped), "=m"(*p) - : "r"(p), "n"(ASI_P), "r"(prev), "m"(*p)); - if (swapped == prev) - break; - } -} - -/* - * This routine atomically replaces the value in 'p' with 'val', if the - * original value is equal to 'cmpval'. The original value is returned in any - * case. - */ -static inline int32_t -isc_atomic_cmpxchg(int32_t *p, int32_t cmpval, int32_t val) { - int32_t temp = val; - - __asm__ volatile( - "casa [%2] %3, %4, %0" - : "+r"(temp), "=m"(*p) - : "r"(p), "n"(ASI_P), "r"(cmpval), "m"(*p)); - - return (temp); -} - -#else /* ISC_PLATFORM_USEGCCASM */ - -#error "unsupported compiler. disable atomic ops by --disable-atomic" - -#endif /* ISC_PLATFORM_USEGCCASM */ - -#endif /* ISC_ATOMIC_H */ diff --git a/lib/isc/win32/include/isc/atomic.h b/lib/isc/win32/include/isc/atomic.h deleted file mode 100644 index 4b3d92dbd4..0000000000 --- a/lib/isc/win32/include/isc/atomic.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * 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_ATOMIC_H -#define ISC_ATOMIC_H 1 - -#include - -#include -#include - -/* - * This routine atomically increments the value stored in 'p' by 'val', and - * returns the previous value. - */ -#ifdef ISC_PLATFORM_HAVEXADD -static __inline int32_t -isc_atomic_xadd(int32_t *p, int32_t val) { - return (int32_t) _InterlockedExchangeAdd((long *)p, (long)val); -} -#endif - -#ifdef ISC_PLATFORM_HAVEXADDQ -static __inline int64_t -isc_atomic_xaddq(int64_t *p, int64_t val) { - return (int64_t) _InterlockedExchangeAdd64((__int64 *)p, - (__int64) val); -} -#endif - -/* - * This routine atomically stores the value 'val' in 'p' (32-bit version). - */ -#ifdef ISC_PLATFORM_HAVEATOMICSTORE -static __inline void -isc_atomic_store(int32_t *p, int32_t val) { - (void) _InterlockedExchange((long *)p, (long)val); -} -#endif - -/* - * This routine atomically stores the value 'val' in 'p' (64-bit version). - */ -#ifdef ISC_PLATFORM_HAVEATOMICSTOREQ -static __inline void -isc_atomic_storeq(int64_t *p, int64_t val) { - (void) _InterlockedExchange64((__int64 *)p, (__int64)val); -} -#endif - -/* - * This routine atomically replaces the value in 'p' with 'val', if the - * original value is equal to 'cmpval'. The original value is returned in any - * case. - */ -#ifdef ISC_PLATFORM_HAVECMPXCHG -static __inline int32_t -isc_atomic_cmpxchg(int32_t *p, int32_t cmpval, int32_t val) { - /* beware: swap arguments */ - return (int32_t) _InterlockedCompareExchange((long *)p, - (long)val, - (long)cmpval); -} -#endif - -#endif /* ISC_ATOMIC_H */ diff --git a/lib/isc/win32/include/isc/stdatomic.h b/lib/isc/win32/include/isc/stdatomic.h new file mode 100644 index 0000000000..4eeb10f88e --- /dev/null +++ b/lib/isc/win32/include/isc/stdatomic.h @@ -0,0 +1,260 @@ +/* + * 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. + */ + +#pragma once + +#define WIN32_LEAN_AND_MEAN +#include +#include +#include +#include + +#include + +#ifndef __ATOMIC_RELAXED +#define __ATOMIC_RELAXED 0 +#endif +#ifndef __ATOMIC_CONSUME +#define __ATOMIC_CONSUME 1 +#endif +#ifndef __ATOMIC_ACQUIRE +#define __ATOMIC_ACQUIRE 2 +#endif +#ifndef __ATOMIC_RELEASE +#define __ATOMIC_RELEASE 3 +#endif +#ifndef __ATOMIC_ACQ_REL +#define __ATOMIC_ACQ_REL 4 +#endif +#ifndef __ATOMIC_SEQ_CST +#define __ATOMIC_SEQ_CST 5 +#endif + +enum memory_order { + memory_order_relaxed = __ATOMIC_RELAXED, + memory_order_consume = __ATOMIC_CONSUME, + memory_order_acquire = __ATOMIC_ACQUIRE, + memory_order_release = __ATOMIC_RELEASE, + memory_order_acq_rel = __ATOMIC_ACQ_REL, + memory_order_seq_cst = __ATOMIC_SEQ_CST +}; + +typedef enum memory_order memory_order; + +typedef int_fast32_t volatile atomic_int_fast32_t; +typedef uint_fast32_t volatile atomic_uint_fast32_t; +typedef int_fast64_t volatile atomic_int_fast64_t; +typedef uint_fast64_t volatile atomic_uint_fast64_t; + +#define atomic_init(obj, desired) \ + (*(obj) = (desired)) + +#define atomic_store_explicit32(obj, desired, order) \ + (order == memory_order_relaxed \ + ? InterlockedExchangeNoFence((atomic_int_fast32_t *)obj, desired) \ + : (order == memory_order_acquire \ + ? InterlockedExchangeAcquire((atomic_int_fast32_t *)obj, desired) \ + : InterlockedExchange((atomic_int_fast32_t *)obj, desired))) + +#define atomic_store_explicit64(obj, desired, order) \ + (order == memory_order_relaxed \ + ? InterlockedExchangeNoFence64((atomic_int_fast64_t *)obj, desired) \ + : (order == memory_order_acquire \ + ? InterlockedExchangeAcquire64((atomic_int_fast64_t *)obj, desired) \ + : InterlockedExchange64((atomic_int_fast64_t *)obj, desired))) + +static inline +void +atomic_store_abort() { + INSIST(0); + return; +} + +#define atomic_store_explicit(obj, desired, order) \ + (sizeof(*obj) == 8 \ + ? atomic_store_explicit64(obj, desired, order) \ + : (sizeof(*obj) == 4 \ + ? atomic_store_explicit32(obj, desired, order) \ + : atomic_store_abort())) + +#define atomic_store(obj, desired) \ + atomic_store(obj, desider, memory_order_seq_cst) + +#define atomic_load_explicit32(obj, order) \ + (order == memory_order_relaxed \ + ? (int32_t)InterlockedOrNoFence((atomic_int_fast32_t *)obj, 0) \ + : (order == memory_order_acquire \ + ? (int32_t)InterlockedOrAcquire((atomic_int_fast32_t *)obj, 0) \ + : (order == memory_order_release \ + ? (int32_t)InterlockedOrRelease((atomic_int_fast32_t *)obj, 0) \ + : (int32_t)InterlockedOr((atomic_int_fast32_t *)obj, 0)))) + +#define atomic_load_explicit64(obj, order) \ + (order == memory_order_relaxed \ + ? InterlockedOr64NoFence((atomic_int_fast64_t *)obj, 0) \ + : (order == memory_order_acquire \ + ? InterlockedOr64Acquire((atomic_int_fast64_t *)obj, 0) \ + : (order == memory_order_release \ + ? InterlockedOr64Release((atomic_int_fast64_t *)obj, 0) \ + : InterlockedOr64((atomic_int_fast64_t *)obj, 0)))) + +static inline +int8_t +atomic_load_abort() { + INSIST(0); + return (0); +} + +#define atomic_load_explicit(obj, order) \ + (sizeof(*obj) == 8 \ + ? atomic_load_explicit64(obj, order) \ + : (sizeof(*obj == 4) \ + ? atomic_load_explicit32(obj, order) \ + : atomic_load_abort())) + +#define atomic_load(obj) \ + atomic_load_explicit(obj, memory_order_seq_cst) + +#define atomic_fetch_add_explicit32(obj, arg, order) \ + (order == memory_order_relaxed \ + ? InterlockedExchangeAddNoFence((atomic_int_fast32_t *)obj, arg) \ + : (order == memory_order_acquire \ + ? InterlockedExchangeAddAcquire((atomic_int_fast32_t *)obj, arg) \ + : (order == memory_order_release \ + ? InterlockedExchangeAddRelease((atomic_int_fast32_t *)obj, arg) \ + : InterlockedExchange((atomic_int_fast32_t *)obj, arg)))) + +#define atomic_fetch_add_explicit64(obj, arg, order) \ + (order == memory_order_relaxed \ + ? InterlockedExchangeAddNoFence64((atomic_int_fast64_t *)obj, arg) \ + : (order == memory_order_acquire \ + ? InterlockedExchangeAddAcquire64((atomic_int_fast64_t *)obj, arg) \ + : (order == memory_order_release \ + ? InterlockedExchangeAddRelease64((atomic_int_fast64_t *)obj, arg) \ + : InterlockedExchange64((atomic_int_fast64_t *)obj, arg)))) + +static inline +int8_t +atomic_add_abort() { + INSIST(0); + return (0); +} + +#define atomic_fetch_add_explicit(obj, arg, order) \ + (sizeof(*obj) == 8 \ + ? atomic_fetch_add_explicit64(obj, arg, order) \ + : (sizeof(*obj) == 4 \ + ? atomic_fetch_add_explicit32(obj, arg, order) \ + : atomic_add_abort())) + +#define atomic_fetch_add(obj, arg) \ + atomic_fetch_add_explicit(obj, arg, memory_order_seq_cst) + +#define atomic_fetch_sub_explicit(obj, arg, order) \ + atomic_fetch_add_explicit(obj, -arg, order) + +#define atomic_fetch_sub(obj, arg) \ + atomic_fetch_sub_explicit(obj, arg, memory_order_seq_cst) + +static inline bool +atomic_compare_exchange_strong_explicit32(atomic_int_fast32_t *obj, + int32_t *expected, + int32_t desired, + memory_order succ, + memory_order fail) { + bool __r; + int32_t __v; + REQUIRE(succ == fail); + switch (succ) { + case memory_order_relaxed: + __v = InterlockedCompareExchangeNoFence((atomic_int_fast32_t *)obj, desired, *expected); + break; + case memory_order_acquire: + __v = InterlockedCompareExchangeAcquire((atomic_int_fast32_t *)obj, desired, *expected); + break; + case memory_order_release: + __v = InterlockedCompareExchangeRelease((atomic_int_fast32_t *)obj, desired, *expected); + break; + default: + __v = InterlockedCompareExchange((atomic_int_fast32_t *)obj, desired, *expected); + break; + } + __r = (*(expected) == __v); + if (!__r) { + *(expected) = __v; + } + return (__r); +} + +static inline bool +atomic_compare_exchange_strong_explicit64(atomic_int_fast64_t *obj, + int64_t *expected, + int64_t desired, + memory_order succ, + memory_order fail) { + bool __r; + int64_t __v; + REQUIRE(succ == fail); + switch (succ) { + case memory_order_relaxed: + __v = InterlockedCompareExchange64NoFence((atomic_int_fast64_t *)obj, desired, *expected); + break; + case memory_order_acquire: + __v = InterlockedCompareExchange64Acquire((atomic_int_fast64_t *)obj, desired, *expected); + break; + case memory_order_release: + __v = InterlockedCompareExchange64Release((atomic_int_fast64_t *)obj, desired, *expected); + break; + default: + __v = InterlockedCompareExchange64((atomic_int_fast64_t *)obj, desired, *expected); + break; + } + __r = (*(expected) == __v); + if (!__r) { + *(expected) = __v; + } + return (__r); +} + +static inline +bool +atomic_compare_exchange_abort() { + INSIST(0); + return (false); +} + +#define atomic_compare_exchange_strong_explicit(obj, expected, desired, \ + succ, fail) \ + (sizeof(*obj) == 8 \ + ? atomic_compare_exchange_strong_explicit64(obj, expected, \ + desired, \ + succ, fail) \ + : (sizeof(*obj) == 4 \ + ? atomic_compare_exchange_strong_explicit32(obj, expected, \ + desired, \ + succ, fail) \ + : atomic_compare_exchange_abort())) + +#define atomic_compare_exchange_strong(obj, expected, desired, \ + succ, fail) \ + atomic_compare_exchange_strong_explicit(obj, expected, desired, \ + memory_order_cst_seq, \ + memory_order_cst_seq) + +#define atomic_compare_exchange_weak_explicit(obj, expected, desired, \ + succ, fail) \ + atomic_compare_exchange_strong_explicit(obj, expected, desired, \ + succ, fail) + +#define atomic_compare_exchange_weak(obj, expected, desired) \ + atomic_compare_exchange_weak_explicit(obj, expected, desired, \ + memory_order_cst_seq, \ + memory_order_cst_seq) diff --git a/lib/isc/win32/libisc.vcxproj.filters.in b/lib/isc/win32/libisc.vcxproj.filters.in index 8eab0bd792..8d59e595a7 100644 --- a/lib/isc/win32/libisc.vcxproj.filters.in +++ b/lib/isc/win32/libisc.vcxproj.filters.in @@ -35,6 +35,9 @@ Library Header Files + + Library Header Files + Library Header Files @@ -340,6 +343,9 @@ Win32 Header Files + + Win32 Header Files + Win32 Header Files @@ -378,13 +384,6 @@ Win32 Header Files @END PKCS11 -@IF ATOMIC - -@ELSE ATOMIC - -@END ATOMIC - Library Header Files - Library Header Files diff --git a/lib/isc/win32/libisc.vcxproj.in b/lib/isc/win32/libisc.vcxproj.in index 0df9c26aec..fca91b3267 100644 --- a/lib/isc/win32/libisc.vcxproj.in +++ b/lib/isc/win32/libisc.vcxproj.in @@ -293,6 +293,7 @@ copy InstallFiles ..\Build\Release\ + @@ -381,11 +382,6 @@ copy InstallFiles ..\Build\Release\ @END PKCS11 -@IF ATOMIC - -@ELSE ATOMIC - -@END ATOMIC @@ -402,6 +398,7 @@ copy InstallFiles ..\Build\Release\ + @@ -409,7 +406,7 @@ copy InstallFiles ..\Build\Release\ - + @IF PKCS11 diff --git a/lib/isc/x86_32/Makefile.in b/lib/isc/x86_32/Makefile.in deleted file mode 100644 index 419cf9f875..0000000000 --- a/lib/isc/x86_32/Makefile.in +++ /dev/null @@ -1,17 +0,0 @@ -# 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 = include -TARGETS = - -@BIND9_MAKE_RULES@ diff --git a/lib/isc/x86_32/include/Makefile.in b/lib/isc/x86_32/include/Makefile.in deleted file mode 100644 index d33c0fcb2c..0000000000 --- a/lib/isc/x86_32/include/Makefile.in +++ /dev/null @@ -1,17 +0,0 @@ -# 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/x86_32/include/isc/Makefile.in b/lib/isc/x86_32/include/isc/Makefile.in deleted file mode 100644 index 9f87e48935..0000000000 --- a/lib/isc/x86_32/include/isc/Makefile.in +++ /dev/null @@ -1,34 +0,0 @@ -# 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 = atomic.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 ; \ - done - -uninstall:: - for i in ${HEADERS}; do \ - rm -f ${DESTDIR}${includedir}/isc/$$i ; \ - done diff --git a/lib/isc/x86_32/include/isc/atomic.h b/lib/isc/x86_32/include/isc/atomic.h deleted file mode 100644 index 6c570307e0..0000000000 --- a/lib/isc/x86_32/include/isc/atomic.h +++ /dev/null @@ -1,176 +0,0 @@ -/* - * 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_ATOMIC_H -#define ISC_ATOMIC_H 1 - -#include - -#include -#include - -#ifdef ISC_PLATFORM_USEGCCASM -/* - * This routine atomically increments the value stored in 'p' by 'val', and - * returns the previous value. - */ -static __inline__ int32_t -isc_atomic_xadd(int32_t *p, int32_t val) { - int32_t prev = val; - - __asm__ volatile( - "lock;" - "xadd %0, %1" - :"=q"(prev) - :"m"(*p), "0"(prev) - :"memory", "cc"); - - return (prev); -} - -#ifdef ISC_PLATFORM_HAVEXADDQ -static __inline__ int64_t -isc_atomic_xaddq(int64_t *p, int64_t val) { - int64_t prev = val; - - __asm__ volatile( - "lock;" - "xaddq %0, %1" - :"=q"(prev) - :"m"(*p), "0"(prev) - :"memory", "cc"); - - return (prev); -} -#endif /* ISC_PLATFORM_HAVEXADDQ */ - -/* - * This routine atomically stores the value 'val' in 'p' (32-bit version). - */ -static __inline__ void -isc_atomic_store(int32_t *p, int32_t val) { - __asm__ volatile( - /* - * xchg should automatically lock memory, but we add it - * explicitly just in case (it at least doesn't harm) - */ - "lock;" - - "xchgl %1, %0" - : - : "r"(val), "m"(*p) - : "memory"); -} - -#ifdef ISC_PLATFORM_HAVEATOMICSTOREQ -/* - * This routine atomically stores the value 'val' in 'p' (64-bit version). - */ -static __inline__ void -isc_atomic_storeq(int64_t *p, int64_t val) { - __asm__ volatile( - /* - * xchg should automatically lock memory, but we add it - * explicitly just in case (it at least doesn't harm) - */ - "lock;" - - "xchgq %1, %0" - : - : "r"(val), "m"(*p) - : "memory"); -} -#endif /* ISC_PLATFORM_HAVEATOMICSTOREQ */ - -/* - * This routine atomically replaces the value in 'p' with 'val', if the - * original value is equal to 'cmpval'. The original value is returned in any - * case. - */ -static __inline__ int32_t -isc_atomic_cmpxchg(int32_t *p, int32_t cmpval, int32_t val) { - __asm__ volatile( - "lock;" - "cmpxchgl %1, %2" - : "=a"(cmpval) - : "r"(val), "m"(*p), "a"(cmpval) - : "memory"); - - return (cmpval); -} - -#elif defined(ISC_PLATFORM_USESTDASM) -/* - * The followings are "generic" assembly code which implements the same - * functionality in case the gcc extension cannot be used. It should be - * better to avoid inlining below, since we directly refer to specific - * positions of the stack frame, which would not actually point to the - * intended address in the embedded mnemonic. - */ -static int32_t -isc_atomic_xadd(int32_t *p, int32_t val) { - (void)(p); - (void)(val); - - __asm ( - "movl 8(%ebp), %ecx\n" - "movl 12(%ebp), %edx\n" - "lock;" - "xadd %edx, (%ecx)\n" - - /* - * set the return value directly in the register so that we - * can avoid guessing the correct position in the stack for a - * local variable. - */ - "movl %edx, %eax" - ); -} - -static void -isc_atomic_store(int32_t *p, int32_t val) { - (void)(p); - (void)(val); - - __asm ( - "movl 8(%ebp), %ecx\n" - "movl 12(%ebp), %edx\n" - "lock;" - "xchgl (%ecx), %edx\n" - ); -} - -static int32_t -isc_atomic_cmpxchg(int32_t *p, int32_t cmpval, int32_t val) { - (void)(p); - (void)(cmpval); - (void)(val); - - __asm ( - "movl 8(%ebp), %ecx\n" - "movl 12(%ebp), %eax\n" /* must be %eax for cmpxchgl */ - "movl 16(%ebp), %edx\n" - "lock;" - - /* - * If (%ecx) == %eax then (%ecx) := %edx. - % %eax is set to old (%ecx), which will be the return value. - */ - "cmpxchgl %edx, (%ecx)" - ); -} -#else /* !ISC_PLATFORM_USEGCCASM && !ISC_PLATFORM_USESTDASM */ - -#error "unsupported compiler. disable atomic ops by --disable-atomic" - -#endif -#endif /* ISC_ATOMIC_H */ diff --git a/lib/isc/x86_64/Makefile.in b/lib/isc/x86_64/Makefile.in deleted file mode 100644 index 419cf9f875..0000000000 --- a/lib/isc/x86_64/Makefile.in +++ /dev/null @@ -1,17 +0,0 @@ -# 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 = include -TARGETS = - -@BIND9_MAKE_RULES@ diff --git a/lib/isc/x86_64/include/Makefile.in b/lib/isc/x86_64/include/Makefile.in deleted file mode 100644 index d33c0fcb2c..0000000000 --- a/lib/isc/x86_64/include/Makefile.in +++ /dev/null @@ -1,17 +0,0 @@ -# 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/x86_64/include/isc/Makefile.in b/lib/isc/x86_64/include/isc/Makefile.in deleted file mode 100644 index 9f87e48935..0000000000 --- a/lib/isc/x86_64/include/isc/Makefile.in +++ /dev/null @@ -1,34 +0,0 @@ -# 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 = atomic.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 ; \ - done - -uninstall:: - for i in ${HEADERS}; do \ - rm -f ${DESTDIR}${includedir}/isc/$$i ; \ - done diff --git a/lib/isc/x86_64/include/isc/atomic.h b/lib/isc/x86_64/include/isc/atomic.h deleted file mode 100644 index a94d52cd89..0000000000 --- a/lib/isc/x86_64/include/isc/atomic.h +++ /dev/null @@ -1,129 +0,0 @@ -/* - * 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_ATOMIC_H -#define ISC_ATOMIC_H 1 - -#include - -#include -#include - -#ifdef ISC_PLATFORM_USEGCCASM - -/* We share the gcc-version with x86_32 */ -#error "impossible case. check build configuration" - -#elif defined(ISC_PLATFORM_USESTDASM) -/* - * The followings are "generic" assembly code which implements the same - * functionality in case the gcc extension cannot be used. It should be - * better to avoid inlining below, since we directly refer to specific - * registers for arguments, which would not actually correspond to the - * intended address or value in the embedded mnemonic. - */ - -static int32_t -isc_atomic_xadd(int32_t *p, int32_t val) { - (void)(p); - (void)(val); - - __asm ( - "movq %rdi, %rdx\n" - "movl %esi, %eax\n" - "lock;" - "xadd %eax, (%rdx)\n" - /* - * XXX: assume %eax will be used as the return value. - */ - ); -} - -#ifdef ISC_PLATFORM_HAVEXADDQ -static int64_t -isc_atomic_xaddq(int64_t *p, int64_t val) { - (void)(p); - (void)(val); - - __asm ( - "movq %rdi, %rdx\n" - "movq %rsi, %rax\n" - "lock;" - "xaddq %rax, (%rdx)\n" - /* - * XXX: assume %rax will be used as the return value. - */ - ); -} -#endif - -static void -isc_atomic_store(int32_t *p, int32_t val) { - (void)(p); - (void)(val); - - __asm ( - "movq %rdi, %rax\n" - "movl %esi, %edx\n" - "lock;" - "xchgl (%rax), %edx\n" - ); -} - -#ifdef ISC_PLATFORM_HAVEATOMICSTOREQ -static void -isc_atomic_storeq(int64_t *p, int64_t val) { - (void)(p); - (void)(val); - - __asm ( - "movq %rdi, %rax\n" - "movq %rsi, %rdx\n" - "lock;" - "xchgq (%rax), %rdx\n" - ); -} -#endif - -static int32_t -isc_atomic_cmpxchg(int32_t *p, int32_t cmpval, int32_t val) { - (void)(p); - (void)(cmpval); - (void)(val); - - __asm ( - /* - * p is %rdi, cmpval is %esi, val is %edx. - */ - "movl %edx, %ecx\n" - "movl %esi, %eax\n" - "movq %rdi, %rdx\n" - - "lock;" - /* - * If [%rdi] == %eax then [%rdi] := %ecx (equal to %edx - * from above), and %eax is untouched (equal to %esi) - * from above. - * - * Else if [%rdi] != %eax then [%rdi] := [%rdi] - * (rewritten in write cycle) and %eax := [%rdi]. - */ - "cmpxchgl %ecx, (%rdx)" - ); -} - -#else /* !ISC_PLATFORM_USEGCCASM && !ISC_PLATFORM_USESTDASM */ - -#error "unsupported compiler. disable atomic ops by --disable-atomic" - -#endif -#endif /* ISC_ATOMIC_H */ diff --git a/make/includes.in b/make/includes.in index 2530bff71e..48cdaf7cc3 100644 --- a/make/includes.in +++ b/make/includes.in @@ -17,8 +17,7 @@ ISC_INCLUDES = @BIND9_ISC_BUILDINCLUDE@ \ -I${top_srcdir}/lib/isc \ -I${top_srcdir}/lib/isc/include \ -I${top_srcdir}/lib/isc/unix/include \ - -I${top_srcdir}/lib/isc/pthreads/include \ - -I${top_srcdir}/lib/isc/@ISC_ARCH_DIR@/include + -I${top_srcdir}/lib/isc/pthreads/include ISCCC_INCLUDES = @BIND9_ISCCC_BUILDINCLUDE@ \ -I${top_srcdir}/lib/isccc/include diff --git a/util/copyrights b/util/copyrights index 3047843f32..a7ef15c74a 100644 --- a/util/copyrights +++ b/util/copyrights @@ -3286,7 +3286,6 @@ ./lib/isc/Atffile X 2011,2018 ./lib/isc/Kyuafile X 2017,2018 ./lib/isc/aes.c C 2014,2016,2017,2018 -./lib/isc/alpha/include/isc/atomic.h C 2005,2007,2009,2016,2018 ./lib/isc/api X 1999,2000,2001,2006,2008,2009,2010,2011,2012,2013,2014,2015,2016,2017,2018 ./lib/isc/app_api.c C 2009,2013,2014,2015,2016,2018 ./lib/isc/assertions.c C 1997,1998,1999,2000,2001,2004,2005,2007,2008,2009,2015,2016,2018 @@ -3312,10 +3311,12 @@ ./lib/isc/hmacsha.c C 2005,2006,2007,2009,2011,2012,2013,2014,2015,2016,2017,2018 ./lib/isc/ht.c C 2016,2017,2018 ./lib/isc/httpd.c C 2006,2007,2008,2010,2011,2012,2013,2014,2015,2016,2017,2018 -./lib/isc/ia64/include/isc/atomic.h C 2006,2007,2009,2012,2016,2018 +./lib/isc/include/Makefile.in MAKE 1998,1999,2000,2001,2004,2007,2012,2014,2016,2018 +./lib/isc/include/isc/Makefile.in MAKE 1998,1999,2000,2001,2003,2004,2005,2006,2007,2008,2009,2012,2013,2014,2015,2016,2017,2018 ./lib/isc/include/isc/aes.h C 2014,2016,2018 ./lib/isc/include/isc/app.h C 1999,2000,2001,2004,2005,2006,2007,2009,2013,2014,2015,2016,2018 ./lib/isc/include/isc/assertions.h C 1997,1998,1999,2000,2001,2004,2005,2006,2007,2008,2009,2016,2017,2018 +./lib/isc/include/isc/atomic.h C 2018 ./lib/isc/include/isc/backtrace.h C 2009,2016,2018 ./lib/isc/include/isc/base32.h C 2008,2014,2016,2018 ./lib/isc/include/isc/base64.h C 1999,2000,2001,2004,2005,2006,2007,2016,2018 @@ -3386,6 +3387,7 @@ ./lib/isc/include/isc/sockaddr.h C 1998,1999,2000,2001,2002,2003,2004,2005,2006,2007,2009,2012,2015,2016,2018 ./lib/isc/include/isc/socket.h C 1998,1999,2000,2001,2002,2004,2005,2006,2007,2008,2009,2011,2012,2013,2014,2016,2018 ./lib/isc/include/isc/stats.h C 2009,2012,2016,2018 +./lib/isc/include/isc/stdatomic.h C 2018 ./lib/isc/include/isc/stdio.h C 2000,2001,2004,2005,2006,2007,2013,2016,2018 ./lib/isc/include/isc/string.h C 2000,2001,2003,2004,2005,2006,2007,2014,2016,2018 ./lib/isc/include/isc/symtab.h C 1996,1997,1998,1999,2000,2001,2004,2005,2006,2007,2009,2011,2012,2013,2016,2018 @@ -3413,12 +3415,10 @@ ./lib/isc/log.c C 1999,2000,2001,2002,2003,2004,2005,2006,2007,2009,2011,2012,2013,2014,2016,2017,2018 ./lib/isc/md5.c C 2000,2001,2004,2005,2007,2009,2014,2015,2016,2017,2018 ./lib/isc/mem.c C 1997,1998,1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2012,2013,2014,2015,2016,2017,2018 -./lib/isc/mips/include/isc/atomic.h C 2005,2007,2016,2018 ./lib/isc/mutexblock.c C 1999,2000,2001,2004,2005,2007,2011,2012,2016,2018 ./lib/isc/netaddr.c C 1999,2000,2001,2002,2004,2005,2007,2010,2011,2012,2014,2015,2016,2017,2018 ./lib/isc/netscope.c C 2002,2004,2005,2006,2007,2016,2018 ./lib/isc/nls/msgcat.c C 1999,2000,2001,2004,2005,2007,2016,2018 -./lib/isc/noatomic/include/isc/atomic.h C 2005,2007,2016,2018 ./lib/isc/nonce.c C 2018 ./lib/isc/openssl_shim.c C 2018 ./lib/isc/openssl_shim.h C 2018 @@ -3427,7 +3427,6 @@ ./lib/isc/pk11_result.c C 2014,2015,2016,2018 ./lib/isc/pool.c C 2013,2015,2016,2018 ./lib/isc/portset.c C 2008,2016,2017,2018 -./lib/isc/powerpc/include/isc/atomic.h C 2005,2007,2009,2011,2012,2016,2017,2018 ./lib/isc/pthreads/Makefile.in MAKE 1998,1999,2000,2001,2004,2007,2009,2012,2016,2018 ./lib/isc/pthreads/condition.c C 1998,1999,2000,2001,2004,2005,2007,2012,2016,2018 ./lib/isc/pthreads/include/isc/condition.h C 1998,1999,2000,2001,2004,2005,2007,2016,2018 @@ -3450,7 +3449,6 @@ ./lib/isc/sha2.c C 2005,2006,2007,2009,2011,2012,2014,2016,2017,2018 ./lib/isc/sockaddr.c C 1999,2000,2001,2002,2003,2004,2005,2006,2007,2010,2011,2012,2014,2015,2016,2017,2018 ./lib/isc/socket_api.c C 2009,2011,2012,2013,2014,2015,2016,2018 -./lib/isc/sparc64/include/isc/atomic.h C 2005,2007,2013,2016,2018 ./lib/isc/stats.c C 2009,2012,2013,2014,2015,2016,2017,2018 ./lib/isc/string.c C 1999,2000,2001,2003,2004,2005,2006,2007,2011,2012,2014,2015,2016,2018 ./lib/isc/symtab.c C 1996,1997,1998,1999,2000,2001,2004,2005,2007,2011,2012,2013,2016,2018 @@ -3532,7 +3530,8 @@ ./lib/isc/win32/errno2result.h C 2000,2001,2004,2005,2007,2016,2018 ./lib/isc/win32/file.c C 2000,2001,2002,2004,2007,2009,2011,2012,2013,2014,2015,2016,2017,2018 ./lib/isc/win32/fsaccess.c C 2000,2001,2002,2004,2007,2013,2016,2017,2018 -./lib/isc/win32/include/isc/atomic.h C 2013,2015,2016,2018 +./lib/isc/win32/include/Makefile.in MAKE 1999,2000,2001,2004,2007,2012,2014,2016,2018 +./lib/isc/win32/include/isc/Makefile.in MAKE 1999,2000,2001,2004,2007,2012,2013,2014,2015,2016,2018 ./lib/isc/win32/include/isc/bind_registry.h C 2001,2004,2007,2016,2018 ./lib/isc/win32/include/isc/bindevt.h C 2001,2004,2007,2016,2018 ./lib/isc/win32/include/isc/condition.h C 1998,1999,2000,2001,2004,2007,2016,2018 @@ -3548,6 +3547,7 @@ ./lib/isc/win32/include/isc/once.h C 1999,2000,2001,2004,2007,2016,2018 ./lib/isc/win32/include/isc/platform.h.in C 2001,2004,2005,2007,2008,2009,2013,2014,2015,2016,2017,2018 ./lib/isc/win32/include/isc/stat.h C 2000,2001,2003,2004,2007,2009,2012,2016,2018 +./lib/isc/win32/include/isc/stdatomic.h C 2018 ./lib/isc/win32/include/isc/stdtime.h C 1999,2000,2001,2004,2005,2007,2011,2012,2016,2018 ./lib/isc/win32/include/isc/syslog.h C 1999,2000,2001,2004,2007,2016,2018 ./lib/isc/win32/include/isc/thread.h C 1998,1999,2000,2001,2004,2005,2007,2009,2013,2016,2017,2018 @@ -3582,8 +3582,6 @@ ./lib/isc/win32/unistd.h C 2000,2001,2004,2007,2008,2009,2016,2018 ./lib/isc/win32/version.c C 1998,1999,2000,2001,2004,2007,2016,2018 ./lib/isc/win32/win32os.c C 2002,2004,2007,2013,2014,2015,2016,2018 -./lib/isc/x86_32/include/isc/atomic.h C 2005,2007,2008,2015,2016,2017,2018 -./lib/isc/x86_64/include/isc/atomic.h C 2005,2007,2008,2015,2016,2017,2018 ./lib/isc/xoshiro128starstar.c C.PORTION 2018 ./lib/isccc/alist.c C.NOM 2001,2004,2005,2007,2015,2016,2018 ./lib/isccc/api X 2001,2006,2008,2009,2010,2011,2012,2013,2014,2015,2016,2017,2018