Ignore:
Timestamp:
2010-06-24T13:00:16Z (14 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
2d03471, 33c4f72
Parents:
e821e49
Message:

initial properties annotation and verification support
(does not do much yet, but also does not stand in the way)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/abs32le/include/atomic.h

    re821e49 r09a0bd4a  
    3939#include <arch/barrier.h>
    4040#include <preemption.h>
     41#include <verify.h>
    4142
    42 static inline void atomic_inc(atomic_t *val) {
     43ATOMIC static inline void atomic_inc(atomic_t *val)
     44    REQUIRES(val->count < ATOMIC_COUNT_MAX)
     45{
    4346        /* On real hardware the increment has to be done
    4447           as an atomic action. */
     
    4750}
    4851
    49 static inline void atomic_dec(atomic_t *val) {
     52ATOMIC static inline void atomic_dec(atomic_t *val)
     53    REQUIRES(val->count > ATOMIC_COUNT_MIN)
     54{
    5055        /* On real hardware the decrement has to be done
    5156           as an atomic action. */
    5257       
    53         val->count++;
     58        val->count--;
    5459}
    5560
    56 static inline atomic_count_t atomic_postinc(atomic_t *val)
     61ATOMIC static inline atomic_count_t atomic_postinc(atomic_t *val)
     62    REQUIRES(val->count < ATOMIC_COUNT_MAX)
    5763{
    5864        /* On real hardware both the storing of the previous
     
    6672}
    6773
    68 static inline atomic_count_t atomic_postdec(atomic_t *val)
     74ATOMIC static inline atomic_count_t atomic_postdec(atomic_t *val)
     75    REQUIRES(val->count > ATOMIC_COUNT_MIN)
    6976{
    7077        /* On real hardware both the storing of the previous
     
    8188#define atomic_predec(val)  (atomic_postdec(val) - 1)
    8289
    83 static inline atomic_count_t test_and_set(atomic_t *val)
     90ATOMIC static inline atomic_count_t test_and_set(atomic_t *val)
    8491{
     92        /* On real hardware the retrieving of the original
     93           value and storing 1 have to be done as a single
     94           atomic action. */
     95       
    8596        atomic_count_t prev = val->count;
    8697        val->count = 1;
     
    8899}
    89100
     101ATOMIC static inline atomic_count_t arch_atomic_get(atomic_t *val)
     102{
     103        /* This function is not needed on real hardware, it just
     104           duplicates the functionality of atomic_get(). It is
     105           defined here because atomic_get() is an inline function
     106           declared in a header file which we are included in. */
     107       
     108        return val->count;
     109}
     110
    90111static inline void atomic_lock_arch(atomic_t *val)
    91112{
    92113        do {
    93                 while (val->count);
     114                while (arch_atomic_get(val));
    94115        } while (test_and_set(val));
    95116}
Note: See TracChangeset for help on using the changeset viewer.