From 4a7aad06d95701cf232198093ce396dcdbb53e5b Mon Sep 17 00:00:00 2001 From: Martin Sustrik Date: Thu, 16 Feb 2012 10:01:47 +0900 Subject: ZeroMQ renamed to Crossroads Signed-off-by: Martin Sustrik --- src/atomic_counter.hpp | 70 +++++++++++++++++++++++++------------------------- 1 file changed, 35 insertions(+), 35 deletions(-) (limited to 'src/atomic_counter.hpp') diff --git a/src/atomic_counter.hpp b/src/atomic_counter.hpp index a0a67bf..81779a5 100644 --- a/src/atomic_counter.hpp +++ b/src/atomic_counter.hpp @@ -1,16 +1,16 @@ /* - Copyright (c) 2009-2011 250bpm s.r.o. + Copyright (c) 2009-2012 250bpm s.r.o. Copyright (c) 2007-2009 iMatix Corporation Copyright (c) 2007-2011 Other contributors as noted in the AUTHORS file - This file is part of 0MQ. + This file is part of Crossroads project. - 0MQ is free software; you can redistribute it and/or modify it under + Crossroads is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. - 0MQ is distributed in the hope that it will be useful, + Crossroads is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. @@ -19,33 +19,33 @@ along with this program. If not, see . */ -#ifndef __ZMQ_ATOMIC_COUNTER_HPP_INCLUDED__ -#define __ZMQ_ATOMIC_COUNTER_HPP_INCLUDED__ +#ifndef __XS_ATOMIC_COUNTER_HPP_INCLUDED__ +#define __XS_ATOMIC_COUNTER_HPP_INCLUDED__ #include "stdint.hpp" #include "platform.hpp" -#if defined ZMQ_FORCE_MUTEXES -#define ZMQ_ATOMIC_COUNTER_MUTEX +#if defined XS_FORCE_MUTEXES +#define XS_ATOMIC_COUNTER_MUTEX #elif (defined __i386__ || defined __x86_64__) && defined __GNUC__ -#define ZMQ_ATOMIC_COUNTER_X86 -#elif defined ZMQ_HAVE_WINDOWS -#define ZMQ_ATOMIC_COUNTER_WINDOWS -#elif (defined ZMQ_HAVE_SOLARIS || defined ZMQ_HAVE_NETBSD) -#define ZMQ_ATOMIC_COUNTER_ATOMIC_H +#define XS_ATOMIC_COUNTER_X86 +#elif defined XS_HAVE_WINDOWS +#define XS_ATOMIC_COUNTER_WINDOWS +#elif (defined XS_HAVE_SOLARIS || defined XS_HAVE_NETBSD) +#define XS_ATOMIC_COUNTER_ATOMIC_H #else -#define ZMQ_ATOMIC_COUNTER_MUTEX +#define XS_ATOMIC_COUNTER_MUTEX #endif -#if defined ZMQ_ATOMIC_COUNTER_MUTEX +#if defined XS_ATOMIC_COUNTER_MUTEX #include "mutex.hpp" -#elif defined ZMQ_ATOMIC_COUNTER_WINDOWS +#elif defined XS_ATOMIC_COUNTER_WINDOWS #include "windows.hpp" -#elif defined ZMQ_ATOMIC_COUNTER_ATOMIC_H +#elif defined XS_ATOMIC_COUNTER_ATOMIC_H #include #endif -namespace zmq +namespace xs { // This class represents an integer that can be incremented/decremented @@ -77,18 +77,18 @@ namespace zmq { integer_t old_value; -#if defined ZMQ_ATOMIC_COUNTER_WINDOWS +#if defined XS_ATOMIC_COUNTER_WINDOWS old_value = InterlockedExchangeAdd ((LONG*) &value, increment_); -#elif defined ZMQ_ATOMIC_COUNTER_ATOMIC_H +#elif defined XS_ATOMIC_COUNTER_ATOMIC_H integer_t new_value = atomic_add_32_nv (&value, increment_); old_value = new_value - increment_; -#elif defined ZMQ_ATOMIC_COUNTER_X86 +#elif defined XS_ATOMIC_COUNTER_X86 __asm__ volatile ( "lock; xadd %0, %1 \n\t" : "=r" (old_value), "=m" (value) : "0" (increment_), "m" (value) : "cc", "memory"); -#elif defined ZMQ_ATOMIC_COUNTER_MUTEX +#elif defined XS_ATOMIC_COUNTER_MUTEX sync.lock (); old_value = value; value += increment_; @@ -102,15 +102,15 @@ namespace zmq // Atomic subtraction. Returns false if the counter drops to zero. inline bool sub (integer_t decrement) { -#if defined ZMQ_ATOMIC_COUNTER_WINDOWS +#if defined XS_ATOMIC_COUNTER_WINDOWS LONG delta = - ((LONG) decrement); integer_t old = InterlockedExchangeAdd ((LONG*) &value, delta); return old - decrement != 0; -#elif defined ZMQ_ATOMIC_COUNTER_ATOMIC_H +#elif defined XS_ATOMIC_COUNTER_ATOMIC_H int32_t delta = - ((int32_t) decrement); integer_t nv = atomic_add_32_nv (&value, delta); return nv != 0; -#elif defined ZMQ_ATOMIC_COUNTER_X86 +#elif defined XS_ATOMIC_COUNTER_X86 integer_t oldval = -decrement; volatile integer_t *val = &value; __asm__ volatile ("lock; xaddl %0,%1" @@ -118,7 +118,7 @@ namespace zmq : "0" (oldval), "m" (*val) : "cc", "memory"); return oldval != decrement; -#elif defined ZMQ_ATOMIC_COUNTER_MUTEX +#elif defined XS_ATOMIC_COUNTER_MUTEX sync.lock (); value -= decrement; bool result = value ? true : false; @@ -137,7 +137,7 @@ namespace zmq private: volatile integer_t value; -#if defined ZMQ_ATOMIC_COUNTER_MUTEX +#if defined XS_ATOMIC_COUNTER_MUTEX mutex_t sync; #endif @@ -148,17 +148,17 @@ namespace zmq } // Remove macros local to this file. -#if defined ZMQ_ATOMIC_COUNTER_WINDOWS -#undef ZMQ_ATOMIC_COUNTER_WINDOWS +#if defined XS_ATOMIC_COUNTER_WINDOWS +#undef XS_ATOMIC_COUNTER_WINDOWS #endif -#if defined ZMQ_ATOMIC_COUNTER_ATOMIC_H -#undef ZMQ_ATOMIC_COUNTER_ATOMIC_H +#if defined XS_ATOMIC_COUNTER_ATOMIC_H +#undef XS_ATOMIC_COUNTER_ATOMIC_H #endif -#if defined ZMQ_ATOMIC_COUNTER_X86 -#undef ZMQ_ATOMIC_COUNTER_X86 +#if defined XS_ATOMIC_COUNTER_X86 +#undef XS_ATOMIC_COUNTER_X86 #endif -#if defined ZMQ_ATOMIC_COUNTER_MUTEX -#undef ZMQ_ATOMIC_COUNTER_MUTEX +#if defined XS_ATOMIC_COUNTER_MUTEX +#undef XS_ATOMIC_COUNTER_MUTEX #endif #endif -- cgit v1.2.3