Changeset 985e26d2 in mainline for uspace/lib/libc/include/atomicdflt.h
- Timestamp:
- 2010-01-07T19:06:59Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 8190e63
- Parents:
- 743e17b (diff), eca2435 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/libc/include/atomicdflt.h
r743e17b r985e26d2 1 1 /* 2 * Copyright (c) 200 5Jakub Jermar2 * Copyright (c) 2006 Jakub Jermar 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup generic29 /** @addtogroup libc 30 30 * @{ 31 31 */ … … 33 33 */ 34 34 35 /* 36 * Variable argument list manipulation macros 37 * for architectures using stack to pass arguments. 38 */ 39 40 #ifndef KERN_STACKARG_H_ 41 #define KERN_STACKARG_H_ 35 #ifndef LIBC_ATOMICDFLT_H_ 36 #define LIBC_ATOMICDFLT_H_ 42 37 43 #include <arch/types.h> 38 #ifndef LIBC_ARCH_ATOMIC_H_ 39 #error This file cannot be included directly, include atomic.h instead. 40 #endif 44 41 45 typedef struct va_list { 46 int pos; 47 uint8_t *last; 48 } va_list; 42 #include <bool.h> 49 43 50 #define va_start(ap, lst) \ 51 (ap).pos = sizeof(lst); \52 (ap).last = (uint8_t *) &(lst) 44 typedef struct atomic { 45 volatile long count; 46 } atomic_t; 53 47 54 #define va_arg(ap, type) \ 55 (*((type *)((ap).last + ((ap).pos += sizeof(type)) - sizeof(type)))) 48 static inline void atomic_set(atomic_t *val, long i) 49 { 50 val->count = i; 51 } 56 52 57 #define va_copy(dst, src) dst = src 58 #define va_end(ap) 53 static inline long atomic_get(atomic_t *val) 54 { 55 return val->count; 56 } 59 57 58 #ifndef CAS 59 static inline bool cas(atomic_t *val, long ov, long nv) 60 { 61 return __sync_bool_compare_and_swap(&val->count, ov, nv); 62 } 63 #endif 60 64 61 65 #endif
Note:
See TracChangeset
for help on using the changeset viewer.