Qore Programming Language
0.8.11
Main Page
Related Pages
Modules
Classes
Files
File List
File Members
All
Classes
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Groups
Pages
include
qore
macros-powerpc.h
1
/* -*- mode: c++; indent-tabs-mode: nil -*- */
2
/*
3
Qore Programming Language
4
5
Copyright 2003 - 2013 David Nichols
6
7
This library is free software; you can redistribute it and/or
8
modify it under the terms of the GNU Lesser General Public
9
License as published by the Free Software Foundation; either
10
version 2.1 of the License, or (at your option) any later version.
11
12
This library is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
Lesser General Public License for more details.
16
17
You should have received a copy of the GNU Lesser General Public
18
License along with this library; if not, write to the Free Software
19
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20
*/
21
22
#ifndef _QORE_CONFIG_MACHINE_MACROS_H
23
24
#define _QORE_CONFIG_MACHINE_MACROS_H
25
26
// only have support for 32-bit ppc for now
27
#ifndef __ppc64
28
29
#define HAVE_ATOMIC_MACROS
30
31
static
inline
int
atomic_inc(
int
*v)
32
{
33
int
t;
34
35
asm
volatile
(
36
"1: lwarx %0,0,%1\n"
37
" addic %0,%0,1\n"
38
" stwcx. %0,0,%1\n"
39
" bne- 1b"
40
:
"=&r"
(t)
41
:
"r"
(v)
42
:
"cc"
,
"memory"
);
43
return
t;
44
}
45
46
static
inline
int
atomic_dec(
int
*v)
47
{
48
int
t;
49
50
asm
volatile
(
51
"1: lwarx %0,0,%1\n"
52
" addic %0,%0,-1\n"
53
" stwcx. %0,0,%1\n"
54
" bne- 1b"
55
:
"=&r"
(t)
56
:
"r"
(v)
57
:
"cc"
,
"memory"
);
58
return
!t;
59
}
60
61
#define HAVE_CHECK_STACK_POS
62
#define STACK_DIRECTION_DOWN 1
63
64
static
inline
size_t
get_stack_pos() {
65
size_t
addr;
66
__asm(
"mr %0, r1"
:
"=r"
(addr) );
67
return
addr;
68
}
69
70
#endif
71
72
#endif