Ignore:
Timestamp:
2013-12-28T17:30:44Z (10 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
41b735f3
Parents:
c1023bcb
Message:

code revision
coding style fixes
removal of debugging printouts and other temporary stuff

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/arch/sparc32/include/libarch/atomic.h

    rc1023bcb r1df1905  
    2727 */
    2828
    29 /** @addtogroup libcsparc64
     29/** @addtogroup libcsparc32
    3030 * @{
    3131 */
     
    3333 */
    3434
    35 #ifndef LIBC_sparc64_ATOMIC_H_
    36 #define LIBC_sparc64_ATOMIC_H_
     35#ifndef LIBC_sparc32_ATOMIC_H_
     36#define LIBC_sparc32_ATOMIC_H_
    3737
    3838#define LIBC_ARCH_ATOMIC_H_
    3939
    40 #define CAS
     40#define CAS
    4141
    4242#include <atomicdflt.h>
     
    5353}
    5454
    55 static inline void atomic_inc(atomic_t *val) {
    56         /* On real hardware the increment has to be done
    57            as an atomic action. */
    58        
     55static inline void atomic_inc(atomic_t *val)
     56{
     57        // FIXME TODO
    5958        val->count++;
    6059}
    6160
    62 static inline void atomic_dec(atomic_t *val) {
    63         /* On real hardware the decrement has to be done
    64            as an atomic action. */
    65        
     61static inline void atomic_dec(atomic_t *val)
     62{
     63        // FIXME TODO
    6664        val->count++;
    6765}
     
    6967static inline atomic_count_t atomic_postinc(atomic_t *val)
    7068{
    71         /* On real hardware both the storing of the previous
    72            value and the increment have to be done as a single
    73            atomic action. */
     69        // FIXME TODO
    7470       
    7571        atomic_count_t prev = val->count;
     
    8177static inline atomic_count_t atomic_postdec(atomic_t *val)
    8278{
    83         /* On real hardware both the storing of the previous
    84            value and the decrement have to be done as a single
    85            atomic action. */
     79        // FIXME TODO
    8680       
    8781        atomic_count_t prev = val->count;
     
    9488#define atomic_predec(val) (atomic_postdec(val) - 1)
    9589
    96 #if 0
    97 /** Atomic add operation.
    98  *
    99  * Use atomic compare and swap operation to atomically add signed value.
    100  *
    101  * @param val Atomic variable.
    102  * @param i   Signed value to be added.
    103  *
    104  * @return Value of the atomic variable as it existed before addition.
    105  *
    106  */
    107 static inline atomic_count_t atomic_add(atomic_t *val, atomic_count_t i)
    108 {
    109         atomic_count_t a;
    110         atomic_count_t b;
    111        
    112         do {
    113                 volatile uintptr_t ptr = (uintptr_t) &val->count;
    114                
    115                 a = *((atomic_count_t *) ptr);
    116                 b = a + i;
    117                
    118 // XXX          asm volatile (
    119 //                      "cas %0, %2, %1\n"
    120 //                      : "+m" (*((atomic_count_t *) ptr)),
    121 //                        "+r" (b)
    122 //                      : "r" (a)
    123 //              );
    124         } while (a != b);
    125        
    126         return a;
    127 }
    128 
    129 static inline atomic_count_t atomic_preinc(atomic_t *val)
    130 {
    131         return atomic_add(val, 1) + 1;
    132 }
    133 
    134 static inline atomic_count_t atomic_postinc(atomic_t *val)
    135 {
    136         return atomic_add(val, 1);
    137 }
    138 
    139 static inline atomic_count_t atomic_predec(atomic_t *val)
    140 {
    141         return atomic_add(val, -1) - 1;
    142 }
    143 
    144 static inline atomic_count_t atomic_postdec(atomic_t *val)
    145 {
    146         return atomic_add(val, -1);
    147 }
    148 
    149 static inline void atomic_inc(atomic_t *val)
    150 {
    151         (void) atomic_add(val, 1);
    152 }
    153 
    154 static inline void atomic_dec(atomic_t *val)
    155 {
    156         (void) atomic_add(val, -1);
    157 }
    158 #endif
    159 
    16090#endif
    16191
Note: See TracChangeset for help on using the changeset viewer.