oro_system.h
Go to the documentation of this file.
00001 /***************************************************************************
00002  tag: FMTC  Tue Mar 11 21:49:19 CET 2008  oro_system.h
00003 
00004  oro_system.h -  description
00005  -------------------
00006  begin                : Tue March 11 2008
00007  copyright            : (C) 2008 FMTC
00008  email                : peter.soetens@fmtc.be
00009 
00010  ***************************************************************************
00011  *   This library is free software; you can redistribute it and/or         *
00012  *   modify it under the terms of the GNU General Public                   *
00013  *   License as published by the Free Software Foundation;                 *
00014  *   version 2 of the License.                                             *
00015  *                                                                         *
00016  *   As a special exception, you may use this file as part of a free       *
00017  *   software library without restriction.  Specifically, if other files   *
00018  *   instantiate templates or use macros or inline functions from this     *
00019  *   file, or you compile this file and link it with other files to        *
00020  *   produce an executable, this file does not by itself cause the         *
00021  *   resulting executable to be covered by the GNU General Public          *
00022  *   License.  This exception does not however invalidate any other        *
00023  *   reasons why the executable file might be covered by the GNU General   *
00024  *   Public License.                                                       *
00025  *                                                                         *
00026  *   This library is distributed in the hope that it will be useful,       *
00027  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00028  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
00029  *   Lesser General Public License for more details.                       *
00030  *                                                                         *
00031  *   You should have received a copy of the GNU General Public             *
00032  *   License along with this library; if not, write to the Free Software   *
00033  *   Foundation, Inc., 59 Temple Place,                                    *
00034  *   Suite 330, Boston, MA  02111-1307  USA                                *
00035  *                                                                         *
00036  ***************************************************************************/
00037 
00038 #include <youbot_driver/generic/dataobjectlockfree/os/oro_powerpc/oro_atomic.h>
00039 
00040 #ifdef _cplusplus
00041 extern "C"
00042 {
00043 #endif // _cplusplus
00044 #define __HAVE_ARCH_CMPXCHG     1
00045 
00046 static __inline__ unsigned long __cmpxchg_u32(volatile unsigned int *p, unsigned long old, unsigned long newp)
00047 {
00048   unsigned int prev;
00049 
00050   __asm__ __volatile__ (
00051       LWSYNC_ON_SMP
00052       "1:       lwarx   %0,0,%2         # __cmpxchg_u32\n\
00053         cmpw    0,%0,%3\n\
00054         bne-    2f\n"
00055       PPC405_ERR77(0,%2)
00056       " stwcx.  %4,0,%2\n\
00057         bne-    1b"
00058       ISYNC_ON_SMP
00059       "\n\
00060 2:"
00061       : "=&r" (prev), "=m" (*p)
00062       : "r" (p), "r" (old), "r" (newp), "m" (*p)
00063       : "cc", "memory");
00064 
00065   return prev;
00066 }
00067 
00068 // KG did explicit cast to remove following error
00069 /*
00070  /kgad/orocos-port-branch/ports/ecos/arch/powerpc/boa5200/orecos-library/install/include/os/oro_powerpc/oro_system.h:
00071  In function `long unsigned int __oro_cmpxchg(volatile void*, long
00072  unsigned int, long unsigned int, unsigned int)':
00073  /kgad/orocos-port-branch/ports/ecos/arch/powerpc/boa5200/orecos-library/install/include/os/oro_powerpc/oro_system.h:52:
00074  error: invalid conversion from `volatile void*' to `volatile
00075  unsigned int*'
00076  /kgad/orocos-port-branch/ports/ecos/arch/powerpc/boa5200/orecos-library/install/include/os/oro_powerpc/oro_system.h:52:
00077  error:   initializing argument 1 of `long unsigned int
00078  __cmpxchg_u32(volatile unsigned int*, long unsigned int, long
00079  unsigned int)' */
00080 
00081 static __inline__ unsigned long __oro_cmpxchg(volatile void *ptr, unsigned long old, unsigned long newp,
00082                                               unsigned int size)
00083 {
00084   switch (size)
00085   {
00086     case 4:
00087       return __cmpxchg_u32((volatile unsigned int *)ptr, old, newp);
00088   }
00089   return old;
00090 }
00091 
00092 #define oro_cmpxchg(ptr,o,n)                                             \
00093   ({                                                                     \
00094      __typeof__(*(ptr)) _o_ = (o);                                       \
00095      __typeof__(*(ptr)) _n_ = (n);                                       \
00096      (__typeof__(*(ptr))) __oro_cmpxchg((ptr), (unsigned long)_o_,               \
00097                                     (unsigned long)_n_, sizeof(*(ptr))); \
00098   })
00099 
00100 #ifdef _cplusplus
00101 } // end extern "C"
00102 #endif // _cplusplus


youbot_driver
Author(s): Jan Paulus
autogenerated on Mon Oct 6 2014 09:08:01