* Added an atomic.h header that provides a C++ file with a templatized
64-bit safe version of atomic_test_and_set() for pointers: atomic_pointer_test_and_set(). * The VFS is now using this function (it's not used anywhere else in the kernel this way). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25260 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright 2008, Axel Dörfler, [email protected].
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _KERNEL_UTIL_ATOMIC_H
|
||||
#define _KERNEL_UTIL_ATOMIC_H
|
||||
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
#include <SupportDefs.h>
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
template<typename PointerType> PointerType*
|
||||
atomic_pointer_test_and_set(PointerType** _pointer, PointerType* set,
|
||||
PointerType* test)
|
||||
{
|
||||
#if LONG_MAX == INT_MAX
|
||||
return (PointerType*)atomic_test_and_set((vint32*)_pointer, (int32)set,
|
||||
(int32)test);
|
||||
#else
|
||||
return (PointerType*)atomic_test_and_set64((vint64*)_pointer, (int64)set,
|
||||
(int64)test);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif /* _KERNEL_UTIL_ATOMIC_H */
|
||||
Reference in New Issue
Block a user