summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2022-02-14 09:13:02 +0300
committerIvan Maidanski <ivmai@mail.ru>2022-02-14 12:28:29 +0300
commit691685d27474cafc9475650564d43362bb35245c (patch)
treec22b547a1e39e89dd38e2d0f2b0e8b924d9f5840
parent108720a92507e699370093754b3baed39d4c341c (diff)
downloadlibatomic_ops-691685d27474cafc9475650564d43362bb35245c.tar.gz
Always export stack_init/push_release/pop_acquire from atomic_ops_gpl
Previously AO_stack_init() was declared as inline, and AO_stack_push_release() and AO_stack_pop_acquire() were define as macros in case of USE_ALMOST_LOCK_FREE. Now, these 3 functions are always defined in atomic_ops_stack.c. * src/atomic_ops_stack.c [USE_ALMOST_LOCK_FREE] (AO_stack_init, AO_stack_push_release, AO_stack_pop_acquire): Implement. * src/atomic_ops_stack.c [!USE_ALMOST_LOCK_FREE] (AO_stack_init): Likewise. * src/atomic_ops_stack.h (AO_stack_init): Remove inline function definition; declare as AO_API function instead. * src/atomic_ops_stack.h [USE_ALMOST_LOCK_FREE] (AO_stack_push_release, AO_stack_pop_acquire): Declare as AO_API function instead of macro. * src/atomic_ops_stack.h (AO_stack_push, AO_HAVE_stack_push, AO_stack_pop, AO_HAVE_stack_pop): Define macro unconditionally.
-rw-r--r--src/atomic_ops_stack.c29
-rw-r--r--src/atomic_ops_stack.h51
2 files changed, 40 insertions, 40 deletions
diff --git a/src/atomic_ops_stack.c b/src/atomic_ops_stack.c
index 2067361..c03be7a 100644
--- a/src/atomic_ops_stack.c
+++ b/src/atomic_ops_stack.c
@@ -215,8 +215,37 @@
return first_ptr;
}
+ AO_API void AO_stack_init(AO_stack_t *list)
+ {
+# if AO_BL_SIZE == 2
+ list -> AO_aux.AO_stack_bl[0] = 0;
+ list -> AO_aux.AO_stack_bl[1] = 0;
+# else
+ int i;
+ for (i = 0; i < AO_BL_SIZE; ++i)
+ list -> AO_aux.AO_stack_bl[i] = 0;
+# endif
+ list -> AO_ptr = 0;
+ }
+
+ AO_API void AO_stack_push_release(AO_stack_t *list, AO_t *x)
+ {
+ AO_stack_push_explicit_aux_release(&list->AO_ptr, x, &list->AO_aux);
+ }
+
+ AO_API AO_t *AO_stack_pop_acquire(AO_stack_t *list)
+ {
+ return AO_stack_pop_explicit_aux_acquire(&list->AO_ptr, &list->AO_aux);
+ }
+
#else /* ! USE_ALMOST_LOCK_FREE */
+ AO_API void AO_stack_init(AO_stack_t *list)
+ {
+ list -> AO_val1 = 0;
+ list -> AO_val2 = 0;
+ }
+
/* The functionality is the same as of AO_load_next but the atomicity */
/* is not needed. The usage is similar to that of store_before_cas. */
# if defined(AO_THREAD_SANITIZER) \
diff --git a/src/atomic_ops_stack.h b/src/atomic_ops_stack.h
index cf231ab..dc37904 100644
--- a/src/atomic_ops_stack.h
+++ b/src/atomic_ops_stack.h
@@ -126,31 +126,10 @@
# define AO_STACK_INITIALIZER {0,{{0}}}
- AO_INLINE void AO_stack_init(AO_stack_t *list)
- {
-# if AO_BL_SIZE == 2
- list -> AO_aux.AO_stack_bl[0] = 0;
- list -> AO_aux.AO_stack_bl[1] = 0;
-# else
- int i;
- for (i = 0; i < AO_BL_SIZE; ++i)
- list -> AO_aux.AO_stack_bl[i] = 0;
-# endif
- list -> AO_ptr = 0;
- }
-
/* Convert an AO_stack_t to a pointer to the link field in */
/* the first element. */
# define AO_REAL_HEAD_PTR(x) AO_REAL_NEXT_PTR((x).AO_ptr)
-# define AO_stack_push_release(l, e) \
- AO_stack_push_explicit_aux_release(&((l)->AO_ptr), e, &((l)->AO_aux))
-# define AO_HAVE_stack_push_release
-
-# define AO_stack_pop_acquire(l) \
- AO_stack_pop_explicit_aux_acquire(&((l)->AO_ptr), &((l)->AO_aux))
-# define AO_HAVE_stack_pop_acquire
-
#else /* Use fully non-blocking data structure, wide CAS. */
# ifndef AO_HAVE_double_t
@@ -173,32 +152,24 @@
# define AO_STACK_INITIALIZER AO_DOUBLE_T_INITIALIZER
- AO_INLINE void AO_stack_init(AO_stack_t *list)
- {
- list -> AO_val1 = 0;
- list -> AO_val2 = 0;
- }
-
# define AO_REAL_HEAD_PTR(x) (AO_t *)((x).AO_val2)
# define AO_REAL_NEXT_PTR(x) (AO_t *)(x)
- AO_API void AO_stack_push_release(AO_stack_t *list, AO_t *new_element);
-# define AO_HAVE_stack_push_release
+#endif /* !AO_USE_ALMOST_LOCK_FREE */
- AO_API AO_t *AO_stack_pop_acquire(AO_stack_t *list);
-# define AO_HAVE_stack_pop_acquire
+AO_API void AO_stack_init(AO_stack_t *list);
-#endif /* !AO_USE_ALMOST_LOCK_FREE */
+AO_API void AO_stack_push_release(AO_stack_t *list, AO_t *new_element);
+#define AO_HAVE_stack_push_release
-#if defined(AO_HAVE_stack_push_release) && !defined(AO_HAVE_stack_push)
-# define AO_stack_push(l, e) AO_stack_push_release(l, e)
-# define AO_HAVE_stack_push
-#endif
+#define AO_stack_push(l, e) AO_stack_push_release(l, e)
+#define AO_HAVE_stack_push
-#if defined(AO_HAVE_stack_pop_acquire) && !defined(AO_HAVE_stack_pop)
-# define AO_stack_pop(l) AO_stack_pop_acquire(l)
-# define AO_HAVE_stack_pop
-#endif
+AO_API AO_t *AO_stack_pop_acquire(AO_stack_t *list);
+#define AO_HAVE_stack_pop_acquire
+
+#define AO_stack_pop(l) AO_stack_pop_acquire(l)
+#define AO_HAVE_stack_pop
#ifdef __cplusplus
} /* extern "C" */