Qore Programming Language  0.8.3
include/qore/macros-powerpc.h (4311)
00001 /* -*- mode: c++; indent-tabs-mode: nil -*- */
00002 /*
00003   Qore Programming Language
00004 
00005   Copyright 2003 - 2011 David Nichols
00006 
00007   This library is free software; you can redistribute it and/or
00008   modify it under the terms of the GNU Lesser General Public
00009   License as published by the Free Software Foundation; either
00010   version 2.1 of the License, or (at your option) any later version.
00011 
00012   This library is distributed in the hope that it will be useful,
00013   but WITHOUT ANY WARRANTY; without even the implied warranty of
00014   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015   Lesser General Public License for more details.
00016 
00017   You should have received a copy of the GNU Lesser General Public
00018   License along with this library; if not, write to the Free Software
00019   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00020  */
00021 
00022 #ifndef _QORE_CONFIG_MACHINE_MACROS_H
00023 
00024 #define _QORE_CONFIG_MACHINE_MACROS_H
00025 
00026 // only have support for 32-bit ppc for now
00027 #ifndef __ppc64
00028 
00029 #define HAVE_ATOMIC_MACROS
00030 
00031 static inline int atomic_inc(int *v)
00032 {
00033    int t;
00034 
00035    asm volatile(
00036                 "1:     lwarx   %0,0,%1\n"
00037                 "       addic   %0,%0,1\n"
00038                 "       stwcx.  %0,0,%1\n"
00039                 "       bne-    1b"
00040                 : "=&r" (t)
00041                 : "r" (v)
00042                 : "cc", "memory");
00043    return t;
00044 }
00045 
00046 static inline int atomic_dec(int *v)
00047 {
00048    int t;
00049 
00050    asm volatile(
00051                 "1:     lwarx   %0,0,%1\n"
00052                 "       addic   %0,%0,-1\n"
00053                 "       stwcx.  %0,0,%1\n"
00054                 "       bne-    1b"
00055                 : "=&r" (t)
00056                 : "r" (v)
00057                 : "cc", "memory");
00058    return !t;
00059 }
00060 
00061 #define HAVE_CHECK_STACK_POS
00062 #define STACK_DIRECTION_DOWN 1
00063 
00064 static inline size_t get_stack_pos() {
00065    size_t addr;
00066    __asm("mr %0, r1" : "=r" (addr) );
00067    return addr;
00068 }
00069 
00070 #endif
00071 
00072 #endif
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines