From a87fa37e46e2a2b36d489ea7d03f15892ba82192 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Thu, 8 Jun 2017 11:31:51 +0800 Subject: [PATCH] cmake,debian,rpm: remove atomic_t completely Signed-off-by: Kefu Chai --- CMakeLists.txt | 6 -- alpine/APKBUILD.in | 1 - ceph.spec.in | 1 - cmake/modules/Findatomic_ops.cmake | 28 ----- debian/control | 1 - install-deps.sh | 1 - src/include/atomic.h | 157 ----------------------------- src/include/config-h.in.cmake | 3 - 8 files changed, 198 deletions(-) delete mode 100644 cmake/modules/Findatomic_ops.cmake delete mode 100644 src/include/atomic.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 1317765af38..c689b058921 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -250,12 +250,6 @@ if(WITH_LEVELDB) find_file(HAVE_LEVELDB_FILTER_POLICY leveldb/filter_policy.h PATHS ${LEVELDB_INCLUDE_DIR}) endif(WITH_LEVELDB) -find_package(atomic_ops REQUIRED) -message(STATUS "${ATOMIC_OPS_LIBRARIES}") -if(NOT ${ATOMIC_OPS_FOUND}) - set(NO_ATOMIC_OPS 1) -endif(NOT ${ATOMIC_OPS_FOUND}) - find_package(snappy REQUIRED) option(WITH_LZ4 "LZ4 compression support" OFF) diff --git a/alpine/APKBUILD.in b/alpine/APKBUILD.in index 51245ea5a1f..90a697d96d3 100644 --- a/alpine/APKBUILD.in +++ b/alpine/APKBUILD.in @@ -38,7 +38,6 @@ makedepends=" keyutils-dev leveldb-dev libaio-dev - libatomic_ops-dev libedit-dev libressl-dev libtirpc-dev diff --git a/ceph.spec.in b/ceph.spec.in index e415e2b442d..1396db125da 100644 --- a/ceph.spec.in +++ b/ceph.spec.in @@ -115,7 +115,6 @@ BuildRequires: gperftools-devel >= 2.4 BuildRequires: jq BuildRequires: leveldb-devel > 1.2 BuildRequires: libaio-devel -BuildRequires: libatomic_ops-devel BuildRequires: libblkid-devel >= 2.17 BuildRequires: libcurl-devel BuildRequires: libudev-devel diff --git a/cmake/modules/Findatomic_ops.cmake b/cmake/modules/Findatomic_ops.cmake deleted file mode 100644 index c6714b77f96..00000000000 --- a/cmake/modules/Findatomic_ops.cmake +++ /dev/null @@ -1,28 +0,0 @@ -# - Find atomic_ops -# Find the native ATOMIC_OPS headers and libraries. -# -# ATOMIC_OPS_INCLUDE_DIRS - where to find atomic_ops.h, etc. -# ATOMIC_OPS_LIBRARIES - List of libraries when using atomic_ops. -# ATOMIC_OPS_FOUND - True if atomic_ops found. - -# Look for the header file. -FIND_PATH(ATOMIC_OPS_INCLUDE_DIR NAMES atomic_ops.h) - -# Look for the library. -FIND_LIBRARY(ATOMIC_OPS_LIBRARY NAMES atomic_ops) - -# handle the QUIETLY and REQUIRED arguments and set ATOMIC_OPS_FOUND to TRUE if -# all listed variables are TRUE -INCLUDE(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(atomic_ops DEFAULT_MSG ATOMIC_OPS_LIBRARY ATOMIC_OPS_INCLUDE_DIR) - -# Copy the results to the output variables. -IF(ATOMIC_OPS_FOUND) - SET(ATOMIC_OPS_LIBRARIES ${ATOMIC_OPS_LIBRARY}) - SET(ATOMIC_OPS_INCLUDE_DIRS ${ATOMIC_OPS_INCLUDE_DIR}) -ELSE(ATOMIC_OPS_FOUND) - SET(ATOMIC_OPS_LIBRARIES) - SET(ATOMIC_OPS_INCLUDE_DIRS) -ENDIF(ATOMIC_OPS_FOUND) - -MARK_AS_ADVANCED(ATOMIC_OPS_INCLUDE_DIR ATOMIC_OPS_LIBRARY) diff --git a/debian/control b/debian/control index 57bd840b40c..abab52cef84 100644 --- a/debian/control +++ b/debian/control @@ -26,7 +26,6 @@ Build-Depends: bc, jq, junit4, libaio-dev, - libatomic-ops-dev, libbabeltrace-ctf-dev, libbabeltrace-dev, libblkid-dev (>= 2.17), diff --git a/install-deps.sh b/install-deps.sh index ec3d1739194..507cca73c48 100755 --- a/install-deps.sh +++ b/install-deps.sh @@ -30,7 +30,6 @@ if [ x`uname`x = xFreeBSDx ]; then devel/boost-python-libs \ devel/valgrind \ devel/pkgconf \ - devel/libatomic_ops \ devel/libedit \ devel/libtool \ devel/google-perftools \ diff --git a/src/include/atomic.h b/src/include/atomic.h deleted file mode 100644 index d5bc1c722d0..00000000000 --- a/src/include/atomic.h +++ /dev/null @@ -1,157 +0,0 @@ -// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- -// vim: ts=8 sw=2 smarttab -/* - * Ceph - scalable distributed file system - * - * Copyright (C) 2004-2011 New Dream Network - * - * This is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License version 2.1, as published by the Free Software - * Foundation. See file COPYING. - * - * @author Sage Weil - */ - -#ifndef CEPH_ATOMIC_H -#define CEPH_ATOMIC_H - -#ifdef __CEPH__ -# include "acconfig.h" -#endif - -#include -#include "include/Spinlock.h" - -namespace ceph { - template - class atomic_spinlock_t { - mutable ceph_spinlock_t lock; - T val; - public: - atomic_spinlock_t(T i=0) - : val(i) { - ceph_spin_init(&lock); - } - ~atomic_spinlock_t() { - ceph_spin_destroy(&lock); - } - void set(T v) { - ceph_spin_lock(&lock); - val = v; - ceph_spin_unlock(&lock); - } - T inc() { - ceph_spin_lock(&lock); - T r = ++val; - ceph_spin_unlock(&lock); - return r; - } - T dec() { - ceph_spin_lock(&lock); - T r = --val; - ceph_spin_unlock(&lock); - return r; - } - void add(T d) { - ceph_spin_lock(&lock); - val += d; - ceph_spin_unlock(&lock); - } - void sub(T d) { - ceph_spin_lock(&lock); - val -= d; - ceph_spin_unlock(&lock); - } - T read() const { - T ret; - ceph_spin_lock(&lock); - ret = val; - ceph_spin_unlock(&lock); - return ret; - } - bool compare_and_swap(T o, T n) { - bool success = false; - ceph_spin_lock(&lock); - if (val == o) { - success = true; - val = n; - } - ceph_spin_unlock(&lock); - return success; - } - - private: - // forbid copying - atomic_spinlock_t(const atomic_spinlock_t &other); - atomic_spinlock_t &operator=(const atomic_spinlock_t &rhs); - }; -} - -#ifndef NO_ATOMIC_OPS - -// libatomic_ops implementation -#define AO_REQUIRE_CAS -#include - -// reinclude our assert to clobber the system one -#include "include/assert.h" - -namespace ceph { - class atomic_t { - AO_t val; - public: - atomic_t(AO_t i=0) : val(i) {} - void set(AO_t v) { - AO_store(&val, v); - } - AO_t inc() { - return AO_fetch_and_add1(&val) + 1; - } - AO_t dec() { - return AO_fetch_and_sub1_write(&val) - 1; - } - AO_t add(AO_t add_me) { - return AO_fetch_and_add(&val, add_me) + add_me; - } - AO_t sub(AO_t sub_me) { - AO_t negsub = 0 - sub_me; - return AO_fetch_and_add_write(&val, negsub) + negsub; - } - AO_t read() const { - // cast away const on the pointer. this is only needed to build - // on lenny, but not newer debians, so the atomic_ops.h got fixed - // at some point. this hack can go away someday... - return AO_load_full((AO_t *)&val); - } - bool compare_and_swap(AO_t o, AO_t n) { - return AO_compare_and_swap(&val, o, n); - } - - private: - // forbid copying - atomic_t(const atomic_t &other); - atomic_t &operator=(const atomic_t &rhs); - }; - -#if SIZEOF_AO_T == 8 - typedef atomic_t atomic64_t; -#else - typedef atomic_spinlock_t atomic64_t; -#endif - -} - -#else -/* - * crappy slow implementation that uses a pthreads spinlock. - */ -#include "include/Spinlock.h" - -namespace ceph { - typedef atomic_spinlock_t atomic_t; - typedef atomic_spinlock_t atomic64_t; -} - -#endif -#endif diff --git a/src/include/config-h.in.cmake b/src/include/config-h.in.cmake index 20153faed8d..8aff51ec6bc 100644 --- a/src/include/config-h.in.cmake +++ b/src/include/config-h.in.cmake @@ -84,9 +84,6 @@ /* Define if you have res_nquery */ #cmakedefine HAVE_RES_NQUERY -/* Defined if you don't have atomic_ops */ -#cmakedefine NO_ATOMIC_OPS - /* Defined if you have LZ4 */ #cmakedefine HAVE_LZ4 -- 2.39.5