Added copyright and license
[libcds.git] / cds / compiler / gcc / ia64 / cxx11_atomic.h
index cacfa9d19e744b48ba3331364d7b1056604607b5..f29d1e9632604029d4ed55a9d435f0e8b7f00daf 100644 (file)
@@ -1,7 +1,35 @@
-//$$CDS-header$$
+/*
+    This file is a part of libcds - Concurrent Data Structures library
+
+    (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016
+
+    Source code repo: http://github.com/khizmax/libcds/
+    Download: http://sourceforge.net/projects/libcds/files/
+    
+    Redistribution and use in source and binary forms, with or without
+    modification, are permitted provided that the following conditions are met:
+
+    * Redistributions of source code must retain the above copyright notice, this
+      list of conditions and the following disclaimer.
+
+    * 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 COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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.     
+*/
 
-#ifndef __CDS_COMPILER_GCC_IA64_CXX11_ATOMIC_H
-#define __CDS_COMPILER_GCC_IA64_CXX11_ATOMIC_H
+#ifndef CDSLIB_COMPILER_GCC_IA64_CXX11_ATOMIC_H
+#define CDSLIB_COMPILER_GCC_IA64_CXX11_ATOMIC_H
 
 /*
     Source:
@@ -12,7 +40,7 @@
 #include <cstdint>
 
 //@cond
-namespace cds { namespace cxx11_atomics {
+namespace cds { namespace cxx11_atomic {
     namespace platform { CDS_CXX11_INLINE_NAMESPACE namespace gcc { CDS_CXX11_INLINE_NAMESPACE namespace ia64 {
 
         static inline void itanium_full_fence() CDS_NOEXCEPT
@@ -105,7 +133,7 @@ namespace cds { namespace cxx11_atomics {
                 || order ==  memory_order_acquire  \
                 || order == memory_order_seq_cst   \
                 ) ; \
-            assert( pSrc != NULL )  ; \
+            assert( pSrc )  ; \
             T val    ; \
             __asm__ __volatile__ ( \
                 "ld" #n_bytes ".acq %[val] = [%[pSrc]]  \n\t" \
@@ -125,7 +153,7 @@ namespace cds { namespace cxx11_atomics {
                 || order ==  memory_order_release  \
                 || order == memory_order_seq_cst   \
                 ) ; \
-            assert( pDest != NULL )  ; \
+            assert( pDest )  ; \
             if ( order == memory_order_seq_cst ) { \
                 __asm__ __volatile__ ( \
                     "st" #n_bytes ".rel [%[pDest]] = %[val] \n\t" \
@@ -199,7 +227,7 @@ namespace cds { namespace cxx11_atomics {
         static inline T exchange##n_bits( T volatile * pDest, T val, memory_order order ) CDS_NOEXCEPT \
         { \
             static_assert( sizeof(T) == n_bytes, "Illegal size of operand" )   ; \
-            assert( pDest != NULL ) ; \
+            assert( pDest ) ; \
             T current ; \
             switch(order) \
             { \
@@ -295,7 +323,7 @@ namespace cds { namespace cxx11_atomics {
         static inline T fetch32_add( T volatile * pDest, T val, memory_order order) CDS_NOEXCEPT
         {
             static_assert( sizeof(T) == 4, "Illegal size of operand" );
-            assert( pDest != NULL );
+            assert( pDest );
 
             T cur;
             switch ( val ) {
@@ -324,7 +352,7 @@ namespace cds { namespace cxx11_atomics {
         static inline T fetch32_sub( T volatile * pDest, T val, memory_order order) CDS_NOEXCEPT
         {
             static_assert( sizeof(T) == 4, "Illegal size of operand" );
-            assert( pDest != NULL );
+            assert( pDest );
             T cur;
             switch ( val ) {
                 case 1:
@@ -361,7 +389,7 @@ namespace cds { namespace cxx11_atomics {
         static inline T fetch64_add( T volatile * pDest, T val, memory_order order) CDS_NOEXCEPT
         {
             static_assert( sizeof(T) == 8, "Illegal size of operand" );
-            assert( pDest != NULL );
+            assert( pDest );
 
             T cur;
             switch ( val ) {
@@ -390,7 +418,7 @@ namespace cds { namespace cxx11_atomics {
         static inline T fetch64_sub( T volatile * pDest, T val, memory_order order) CDS_NOEXCEPT
         {
             static_assert( sizeof(T) == 8, "Illegal size of operand" );
-            assert( pDest != NULL );
+            assert( pDest );
             T cur;
             switch ( val ) {
                 case 1:
@@ -424,7 +452,7 @@ namespace cds { namespace cxx11_atomics {
                  || order ==  memory_order_acquire
                  || order == memory_order_seq_cst
             );
-            assert( pSrc != NULL );
+            assert( pSrc );
             T * val;
             __asm__ __volatile__ (
                 "ld8.acq %[val] = [%[pSrc]]  \n\t"
@@ -442,7 +470,7 @@ namespace cds { namespace cxx11_atomics {
                  || order ==  memory_order_release
                  || order == memory_order_seq_cst
             );
-            assert( pDest != NULL );
+            assert( pDest );
 
             if ( order == memory_order_seq_cst ) {
                 __asm__ __volatile__ (
@@ -466,7 +494,7 @@ namespace cds { namespace cxx11_atomics {
         static inline bool cas_ptr_strong( T * volatile * pDest, T *& expected, T * desired, memory_order mo_success, memory_order mo_fail ) CDS_NOEXCEPT
         {
             static_assert( sizeof(T *) == 8, "Illegal size of operand" );
-            assert( pDest != NULL );
+            assert( pDest );
 
             T * current;
 
@@ -523,7 +551,7 @@ namespace cds { namespace cxx11_atomics {
         static inline T * exchange_ptr( T * volatile * pDest, T * val, memory_order order ) CDS_NOEXCEPT
         {
             static_assert( sizeof(T *) == 8, "Illegal size of operand" );
-            assert( pDest != NULL );
+            assert( pDest );
 
             T * current;
             switch(order) {
@@ -558,13 +586,13 @@ namespace cds { namespace cxx11_atomics {
         template <> struct atomic_pointer_sizeof<void> { enum { value = 1 }; };
 
         // It does not work properly
-        // atomic.fetch_add( ... ) returns NULL, why?..
+        // atomic.fetch_add( ... ) returns nullptr, why?..
 //#       define CDS_ATOMIC_fetch_ptr_add_defined
         template <typename T>
         static inline T * fetch_ptr_add( T * volatile * pDest, ptrdiff_t val, memory_order order) CDS_NOEXCEPT
         {
             static_assert( sizeof(T *) == 8, "Illegal size of operand" );
-            assert( pDest != NULL );
+            assert( pDest );
 
             T * cur;
             val *= atomic_pointer_sizeof<T>::value;
@@ -590,13 +618,13 @@ namespace cds { namespace cxx11_atomics {
         }
 
         // It does not work properly
-        // atomic.fetch_sub( ... ) returns NULL, why?..
+        // atomic.fetch_sub( ... ) returns nullptr, why?..
 //#       define CDS_ATOMIC_fetch_ptr_sub_defined
         template <typename T>
         static inline T * fetch_ptr_sub( T * volatile * pDest, ptrdiff_t val, memory_order order) CDS_NOEXCEPT
         {
             static_assert( sizeof(T *) == 8, "Illegal size of operand" );
-            assert( pDest != NULL );
+            assert( pDest );
             T * cur;
             val *= atomic_pointer_sizeof<T>::value;
             switch ( val ) {
@@ -647,7 +675,7 @@ namespace cds { namespace cxx11_atomics {
     using namespace gcc::ia64;
 #endif
     }   // namespace platform
-}}  // namespace cds::cxx11_atomics
+}}  // namespace cds::cxx11_atomic
 //@endcond
 
-#endif // #ifndef __CDS_COMPILER_GCC_IA64_CXX11_ATOMIC_H
+#endif // #ifndef CDSLIB_COMPILER_GCC_IA64_CXX11_ATOMIC_H