Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset e9d2905 in mainline


Ignore:
Timestamp:
2018-09-07T15:50:02Z (4 years ago)
Author:
Jiří Zárevúcky <jiri.zarevucky@…>
Branches:
lfn, master, serial
Children:
036e97c
Parents:
077842c
Message:

Convert atomic_t to atomic_size_t (2): Redefine atomic_t to atomic_size_t

Location:
kernel
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/include/atomic.h

    r077842c re9d2905  
    4242typedef size_t atomic_count_t;
    4343typedef ssize_t atomic_signed_t;
    44 
    45 typedef struct {
    46         volatile atomic_size_t count;
    47 } atomic_t;
     44typedef atomic_size_t atomic_t;
    4845
    4946static inline void atomic_set(atomic_t *val, atomic_count_t i)
    5047{
    51         atomic_store(&val->count, i);
     48        atomic_store(val, i);
    5249}
    5350
    5451static inline atomic_count_t atomic_get(atomic_t *val)
    5552{
    56         return atomic_load(&val->count);
     53        return atomic_load(val);
    5754}
    5855
    5956static inline size_t atomic_predec(atomic_t *val)
    6057{
    61         return atomic_fetch_sub(&val->count, 1) - 1;
     58        return atomic_fetch_sub(val, 1) - 1;
    6259}
    6360
    6461static inline size_t atomic_preinc(atomic_t *val)
    6562{
    66         return atomic_fetch_add(&val->count, 1) + 1;
     63        return atomic_fetch_add(val, 1) + 1;
    6764}
    6865
    6966static inline size_t atomic_postdec(atomic_t *val)
    7067{
    71         return atomic_fetch_sub(&val->count, 1);
     68        return atomic_fetch_sub(val, 1);
    7269}
    7370
    7471static inline size_t atomic_postinc(atomic_t *val)
    7572{
    76         return atomic_fetch_add(&val->count, 1);
     73        return atomic_fetch_add(val, 1);
    7774}
    7875
    7976static inline void atomic_dec(atomic_t *val)
    8077{
    81         atomic_fetch_sub(&val->count, 1);
     78        atomic_fetch_sub(val, 1);
    8279}
    8380
    8481static inline void atomic_inc(atomic_t *val)
    8582{
    86         atomic_fetch_add(&val->count, 1);
     83        atomic_fetch_add(val, 1);
    8784}
    8885
     
    9289static inline bool test_and_set(atomic_t *val)
    9390{
    94         return atomic_exchange(&val->count, 1);
     91        return atomic_exchange(val, 1);
    9592}
    9693
  • kernel/test/synch/semaphore1.c

    r077842c re9d2905  
    115115                waitq_wakeup(&can_start, WAKEUP_ALL);
    116116
    117                 while ((items_consumed.count != consumers) || (items_produced.count != producers)) {
     117                while ((items_consumed != consumers) || (items_produced != producers)) {
    118118                        TPRINTF("%zu consumers remaining, %zu producers remaining\n",
    119                             consumers - items_consumed.count, producers - items_produced.count);
     119                            consumers - items_consumed, producers - items_produced);
    120120                        thread_sleep(1);
    121121                }
Note: See TracChangeset for help on using the changeset viewer.