summaryrefslogtreecommitdiff
path: root/libguile/atomics-internal.h
diff options
context:
space:
mode:
Diffstat (limited to 'libguile/atomics-internal.h')
-rw-r--r--libguile/atomics-internal.h62
1 files changed, 31 insertions, 31 deletions
diff --git a/libguile/atomics-internal.h b/libguile/atomics-internal.h
index 3c4f0cbbd..e15ea3564 100644
--- a/libguile/atomics-internal.h
+++ b/libguile/atomics-internal.h
@@ -1,29 +1,29 @@
#ifndef SCM_ATOMICS_INTERNAL_H
#define SCM_ATOMICS_INTERNAL_H
-/* Copyright (C) 2016
- * Free Software Foundation, Inc.
- *
- * This library 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.
- *
- * This library 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.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA
- */
+/* Copyright 2016,2018-2019
+ Free Software Foundation, Inc.
+
+ This file is part of Guile.
+
+ Guile 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.
+
+ Guile 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.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Guile. If not, see
+ <https://www.gnu.org/licenses/>. */
-#include <stdint.h>
+#include "scm.h"
@@ -75,13 +75,14 @@ scm_atomic_swap_scm (SCM *loc, SCM val)
atomic_uintptr_t *a_loc = (atomic_uintptr_t *) loc;
return SCM_PACK (atomic_exchange (a_loc, SCM_UNPACK (val)));
}
-static inline _Bool
-scm_atomic_compare_and_swap_scm (SCM *loc, SCM *expected, SCM desired)
+static inline SCM
+scm_atomic_compare_and_swap_scm (SCM *loc, SCM expected, SCM desired)
{
atomic_uintptr_t *a_loc = (atomic_uintptr_t *) loc;
- return atomic_compare_exchange_weak (a_loc,
- (uintptr_t *) expected,
- SCM_UNPACK (desired));
+ SCM result = expected;
+ atomic_compare_exchange_strong (a_loc, (uintptr_t *) &result,
+ SCM_UNPACK (desired));
+ return result;
}
#else /* HAVE_STDATOMIC_H */
@@ -161,20 +162,19 @@ scm_atomic_swap_scm (SCM *loc, SCM val)
scm_i_pthread_mutex_unlock (&atomics_lock);
return ret;
}
-static inline int
-scm_atomic_compare_and_swap_scm (SCM *loc, SCM *expected, SCM desired)
+static inline SCM
+scm_atomic_compare_and_swap_scm (SCM *loc, SCM expected, SCM desired)
{
- int ret;
+ SCM ret;
scm_i_pthread_mutex_lock (&atomics_lock);
- if (*loc == *expected)
+ if (*loc == expected)
{
*loc = desired;
- ret = 1;
+ ret = expected;
}
else
{
- *expected = *loc;
- ret = 0;
+ ret = *loc;
}
scm_i_pthread_mutex_unlock (&atomics_lock);
return ret;