Loading...
Searching...
No Matches
atomic.h
Go to the documentation of this file.
/*
* (c) 2004-2009 Adam Lackorzynski <adam@os.inf.tu-dresden.de>,
* Alexander Warg <warg@os.inf.tu-dresden.de>
* economic rights: Technische Universität Dresden (Germany)
*
* License: see LICENSE.spdx (in this directory or the directories above)
*/
#pragma once
#include <l4/util/atomic.h>
extern "C" void ____error_compare_and_swap_does_not_support_3_bytes____();
extern "C" void ____error_compare_and_swap_does_not_support_more_than_4_bytes____();
namespace L4
{
template< typename X >
inline int compare_and_swap(X volatile *dst, X old_val, X new_val)
{
switch (sizeof(X))
{
case 1:
return l4util_cmpxchg8((l4_uint8_t volatile*)dst, old_val, new_val);
case 2:
return l4util_cmpxchg16((l4_uint16_t volatile *)dst, old_val, new_val);
case 3: ____error_compare_and_swap_does_not_support_3_bytes____();
case 4:
return l4util_cmpxchg32((l4_uint32_t volatile*)dst, old_val, new_val);
default:
____error_compare_and_swap_does_not_support_more_than_4_bytes____();
}
return 0;
}
}
l4_uint8_t
unsigned char l4_uint8_t
Unsigned 8bit value.
Definition l4int.h:25
l4_uint32_t
unsigned int l4_uint32_t
Unsigned 32bit value.
Definition l4int.h:29
l4_uint16_t
unsigned short int l4_uint16_t
Unsigned 16bit value.
Definition l4int.h:27
l4util_cmpxchg8
int l4util_cmpxchg8(volatile l4_uint8_t *dest, l4_uint8_t cmp_val, l4_uint8_t new_val)
Atomic compare and exchange (8 bit version).
Definition atomic.h:371
l4util_cmpxchg16
int l4util_cmpxchg16(volatile l4_uint16_t *dest, l4_uint16_t cmp_val, l4_uint16_t new_val)
Atomic compare and exchange (16 bit version).
Definition atomic.h:363
l4util_cmpxchg32
int l4util_cmpxchg32(volatile l4_uint32_t *dest, l4_uint32_t cmp_val, l4_uint32_t new_val)
Atomic compare and exchange (32 bit version).
Definition atomic.h:355
atomic.h
atomic operations header and generic implementations
L4
L4 low-level kernel interface.
Definition l4sys-l4f-groups.dox:50