Return-Path: X-Original-To: apmail-activemq-commits-archive@www.apache.org Delivered-To: apmail-activemq-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 79E6A6862 for ; Sat, 14 May 2011 22:42:40 +0000 (UTC) Received: (qmail 10738 invoked by uid 500); 14 May 2011 22:42:40 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 10703 invoked by uid 500); 14 May 2011 22:42:40 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 10696 invoked by uid 99); 14 May 2011 22:42:40 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 14 May 2011 22:42:40 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 14 May 2011 22:42:39 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id EE39F23888FD; Sat, 14 May 2011 22:42:18 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1103246 - in /activemq/activemq-cpp/trunk/activemq-cpp: configure.ac m4/check_atomics.m4 Date: Sat, 14 May 2011 22:42:18 -0000 To: commits@activemq.apache.org From: tabish@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110514224218.EE39F23888FD@eris.apache.org> Author: tabish Date: Sat May 14 22:42:18 2011 New Revision: 1103246 URL: http://svn.apache.org/viewvc?rev=1103246&view=rev Log: Detect compiler built-in Atomic operations Added: activemq/activemq-cpp/trunk/activemq-cpp/m4/check_atomics.m4 (with props) Modified: activemq/activemq-cpp/trunk/activemq-cpp/configure.ac Modified: activemq/activemq-cpp/trunk/activemq-cpp/configure.ac URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/configure.ac?rev=1103246&r1=1103245&r2=1103246&view=diff ============================================================================== --- activemq/activemq-cpp/trunk/activemq-cpp/configure.ac (original) +++ activemq/activemq-cpp/trunk/activemq-cpp/configure.ac Sat May 14 22:42:18 2011 @@ -178,6 +178,9 @@ PLAT_LIBS= # Detect the presence of pthreads and the correct linker settings. DECAF_CHECK_PTHREADS() +# Detect the presence of atomic operations. +DECAF_CHECK_ATOMICS() + case "${host_os}" in *darwin* ) ## Mac OS X configuration Added: activemq/activemq-cpp/trunk/activemq-cpp/m4/check_atomics.m4 URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/m4/check_atomics.m4?rev=1103246&view=auto ============================================================================== --- activemq/activemq-cpp/trunk/activemq-cpp/m4/check_atomics.m4 (added) +++ activemq/activemq-cpp/trunk/activemq-cpp/m4/check_atomics.m4 Sat May 14 22:42:18 2011 @@ -0,0 +1,86 @@ +dnl -------------------------------------------------------- -*- autoconf -*- +dnl Licensed to the Apache Software Foundation (ASF) under one or more +dnl contributor license agreements. See the NOTICE file distributed with +dnl this work for additional information regarding copyright ownership. +dnl The ASF licenses this file to You under the Apache License, Version 2.0 +dnl (the "License"); you may not use this file except in compliance with +dnl the License. You may obtain a copy of the License at +dnl +dnl http://www.apache.org/licenses/LICENSE-2.0 +dnl +dnl Unless required by applicable law or agreed to in writing, software +dnl distributed under the License is distributed on an "AS IS" BASIS, +dnl WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +dnl See the License for the specific language governing permissions and +dnl limitations under the License. + +dnl +dnl check_atomics.m4 - checks support for atomics and determines what the +dnl features of the installed library are on this platform. +dnl +dnl This macro checks for the presence of the atomics operations. If found then +dnl the library is tested to determine what features it supports, or lacks and +dnl configuration options are set to indicate this information. +dnl + +dnl +dnl DECAF_CHECK_FOR_ATOMIC_BUILTINS in GCC +dnl +AC_DEFUN([DECAF_CHECK_FOR_ATOMIC_BUILTINS], [ + + AC_CACHE_CHECK([whether the compiler provides atomic builtins], [ap_cv_atomic_builtins], + [AC_TRY_RUN([ + int main() + { + unsigned long val = 1010, tmp, *mem = &val; + + if (__sync_fetch_and_add(&val, 1010) != 1010 || val != 2020) + return 1; + + tmp = val; + + if (__sync_fetch_and_sub(mem, 1010) != tmp || val != 1010) + return 1; + + if (__sync_sub_and_fetch(&val, 1010) != 0 || val != 0) + return 1; + + tmp = 3030; + + if (__sync_val_compare_and_swap(mem, 0, tmp) != 0 || val != tmp) + return 1; + + if (__sync_lock_test_and_set(&val, 4040) != 3030) + return 1; + + mem = &tmp; + + if (__sync_val_compare_and_swap(&mem, &tmp, &val) != &tmp) + return 1; + + __sync_synchronize(); + + if (mem != &val) + return 1; + + return 0; + }], [ap_cv_atomic_builtins=yes], [ap_cv_atomic_builtins=no], [ap_cv_atomic_builtins=no])]) + + if test "$ap_cv_atomic_builtins" = "yes"; then + AC_DEFINE(HAVE_ATOMIC_BUILTINS, 1, [Define if compiler provides atomic builtins]) + fi + +])dnl + +dnl --------------------------------------------------------------------------- +dnl Checks for atomic operations support and the various features that are +dnl needed in order to build the DECAF Code that uses atomics provided by +dnl the compiler or OS rather than using Mutex based atomic operations. +dnl --------------------------------------------------------------------------- + +AC_DEFUN([DECAF_CHECK_ATOMICS], [ + + dnl Attempts to enable atomic builtins compilation on this platform. + DECAF_CHECK_FOR_ATOMIC_BUILTINS + +]) Propchange: activemq/activemq-cpp/trunk/activemq-cpp/m4/check_atomics.m4 ------------------------------------------------------------------------------ svn:eol-style = native Propchange: activemq/activemq-cpp/trunk/activemq-cpp/m4/check_atomics.m4 ------------------------------------------------------------------------------ svn:executable = *