]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Replace arch specific atomic.h with global atomic.h header using either stdatomic...
authorOndřej Surý <ondrej@sury.org>
Tue, 14 Aug 2018 08:23:50 +0000 (10:23 +0200)
committerOndřej Surý <ondrej@sury.org>
Tue, 28 Aug 2018 10:15:39 +0000 (12:15 +0200)
42 files changed:
configure.in
lib/isc/Makefile.in
lib/isc/alpha/Makefile.in [deleted file]
lib/isc/alpha/include/Makefile.in [deleted file]
lib/isc/alpha/include/isc/Makefile.in [deleted file]
lib/isc/alpha/include/isc/atomic.h [deleted file]
lib/isc/ia64/Makefile.in [deleted file]
lib/isc/ia64/include/Makefile.in [deleted file]
lib/isc/ia64/include/isc/Makefile.in [deleted file]
lib/isc/ia64/include/isc/atomic.h [deleted file]
lib/isc/include/isc/Makefile.in
lib/isc/include/isc/atomic.h [moved from lib/isc/noatomic/include/isc/atomic.h with 78% similarity]
lib/isc/include/isc/stdatomic.h [new file with mode: 0644]
lib/isc/mips/Makefile.in [deleted file]
lib/isc/mips/include/Makefile.in [deleted file]
lib/isc/mips/include/isc/Makefile.in [deleted file]
lib/isc/mips/include/isc/atomic.h [deleted file]
lib/isc/noatomic/Makefile.in [deleted file]
lib/isc/noatomic/include/Makefile.in [deleted file]
lib/isc/noatomic/include/isc/Makefile.in [deleted file]
lib/isc/powerpc/Makefile.in [deleted file]
lib/isc/powerpc/include/Makefile.in [deleted file]
lib/isc/powerpc/include/isc/Makefile.in [deleted file]
lib/isc/powerpc/include/isc/atomic.h [deleted file]
lib/isc/sparc64/Makefile.in [deleted file]
lib/isc/sparc64/include/Makefile.in [deleted file]
lib/isc/sparc64/include/isc/Makefile.in [deleted file]
lib/isc/sparc64/include/isc/atomic.h [deleted file]
lib/isc/win32/include/isc/atomic.h [deleted file]
lib/isc/win32/include/isc/stdatomic.h [new file with mode: 0644]
lib/isc/win32/libisc.vcxproj.filters.in
lib/isc/win32/libisc.vcxproj.in
lib/isc/x86_32/Makefile.in [deleted file]
lib/isc/x86_32/include/Makefile.in [deleted file]
lib/isc/x86_32/include/isc/Makefile.in [deleted file]
lib/isc/x86_32/include/isc/atomic.h [deleted file]
lib/isc/x86_64/Makefile.in [deleted file]
lib/isc/x86_64/include/Makefile.in [deleted file]
lib/isc/x86_64/include/isc/Makefile.in [deleted file]
lib/isc/x86_64/include/isc/atomic.h [deleted file]
make/includes.in
util/copyrights

index 9053c593e3530db6955fde8b86c16cd1797829bb..ff3595a5b7f21663ff27e9541df4f04efb62ea9e 100644 (file)
@@ -2273,6 +2273,8 @@ AC_CHECK_HEADERS(
   ])
 LIBS="$LIBS $ISC_ATOMIC_LIBS"
 
+AC_CHECK_HEADERS([uchar.h])
+
 #
 # Check for __builtin_expect
 #
index 8f5233fffa806e8503bc8d1fc0e26e5c5a05d7f0..0e1d0d9e63f39757533ee9c440b9c41dc0b6607f 100644 (file)
@@ -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 (file)
index 419cf9f..0000000
+++ /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 (file)
index d33c0fc..0000000
+++ /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 (file)
index 9f87e48..0000000
+++ /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 (file)
index 9e60912..0000000
+++ /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 <inttypes.h>
-
-#include <isc/platform.h>
-#include <isc/types.h>
-
-#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 (file)
index 419cf9f..0000000
+++ /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 (file)
index d33c0fc..0000000
+++ /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 (file)
index 9f87e48..0000000
+++ /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 (file)
index e2f4331..0000000
+++ /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 <inttypes.h>
-
-#include <isc/platform.h>
-#include <isc/types.h>
-
-#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 */
index 5c0004f8a5948727a03c5fbf91951bc179c93e7f..f9db80aec661e7bd37e7c6084837592d15f3a1b4 100644 (file)
@@ -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 \
similarity index 78%
rename from lib/isc/noatomic/include/isc/atomic.h
rename to lib/isc/include/isc/atomic.h
index 5953e4b9524450ffacbaa6566f8a37191eb1fa8b..d6f95de111c786f728b435ca11148e9876a78ace 100644 (file)
@@ -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 <stdatomic.h>
+#else
+#include <isc/stdatomic.h>
+#endif
diff --git a/lib/isc/include/isc/stdatomic.h b/lib/isc/include/isc/stdatomic.h
new file mode 100644 (file)
index 0000000..723ed1e
--- /dev/null
@@ -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 (file)
index 419cf9f..0000000
+++ /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 (file)
index d33c0fc..0000000
+++ /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 (file)
index 9f87e48..0000000
+++ /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 (file)
index caba82f..0000000
+++ /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 <inttypes.h>
-
-#include <isc/platform.h>
-#include <isc/types.h>
-
-#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 (file)
index 419cf9f..0000000
+++ /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 (file)
index d33c0fc..0000000
+++ /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 (file)
index 9f87e48..0000000
+++ /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 (file)
index 419cf9f..0000000
+++ /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 (file)
index d33c0fc..0000000
+++ /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 (file)
index 9f87e48..0000000
+++ /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 (file)
index 66913d3..0000000
+++ /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 <inttypes.h>
-
-#include <isc/platform.h>
-#include <isc/types.h>
-
-/*!\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 (file)
index 419cf9f..0000000
+++ /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 (file)
index d33c0fc..0000000
+++ /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 (file)
index 11e93a4..0000000
+++ /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 (file)
index 21ec67e..0000000
+++ /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 <inttypes.h>
-
-#include <isc/platform.h>
-#include <isc/types.h>
-
-#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 (file)
index 4b3d92d..0000000
+++ /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 <inttypes.h>
-
-#include <isc/platform.h>
-#include <isc/types.h>
-
-/*
- * 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 (file)
index 0000000..4eeb10f
--- /dev/null
@@ -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 <stdbool.h>
+#include <stddef.h>
+#include <stdint.h>
+#include <windows.h>
+
+#include <isc/util.h>
+
+#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)
index 8eab0bd792608749294ac9167ea7564e95a4333f..8d59e595a7d3f2e59d2e4a3a87070a0a34fae6ef 100644 (file)
@@ -35,6 +35,9 @@
     <ClInclude Include="..\include\isc\assertions.h">
       <Filter>Library Header Files</Filter>
     </ClInclude>
+    <ClInclude Include="..\include\isc\atomic.h">
+      <Filter>Library Header Files</Filter>
+    </ClInclude>
     <ClInclude Include="..\include\isc\backtrace.h">
       <Filter>Library Header Files</Filter>
     </ClInclude>
     <ClInclude Include="include\isc\stat.h">
       <Filter>Win32 Header Files</Filter>
     </ClInclude>
+    <ClInclude Include="include\isc\stdatomic.h">
+      <Filter>Win32 Header Files</Filter>
+    </ClInclude>
     <ClInclude Include="include\isc\stdtime.h">
       <Filter>Win32 Header Files</Filter>
     </ClInclude>
       <Filter>Win32 Header Files</Filter>
     </ClInclude>
 @END PKCS11
-@IF ATOMIC
-    <ClInclude Include="include\isc\atomic.h">
-@ELSE ATOMIC
-    <ClInclude Include="..\noatomic\include\isc\atomic.h">
-@END ATOMIC
-      <Filter>Library Header Files</Filter>
-    </ClInclude>
     <ClInclude Include="..\..\..\config.h">
       <Filter>Library Header Files</Filter>
     </ClInclude>
index 0df9c26aec67f088f8346c9b5a95cf0866ece72b..fca91b3267488ffe8791add620b78c65b957bbbd 100644 (file)
@@ -293,6 +293,7 @@ copy InstallFiles ..\Build\Release\
     <ClInclude Include="..\include\isc\aes.h" />
     <ClInclude Include="..\include\isc\app.h" />
     <ClInclude Include="..\include\isc\assertions.h" />
+    <ClInclude Include="..\include\isc\atomic.h" />
     <ClInclude Include="..\include\isc\backtrace.h" />
     <ClInclude Include="..\include\isc\base32.h" />
     <ClInclude Include="..\include\isc\base64.h" />
@@ -381,11 +382,6 @@ copy InstallFiles ..\Build\Release\
     <ClInclude Include="..\include\pkcs11\pkcs11f.h" />
     <ClInclude Include="..\include\pkcs11\pkcs11t.h" />
 @END PKCS11
-@IF ATOMIC
-    <ClInclude Include="include\isc\atomic.h" />
-@ELSE ATOMIC
-    <ClInclude Include="..\noatomic\include\isc\atomic.h" />
-@END ATOMIC
     <ClInclude Include="errno2result.h" />
     <ClInclude Include="include\isc\bindevt.h" />
     <ClInclude Include="include\isc\bind_registry.h" />
@@ -402,6 +398,7 @@ copy InstallFiles ..\Build\Release\
     <ClInclude Include="include\isc\once.h" />
     <ClInclude Include="include\isc\platform.h" />
     <ClInclude Include="include\isc\stat.h" />
+    <ClInclude Include="include\isc\stdatomic.h" />
     <ClInclude Include="include\isc\stdtime.h" />
     <ClInclude Include="include\isc\strerror.h" />
     <ClInclude Include="include\isc\syslog.h" />
@@ -409,7 +406,7 @@ copy InstallFiles ..\Build\Release\
     <ClInclude Include="include\isc\time.h" />
     <ClInclude Include="include\isc\win32os.h" />
     <ClInclude Include="../entropy_private.h" />
-    <ClInclude Include="../openssl_shim.h" />\r    
+    <ClInclude Include="../openssl_shim.h" />
     <ClInclude Include="syslog.h" />
     <ClInclude Include="unistd.h" />
 @IF PKCS11
diff --git a/lib/isc/x86_32/Makefile.in b/lib/isc/x86_32/Makefile.in
deleted file mode 100644 (file)
index 419cf9f..0000000
+++ /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 (file)
index d33c0fc..0000000
+++ /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 (file)
index 9f87e48..0000000
+++ /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 (file)
index 6c57030..0000000
+++ /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 <inttypes.h>
-
-#include <isc/platform.h>
-#include <isc/types.h>
-
-#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 (file)
index 419cf9f..0000000
+++ /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 (file)
index d33c0fc..0000000
+++ /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 (file)
index 9f87e48..0000000
+++ /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 (file)
index a94d52c..0000000
+++ /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 <inttypes.h>
-
-#include <isc/platform.h>
-#include <isc/types.h>
-
-#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 */
index 2530bff71e170b8c6a2e253a929fe08539c54c6e..48cdaf7cc3b808678caba07811cfb4a3a338875a 100644 (file)
@@ -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
index 3047843f3221048dda755a325413940b4ce8a206..a7ef15c74aedb388921f4fa0185b0ef88487054c 100644 (file)
 ./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
 ./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
 ./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
 ./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
 ./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
 ./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
 ./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
 ./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
 ./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