Shadowrun: Awakened 29 September 2011 - Build 871
Defines | Functions
sunos_sparc.h File Reference
#include <stdint.h>
#include <unistd.h>
#include <sched.h>
Include dependency graph for sunos_sparc.h:

Go to the source code of this file.

Defines

#define __TBB_AtomicAND(P, V)   __TBB_machine_and(P,V)
#define __TBB_AtomicOR(P, V)   __TBB_machine_or(P,V)
#define __TBB_BIG_ENDIAN   1
#define __TBB_CompareAndSwap4(P, V, C)   __TBB_machine_cmpswp4(P,V,C)
#define __TBB_CompareAndSwap8(P, V, C)   __TBB_machine_cmpswp8(P,V,C)
#define __TBB_CompareAndSwapW(P, V, C)   __TBB_machine_cmpswp8(P,V,C)
#define __TBB_FetchAndAdd4(P, V)   __TBB_machine_fetchadd4(P,V)
#define __TBB_FetchAndAdd8(P, V)   __TBB_machine_fetchadd8(P,V)
#define __TBB_FetchAndAddW(P, V)   __TBB_machine_fetchadd8(P,V)
#define __TBB_FetchAndAddWrelease(P, V)   __TBB_FetchAndAddW(P,V)
#define __TBB_FetchAndDecrementWrelease(P)   __TBB_FetchAndAddW(P,-1)
#define __TBB_FetchAndIncrementWacquire(P)   __TBB_FetchAndAddW(P,1)
#define __TBB_Load8(P)   (*P)
#define __TBB_Log2(V)   __TBB_machine_lg(V)
#define __TBB_Pause(V)   __TBB_machine_pause(V)
#define __TBB_release_consistency_helper()   __asm__ __volatile__ ("": : :"memory")
#define __TBB_Store8(P, V)   (*P = V)
#define __TBB_TryLockByte(P)   __TBB_machine_trylockbyte(P)
#define __TBB_WORDSIZE   8
#define __TBB_Yield()   sched_yield()

Functions

static void __TBB_machine_and (volatile void *ptr, uint64_t addend)
static int32_t __TBB_machine_cmpswp4 (volatile void *ptr, int32_t value, int32_t comparand)
static int64_t __TBB_machine_cmpswp8 (volatile void *ptr, int64_t value, int64_t comparand)
static int32_t __TBB_machine_fetchadd4 (volatile void *ptr, int32_t addend)
static int64_t __TBB_machine_fetchadd8 (volatile void *ptr, int64_t addend)
static int64_t __TBB_machine_lg (uint64_t x)
static void __TBB_machine_or (volatile void *ptr, uint64_t addend)
static void __TBB_machine_pause (int32_t delay)
static bool __TBB_machine_trylockbyte (unsigned char &flag)
void __TBB_rel_acq_fence ()

Define Documentation

#define __TBB_AtomicAND (   P,
  V 
)    __TBB_machine_and(P,V)

Definition at line 216 of file sunos_sparc.h.

#define __TBB_AtomicOR (   P,
  V 
)    __TBB_machine_or(P,V)

Definition at line 215 of file sunos_sparc.h.

#define __TBB_BIG_ENDIAN   1

Definition at line 40 of file sunos_sparc.h.

#define __TBB_CompareAndSwap4 (   P,
  V,
 
)    __TBB_machine_cmpswp4(P,V,C)

Definition at line 195 of file sunos_sparc.h.

#define __TBB_CompareAndSwap8 (   P,
  V,
 
)    __TBB_machine_cmpswp8(P,V,C)

Definition at line 196 of file sunos_sparc.h.

#define __TBB_CompareAndSwapW (   P,
  V,
 
)    __TBB_machine_cmpswp8(P,V,C)

Definition at line 197 of file sunos_sparc.h.

#define __TBB_FetchAndAdd4 (   P,
  V 
)    __TBB_machine_fetchadd4(P,V)

Definition at line 201 of file sunos_sparc.h.

#define __TBB_FetchAndAdd8 (   P,
  V 
)    __TBB_machine_fetchadd8(P,V)

Definition at line 202 of file sunos_sparc.h.

#define __TBB_FetchAndAddW (   P,
  V 
)    __TBB_machine_fetchadd8(P,V)

Definition at line 203 of file sunos_sparc.h.

#define __TBB_FetchAndAddWrelease (   P,
  V 
)    __TBB_FetchAndAddW(P,V)

Definition at line 223 of file sunos_sparc.h.

#define __TBB_FetchAndDecrementWrelease (   P)    __TBB_FetchAndAddW(P,-1)

Definition at line 225 of file sunos_sparc.h.

#define __TBB_FetchAndIncrementWacquire (   P)    __TBB_FetchAndAddW(P,1)

Definition at line 224 of file sunos_sparc.h.

#define __TBB_Load8 (   P)    (*P)

Definition at line 213 of file sunos_sparc.h.

#define __TBB_Log2 (   V)    __TBB_machine_lg(V)

Definition at line 220 of file sunos_sparc.h.

#define __TBB_Pause (   V)    __TBB_machine_pause(V)

Definition at line 219 of file sunos_sparc.h.

#define __TBB_release_consistency_helper ( )    __asm__ __volatile__ ("": : :"memory")

Definition at line 42 of file sunos_sparc.h.

#define __TBB_Store8 (   P,
  V 
)    (*P = V)

Definition at line 212 of file sunos_sparc.h.

#define __TBB_TryLockByte (   P)    __TBB_machine_trylockbyte(P)

Definition at line 231 of file sunos_sparc.h.

#define __TBB_WORDSIZE   8

Definition at line 39 of file sunos_sparc.h.

#define __TBB_Yield ( )    sched_yield()

Definition at line 233 of file sunos_sparc.h.


Function Documentation

static void __TBB_machine_and ( volatile void *  ptr,
uint64_t  addend 
) [inline, static]

Definition at line 160 of file sunos_sparc.h.

                                                                            {
  __asm__ __volatile__ (
                        "0:\t and\t %2, %3, %%g1\n"        // do addition
                        "\t casx\t [%1], %2, %%g1\n"            // cas to store result in memory
                        "\t cmp\t %2, %%g1\n"                   // check if value from memory is original
                        "\t bne,a,pn\t %%xcc, 0b\n"         // if not try again
                        "\t mov %%g1, %2\n"                     // use branch delay slot to move new value in memory to be added
                : "=m"(*(int64_t *)ptr)
                : "r"(ptr), "r"(*(int64_t *)ptr), "r"(addend), "m"(*(int64_t *)ptr)
                : "ccr", "g1", "memory");
}
static int32_t __TBB_machine_cmpswp4 ( volatile void *  ptr,
int32_t  value,
int32_t  comparand 
) [inline, static]

Atomic CAS for 32 bit values, if *ptr==comparand, then *ptr=value, returns *ptr

Parameters:
ptrpointer to value in memory to be swapped with value if *ptr==comparand
valuevalue to assign *ptr to if *ptr==comparand
comparandvalue to compare with *ptr (
Returns:
value originally in memory at ptr, regardless of success

Definition at line 57 of file sunos_sparc.h.

                                                                                                  {
  int32_t result;
  __asm__ __volatile__(
                       "cas\t[%5],%4,%1"
                       : "=m"(*(int32_t *)ptr), "=r"(result)
                       : "m"(*(int32_t *)ptr), "1"(value), "r"(comparand), "r"(ptr)
                       : "memory");
  return result;
}
static int64_t __TBB_machine_cmpswp8 ( volatile void *  ptr,
int64_t  value,
int64_t  comparand 
) [inline, static]

Atomic CAS for 64 bit values, if *ptr==comparand, then *ptr=value, returns *ptr

Parameters:
ptrpointer to value in memory to be swapped with value if *ptr==comparand
valuevalue to assign *ptr to if *ptr==comparand
comparandvalue to compare with *ptr (
Returns:
value originally in memory at ptr, regardless of success

Definition at line 74 of file sunos_sparc.h.

                                                                                                  {
  int64_t result;
  __asm__ __volatile__(
                       "casx\t[%5],%4,%1"
               : "=m"(*(int64_t *)ptr), "=r"(result)
               : "m"(*(int64_t *)ptr), "1"(value), "r"(comparand), "r"(ptr)
               : "memory");
  return result;
}
static int32_t __TBB_machine_fetchadd4 ( volatile void *  ptr,
int32_t  addend 
) [inline, static]

Atomic fetch and add for 32 bit values, in this case implemented by continuously checking success of atomicity

Parameters:
ptrpointer to value to add addend to
addenedvalue to add to *ptr
Returns:
value at ptr before addened was added

Definition at line 94 of file sunos_sparc.h.

                                                                                 {
  int32_t result;
  __asm__ __volatile__ (                                 
                        "0:\t add\t %3, %4, %0\n"    // do addition
                        "\t cas\t [%2], %3, %0\n"        // cas to store result in memory
                        "\t cmp\t %3, %0\n"            // check if value from memory is original
                        "\t bne,a,pn\t %%icc, 0b\n"        // if not try again
                        "\t mov %0, %3\n"            // use branch delay slot to move new value in memory to be added
               : "=&r"(result), "=m"(*(int32_t *)ptr)
               : "r"(ptr), "r"(*(int32_t *)ptr), "r"(addend), "m"(*(int32_t *)ptr)
               : "ccr", "memory");
  return result;
}
static int64_t __TBB_machine_fetchadd8 ( volatile void *  ptr,
int64_t  addend 
) [inline, static]

Atomic fetch and add for 64 bit values, in this case implemented by continuously checking success of atomicity

Parameters:
ptrpointer to value to add addend to
addenedvalue to add to *ptr
Returns:
value at ptr before addened was added

Definition at line 114 of file sunos_sparc.h.

                                                                                 {
  int64_t result;
  __asm__ __volatile__ (
                        "0:\t add\t %3, %4, %0\n"    // do addition
                        "\t casx\t [%2], %3, %0\n"        // cas to store result in memory
                        "\t cmp\t %3, %0\n"            // check if value from memory is original
                        "\t bne,a,pn\t %%xcc, 0b\n"        // if not try again
                        "\t mov %0, %3\n"            // use branch delay slot to move new value in memory to be added
                : "=&r"(result), "=m"(*(int64_t *)ptr)
                : "r"(ptr), "r"(*(int64_t *)ptr), "r"(addend), "m"(*(int64_t *)ptr)
                : "ccr", "memory");
  return result;
}
static int64_t __TBB_machine_lg ( uint64_t  x) [inline, static]

Definition at line 132 of file sunos_sparc.h.

                                                     {
    uint64_t count;
    // one hot encode
    x |= (x >> 1);
    x |= (x >> 2);
    x |= (x >> 4);
    x |= (x >> 8);
    x |= (x >> 16);
    x |= (x >> 32);
    // count 1's
    __asm__ ("popc %1, %0" : "=r"(count) : "r"(x) );
    return count-1;
}
static void __TBB_machine_or ( volatile void *  ptr,
uint64_t  addend 
) [inline, static]

Definition at line 148 of file sunos_sparc.h.

                                                                           {
  __asm__ __volatile__ (
                        "0:\t or\t %2, %3, %%g1\n" // do addition
                        "\t casx\t [%1], %2, %%g1\n"            // cas to store result in memory
                        "\t cmp\t %2, %%g1\n"                   // check if value from memory is original
                        "\t bne,a,pn\t %%xcc, 0b\n" // if not try again
                        "\t mov %%g1, %2\n"                     // use branch delay slot to move new value in memory to be added
                : "=m"(*(int64_t *)ptr)
                : "r"(ptr), "r"(*(int64_t *)ptr), "r"(addend), "m"(*(int64_t *)ptr)
                : "ccr", "g1", "memory");
}
static void __TBB_machine_pause ( int32_t  delay) [inline, static]

Definition at line 173 of file sunos_sparc.h.

                                                        {
    // do nothing, inlined, doesnt matter
}
static bool __TBB_machine_trylockbyte ( unsigned char &  flag) [inline, static]

Definition at line 180 of file sunos_sparc.h.

                                                                 {
    unsigned char result;
    __asm__ __volatile__ (
            "ldstub\t [%2], %0\n"
        : "=r"(result), "=m"(flag)
        : "r"(&flag), "m"(flag)
        : "memory");
    return result == 0;
}
void __TBB_rel_acq_fence ( ) [inline]

Definition at line 44 of file sunos_sparc.h.

{ __asm__ __volatile__("membar #LoadLoad|#LoadStore|#StoreStore|#StoreLoad": : : "memory"); }

Copyright © 2007-2010 by The Shadowrun: Awakened Team. This work is licensed under the GNU Lesser General Public License 3.

GNU Lesser General Public License 3 Sourceforge.net