X-Git-Url: https://git.liburcu.org/?a=blobdiff_plain;f=include%2Furcu%2Fuatomic%2Fs390.h;h=25626961dc320a01c25a2b56f4f5e0928cc3a4e2;hb=HEAD;hp=47b97b1da08159e26abc727679f33c9815768461;hpb=835b9ab3ca3777fe42e37e92096226ebd19ca75b;p=urcu.git diff --git a/include/urcu/uatomic/s390.h b/include/urcu/uatomic/s390.h index 47b97b1..2562696 100644 --- a/include/urcu/uatomic/s390.h +++ b/include/urcu/uatomic/s390.h @@ -1,3 +1,8 @@ +// SPDX-FileCopyrightText: 2009 Novell, Inc. +// SPDX-FileCopyrightText: 2009 Mathieu Desnoyers +// +// SPDX-License-Identifier: MIT + #ifndef _URCU_UATOMIC_ARCH_S390_H #define _URCU_UATOMIC_ARCH_S390_H @@ -6,27 +11,7 @@ * taken from the Principles of Operation Appendix A "Conditional Swapping * Instructions (CS, CDS)". * - * Copyright (c) 2009 Novell, Inc. * Author: Jan Blunck - * Copyright (c) 2009 Mathieu Desnoyers - * - * 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. */ #include @@ -62,13 +47,18 @@ extern "C" { #endif /* !COMPILER_HAVE_SHORT_MEM_OPERAND */ /* - * The __hp() macro casts the void pointer "x" to a pointer to a structure + * The __hp() macro casts the void pointer @x to a pointer to a structure * containing an array of char of the specified size. This allows passing the * @addr arguments of the following inline functions as "m" and "+m" operands - * to the assembly. + * to the assembly. The @size parameter should be a constant to support + * compilers such as clang which do not support VLA. Create typedefs because + * C++ does not allow types be defined in casts. */ -#define __hp(size, x) ((struct { char v[size]; } *)(x)) +typedef struct { char v[4]; } __hp_4; +typedef struct { char v[8]; } __hp_8; + +#define __hp(size, x) ((__hp_##size *)(x)) /* xchg */ @@ -83,8 +73,8 @@ unsigned long _uatomic_exchange(volatile void *addr, unsigned long val, int len) __asm__ __volatile__( "0: cs %0,%2," MEMOP_REF(%3) "\n" " brc 4,0b\n" - : "=&r" (old_val), MEMOP_OUT (__hp(len, addr)) - : "r" (val), MEMOP_IN (__hp(len, addr)) + : "=&r" (old_val), MEMOP_OUT (__hp(4, addr)) + : "r" (val), MEMOP_IN (__hp(4, addr)) : "memory", "cc"); return old_val; } @@ -96,8 +86,8 @@ unsigned long _uatomic_exchange(volatile void *addr, unsigned long val, int len) __asm__ __volatile__( "0: csg %0,%2," MEMOP_REF(%3) "\n" " brc 4,0b\n" - : "=&r" (old_val), MEMOP_OUT (__hp(len, addr)) - : "r" (val), MEMOP_IN (__hp(len, addr)) + : "=&r" (old_val), MEMOP_OUT (__hp(8, addr)) + : "r" (val), MEMOP_IN (__hp(8, addr)) : "memory", "cc"); return old_val; } @@ -127,8 +117,8 @@ unsigned long _uatomic_cmpxchg(void *addr, unsigned long old, __asm__ __volatile__( " cs %0,%2," MEMOP_REF(%3) "\n" - : "+r" (old_val), MEMOP_OUT (__hp(len, addr)) - : "r" (_new), MEMOP_IN (__hp(len, addr)) + : "+r" (old_val), MEMOP_OUT (__hp(4, addr)) + : "r" (_new), MEMOP_IN (__hp(4, addr)) : "memory", "cc"); return old_val; } @@ -137,8 +127,8 @@ unsigned long _uatomic_cmpxchg(void *addr, unsigned long old, { __asm__ __volatile__( " csg %0,%2," MEMOP_REF(%3) "\n" - : "+r" (old), MEMOP_OUT (__hp(len, addr)) - : "r" (_new), MEMOP_IN (__hp(len, addr)) + : "+r" (old), MEMOP_OUT (__hp(8, addr)) + : "r" (_new), MEMOP_IN (__hp(8, addr)) : "memory", "cc"); return old; }