Back to index

glibc  2.9
atomic.h
Go to the documentation of this file.
00001 /* Copyright (C) 2003 Free Software Foundation, Inc.
00002    This file is part of the GNU C Library.
00003    Contributed by Martin Schwidefsky <schwidefsky@de.ibm.com>, 2003.
00004 
00005    The GNU C Library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Lesser General Public
00007    License as published by the Free Software Foundation; either
00008    version 2.1 of the License, or (at your option) any later version.
00009 
00010    The GNU C Library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Lesser General Public License for more details.
00014 
00015    You should have received a copy of the GNU Lesser General Public
00016    License along with the GNU C Library; if not, write to the Free
00017    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00018    02111-1307 USA.  */
00019 
00020 #include <stdint.h>
00021 
00022 typedef int8_t atomic8_t;
00023 typedef uint8_t uatomic8_t;
00024 typedef int_fast8_t atomic_fast8_t;
00025 typedef uint_fast8_t uatomic_fast8_t;
00026 
00027 typedef int16_t atomic16_t;
00028 typedef uint16_t uatomic16_t;
00029 typedef int_fast16_t atomic_fast16_t;
00030 typedef uint_fast16_t uatomic_fast16_t;
00031 
00032 typedef int32_t atomic32_t;
00033 typedef uint32_t uatomic32_t;
00034 typedef int_fast32_t atomic_fast32_t;
00035 typedef uint_fast32_t uatomic_fast32_t;
00036 
00037 typedef int64_t atomic64_t;
00038 typedef uint64_t uatomic64_t;
00039 typedef int_fast64_t atomic_fast64_t;
00040 typedef uint_fast64_t uatomic_fast64_t;
00041 
00042 typedef intptr_t atomicptr_t;
00043 typedef uintptr_t uatomicptr_t;
00044 typedef intmax_t atomic_max_t;
00045 typedef uintmax_t uatomic_max_t;
00046 
00047 
00048 #define __arch_compare_and_exchange_val_8_acq(mem, newval, oldval) \
00049   (abort (), (__typeof (*mem)) 0)
00050 
00051 #define __arch_compare_and_exchange_val_16_acq(mem, newval, oldval) \
00052   (abort (), (__typeof (*mem)) 0)
00053 
00054 #define __arch_compare_and_exchange_val_32_acq(mem, newval, oldval) \
00055   ({ __typeof (mem) __archmem = (mem);                                      \
00056      __typeof (*mem) __archold = (oldval);                                  \
00057      __asm __volatile ("cs %0,%2,%1"                                        \
00058                      : "+d" (__archold), "=Q" (*__archmem)                  \
00059                      : "d" (newval), "m" (*__archmem) : "cc", "memory" );          \
00060      __archold; })
00061 
00062 #ifdef __s390x__
00063 # define __arch_compare_and_exchange_val_64_acq(mem, newval, oldval) \
00064   ({ __typeof (mem) __archmem = (mem);                                      \
00065      __typeof (*mem) __archold = (oldval);                                  \
00066      __asm __volatile ("csg %0,%2,%1"                                       \
00067                      : "+d" (__archold), "=Q" (*__archmem)                  \
00068                      : "d" ((long) (newval)), "m" (*__archmem) : "cc", "memory" );    \
00069      __archold; })
00070 #else
00071 /* For 31 bit we do not really need 64-bit compare-and-exchange. We can
00072    implement them by use of the csd instruction. The straightforward
00073    implementation causes warnings so we skip the definition for now.  */
00074 # define __arch_compare_and_exchange_val_64_acq(mem, newval, oldval) \
00075   (abort (), (__typeof (*mem)) 0)
00076 #endif