1111 * Copyright (c) 2004-2005 The Regents of the University of California.
1212 * All rights reserved.
1313 * Copyright (c) 2007-2014 Cisco Systems, Inc. All rights reserved.
14- * Copyright (c) 2014 Research Organization for Information Science
14+ * Copyright (c) 2014-2016 Research Organization for Information Science
1515 * and Technology (RIST). All rights reserved.
1616 * Copyright (c) 2015-2016 Los Alamos National Security, LLC. All rights
1717 * reserved.
@@ -103,6 +103,16 @@ static inline type opal_thread_add_ ## suffix (volatile type *addr, type delta)
103103 return (*addr += delta); \
104104}
105105
106+ #define OPAL_THREAD_DEFINE_ATOMIC_SUB (type , suffix ) \
107+ static inline type opal_thread_sub_ ## suffix (volatile type *addr, type delta) \
108+ { \
109+ if (OPAL_UNLIKELY(opal_using_threads())) { \
110+ return opal_atomic_sub_ ## suffix (addr, delta); \
111+ } \
112+ \
113+ return (*addr -= delta); \
114+ }
115+
106116#define OPAL_THREAD_DEFINE_ATOMIC_CMPSET (type , addr_type , suffix ) \
107117static inline bool opal_thread_cmpset_bool_ ## suffix (volatile addr_type *addr, type compare, type value) \
108118{ \
@@ -133,6 +143,7 @@ static inline type opal_thread_swap_ ## suffix (volatile addr_type *ptr, type ne
133143
134144OPAL_THREAD_DEFINE_ATOMIC_ADD (int32_t , 32 )
135145OPAL_THREAD_DEFINE_ATOMIC_ADD (size_t , size_t )
146+ OPAL_THREAD_DEFINE_ATOMIC_SUB (size_t , size_t )
136147OPAL_THREAD_DEFINE_ATOMIC_CMPSET (int32_t , int32_t , 32 )
137148OPAL_THREAD_DEFINE_ATOMIC_CMPSET (void * , intptr_t , ptr )
138149OPAL_THREAD_DEFINE_ATOMIC_SWAP (int32_t , int32_t , 32 )
@@ -144,6 +155,9 @@ OPAL_THREAD_DEFINE_ATOMIC_SWAP(void *, intptr_t, ptr)
144155#define OPAL_THREAD_ADD_SIZE_T opal_thread_add_size_t
145156#define OPAL_ATOMIC_ADD_SIZE_T opal_thread_add_size_t
146157
158+ #define OPAL_THREAD_SUB_SIZE_T opal_thread_sub_size_t
159+ #define OPAL_ATOMIC_SUB_SIZE_T opal_thread_sub_size_t
160+
147161#define OPAL_THREAD_CMPSET_32 opal_thread_cmpset_bool_32
148162#define OPAL_ATOMIC_CMPSET_32 opal_thread_cmpset_bool_32
149163
0 commit comments