oro_system.h
Go to the documentation of this file.
1 /***************************************************************************
2  tag: FMTC Tue Mar 11 21:49:19 CET 2008 oro_system.h
3 
4  oro_system.h - description
5  -------------------
6  begin : Tue March 11 2008
7  copyright : (C) 2008 FMTC
8  email : peter.soetens@fmtc.be
9 
10  ***************************************************************************
11  * This library is free software; you can redistribute it and/or *
12  * modify it under the terms of the GNU General Public *
13  * License as published by the Free Software Foundation; *
14  * version 2 of the License. *
15  * *
16  * As a special exception, you may use this file as part of a free *
17  * software library without restriction. Specifically, if other files *
18  * instantiate templates or use macros or inline functions from this *
19  * file, or you compile this file and link it with other files to *
20  * produce an executable, this file does not by itself cause the *
21  * resulting executable to be covered by the GNU General Public *
22  * License. This exception does not however invalidate any other *
23  * reasons why the executable file might be covered by the GNU General *
24  * Public License. *
25  * *
26  * This library is distributed in the hope that it will be useful, *
27  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
28  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
29  * Lesser General Public License for more details. *
30  * *
31  * You should have received a copy of the GNU General Public *
32  * License along with this library; if not, write to the Free Software *
33  * Foundation, Inc., 59 Temple Place, *
34  * Suite 330, Boston, MA 02111-1307 USA *
35  * *
36  ***************************************************************************/
37 
38 
39 #include "oro_atomic.h"
40 
41 #ifdef _cplusplus
42 extern "C"
43 {
44 #endif // _cplusplus
45 
46 #define __HAVE_ARCH_CMPXCHG 1
47 
48 static __inline__ unsigned long
49 __cmpxchg_u32(volatile unsigned int *p, unsigned long old, unsigned long newp)
50 {
51  unsigned int prev;
52 
53  __asm__ __volatile__ (
55 "1: lwarx %0,0,%2 # __cmpxchg_u32\n\
56  cmpw 0,%0,%3\n\
57  bne- 2f\n"
58  PPC405_ERR77(0,%2)
59 " stwcx. %4,0,%2\n\
60  bne- 1b"
62  "\n\
63 2:"
64  : "=&r" (prev), "=m" (*p)
65  : "r" (p), "r" (old), "r" (newp), "m" (*p)
66  : "cc", "memory");
67 
68  return prev;
69 }
70 
71  // KG did explicit cast to remove following error
72  /*
73  /kgad/orocos-port-branch/ports/ecos/arch/powerpc/boa5200/orecos-library/install/include/os/oro_powerpc/oro_system.h:
74  In function `long unsigned int __oro_cmpxchg(volatile void*, long
75  unsigned int, long unsigned int, unsigned int)':
76  /kgad/orocos-port-branch/ports/ecos/arch/powerpc/boa5200/orecos-library/install/include/os/oro_powerpc/oro_system.h:52:
77  error: invalid conversion from `volatile void*' to `volatile
78  unsigned int*'
79  /kgad/orocos-port-branch/ports/ecos/arch/powerpc/boa5200/orecos-library/install/include/os/oro_powerpc/oro_system.h:52:
80  error: initializing argument 1 of `long unsigned int
81  __cmpxchg_u32(volatile unsigned int*, long unsigned int, long
82  unsigned int)' */
83 
84 static __inline__ unsigned long
85 __oro_cmpxchg(volatile void *ptr, unsigned long old, unsigned long newp, unsigned int size)
86 {
87  switch (size) {
88  case 4:
89  return __cmpxchg_u32((volatile unsigned int *) ptr, old, newp);
90  }
91  return old;
92 }
93 
94 #define oro_cmpxchg(ptr,o,n) \
95  ({ \
96  __typeof__(*(ptr)) _o_ = (o); \
97  __typeof__(*(ptr)) _n_ = (n); \
98  (__typeof__(*(ptr))) __oro_cmpxchg((ptr), (unsigned long)_o_, \
99  (unsigned long)_n_, sizeof(*(ptr))); \
100  })
101 
102 #ifdef _cplusplus
103 } // end extern "C"
104 #endif // _cplusplus
#define LWSYNC_ON_SMP
Definition: oro_atomic.h:63
#define PPC405_ERR77(ra, rb)
Definition: oro_atomic.h:106
static __inline__ unsigned long __oro_cmpxchg(volatile void *ptr, unsigned long old, unsigned long newp, unsigned int size)
Definition: oro_system.h:85
static __inline__ unsigned long __cmpxchg_u32(volatile unsigned int *p, unsigned long old, unsigned long newp)
Definition: oro_system.h:49
#define ISYNC_ON_SMP
Definition: oro_atomic.h:62


youbot_driver
Author(s): Jan Paulus
autogenerated on Mon Jun 10 2019 15:46:24