summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2013-01-05 18:56:53 +0400
committerIvan Maidanski <ivmai@mail.ru>2013-01-05 18:56:53 +0400
commite723868de770f70f4fbd39286905c24572bcc7e7 (patch)
tree41695107fd48a349f1e476e3d18fdb557ec86eb6
parent13fe31e3151927ca5d84ca1df68e144b827c5552 (diff)
downloadlibatomic_ops-e723868de770f70f4fbd39286905c24572bcc7e7.tar.gz
Remove X_aligned_atomic_load_store headers and template
(code refactoring) * src/Makefile.am (EXTRA_DIST): Remove aligned_atomic_load_store.template entry. * src/Makefile.am (BUILT_SOURCES, nobase_private_HEADERS): Remove aligned_atomic_load_store.h, int_aligned_atomic_load_store.h, short_aligned_atomic_load_store.h entries. * src/Makefile.am (atomic_ops/sysdeps/loadstore/aligned_atomic_load_store.h, atomic_ops/sysdeps/loadstore/int_aligned_atomic_load_store.h, atomic_ops/sysdeps/loadstore/short_aligned_atomic_load_store.h): Remove rules. * src/atomic_ops/sysdeps/all_aligned_atomic_load_store.h: Refine comment; include X_atomic_load_store.h instead of the corresponding X_aligned_atomic_load_store.h file. * src/atomic_ops/sysdeps/all_aligned_atomic_load_store.h (AO_ACCESS_CHECK_ALIGNED, AO_ACCESS_short_CHECK_ALIGNED, AO_ACCESS_int_CHECK_ALIGNED): New macros (defined before inclusion of the corresponding X_atomic_load_store.h file). * src/atomic_ops/sysdeps/loadstore/aligned_atomic_load_store.h: Remove. * src/atomic_ops/sysdeps/loadstore/aligned_atomic_load_store.template: Likewise. * src/atomic_ops/sysdeps/loadstore/int_aligned_atomic_load_store.h: Likewise. * src/atomic_ops/sysdeps/loadstore/short_aligned_atomic_load_store.h: Likewise. * src/atomic_ops/sysdeps/loadstore/atomic_load_store.template (AO_XSIZE_load, AO_XSIZE_store): Add conditional assertion check of (*addr) alignment (enabled only if AO_ACCESS_<XSIZE>_CHECK_ALIGNED). * src/atomic_ops/sysdeps/loadstore/short_atomic_load_store.h: Regenerate. * src/atomic_ops/sysdeps/loadstore/int_atomic_load_store.h: Likewise. * src/atomic_ops/sysdeps/loadstore/char_atomic_load_store.h: Likewise. * src/atomic_ops/sysdeps/loadstore/atomic_load_store.h: Likewise.
-rw-r--r--src/Makefile.am19
-rw-r--r--src/atomic_ops/sysdeps/all_aligned_atomic_load_store.h13
-rw-r--r--src/atomic_ops/sysdeps/loadstore/aligned_atomic_load_store.h42
-rw-r--r--src/atomic_ops/sysdeps/loadstore/aligned_atomic_load_store.template42
-rw-r--r--src/atomic_ops/sysdeps/loadstore/atomic_load_store.h13
-rw-r--r--src/atomic_ops/sysdeps/loadstore/atomic_load_store.template13
-rw-r--r--src/atomic_ops/sysdeps/loadstore/char_atomic_load_store.h13
-rw-r--r--src/atomic_ops/sysdeps/loadstore/int_aligned_atomic_load_store.h42
-rw-r--r--src/atomic_ops/sysdeps/loadstore/int_atomic_load_store.h13
-rw-r--r--src/atomic_ops/sysdeps/loadstore/short_aligned_atomic_load_store.h42
-rw-r--r--src/atomic_ops/sysdeps/loadstore/short_atomic_load_store.h13
11 files changed, 58 insertions, 207 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index bc3d5ed..9b129e1 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -17,22 +17,18 @@ EXTRA_DIST = Makefile.msft atomic_ops/sysdeps/README \
atomic_ops/generalize-arithm.template \
atomic_ops/generalize-small.template \
atomic_ops/sysdeps/loadstore/acquire_release_volatile.template \
- atomic_ops/sysdeps/loadstore/aligned_atomic_load_store.template \
atomic_ops/sysdeps/loadstore/atomic_load_store.template \
atomic_ops/sysdeps/sunc/sparc.S
BUILT_SOURCES = atomic_ops/generalize-arithm.h \
atomic_ops/generalize-small.h \
atomic_ops/sysdeps/loadstore/acquire_release_volatile.h \
- atomic_ops/sysdeps/loadstore/aligned_atomic_load_store.h \
atomic_ops/sysdeps/loadstore/atomic_load_store.h \
atomic_ops/sysdeps/loadstore/char_acquire_release_volatile.h \
atomic_ops/sysdeps/loadstore/char_atomic_load_store.h \
atomic_ops/sysdeps/loadstore/int_acquire_release_volatile.h \
- atomic_ops/sysdeps/loadstore/int_aligned_atomic_load_store.h \
atomic_ops/sysdeps/loadstore/int_atomic_load_store.h \
atomic_ops/sysdeps/loadstore/short_acquire_release_volatile.h \
- atomic_ops/sysdeps/loadstore/short_aligned_atomic_load_store.h \
atomic_ops/sysdeps/loadstore/short_atomic_load_store.h
#Private Headers
@@ -56,15 +52,12 @@ nobase_private_HEADERS = atomic_ops/ao_version.h \
atomic_ops/sysdeps/test_and_set_t_is_char.h \
\
atomic_ops/sysdeps/loadstore/acquire_release_volatile.h \
- atomic_ops/sysdeps/loadstore/aligned_atomic_load_store.h \
atomic_ops/sysdeps/loadstore/atomic_load_store.h \
atomic_ops/sysdeps/loadstore/char_acquire_release_volatile.h \
atomic_ops/sysdeps/loadstore/char_atomic_load_store.h \
atomic_ops/sysdeps/loadstore/int_acquire_release_volatile.h \
- atomic_ops/sysdeps/loadstore/int_aligned_atomic_load_store.h \
atomic_ops/sysdeps/loadstore/int_atomic_load_store.h \
atomic_ops/sysdeps/loadstore/short_acquire_release_volatile.h \
- atomic_ops/sysdeps/loadstore/short_aligned_atomic_load_store.h \
atomic_ops/sysdeps/loadstore/short_atomic_load_store.h \
\
atomic_ops/sysdeps/armcc/arm_v6.h \
@@ -127,18 +120,6 @@ atomic_ops/sysdeps/loadstore/short_acquire_release_volatile.h: \
atomic_ops/sysdeps/loadstore/acquire_release_volatile.template
sed -e s:XSIZE_:short_:g -e s:XCTYPE:unsigned/**/short:g $? > $@
-atomic_ops/sysdeps/loadstore/aligned_atomic_load_store.h: \
- atomic_ops/sysdeps/loadstore/aligned_atomic_load_store.template
- sed -e s:XSIZE_::g -e s:XCTYPE:AO_t:g $? > $@
-
-atomic_ops/sysdeps/loadstore/int_aligned_atomic_load_store.h: \
- atomic_ops/sysdeps/loadstore/aligned_atomic_load_store.template
- sed -e s:XSIZE_:int_:g -e s:XCTYPE:unsigned:g $? > $@
-
-atomic_ops/sysdeps/loadstore/short_aligned_atomic_load_store.h: \
- atomic_ops/sysdeps/loadstore/aligned_atomic_load_store.template
- sed -e s:XSIZE_:short_:g -e s:XCTYPE:unsigned/**/short:g $? > $@
-
atomic_ops/sysdeps/loadstore/atomic_load_store.h: \
atomic_ops/sysdeps/loadstore/atomic_load_store.template
sed -e s:XSIZE_::g -e s:XCTYPE:AO_t:g $? > $@
diff --git a/src/atomic_ops/sysdeps/all_aligned_atomic_load_store.h b/src/atomic_ops/sysdeps/all_aligned_atomic_load_store.h
index 4fb9b02..c4a650f 100644
--- a/src/atomic_ops/sysdeps/all_aligned_atomic_load_store.h
+++ b/src/atomic_ops/sysdeps/all_aligned_atomic_load_store.h
@@ -21,10 +21,13 @@
*/
/* Describes architectures on which AO_t, unsigned char, unsigned */
-/* short, and unsigned int loads and stores are atomic for all normally */
-/* legal alignments. */
+/* short, and unsigned int loads and stores are atomic but only if data */
+/* is suitably aligned. */
-#include "loadstore/aligned_atomic_load_store.h"
+#define AO_ACCESS_CHECK_ALIGNED
+#include "loadstore/atomic_load_store.h"
#include "loadstore/char_atomic_load_store.h"
-#include "loadstore/short_aligned_atomic_load_store.h"
-#include "loadstore/int_aligned_atomic_load_store.h"
+#define AO_ACCESS_short_CHECK_ALIGNED
+#include "loadstore/short_atomic_load_store.h"
+#define AO_ACCESS_int_CHECK_ALIGNED
+#include "loadstore/int_atomic_load_store.h"
diff --git a/src/atomic_ops/sysdeps/loadstore/aligned_atomic_load_store.h b/src/atomic_ops/sysdeps/loadstore/aligned_atomic_load_store.h
deleted file mode 100644
index a2a8ccd..0000000
--- a/src/atomic_ops/sysdeps/loadstore/aligned_atomic_load_store.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (c) 2004 Hewlett-Packard Development Company, L.P.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-/* Definitions for architectures on which loads and stores of given */
-/* type are atomic for all legal alignments. */
-
-AO_INLINE AO_t
-AO_load(const volatile AO_t *addr)
-{
- assert(((size_t)addr & (sizeof(*addr) - 1)) == 0);
- /* Cast away the volatile for architectures like IA64 where */
- /* volatile adds barrier (fence) semantics. */
- return *(const AO_t *)addr;
-}
-#define AO_HAVE_load
-
-AO_INLINE void
-AO_store(volatile AO_t *addr, AO_t new_val)
-{
- assert(((size_t)addr & (sizeof(*addr) - 1)) == 0);
- *(AO_t *)addr = new_val;
-}
-#define AO_HAVE_store
diff --git a/src/atomic_ops/sysdeps/loadstore/aligned_atomic_load_store.template b/src/atomic_ops/sysdeps/loadstore/aligned_atomic_load_store.template
deleted file mode 100644
index a847807..0000000
--- a/src/atomic_ops/sysdeps/loadstore/aligned_atomic_load_store.template
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (c) 2004 Hewlett-Packard Development Company, L.P.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-/* Definitions for architectures on which loads and stores of given */
-/* type are atomic for all legal alignments. */
-
-AO_INLINE XCTYPE
-AO_XSIZE_load(const volatile XCTYPE *addr)
-{
- assert(((size_t)addr & (sizeof(*addr) - 1)) == 0);
- /* Cast away the volatile for architectures like IA64 where */
- /* volatile adds barrier (fence) semantics. */
- return *(const XCTYPE *)addr;
-}
-#define AO_HAVE_XSIZE_load
-
-AO_INLINE void
-AO_XSIZE_store(volatile XCTYPE *addr, XCTYPE new_val)
-{
- assert(((size_t)addr & (sizeof(*addr) - 1)) == 0);
- *(XCTYPE *)addr = new_val;
-}
-#define AO_HAVE_XSIZE_store
diff --git a/src/atomic_ops/sysdeps/loadstore/atomic_load_store.h b/src/atomic_ops/sysdeps/loadstore/atomic_load_store.h
index 9b83ced..1360671 100644
--- a/src/atomic_ops/sysdeps/loadstore/atomic_load_store.h
+++ b/src/atomic_ops/sysdeps/loadstore/atomic_load_store.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003 by Hewlett-Packard Company. All rights reserved.
+ * Copyright (c) 2004 Hewlett-Packard Development Company, L.P.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -21,13 +21,17 @@
*/
/* Definitions for architectures on which loads and stores of given */
-/* type are atomic for all legal alignments. */
+/* type are atomic (either for suitably aligned data only or for any */
+/* legal alignment). */
AO_INLINE AO_t
AO_load(const volatile AO_t *addr)
{
+# ifdef AO_ACCESS_CHECK_ALIGNED
+ assert(((size_t)addr & (sizeof(*addr) - 1)) == 0);
+# endif
/* Cast away the volatile for architectures like IA64 where */
- /* volatile adds barrier semantics. */
+ /* volatile adds barrier (fence) semantics. */
return *(const AO_t *)addr;
}
#define AO_HAVE_load
@@ -35,6 +39,9 @@ AO_load(const volatile AO_t *addr)
AO_INLINE void
AO_store(volatile AO_t *addr, AO_t new_val)
{
+# ifdef AO_ACCESS_CHECK_ALIGNED
+ assert(((size_t)addr & (sizeof(*addr) - 1)) == 0);
+# endif
*(AO_t *)addr = new_val;
}
#define AO_HAVE_store
diff --git a/src/atomic_ops/sysdeps/loadstore/atomic_load_store.template b/src/atomic_ops/sysdeps/loadstore/atomic_load_store.template
index 0364dc2..ea018fe 100644
--- a/src/atomic_ops/sysdeps/loadstore/atomic_load_store.template
+++ b/src/atomic_ops/sysdeps/loadstore/atomic_load_store.template
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003 by Hewlett-Packard Company. All rights reserved.
+ * Copyright (c) 2004 Hewlett-Packard Development Company, L.P.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -21,13 +21,17 @@
*/
/* Definitions for architectures on which loads and stores of given */
-/* type are atomic for all legal alignments. */
+/* type are atomic (either for suitably aligned data only or for any */
+/* legal alignment). */
AO_INLINE XCTYPE
AO_XSIZE_load(const volatile XCTYPE *addr)
{
+# ifdef AO_ACCESS_XSIZE_CHECK_ALIGNED
+ assert(((size_t)addr & (sizeof(*addr) - 1)) == 0);
+# endif
/* Cast away the volatile for architectures like IA64 where */
- /* volatile adds barrier semantics. */
+ /* volatile adds barrier (fence) semantics. */
return *(const XCTYPE *)addr;
}
#define AO_HAVE_XSIZE_load
@@ -35,6 +39,9 @@ AO_XSIZE_load(const volatile XCTYPE *addr)
AO_INLINE void
AO_XSIZE_store(volatile XCTYPE *addr, XCTYPE new_val)
{
+# ifdef AO_ACCESS_XSIZE_CHECK_ALIGNED
+ assert(((size_t)addr & (sizeof(*addr) - 1)) == 0);
+# endif
*(XCTYPE *)addr = new_val;
}
#define AO_HAVE_XSIZE_store
diff --git a/src/atomic_ops/sysdeps/loadstore/char_atomic_load_store.h b/src/atomic_ops/sysdeps/loadstore/char_atomic_load_store.h
index 1f9bef0..0186650 100644
--- a/src/atomic_ops/sysdeps/loadstore/char_atomic_load_store.h
+++ b/src/atomic_ops/sysdeps/loadstore/char_atomic_load_store.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003 by Hewlett-Packard Company. All rights reserved.
+ * Copyright (c) 2004 Hewlett-Packard Development Company, L.P.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -21,13 +21,17 @@
*/
/* Definitions for architectures on which loads and stores of given */
-/* type are atomic for all legal alignments. */
+/* type are atomic (either for suitably aligned data only or for any */
+/* legal alignment). */
AO_INLINE unsigned/**/char
AO_char_load(const volatile unsigned/**/char *addr)
{
+# ifdef AO_ACCESS_char_CHECK_ALIGNED
+ assert(((size_t)addr & (sizeof(*addr) - 1)) == 0);
+# endif
/* Cast away the volatile for architectures like IA64 where */
- /* volatile adds barrier semantics. */
+ /* volatile adds barrier (fence) semantics. */
return *(const unsigned/**/char *)addr;
}
#define AO_HAVE_char_load
@@ -35,6 +39,9 @@ AO_char_load(const volatile unsigned/**/char *addr)
AO_INLINE void
AO_char_store(volatile unsigned/**/char *addr, unsigned/**/char new_val)
{
+# ifdef AO_ACCESS_char_CHECK_ALIGNED
+ assert(((size_t)addr & (sizeof(*addr) - 1)) == 0);
+# endif
*(unsigned/**/char *)addr = new_val;
}
#define AO_HAVE_char_store
diff --git a/src/atomic_ops/sysdeps/loadstore/int_aligned_atomic_load_store.h b/src/atomic_ops/sysdeps/loadstore/int_aligned_atomic_load_store.h
deleted file mode 100644
index 435955d..0000000
--- a/src/atomic_ops/sysdeps/loadstore/int_aligned_atomic_load_store.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (c) 2004 Hewlett-Packard Development Company, L.P.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-/* Definitions for architectures on which loads and stores of given */
-/* type are atomic for all legal alignments. */
-
-AO_INLINE unsigned
-AO_int_load(const volatile unsigned *addr)
-{
- assert(((size_t)addr & (sizeof(*addr) - 1)) == 0);
- /* Cast away the volatile for architectures like IA64 where */
- /* volatile adds barrier (fence) semantics. */
- return *(const unsigned *)addr;
-}
-#define AO_HAVE_int_load
-
-AO_INLINE void
-AO_int_store(volatile unsigned *addr, unsigned new_val)
-{
- assert(((size_t)addr & (sizeof(*addr) - 1)) == 0);
- *(unsigned *)addr = new_val;
-}
-#define AO_HAVE_int_store
diff --git a/src/atomic_ops/sysdeps/loadstore/int_atomic_load_store.h b/src/atomic_ops/sysdeps/loadstore/int_atomic_load_store.h
index d7cca0f..40198ab 100644
--- a/src/atomic_ops/sysdeps/loadstore/int_atomic_load_store.h
+++ b/src/atomic_ops/sysdeps/loadstore/int_atomic_load_store.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003 by Hewlett-Packard Company. All rights reserved.
+ * Copyright (c) 2004 Hewlett-Packard Development Company, L.P.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -21,13 +21,17 @@
*/
/* Definitions for architectures on which loads and stores of given */
-/* type are atomic for all legal alignments. */
+/* type are atomic (either for suitably aligned data only or for any */
+/* legal alignment). */
AO_INLINE unsigned
AO_int_load(const volatile unsigned *addr)
{
+# ifdef AO_ACCESS_int_CHECK_ALIGNED
+ assert(((size_t)addr & (sizeof(*addr) - 1)) == 0);
+# endif
/* Cast away the volatile for architectures like IA64 where */
- /* volatile adds barrier semantics. */
+ /* volatile adds barrier (fence) semantics. */
return *(const unsigned *)addr;
}
#define AO_HAVE_int_load
@@ -35,6 +39,9 @@ AO_int_load(const volatile unsigned *addr)
AO_INLINE void
AO_int_store(volatile unsigned *addr, unsigned new_val)
{
+# ifdef AO_ACCESS_int_CHECK_ALIGNED
+ assert(((size_t)addr & (sizeof(*addr) - 1)) == 0);
+# endif
*(unsigned *)addr = new_val;
}
#define AO_HAVE_int_store
diff --git a/src/atomic_ops/sysdeps/loadstore/short_aligned_atomic_load_store.h b/src/atomic_ops/sysdeps/loadstore/short_aligned_atomic_load_store.h
deleted file mode 100644
index 37bd8df..0000000
--- a/src/atomic_ops/sysdeps/loadstore/short_aligned_atomic_load_store.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (c) 2004 Hewlett-Packard Development Company, L.P.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-/* Definitions for architectures on which loads and stores of given */
-/* type are atomic for all legal alignments. */
-
-AO_INLINE unsigned/**/short
-AO_short_load(const volatile unsigned/**/short *addr)
-{
- assert(((size_t)addr & (sizeof(*addr) - 1)) == 0);
- /* Cast away the volatile for architectures like IA64 where */
- /* volatile adds barrier (fence) semantics. */
- return *(const unsigned/**/short *)addr;
-}
-#define AO_HAVE_short_load
-
-AO_INLINE void
-AO_short_store(volatile unsigned/**/short *addr, unsigned/**/short new_val)
-{
- assert(((size_t)addr & (sizeof(*addr) - 1)) == 0);
- *(unsigned/**/short *)addr = new_val;
-}
-#define AO_HAVE_short_store
diff --git a/src/atomic_ops/sysdeps/loadstore/short_atomic_load_store.h b/src/atomic_ops/sysdeps/loadstore/short_atomic_load_store.h
index ee33964..03c896f 100644
--- a/src/atomic_ops/sysdeps/loadstore/short_atomic_load_store.h
+++ b/src/atomic_ops/sysdeps/loadstore/short_atomic_load_store.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003 by Hewlett-Packard Company. All rights reserved.
+ * Copyright (c) 2004 Hewlett-Packard Development Company, L.P.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -21,13 +21,17 @@
*/
/* Definitions for architectures on which loads and stores of given */
-/* type are atomic for all legal alignments. */
+/* type are atomic (either for suitably aligned data only or for any */
+/* legal alignment). */
AO_INLINE unsigned/**/short
AO_short_load(const volatile unsigned/**/short *addr)
{
+# ifdef AO_ACCESS_short_CHECK_ALIGNED
+ assert(((size_t)addr & (sizeof(*addr) - 1)) == 0);
+# endif
/* Cast away the volatile for architectures like IA64 where */
- /* volatile adds barrier semantics. */
+ /* volatile adds barrier (fence) semantics. */
return *(const unsigned/**/short *)addr;
}
#define AO_HAVE_short_load
@@ -35,6 +39,9 @@ AO_short_load(const volatile unsigned/**/short *addr)
AO_INLINE void
AO_short_store(volatile unsigned/**/short *addr, unsigned/**/short new_val)
{
+# ifdef AO_ACCESS_short_CHECK_ALIGNED
+ assert(((size_t)addr & (sizeof(*addr) - 1)) == 0);
+# endif
*(unsigned/**/short *)addr = new_val;
}
#define AO_HAVE_short_store